예제 #1
0
        public void DumpThemeResources()
        {
            RunOnUIThread.Execute(() =>
            {
                var resourceDictionary = new XamlControlsResources()
                {
                    ControlsResourcesVersion = ControlsResourcesVersion.Version2
                };

                Log.Comment("ThemeDictionaries");
                foreach (var key in resourceDictionary.ThemeDictionaries.Keys)
                {
                    Log.Comment("* " + key.ToString());

                    var themeDictionary = resourceDictionary.ThemeDictionaries[key] as ResourceDictionary;
                    foreach (var entry in themeDictionary)
                    {
                        Log.Comment("\t*" + entry.ToString());
                    }
                }

                Log.Comment("Entries in Resource Dictionary");
                foreach (var entry in resourceDictionary)
                {
                    Log.Comment("* " + entry.ToString());
                }
            });
        }
예제 #2
0
        private bool ShouldEnableAnimation()
        {
            // In ControlsResourceVersion2, animation is disabled.
            return
                // TODO Uno: Move XamlControlsResources to Uno.UI
                (#if !HAS_UNO
                 !XamlControlsResources.IsUsingControlsResourcesVersion2() &&
#endif
                 SharedHelpers.IsAnimationsEnabled());
        }
예제 #3
0
        public void VerifyAllV1KeysExistInV2()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                // https://github.com/microsoft/microsoft-ui-xaml/issues/4674
                Log.Comment("Skipping validation below RS5.");
                return;
            }

            RunOnUIThread.Execute(() =>
            {
                var v1 = new XamlControlsResources()
                {
                    ControlsResourcesVersion = ControlsResourcesVersion.Version1
                };
                var v2 = new XamlControlsResources()
                {
                    ControlsResourcesVersion = ControlsResourcesVersion.Version2
                };

                Verify.IsTrue(AreKeysFromExpectedInActualDictionary(
                                  (ResourceDictionary)v1.ThemeDictionaries["Default"],
                                  "V1.ThemeDictionaries.Default",
                                  (ResourceDictionary)v2.ThemeDictionaries["Default"],
                                  "V2.ThemeDictionaries.Default"),
                              "Resource Keys in V1 Default theme dictionary do not exist in V2 Default theme dictionary");

                Verify.IsTrue(AreKeysFromExpectedInActualDictionary(
                                  (ResourceDictionary)v1.ThemeDictionaries["Light"],
                                  "V1.ThemeDictionaries.Light",
                                  (ResourceDictionary)v2.ThemeDictionaries["Light"],
                                  "V2.ThemeDictionaries.Light"),
                              "Resource Keys in V1 Light theme dictionary do not exist in V2 Light theme dictionary");

                Verify.IsTrue(AreKeysFromExpectedInActualDictionary(
                                  (ResourceDictionary)v1.ThemeDictionaries["HighContrast"],
                                  "V1.ThemeDictionaries.HighContrast",
                                  (ResourceDictionary)v2.ThemeDictionaries["HighContrast"],
                                  "V2.ThemeDictionaries.HighContrast"),
                              "Resource Keys in V1 HighContrast theme dictionary do not exist in V2 HighContrast theme dictionary");

                Verify.IsTrue(AreKeysFromExpectedInActualDictionary(
                                  (ResourceDictionary)v1,
                                  "V1.RootDictionary",
                                  (ResourceDictionary)v2,
                                  "V2.RootDictionary"),
                              "Resource Keys in V1 root dictionary do not exist in V2 root dictionary");
            });
        }
예제 #4
0
        private void EnsureNoMissingThemeResources(IList <string> baseline, XamlControlsResources dictionaryToVerify)
        {
            var actualResourcesKeys  = new HashSet <string>();
            var resourceDictionaries = dictionaryToVerify;

            foreach (var dictionaryName in resourceDictionaries.ThemeDictionaries.Keys)
            {
                var themeDictionary = resourceDictionaries.ThemeDictionaries[dictionaryName] as ResourceDictionary;

                foreach (var entry in themeDictionary)
                {
                    string entryKey = entry.Key as string;
                    if (!actualResourcesKeys.Contains(entryKey))
                    {
                        actualResourcesKeys.Add(entryKey);
                    }
                }
            }

            foreach (var entry in resourceDictionaries)
            {
                string entryKey = entry.Key as string;
                if (!actualResourcesKeys.Contains(entryKey))
                {
                    actualResourcesKeys.Add(entryKey);
                }
            }

            StringBuilder missingKeysList = new StringBuilder();

            bool allBaselineResourceKeysExist = true;

            foreach (var baselineResourceKey in baseline)
            {
                if (!actualResourcesKeys.Contains(baselineResourceKey))
                {
                    missingKeysList.Append(baselineResourceKey + ", ");
                    allBaselineResourceKeysExist = false;
                }
            }

            Verify.IsTrue(allBaselineResourceKeysExist, "List of missing resource keys: " + missingKeysList.ToString());
            if (!allBaselineResourceKeysExist)
            {
                Log.Error("List of missing resource keys: " + missingKeysList.ToString());
            }
        }
예제 #5
0
        public void VerifyUseCompactResourcesAPI()
        {
            //Verify there is no crash and TreeViewItemMinHeight is not the same when changing UseCompactResources.
            RunOnUIThread.Execute(() =>
            {
                var dict   = new XamlControlsResources();
                var height = dict["TreeViewItemMinHeight"].ToString();

                dict.UseCompactResources = true;
                var compactHeight        = dict["TreeViewItemMinHeight"].ToString();
                Verify.AreNotEqual(height, compactHeight, "Height in Compact is not the same as default");
                Verify.AreEqual("24", compactHeight, "Height in 24 in Compact");

                dict.UseCompactResources = false;
                var height2 = dict["TreeViewItemMinHeight"].ToString();
                Verify.AreEqual(height, height2, "Height are the same after disabled compact");
            });

            MUXControlsTestApp.Utilities.IdleSynchronizer.Wait();
        }
예제 #6
0
        public void VerifyAllThemesContainSameResourceKeys()
        {
            bool dictionariesContainSameElements = true;

            RunOnUIThread.Execute(() =>
            {
                var resourceDictionaries = new XamlControlsResources()
                {
                    ControlsResourcesVersion = ControlsResourcesVersion.Version2
                };
                Log.Comment("ThemeDictionaries");

                var defaultThemeDictionary = resourceDictionaries.ThemeDictionaries["Default"] as ResourceDictionary;

                foreach (var dictionaryName in resourceDictionaries.ThemeDictionaries.Keys)
                {
                    // Skip the Default theme dictionary
                    if (dictionaryName.ToString() == "Default")
                    {
                        continue;
                    }

                    Log.Comment("Comparing against " + dictionaryName.ToString());
                    var themeDictionary = resourceDictionaries.ThemeDictionaries[dictionaryName] as ResourceDictionary;

                    bool allKeysInDefaultExistInDictionary = AreKeysFromExpectedInActualDictionary(defaultThemeDictionary, "Default", themeDictionary, dictionaryName.ToString());
                    bool allKeysInDictionaryExistInDefault = AreKeysFromExpectedInActualDictionary(themeDictionary, dictionaryName.ToString(), defaultThemeDictionary, "Default");

                    dictionariesContainSameElements &= (allKeysInDefaultExistInDictionary && allKeysInDictionaryExistInDefault);
                }

                Verify.AreEqual(0, resourceDictionaries.MergedDictionaries.Count, "MergedDictionaries is not empty, Verify if you really wanted to update the merged dictionary. If so, update the test");
            });

            Verify.IsTrue(dictionariesContainSameElements, "Resource Keys you have added are missing in one of the theme dictionaries. This is trouble since we might end up crashing when trying to resolve the key in that Theme.");
            if (!dictionariesContainSameElements)
            {
                Log.Error("Resource Keys you have added are missing in one of the theme dictionaries. This is trouble since we might end up crashing when trying to resolve the key in that Theme.");
            }
        }