private void AccessibilityDemoPage_Loaded(object sender, RoutedEventArgs e)
        {
            var analyzer = new AccessibilityAnalyzer();
            var walker   = new VisualTreeWalker(this, analyzer);

            walker.ScanVisualTree();

            timer = new VisualTreeWalkerTimer(walker);
            timer.Start();
        }
        public void VerifyRemovingRulesWorks()
        {
            var button = new Button();

            var analyzer = new AccessibilityAnalyzer();

            analyzer.AccessibilityRules.Clear();
            analyzer.Analyze(button);

            Assert.AreEqual(false, IsMarkedProblematic(button));
        }
Example #3
0
        private SiteReview GetReview()
        {
            //Get the main page HTML and the time to download
            var mainPageContent = SiteContentDownloader.GetContent(_siteUrl);

            //Analyze the HTML for keywords and accessibility features.
            var keywords      = new KeywordAnalyzer(mainPageContent.Content).AnalyzeHtml();
            var accessibility = new AccessibilityAnalyzer(mainPageContent.Content).AnalyzeHtml();

            var cleanHtml = SiteCleaner.CleanSiteHtml(mainPageContent);

            return(new SiteReview()
            {
                URL = _siteUrl,
                AccessibilityResult = accessibility,
                KeywordResult = keywords,
                TimeToLoad = mainPageContent.TimeToDownload,
                HtmlContent = cleanHtml
            });
        }
        public void AnalyzeAccessibilityTest()
        {
            var expectedResults = new List <string>()
            {
                "75% of image tags have 'alt' attributes (3 of 4)"
            };

            var testHtml = GetHtml();
            var actual   = new AccessibilityAnalyzer(testHtml).AnalyzeHtml();

            foreach (var actualResult in actual)
            {
                Console.WriteLine(actualResult);
            }

            foreach (var expectedResult in expectedResults)
            {
                Assert.IsTrue(actual.Contains(expectedResult));
            }
        }
        public void ClearsStateCorrectly()
        {
            var mainButton = new Button();

            AutomationProperties.SetLandmarkType(mainButton, AutomationLandmarkType.Main);

            var analyzer = new AccessibilityAnalyzer();

            analyzer.AccessibilityRules.Clear();
            analyzer.AccessibilityRules.Add(new LandmarkTypeMainOnceRule());
            analyzer.Analyze(mainButton);
            analyzer.Analyze(mainButton);
            Assert.IsTrue(IsMarkedProblematic(mainButton));

            mainButton = new Button();
            AutomationProperties.SetLandmarkType(mainButton, AutomationLandmarkType.Main);
            Assert.IsFalse(IsMarkedProblematic(mainButton));

            analyzer.ResetState();
            analyzer.Analyze(mainButton);
            Assert.IsFalse(IsMarkedProblematic(mainButton));
        }
        public void VerifyPerformanceSameItemWithSkippingBehavior()
        {
            RunOnUIThread.Execute(() =>
            {
                Stopwatch sw = new Stopwatch();
                var element  = new Button();
                App.Content  = element;
                var analyzer = new AccessibilityAnalyzer(false);
                analyzer.Analyze(element);

                sw.Start();
                for (int i = 0; i < 10000; i++)
                {
                    analyzer.Analyze(element);
                }

                sw.Stop();

                // The item is already flagged, scanning it should take not much time.
                Assert.IsTrue(AccessibilityAnalyzer.GetAccessibilityAnalyzerViolationCount(element) > 0);
                Assert.IsTrue(sw.ElapsedMilliseconds < 200);
                Logger.LogMessage("Elapsed time: " + sw.ElapsedMilliseconds.ToString());
            });
        }