Beispiel #1
0
        public static bool VerifyVisualTree(UIElement root, string masterFilePrefix, Theme theme = Theme.None, IPropertyValueTranslator translator = null, IFilter filter = null, IVisualTreeLogger logger = null)
        {
            VisualTreeLog.LogInfo("VerifyVisualTree for theme " + theme.ToString());
            TestExecution helper = new TestExecution(translator, filter, logger, AlwaysLogMasterFile);

            if (theme == Theme.None)
            {
                helper.DumpAndVerifyVisualTree(root, masterFilePrefix);
            }
            else
            {
                List <ElementTheme> themes = new List <ElementTheme>();
                if (theme == Theme.Dark)
                {
                    themes.Add(ElementTheme.Dark);
                }
                else if (theme == Theme.Light)
                {
                    themes.Add(ElementTheme.Light);
                }
                else if (theme == Theme.All)
                {
                    themes = new List <ElementTheme>()
                    {
                        ElementTheme.Dark, ElementTheme.Light
                    };
                }

                foreach (var requestedTheme in themes)
                {
                    string themeName = requestedTheme.ToString();
                    VisualTreeLog.LogInfo("Change RequestedTheme to " + themeName);
                    ChangeRequestedTheme(root, requestedTheme);

                    helper.DumpAndVerifyVisualTree(root, masterFilePrefix + "_" + themeName, "DumpAndVerifyVisualTree for " + themeName);
                }
            }
            if (helper.HasError())
            {
                Verify.Fail(helper.GetTestResult(), "Test Failed");
                return(false);
            }
            return(true);
        }