示例#1
0
        public void VerifyVisualTreeForCommandBarCornerRadius()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                return;
            }

            var xaml =
                @"<StackPanel Width='400' Height='400' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
                    xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> 
                        <CommandBar Background='Green' CornerRadius='10,10,10,10' IsOpen='True'>
                        <AppBarToggleButton Icon='Shuffle' Label='Shuffle'  />
                        <AppBarToggleButton Icon='RepeatAll' Label='Repeat' />
                        <AppBarSeparator Margin='20,10,20,0' Foreground='Yellow'/>
        
                        <CommandBar.Content>
                            <TextBlock Text='Now playing...' Margin='12,14'/>
                        </CommandBar.Content>
                        </CommandBar>

                        <CommandBar Background='Green' CornerRadius='5,10,5,10' IsOpen='False'>
                        <AppBarToggleButton Icon='Shuffle' Label='Shuffle'  />
                        <AppBarToggleButton Icon='RepeatAll' Label='Repeat' />
                        <AppBarSeparator Margin='20,10,20,0' Padding='16,12,15,12' Foreground='Yellow'/>

                        <CommandBar.Content>
                            <TextBlock Text='Now playing...' Margin='12,14'/>
                        </CommandBar.Content>
                        </CommandBar>
                    </StackPanel>";

            VisualTreeTestHelper.VerifyVisualTree(xaml: xaml,
                                                  verificationFileNamePrefix: "VerifyVisualTreeForCommandBarCornerRadius");
        }
        public void VerifyVisualTreeExampleLoadAndVerifyForAllThemes()
        {
            if (!PlatformConfiguration.IsOsVersion(OSVersion.Redstone5))
            {
                return;
            }

            var xaml = @"<Grid Width='400' Height='400' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> 
                       </Grid>";

            VisualTreeTestHelper.VerifyVisualTree(xaml: xaml,
                                                  masterFilePrefix: "VerifyVisualTreeExampleLoadAndVerifyForAllThemes",
                                                  theme: Theme.All);
        }
示例#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");
            });
        }
        public void VerifyVisualTreeExampleForLightTheme()
        {
            if (!PlatformConfiguration.IsOsVersion(OSVersion.Redstone5))
            {
                return;
            }

            var       xaml = @"<Grid Width='400' Height='400' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> 
                       </Grid>";
            UIElement root = VisualTreeTestHelper.SetupVisualTree(xaml);

            VisualTreeTestHelper.VerifyVisualTree(root: root,
                                                  masterFilePrefix: "VerifyVisualTreeExampleForLightTheme",
                                                  theme: Theme.Light);
        }
        public void VerifyVisualTreeExampleWithCustomerPropertyValueTranslator()
        {
            if (!PlatformConfiguration.IsOsVersion(OSVersion.Redstone5))
            {
                return;
            }

            var xaml = @"<Grid Width='400' Height='400' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> 
                            <TextBlock Text='Abc' />
                       </Grid>";

            VisualTreeTestHelper.VerifyVisualTree(xaml: xaml,
                                                  masterFilePrefix: "VerifyVisualTreeExampleWithCustomerPropertyValueTranslator",
                                                  translator: new CustomizedTranslator());
        }
        public void VerifyVisualTreeForAppBarAndAppBarToggleButton()
        {
            if (!PlatformConfiguration.IsOsVersion(OSVersion.Redstone5))
            {
                return;
            }

            var xaml = @"<Grid Width='400' Height='400' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> 
                            <StackPanel>
                                <AppBarButton Icon='Accept' Label='Accept'/>
                                <AppBarToggleButton Icon='Dislike' Label='Dislike'/>
                            </StackPanel>
                       </Grid>";

            VisualTreeTestHelper.VerifyVisualTree(xaml: xaml,
                                                  masterFilePrefix: "VerifyVisualTreeForAppBarAndAppBarToggleButton");
        }
示例#7
0
        public void CornerRadiusFilterConverterTest()
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone4))
            {
                Log.Comment("Corner radius is only available on RS5+");
                return;
            }

            RunOnUIThread.Execute(() =>
            {
                var root = (StackPanel)XamlReader.Load(
                    @"<StackPanel xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' 
                             xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'
                             xmlns:primitives='using:Microsoft.UI.Xaml.Controls.Primitives'> 
                            <StackPanel.Resources>
                                <primitives:CornerRadiusFilterConverter x:Key='TopCornerRadiusFilterConverter' Filter='Top' Scale='2'/>
                                <primitives:CornerRadiusFilterConverter x:Key='RightCornerRadiusFilterConverter' Filter='Right'/>
                                <primitives:CornerRadiusFilterConverter x:Key='BottomCornerRadiusFilterConverter' Filter='Bottom'/>
                                <primitives:CornerRadiusFilterConverter x:Key='LeftCornerRadiusFilterConverter' Filter='Left'/>
                                <CornerRadius x:Key='testCornerRadius'>6,6,6,6</CornerRadius>
                            </StackPanel.Resources>
                            <Grid x:Name='TopRadiusGrid'
                                CornerRadius='{Binding Source={StaticResource testCornerRadius}, Converter={StaticResource TopCornerRadiusFilterConverter}}'>
                            </Grid>
                            <Grid x:Name='RightRadiusGrid'
                                CornerRadius='{Binding Source={StaticResource testCornerRadius}, Converter={StaticResource RightCornerRadiusFilterConverter}}'>
                            </Grid>
                            <Grid x:Name='BottomRadiusGrid'
                                CornerRadius='{Binding Source={StaticResource testCornerRadius}, Converter={StaticResource BottomCornerRadiusFilterConverter}}'>
                            </Grid>
                            <Grid x:Name='LeftRadiusGrid'
                                CornerRadius='{Binding Source={StaticResource testCornerRadius}, Converter={StaticResource LeftCornerRadiusFilterConverter}}'>
                            </Grid>
                       </StackPanel>");

                var topRadiusGrid    = (Grid)root.FindName("TopRadiusGrid");
                var rightRadiusGrid  = (Grid)root.FindName("RightRadiusGrid");
                var bottomRadiusGrid = (Grid)root.FindName("BottomRadiusGrid");
                var leftRadiusGrid   = (Grid)root.FindName("LeftRadiusGrid");

                Verify.AreEqual(new CornerRadius(12, 12, 0, 0), topRadiusGrid.CornerRadius);
                Verify.AreEqual(new CornerRadius(0, 6, 6, 0), rightRadiusGrid.CornerRadius);
                Verify.AreEqual(new CornerRadius(0, 0, 6, 6), bottomRadiusGrid.CornerRadius);
                Verify.AreEqual(new CornerRadius(6, 0, 0, 6), leftRadiusGrid.CornerRadius);
            });
        }
        public void VerifyVisualTreeExampleLoadAndVerifyForDarkThemeWithCustomName()
        {
            if (!PlatformConfiguration.IsOsVersion(OSVersion.Redstone5))
            {
                return;
            }

            var       xaml = @"<Grid Width='400' Height='400' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'> 
                       </Grid>";
            UIElement root = VisualTreeTestHelper.SetupVisualTree(xaml);

            RunOnUIThread.Execute(() =>
            {
                (root as FrameworkElement).RequestedTheme = ElementTheme.Dark;
            });
            VisualTreeTestHelper.VerifyVisualTree(root: root,
                                                  masterFilePrefix: "VerifyVisualTreeExampleLoadAndVerifyForDarkThemeWithCustomName");
        }
 private string SearchBestMatchedMasterFileName(string fileNamePrefix)
 {
     for (ushort version = PlatformConfiguration.GetCurrentAPIVersion(); version >= 2; version--)
     {
         string fileName = string.Format("{0}-{1}.xml", fileNamePrefix, version);
         if (MasterFileStorage.IsMasterFilePresent(fileName))
         {
             return(fileName);
         }
     }
     {
         string fileName = fileNamePrefix + ".xml";
         if (MasterFileStorage.IsMasterFilePresent(fileName))
         {
             return(fileName);
         }
     }
     return(null);
 }
示例#10
0
        public void VerifyNoResourceKeysWereRemovedFromPreviousStableReleaseInV2Styles()
        {
            if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone5))
            {
                // https://github.com/microsoft/microsoft-ui-xaml/issues/4674
                Log.Comment("Skipping validation below RS5.");
                return;
            }

            RunOnUIThread.Execute(() =>
            {
                EnsureNoMissingThemeResources(
                    BaselineResources.BaselineResourcesList2dot5Stable,
                    new XamlControlsResources()
                {
                    ControlsResourcesVersion = ControlsResourcesVersion.Version2
                });
            });
        }
 private string GetExpectedMasterFileName(string fileNamePrefix)
 {
     return(string.Format("{0}-{1}.xml", fileNamePrefix, PlatformConfiguration.GetCurrentAPIVersion()));
 }