Пример #1
0
        public void ResourceManagerWithFile()
        {
            var resourceManager = new ResourceManager("resources.pri.standalone");
            var resourceMap     = resourceManager.MainResourceMap;
            var map             = resourceMap.GetSubtree("resources");

            Verify.AreNotEqual(map.ResourceCount, 0u);
            var resource = map.GetValue("IDS_MANIFEST_MUSIC_APP_NAME").ValueAsString;

            Verify.AreEqual(resource, "Groove Music");
        }
        private void CompositionTarget_Rendering(object sender, object e)
        {
            CompositionTarget.Rendering -= CompositionTarget_Rendering;

            // Find and store FullWindow Media Root
            _fullWindowMediaRoot = GetTopParent(_mpe.TransportControls);
            Verify.AreNotEqual(_visualRoot, _fullWindowMediaRoot);

            _mpe.IsFullWindow = false;
            _mediaFullScreened.Set();
        }
Пример #3
0
        public void MultipleDiscoveries()
        {
            using (RemoteControllerLogGroup lg = new RemoteControllerLogGroup(remoteWFDController))
            {
                // Publish 2 services on remote
                var publishParams1 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser1 = ExecutePublishScenario(publishParams1);
                var publishParams2 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser2 = ExecutePublishScenario(publishParams2);

                // Quick sanity check that the service names are different
                Verify.AreNotEqual(publishParams1.ServiceName, publishParams2.ServiceName);

                // Discover same services from local
                var discoveryParams1 = new ServicesDiscoveryParameters(
                    publishParams1.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser1
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams1);

                var discoveryParams2 = new ServicesDiscoveryParameters(
                    publishParams2.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser2
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams2);

                // Publish 3rd service on remote
                var publishParams3 = new ServicesPublishParameters(
                    remoteWFDController.GenerateUniqueServiceName()
                    );
                WFDSvcWrapperHandle advertiser3 = ExecutePublishScenario(publishParams3);

                Verify.AreNotEqual(publishParams3.ServiceName, publishParams1.ServiceName);
                Verify.AreNotEqual(publishParams3.ServiceName, publishParams2.ServiceName);

                // Discover 3rd service from local
                var discoveryParams3 = new ServicesDiscoveryParameters(
                    publishParams3.ServiceName,
                    advertisersToMatch: new List <WFDSvcWrapperHandle> {
                    advertiser3
                }
                    );
                ExecuteDiscoveryScenario(discoveryParams3);
            }
        }
Пример #4
0
        public void DefaultResourceManagerWithExePri()
        {
            File.Copy(Path.Combine(m_assemblyFolder, "resources.pri.standalone"), Path.Combine(m_assemblyFolder, "te.processhost.pri"));

            var resourceManager = new ResourceManager();
            var resourceMap     = resourceManager.MainResourceMap;
            var map             = resourceMap.GetSubtree("resources");

            Verify.AreNotEqual(map.ResourceCount, 0u);
            var resource = map.GetValue("IDS_MANIFEST_MUSIC_APP_NAME").ValueAsString;

            Verify.AreEqual(resource, "Groove Music");
        }
Пример #5
0
        public void VerifyAccessibilityView()
        {
            RunOnUIThread.Execute(() =>
            {
                var progressRing      = new ProgressRing();
                progressRing.IsActive = true;

                Verify.AreNotEqual(AccessibilityView.Raw, AutomationProperties.GetAccessibilityView(progressRing));

                progressRing.IsActive = false;
                Verify.AreEqual(AccessibilityView.Raw, AutomationProperties.GetAccessibilityView(progressRing));
            });
        }
Пример #6
0
        public static void TestEncryption(string message)
        {
            string encryptedMessage = CryptographyHelper.Encrypt(message);

            if (!string.IsNullOrEmpty(message))
            {
                Verify.AreNotEqual(message, encryptedMessage);
            }

            string decryptedMessage = CryptographyHelper.Decrypt(encryptedMessage);

            Verify.AreEqual(message, decryptedMessage);
        }
        [TestProperty("TestPass:IncludeOnlyOn", "Desktop")] // TeachingTip doesn't appear to show up correctly in OneCore.
        public void TeachingTipBackgroundTest()
        {
            var loadedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                TeachingTip teachingTip = new TeachingTip();
                teachingTip.Loaded     += (object sender, RoutedEventArgs args) => { loadedEvent.Set(); };
                MUXControlsTestApp.App.TestContentRoot = teachingTip;
            });

            IdleSynchronizer.Wait();
            loadedEvent.WaitOne();

            RunOnUIThread.Execute(() =>
            {
                TeachingTip teachingTip = (TeachingTip)MUXControlsTestApp.App.TestContentRoot;
                var redBrush            = new SolidColorBrush(Colors.Red);
                teachingTip.SetValue(TeachingTip.BackgroundProperty, redBrush);
                Verify.AreSame(redBrush, teachingTip.GetValue(TeachingTip.BackgroundProperty) as Brush);
                Verify.AreSame(redBrush, teachingTip.Background);

                var blueBrush          = new SolidColorBrush(Colors.Blue);
                teachingTip.Background = blueBrush;
                Verify.AreSame(blueBrush, teachingTip.Background);

                var child      = VisualTreeHelper.GetChild(teachingTip, 0);
                var grandChild = VisualTreeHelper.GetChild(child, 1);
                Verify.AreSame(blueBrush, ((Grid)grandChild).Background);

                teachingTip.IsLightDismissEnabled = true;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                TeachingTip teachingTip = (TeachingTip)MUXControlsTestApp.App.TestContentRoot;
                var blueBrush           = new SolidColorBrush(Colors.Blue);
                Verify.AreEqual(blueBrush.Color, ((SolidColorBrush)teachingTip.Background).Color);
                var child      = VisualTreeHelper.GetChild(teachingTip, 0);
                var grandChild = VisualTreeHelper.GetChild(child, 1);
                var grandChildBackgroundBrush = ((Grid)grandChild).Background;
                //If we can no longer cast the background brush to a solid color brush then changing the
                //IsLightDismissEnabled has changed the background as we expected it to.
                if (grandChildBackgroundBrush is SolidColorBrush)
                {
                    Verify.AreNotEqual(blueBrush.Color, ((SolidColorBrush)grandChildBackgroundBrush).Color);
                }
            });
        }
        public void ChangingVisualTrees()
        {
            AnimatedIcon animatedIcon    = null;
            Grid         parentGrid      = null;
            Grid         grandParentGrid = null;
            Grid         newParentGrid   = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon    = new AnimatedIcon();
                parentGrid      = new Grid();
                grandParentGrid = new Grid();
                newParentGrid   = new Grid();
                parentGrid.Children.Add(animatedIcon);
                grandParentGrid.Children.Add(parentGrid);
                AnimatedIcon.SetState(parentGrid, "Initial State");

                Content = grandParentGrid;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(parentGrid, stateString);
                Verify.AreEqual(stateString, AnimatedIcon.GetState(animatedIcon));

                parentGrid.Children.Clear();
                newParentGrid.Children.Add(animatedIcon);
                grandParentGrid.Children.Clear();
                grandParentGrid.Children.Add(newParentGrid);
                AnimatedIcon.SetState(newParentGrid, "Initial State");

                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string state2String = "Test State2";
                AnimatedIcon.SetState(newParentGrid, state2String);
                Verify.AreEqual(state2String, AnimatedIcon.GetState(animatedIcon));

                string badStateString = "Bad State";
                AnimatedIcon.SetState(parentGrid, badStateString);
                Verify.AreNotEqual(badStateString, AnimatedIcon.GetState(animatedIcon));
            });
        }
Пример #9
0
        public static void SetHorizontalScrollPercent(Scroller scroller, double horizontalPercent)
        {
            Verify.IsNotNull(scroller);
            Verify.AreNotEqual(horizontalPercent, 0.0);
            Log.Comment("ScrollHelper.SetHorizontalScrollPercent scroller={0}, horizontalPercent={1}, before-horizontal-offset={2}.",
                        string.IsNullOrWhiteSpace(scroller.AutomationId) ? scroller.Name : scroller.AutomationId,
                        horizontalPercent,
                        scroller.HorizontalScrollPercent);

            scroller.SetScrollPercent(horizontalPercent, -1 /*NoScroll*/);
            Wait.ForScrollChanged(scroller, ScrollProperty.HorizontalScrollPercent);

            Log.Comment("ScrollHelper.SetHorizontalScrollPercent after-horizontal-offset={0}.",
                        scroller.HorizontalScrollPercent);
        }
Пример #10
0
        public static void ScrollVertically(Scroller scroller, ScrollAmount amount)
        {
            Verify.IsNotNull(scroller);
            Verify.AreNotEqual(amount, ScrollAmount.NoAmount);
            Log.Comment("ScrollHelper.ScrollVertically scroller={0}, amount={1}, before-offset={2}.",
                        string.IsNullOrWhiteSpace(scroller.AutomationId) ? scroller.Name : scroller.AutomationId,
                        amount,
                        scroller.VerticalScrollPercent);

            scroller.ScrollVertical(amount);
            Wait.ForScrollChanged(scroller, ScrollProperty.VerticalScrollPercent);

            Log.Comment("ScrollHelper.ScrollVertically after-offset={0}.",
                        scroller.VerticalScrollPercent);
        }
 public void VerifyTabKeyWorks()
 {
     using (var setup = new TestSetupHelper("TwoPaneView Tests")) // This clicks the button corresponding to the test page.
     {
         UIObject twoPaneView = TryFindElement.ByName("TwoPaneViewLarge");
         Verify.IsNotNull(twoPaneView, "TwoPaneView is present");
         twoPaneView.SetFocus();
         Wait.ForIdle();
         Verify.AreNotEqual(UIObject.Focused, twoPaneView, "TwoPaneView should not be focused");
         KeyboardHelper.PressKey(Key.Tab);
         Verify.AreNotEqual(UIObject.Focused, twoPaneView, "TwoPaneView should not be focused");
         KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift);
         Verify.AreNotEqual(UIObject.Focused, twoPaneView, "TwoPaneView should not be focused");
     }
 }
Пример #12
0
        public void TestChannelerTalentAutosetRule()
        {
            var channeler = new ChannelerTalent();

            var behavior       = this.playerThing.Behaviors.FindFirst <TalentsBehavior>();
            var damageStat     = this.playerThing.FindGameStat("Damage");
            int oldDamaveValue = damageStat.Value;

            behavior.AddTalent(channeler);

            Verify.AreNotEqual(oldDamaveValue, damageStat.Value);

            behavior.RemoveTalent(channeler);

            Verify.AreEqual(oldDamaveValue, damageStat.Value);
        }
Пример #13
0
        public void TestMassiveAttackTalentAutosetRule()
        {
            var massiveAttack = new MassiveAttackTalent();

            var behavior = this.playerThing.Behaviors.FindFirst <TalentsBehavior>();

            var damageStat     = this.playerThing.FindGameStat("Damage");
            int oldDamaveValue = damageStat.Value;

            behavior.AddTalent(massiveAttack);

            Verify.AreNotEqual(oldDamaveValue, damageStat.Value);

            behavior.RemoveTalent(massiveAttack);

            Verify.AreEqual(oldDamaveValue, damageStat.Value);
        }
        public void TestProvisionOfDefaultImageStoreConnectionString()
        {
            using (FabricLayoutInfo fabricLayoutInfo = new FabricLayoutInfo(this.imageStore))
            {
                string defaultImageStoreConnectionString = "_default_";
                fabricLayoutInfo.PatchVersion = null;

                TestUtility.AddToFabricSettings(
                    FabricValidatorConstants.SectionNames.Management,
                    FabricValidatorConstants.ParameterNames.ImageStoreConnectionString,
                    defaultImageStoreConnectionString,
                    false /*isEncrypted*/,
                    fabricLayoutInfo.ClusterManifest);

                string codePath, configPath, infrastructureManifestFilePath;
                fabricLayoutInfo.Create(out codePath, out configPath, out infrastructureManifestFilePath);

                string currentExecutingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
                string configurationCsvFilePath  = Path.Combine(currentExecutingDirectory, "Configurations.csv");

                this.imageBuilder.ProvisionFabric(
                    codePath,
                    configPath,
                    configurationCsvFilePath,
                    infrastructureManifestFilePath,
                    TimeSpan.MaxValue);

                string clusterManifestPath = Path.Combine(
                    "WindowsFabricStore",
                    string.Format("ClusterManifest.{0}.xml",
                                  fabricLayoutInfo.ClusterManifest.Version));
                var provisionedClusterManifest = fabricLayoutInfo.ImageStoreWrapper.GetFromStore <ClusterManifestType>(clusterManifestPath, TestUtility.ImageStoreDefaultTimeout);

                var imageStoreConnectionStringValue = provisionedClusterManifest.FabricSettings.First(
                    section => TestUtility.Equals(section.Name, FabricValidatorConstants.SectionNames.Management)).Parameter.First(
                    parameter => TestUtility.Equals(parameter.Name, FabricValidatorConstants.ParameterNames.ImageStoreConnectionString)).Value;

                Verify.AreNotEqual(imageStoreConnectionStringValue, defaultImageStoreConnectionString);

                Verify.IsTrue(imageStoreConnectionStringValue.StartsWith("file:"));

                TestUtility.VerifyWinFabLayout(fabricLayoutInfo);
            }
        }
Пример #15
0
        public static void Scroll(Scroller scroller, ScrollAmount horizontalAmount, ScrollAmount verticalAmount)
        {
            Verify.IsNotNull(scroller);
            Verify.AreNotEqual(horizontalAmount, ScrollAmount.NoAmount);
            Verify.AreNotEqual(verticalAmount, ScrollAmount.NoAmount);
            Log.Comment("ScrollHelper.Scroll scroller={0}, horizontalAmount={1}, verticalAmount={2}, before-horizontal-offset={3}, before-vertical-offset={4}.",
                        string.IsNullOrWhiteSpace(scroller.AutomationId) ? scroller.Name : scroller.AutomationId,
                        horizontalAmount,
                        verticalAmount,
                        scroller.HorizontalScrollPercent,
                        scroller.VerticalScrollPercent);

            scroller.Scroll(horizontalAmount, verticalAmount);
            Wait.ForScrollChanged(scroller, ScrollProperty.HorizontalScrollPercent);

            Log.Comment("ScrollHelper.Scroll after-horizontal-offset={0}, after-vertical-offset={1}.",
                        scroller.HorizontalScrollPercent,
                        scroller.VerticalScrollPercent);
        }
Пример #16
0
 private static void ValidateCommand(bool isValidScenario, CLIApplication application, string[] args)
 {
     try
     {
         if (isValidScenario)
         {
             // the command should be valid
             Verify.AreEqual(application.Execute(args), 0);
         }
         else
         {
             // the command should be invalid
             Verify.AreNotEqual(application.Execute(args), 0);
         }
     }
     catch (Exception e)
     {
         Verify.Fail(e.Message);
     }
 }
Пример #17
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();
        }
Пример #18
0
        public void CanSetStateOnAnimatedIconDirectlyWithoutPropagationToChild()
        {
            AnimatedIcon animatedIcon = null;

            RunOnUIThread.Execute(() =>
            {
                animatedIcon = new AnimatedIcon();

                Content = animatedIcon;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                string stateString = "Test State";
                AnimatedIcon.SetState(animatedIcon, stateString);
                Verify.AreEqual(stateString, AnimatedIcon.GetState(animatedIcon));
                Verify.AreNotEqual(stateString, AnimatedIcon.GetState(VisualTreeHelper.GetChild(animatedIcon, 0)));
            });
        }
Пример #19
0
        public void TestChampionTalentAutosetRule()
        {
            var champion = new ChampionTalent();

            var behavior = this.playerThing.Behaviors.FindFirst <TalentsBehavior>();

            var attackStat     = this.playerThing.FindGameStat("Attack");
            int oldAttackValue = attackStat.Value;

            var damageStat     = this.playerThing.FindGameStat("Damage");
            int oldDamageValue = damageStat.Value;

            behavior.AddTalent(champion);

            Verify.AreNotEqual(oldAttackValue, attackStat.Value);
            Verify.AreNotEqual(oldDamageValue, damageStat.Value);

            behavior.RemoveTalent(champion);

            Verify.AreEqual(oldAttackValue, attackStat.Value);
            Verify.AreEqual(oldDamageValue, damageStat.Value);
        }
        [TestProperty("TestPass:IncludeOnlyOn", "Desktop")] // TeachingTip doesn't appear to show up correctly in OneCore.
        public void TeachingTipBackgroundTest()
        {
            TeachingTip     teachingTip = null, teachingTipLightDismiss = null;
            SolidColorBrush blueBrush = null;
            Brush           lightDismissBackgroundBrush = null;
            var             loadedEvent = new AutoResetEvent(false);

            RunOnUIThread.Execute(() =>
            {
                Grid root           = new Grid();
                teachingTip         = new TeachingTip();
                teachingTip.Loaded += (object sender, RoutedEventArgs args) => { loadedEvent.Set(); };

                teachingTipLightDismiss = new TeachingTip();
                teachingTipLightDismiss.IsLightDismissEnabled = true;

                // Set LightDismiss background before show... it shouldn't take effect in the tree
                blueBrush = new SolidColorBrush(Colors.Blue);
                teachingTipLightDismiss.Background = blueBrush;

                root.Resources.Add("TeachingTip", teachingTip);
                root.Resources.Add("TeachingTipLightDismiss", teachingTipLightDismiss);

                lightDismissBackgroundBrush = MUXControlsTestApp.App.Current.Resources["TeachingTipTransientBackground"] as Brush;
                Verify.IsNotNull(lightDismissBackgroundBrush, "lightDismissBackgroundBrush");

                teachingTip.IsOpen             = true;
                teachingTipLightDismiss.IsOpen = true;

                MUXControlsTestApp.App.TestContentRoot = root;
            });

            IdleSynchronizer.Wait();
            loadedEvent.WaitOne();
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                var redBrush = new SolidColorBrush(Colors.Red);
                teachingTip.SetValue(TeachingTip.BackgroundProperty, redBrush);
                Verify.AreSame(redBrush, teachingTip.GetValue(TeachingTip.BackgroundProperty) as Brush);
                Verify.AreSame(redBrush, teachingTip.Background);

                teachingTip.Background = blueBrush;
                Verify.AreSame(blueBrush, teachingTip.Background);

                {
                    var popup      = TeachingTipTestHooks.GetPopup(teachingTip);
                    var child      = popup.Child;
                    var grandChild = VisualTreeHelper.GetChild(child, 0);
                    Verify.AreSame(blueBrush, ((Grid)grandChild).Background, "Checking TeachingTip.Background TemplateBinding works");
                }

                {
                    var popup       = TeachingTipTestHooks.GetPopup(teachingTipLightDismiss);
                    var child       = popup.Child;
                    var grandChild  = VisualTreeHelper.GetChild(child, 0);
                    var actualBrush = ((Grid)grandChild).Background;
                    Log.Comment("Checking LightDismiss TeachingTip Background is using resource for first invocation");
                    if (lightDismissBackgroundBrush != actualBrush)
                    {
                        if (actualBrush is SolidColorBrush actualSolidBrush)
                        {
                            string teachingTipMessage = $"LightDismiss TeachingTip Background is SolidColorBrush with color {actualSolidBrush.Color}";
                            Log.Comment(teachingTipMessage);
                            Verify.Fail(teachingTipMessage);
                        }
                        else
                        {
                            Verify.AreSame(lightDismissBackgroundBrush, actualBrush, "Checking LightDismiss TeachingTip Background is using resource for first invocation");
                        }
                    }
                }

                teachingTip.IsLightDismissEnabled = true;
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                Verify.AreEqual(blueBrush.Color, ((SolidColorBrush)teachingTip.Background).Color);

                var popup      = TeachingTipTestHooks.GetPopup(teachingTip);
                var child      = popup.Child as Grid;
                var grandChild = VisualTreeHelper.GetChild(child, 0);
                var grandChildBackgroundBrush = ((Grid)grandChild).Background;
                //If we can no longer cast the background brush to a solid color brush then changing the
                //IsLightDismissEnabled has changed the background as we expected it to.
                if (grandChildBackgroundBrush is SolidColorBrush)
                {
                    Verify.AreNotEqual(blueBrush.Color, ((SolidColorBrush)grandChildBackgroundBrush).Color);
                }
            });
        }
Пример #21
0
Файл: Basic.cs Проект: i2ali/RAD
        public void CreateSlicerFactory()
        {
            // This function saves a bitmap source
            Action <String, BitmapSource> saveBitmapSource = (String argFileName, BitmapSource argBitmapSource) =>
            {
                FileStream       stream  = new FileStream(argFileName, FileMode.Create);
                BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(argBitmapSource));
                encoder.Save(stream);
                stream.Flush();
                stream.Close();
            };

            // This function creates a bitmap source from a system bitmap
            Func <SystemBitmap, BitmapSource> createBitmapSource = (SystemBitmap argSystemBitmap) =>
            {
                // Convert from RGBA to BGRA
                uint currentScanLine = 0;

                for (uint y = 0; y < argSystemBitmap.Height; ++y)
                {
                    uint currentPixel = currentScanLine;

                    for (uint x = 0; x < argSystemBitmap.Width; ++x)
                    {
                        byte tempRed = argSystemBitmap.Data[currentPixel + 0];
                        argSystemBitmap.Data[currentPixel + 0] = argSystemBitmap.Data[currentPixel + 2];
                        argSystemBitmap.Data[currentPixel + 2] = tempRed;

                        currentPixel += 4;
                    }

                    currentScanLine += argSystemBitmap.Stride;
                }


                return(BitmapSource.Create(
                           (int)argSystemBitmap.Width,
                           (int)argSystemBitmap.Height,
                           96,
                           96,
                           PixelFormats.Bgra32,
                           null,
                           argSystemBitmap.Data,
                           (int)argSystemBitmap.Stride));
            };


            SlicerFactory slicerFactory = null;
            IGdiSlicer    gdiSlicer     = null;
            IDwmSlicer    dwmSlicer     = null;


            // Test creating a slicer factory
            int retval = SlicerFactory.Create(out slicerFactory, ComputeShaderModel.None);

            Verify.AreEqual(0, retval, String.Format("SlicerFactory.Create: {0:X08}", retval));
            Verify.IsNotNull(slicerFactory);

            // Put the SlicerFactory object in a "using" block so that we test
            // what happens when the SlicerFactory's resources are freed.
            using (slicerFactory)
            {
                // Test creating a GDI slicer
                retval = slicerFactory.CreateGdiSlicer(out gdiSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateGdiSlicer: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicer);

                // Test creating a DWM slicer
                retval = slicerFactory.CreateDwmSlicer(out dwmSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateDwmSlicer: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicer);
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and GDI slicer after the slcier factory has been
            // destroyed
            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("gdiSlicerTestManaged.1.0.bmp", createBitmapSource(gdiSlicerBitmap));
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("gdiSlicerTestManaged.2.0.bmp", createBitmapSource(gdiSlicerBitmapLeft));
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNotNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("gdiSlicerTestManaged.3.0.bmp", createBitmapSource(gdiSlicerBitmapLeft));
                saveBitmapSource("gdiSlicerTestManaged.3.1.bmp", createBitmapSource(gdiSlicerBitmapRight));
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and DWM slicer after the slcier factory has been
            // destroyed
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;
                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("dwmSlicerTestManaged.1.0.bmp", createBitmapSource(dwmSlicerBitmap));
            }

            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("dwmSlicerTestManaged.2.0.bmp", createBitmapSource(dwmSlicerBitmapLeft));
            }

            // Note: Windows 8 Bugs #11553 and Windows Blue Bugs #22133
            // Capture left and right channels
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNotNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                saveBitmapSource("dwmSlicerTestManaged.3.0.bmp", createBitmapSource(dwmSlicerBitmapLeft));
                saveBitmapSource("dwmSlicerTestManaged.3.1.bmp", createBitmapSource(dwmSlicerBitmapRight));
            }
        }
        public void ColorPickerTest()
        {
            RunOnUIThread.Execute(() =>
            {
                ColorPicker colorPicker = new ColorPicker();
                Verify.IsNotNull(colorPicker);

                Verify.AreEqual(Colors.White, colorPicker.Color);
                Verify.IsNull(colorPicker.PreviousColor);
                Verify.IsFalse(colorPicker.IsAlphaEnabled);
                Verify.IsTrue(colorPicker.IsColorSpectrumVisible);
                Verify.IsTrue(colorPicker.IsColorPreviewVisible);
                Verify.IsTrue(colorPicker.IsColorSliderVisible);
                Verify.IsTrue(colorPicker.IsAlphaSliderVisible);
                Verify.IsFalse(colorPicker.IsMoreButtonVisible);
                Verify.IsTrue(colorPicker.IsColorChannelTextInputVisible);
                Verify.IsTrue(colorPicker.IsAlphaTextInputVisible);
                Verify.IsTrue(colorPicker.IsHexInputVisible);
                Verify.AreEqual(0, colorPicker.MinHue);
                Verify.AreEqual(359, colorPicker.MaxHue);
                Verify.AreEqual(0, colorPicker.MinSaturation);
                Verify.AreEqual(100, colorPicker.MaxSaturation);
                Verify.AreEqual(0, colorPicker.MinValue);
                Verify.AreEqual(100, colorPicker.MaxValue);
                Verify.AreEqual(ColorSpectrumShape.Box, colorPicker.ColorSpectrumShape);
                Verify.AreEqual(ColorSpectrumComponents.HueSaturation, colorPicker.ColorSpectrumComponents);

                // Clamping the min and max properties changes the color value,
                // so let's test this new value before we change those.
                colorPicker.Color = Colors.Green;
                Verify.AreEqual(Colors.Green, colorPicker.Color);

                colorPicker.PreviousColor                  = Colors.Red;
                colorPicker.IsAlphaEnabled                 = true;
                colorPicker.IsColorSpectrumVisible         = false;
                colorPicker.IsColorPreviewVisible          = false;
                colorPicker.IsColorSliderVisible           = false;
                colorPicker.IsAlphaSliderVisible           = false;
                colorPicker.IsMoreButtonVisible            = true;
                colorPicker.IsColorChannelTextInputVisible = false;
                colorPicker.IsAlphaTextInputVisible        = false;
                colorPicker.IsHexInputVisible              = false;
                colorPicker.MinHue                  = 10;
                colorPicker.MaxHue                  = 300;
                colorPicker.MinSaturation           = 10;
                colorPicker.MaxSaturation           = 90;
                colorPicker.MinValue                = 10;
                colorPicker.MaxValue                = 90;
                colorPicker.ColorSpectrumShape      = ColorSpectrumShape.Ring;
                colorPicker.ColorSpectrumComponents = ColorSpectrumComponents.HueValue;

                Verify.AreNotEqual(Colors.Green, colorPicker.Color);
                Verify.AreEqual(Colors.Red, colorPicker.PreviousColor);
                Verify.IsTrue(colorPicker.IsAlphaEnabled);
                Verify.IsFalse(colorPicker.IsColorSpectrumVisible);
                Verify.IsFalse(colorPicker.IsColorPreviewVisible);
                Verify.IsFalse(colorPicker.IsColorSliderVisible);
                Verify.IsFalse(colorPicker.IsAlphaSliderVisible);
                Verify.IsTrue(colorPicker.IsMoreButtonVisible);
                Verify.IsFalse(colorPicker.IsColorChannelTextInputVisible);
                Verify.IsFalse(colorPicker.IsAlphaTextInputVisible);
                Verify.IsFalse(colorPicker.IsHexInputVisible);
                Verify.AreEqual(10, colorPicker.MinHue);
                Verify.AreEqual(300, colorPicker.MaxHue);
                Verify.AreEqual(10, colorPicker.MinSaturation);
                Verify.AreEqual(90, colorPicker.MaxSaturation);
                Verify.AreEqual(10, colorPicker.MinValue);
                Verify.AreEqual(90, colorPicker.MaxValue);
                Verify.AreEqual(ColorSpectrumShape.Ring, colorPicker.ColorSpectrumShape);
                Verify.AreEqual(ColorSpectrumComponents.HueValue, colorPicker.ColorSpectrumComponents);
            });
        }
Пример #23
0
        public void ExpanderAutomationPeerTest()
        {
            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'
                             xmlns:controls='using:Microsoft.UI.Xaml.Controls'> 
                             <controls:Expander x:Name ='ExpandedExpander' AutomationProperties.Name='ExpandedExpander' IsExpanded='True' Margin='12' HorizontalAlignment='Left'>
                                <controls:Expander.Header>
                                    <Grid>
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition />
                                            <ColumnDefinition Width='80'/>
                                        </Grid.ColumnDefinitions>
                                        <StackPanel Margin='0,14,0,16'>
                                            <TextBlock AutomationProperties.Name='test' Text='This expander is expanded by default.'  Margin='0,0,0,4' />
                                            <TextBlock Text='This is the second line of text.' />
                                        </StackPanel>
                                        <ToggleSwitch Grid.Column='1'/>
                                    </Grid>
                                </controls:Expander.Header>
                                <Button AutomationProperties.AutomationId = 'ExpandedExpanderContent'> Content </Button>
                             </controls:Expander>
                                    </StackPanel>");

                Content = root;
                Content.UpdateLayout();

                var expander = VisualTreeHelper.GetChild(root, 0) as Expander;

                expander.IsExpanded = true;
                Content.UpdateLayout();

                var grid             = VisualTreeHelper.GetChild(expander, 0);
                var toggleButton     = VisualTreeHelper.GetChild(grid, 0);
                var toggleButtonGrid = VisualTreeHelper.GetChild(toggleButton, 0);
                var contentPresenter = VisualTreeHelper.GetChild(toggleButtonGrid, 0);
                var grid2            = VisualTreeHelper.GetChild(contentPresenter, 0);
                var stackPanel       = VisualTreeHelper.GetChild(grid2, 0);
                var textBlock1       = VisualTreeHelper.GetChild(stackPanel, 0) as TextBlock;
                var textBlock2       = VisualTreeHelper.GetChild(stackPanel, 1) as TextBlock;
                var toggleSwitch     = VisualTreeHelper.GetChild(grid2, 1) as ToggleSwitch;

                var border = VisualTreeHelper.GetChild(grid, 1);
                var expanderContentBorder           = VisualTreeHelper.GetChild(border, 0);
                var expanderContentContentPresenter = VisualTreeHelper.GetChild(expanderContentBorder, 0);
                var button = VisualTreeHelper.GetChild(expanderContentContentPresenter, 0) as Button;

                Verify.AreEqual("ExpandedExpander", AutomationProperties.GetName(expander));

                // Verify ExpandedExpander header content are included in the accessibility tree
                Verify.AreEqual(AutomationProperties.GetAccessibilityView(textBlock1), AccessibilityView.Content);
                Verify.AreEqual(AutomationProperties.GetAccessibilityView(textBlock2), AccessibilityView.Content);
                Verify.AreEqual(AutomationProperties.GetAccessibilityView(toggleSwitch), AccessibilityView.Content);

                // Verify ExpandedExpander content is included in the accessibility tree
                Verify.AreEqual(AutomationProperties.GetAccessibilityView(button), AccessibilityView.Content);

                expander.IsExpanded = false;
                Content.UpdateLayout();

                // Verify ExpandedExpander content is not included in the accessibility tree and not readable once collapsed
                Verify.AreNotEqual(AutomationProperties.GetAccessibilityView(button), AccessibilityView.Raw);
            });
        }
Пример #24
0
        internal static void TokenCacheOperationsTest()
        {
            var tokenCache = new TokenCache();

            var cacheDictionary = tokenCache.tokenCacheDictionary;

            tokenCache.Clear();

            TokenCacheKey key  = new TokenCacheKey("https://localhost/MockSts", "resource1", "client1", TokenSubjectType.User, null, "user1");
            TokenCacheKey key2 = new TokenCacheKey("https://localhost/MockSts", "resource1", "client1", TokenSubjectType.User, null, "user2");
            TokenCacheKey key3 = new TokenCacheKey("https://localhost/MockSts", "resource1", "client1", TokenSubjectType.UserPlusClient, null, "user1");

            Verify.AreNotEqual(key, key3);

            var value = CreateCacheValue(null, "user1");
            AuthenticationResult value2;

            do
            {
                value2 = CreateCacheValue(null, "user2");
            }while (value2 == value);

            Verify.AreEqual(0, cacheDictionary.Count);
            AddToDictionary(tokenCache, key, value);
            Verify.AreEqual(1, cacheDictionary.Count);
            var valueInCache = cacheDictionary[key];

            VerifyAuthenticationResultsAreEqual(valueInCache, value);
            VerifyAuthenticationResultsAreNotEqual(valueInCache, value2);
            cacheDictionary[key] = value2;
            Verify.AreEqual(1, cacheDictionary.Count);
            valueInCache = cacheDictionary[key];
            VerifyAuthenticationResultsAreEqual(valueInCache, value2);
            VerifyAuthenticationResultsAreNotEqual(valueInCache, value);
            try
            {
                AddToDictionary(tokenCache, key, value);
                Verify.Fail("Exception expected due to duplicate key");
            }
            catch (ArgumentException)
            {
                // Expected
            }

            Verify.IsTrue(RemoveFromDictionary(tokenCache, key));
            Verify.IsFalse(RemoveFromDictionary(tokenCache, key));
            Verify.AreEqual(0, cacheDictionary.Count);

            AddToDictionary(tokenCache, key, value);
            AddToDictionary(tokenCache, key2, value2);
            Verify.AreEqual(2, cacheDictionary.Count);
            Verify.AreEqual(cacheDictionary[key], value);
            Verify.AreEqual(cacheDictionary[key2], value2);

            try
            {
                AddToDictionary(tokenCache, null, value);
                Verify.Fail("Exception expected due to duplicate key");
            }
            catch (ArgumentNullException)
            {
                // Expected
            }

            try
            {
                cacheDictionary[null] = value;
                Verify.Fail("Exception expected due to duplicate key");
            }
            catch (ArgumentNullException)
            {
                // Expected
            }

            Verify.IsFalse(cacheDictionary.IsReadOnly);

            var keys   = cacheDictionary.Keys.ToList();
            var values = cacheDictionary.Values.ToList();

            Verify.AreEqual(2, keys.Count);
            Verify.AreEqual(2, values.Count);
            if (keys[0].Equals(key))
            {
                Verify.AreEqual(keys[1], key2);
                Verify.AreEqual(values[0], value);
                Verify.AreEqual(values[1], value2);
            }
            else
            {
                Verify.AreEqual(keys[0], key2);
                Verify.AreEqual(keys[1], key);
                Verify.AreEqual(values[0], value2);
                Verify.AreEqual(values[1], value);
            }

            Verify.IsTrue(cacheDictionary.ContainsKey(key));
            Verify.IsTrue(cacheDictionary.ContainsKey(key2));
            Verify.IsFalse(cacheDictionary.ContainsKey(key3));

            Verify.IsTrue(cacheDictionary.Contains(new KeyValuePair <TokenCacheKey, AuthenticationResult>(key, value)));
            Verify.IsTrue(cacheDictionary.Contains(new KeyValuePair <TokenCacheKey, AuthenticationResult>(key2, value2)));
            Verify.IsFalse(cacheDictionary.Contains(new KeyValuePair <TokenCacheKey, AuthenticationResult>(key, value2)));
            Verify.IsFalse(cacheDictionary.Contains(new KeyValuePair <TokenCacheKey, AuthenticationResult>(key2, value)));

            try
            {
                AddToDictionary(tokenCache, key, value);
                Verify.Fail("Exception expected due to duplicate key");
            }
            catch (ArgumentException)
            {
                // Expected
            }

            AddToDictionary(tokenCache, key3, value);
            Verify.AreEqual(3, cacheDictionary.Keys.Count);
            Verify.IsTrue(cacheDictionary.ContainsKey(key3));

            var cacheItemsCopy = new KeyValuePair <TokenCacheKey, AuthenticationResult> [cacheDictionary.Count + 1];

            cacheDictionary.CopyTo(cacheItemsCopy, 1);
            for (int i = 0; i < cacheDictionary.Count; i++)
            {
                Verify.AreEqual(cacheItemsCopy[i + 1].Value, cacheDictionary[cacheItemsCopy[i + 1].Key]);
            }

            try
            {
                cacheDictionary.CopyTo(cacheItemsCopy, 2);
                Verify.Fail("Exception expected");
            }
            catch (ArgumentException)
            {
                // Expected
            }

            try
            {
                cacheDictionary.CopyTo(cacheItemsCopy, -1);
                Verify.Fail("Exception expected");
            }
            catch (ArgumentOutOfRangeException)
            {
                // Expected
            }

            RemoveFromDictionary(tokenCache, key2);
            Verify.AreEqual(2, cacheDictionary.Keys.Count);

            foreach (var kvp in cacheDictionary)
            {
                Verify.IsTrue(kvp.Key.Equals(key) || kvp.Key.Equals(key3));
                Verify.IsTrue(kvp.Value.Equals(value));
            }

            AuthenticationResult cacheValue;

            Verify.IsTrue(cacheDictionary.TryGetValue(key, out cacheValue));
            Verify.AreEqual(cacheValue, value);
            Verify.IsTrue(cacheDictionary.TryGetValue(key3, out cacheValue));
            Verify.AreEqual(cacheValue, value);
            Verify.IsFalse(cacheDictionary.TryGetValue(key2, out cacheValue));

            cacheDictionary.Clear();
            Verify.AreEqual(0, cacheDictionary.Keys.Count);
        }
        public void UpgradeWithSetting()
        {
            string currentExecutingDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string jsonFilePath    = Path.Combine(currentExecutingDirectory, "Application_No_Setting.json");
            string descriptionJson = File.ReadAllText(jsonFilePath);

            SingleInstance.Application application = JsonConvert.DeserializeObject <SingleInstance.Application>(descriptionJson);

            string applicationTypeName    = "MeshApplicationType";
            string applicationTypeVersion = "v1";
            Uri    applicationName        = new Uri("fabric:/myapp");
            string tempBuildPath          = Path.Combine(TestUtility.TestDirectory, Guid.NewGuid().ToString());
            string outputPath             = Path.Combine(TestUtility.TestDirectory, Guid.NewGuid().ToString());

            string applicationId = Guid.NewGuid().ToString();

            this.imageBuilder.BuildSingleInstanceApplication(
                application,
                applicationTypeName,
                applicationTypeVersion,
                applicationId,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath, // output pkg build path
                false,      //use open network
                false,      //use local nat network
                "C:\\",
                new SingleInstance.GenerationConfig());

            BuildLayoutInfo         buildLayoutInfo     = new BuildLayoutInfo(this.imageStore, tempBuildPath);
            ApplicationInstanceType applicationInstance = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 1);

            TestUtility.VerifyStoreLayout(buildLayoutInfo);

            StoreLayoutSpecification storeLayoutSpec = StoreLayoutSpecification.Create();

            storeLayoutSpec.SetRoot(outputPath);
            string servicePackageFile = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance.ServicePackageRef[0].RolloutVersion);
            var    servicepackage     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile, TestUtility.ImageStoreDefaultTimeout);

            string rolloutVersion1 = servicepackage.RolloutVersion;

            // Test Case 1: Instance Count change
            string jsonFilePath2    = Path.Combine(currentExecutingDirectory, "Application_No_Setting2.json");
            string descriptionJson2 = File.ReadAllText(jsonFilePath2);

            SingleInstance.Application application2 = JsonConvert.DeserializeObject <SingleInstance.Application>(descriptionJson2);

            string applicationTypeVersion2 = "v2";

            this.imageBuilder.BuildSingleInstanceApplicationForUpgrade(
                application2,
                applicationTypeName,
                applicationTypeVersion,
                applicationTypeVersion2,
                applicationId,
                applicationInstance.Version,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath,
                false, //use open network
                false, //use local nat network
                "C:\\",
                new SingleInstance.GenerationConfig());

            ApplicationInstanceType applicationInstance2 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 2);
            string servicePackageFile2 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance2.ServicePackageRef[0].RolloutVersion);
            var    servicepackage2     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile2, TestUtility.ImageStoreDefaultTimeout);

            Verify.AreEqual(servicepackage2.ManifestVersion, "v1");

            string rolloutVersion2 = servicepackage2.RolloutVersion;

            Verify.AreEqual(rolloutVersion1, rolloutVersion2);
            TestUtility.VerifyStoreLayout(buildLayoutInfo);

            // Test Case 2: Adding settings
            string jsonSettingFilePath1    = Path.Combine(currentExecutingDirectory, "Application_Setting1.json");
            string settingDescriptionJson1 = File.ReadAllText(jsonSettingFilePath1);

            SingleInstance.Application applicationWithSetting1 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson1);

            string applicationTypeVersion3 = "v3";

            this.imageBuilder.BuildSingleInstanceApplicationForUpgrade(
                applicationWithSetting1,
                applicationTypeName,
                applicationTypeVersion2,
                applicationTypeVersion3,
                applicationId,
                applicationInstance2.Version,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath,
                false, //use open network
                false, //use localnat network
                "C:\\",
                new SingleInstance.GenerationConfig());
            ApplicationInstanceType applicationInstance3 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 3);
            string servicePackageFile3 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance3.ServicePackageRef[0].RolloutVersion);
            var    servicepackage3     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile3, TestUtility.ImageStoreDefaultTimeout);

            Verify.AreEqual(servicepackage3.ManifestVersion, applicationTypeVersion3);

            string rolloutVersion3 = servicepackage3.RolloutVersion;

            Verify.AreNotEqual(rolloutVersion2, rolloutVersion3);
            TestUtility.VerifyStoreLayout(buildLayoutInfo);

            // Test Case 3: Changing settings only
            string jsonSettingFilePath2    = Path.Combine(currentExecutingDirectory, "Application_Setting2.json");
            string settingDescriptionJson2 = File.ReadAllText(jsonSettingFilePath2);

            SingleInstance.Application applicationWithSetting2 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson2);

            string applicationTypeVersion4 = "v4";

            this.imageBuilder.BuildSingleInstanceApplicationForUpgrade(
                applicationWithSetting2,
                applicationTypeName,
                applicationTypeVersion3,
                applicationTypeVersion4,
                applicationId,
                applicationInstance3.Version,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath,
                false, //use open network
                false, //use localnat network
                "C:\\",
                new SingleInstance.GenerationConfig());
            ApplicationInstanceType applicationInstance4 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 4);
            string servicePackageFile4 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance4.ServicePackageRef[0].RolloutVersion);
            var    servicepackage4     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile4, TestUtility.ImageStoreDefaultTimeout);

            Verify.AreEqual(servicepackage4.ManifestVersion, applicationTypeVersion4);

            // Code package version remains the same for settings upgrade
            foreach (var codePackage in servicepackage4.DigestedCodePackage)
            {
                Verify.AreEqual(applicationTypeVersion3, codePackage.CodePackage.Version);
            }
            // Config package version is set to target version for settings upgrade
            foreach (var configPackage in servicepackage4.DigestedConfigPackage)
            {
                Verify.AreEqual(applicationTypeVersion4, configPackage.ConfigPackage.Version);
            }

            string rolloutVersion4 = servicepackage4.RolloutVersion;

            Verify.AreNotEqual(rolloutVersion3, rolloutVersion4);
            TestUtility.VerifyStoreLayout(buildLayoutInfo);

            // Test Case 4: Keep settings
            string jsonSettingFilePath3    = Path.Combine(currentExecutingDirectory, "Application_Setting2InstanceCount.json");
            string settingDescriptionJson3 = File.ReadAllText(jsonSettingFilePath3);

            SingleInstance.Application applicationWithSetting3 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson3);

            string applicationTypeVersion5 = "v5";

            this.imageBuilder.BuildSingleInstanceApplicationForUpgrade(
                applicationWithSetting3,
                applicationTypeName,
                applicationTypeVersion4,
                applicationTypeVersion5,
                applicationId,
                applicationInstance4.Version,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath,
                false, //use open network
                false, //use localnat network
                "C:\\",
                new SingleInstance.GenerationConfig());
            ApplicationInstanceType applicationInstance5 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 5);
            string servicePackageFile5 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance5.ServicePackageRef[0].RolloutVersion);
            var    servicepackage5     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile5, TestUtility.ImageStoreDefaultTimeout);

            // SP manifest version remains the same
            Verify.AreEqual(servicepackage5.ManifestVersion, applicationTypeVersion4);

            // SP rollout version remains the same
            string rolloutVersion5 = servicepackage5.RolloutVersion;

            Verify.AreEqual(rolloutVersion4, rolloutVersion5);
            TestUtility.VerifyStoreLayout(buildLayoutInfo);

            // Test Case 5: Autoscaling - Instance Count change
            string jsonSettingFilePath4    = Path.Combine(currentExecutingDirectory, "Application_Setting3Autoscaling.json");
            string settingDescriptionJson4 = File.ReadAllText(jsonSettingFilePath4);

            SingleInstance.Application applicationWithSetting4 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson4);

            string applicationTypeVersion6 = "v6";

            this.imageBuilder.BuildSingleInstanceApplicationForUpgrade(
                applicationWithSetting4,
                applicationTypeName,
                applicationTypeVersion5,
                applicationTypeVersion6,
                applicationId,
                applicationInstance5.Version,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath,
                false, //use open network
                false, //use localnat network
                "C:\\",
                new SingleInstance.GenerationConfig());

            ApplicationInstanceType applicationInstance6 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 6);
            string servicePackageFile6 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance6.ServicePackageRef[0].RolloutVersion);
            var    servicepackage6     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile6, TestUtility.ImageStoreDefaultTimeout);

            Verify.AreEqual(servicepackage6.ManifestVersion, "v4");

            string rolloutVersion6 = servicepackage6.RolloutVersion;

            Verify.AreEqual(rolloutVersion5, rolloutVersion6);
            TestUtility.VerifyStoreLayout(buildLayoutInfo);

            // Test Case 6: Changing settings and image at the same time
            string jsonSettingFilePath5    = Path.Combine(currentExecutingDirectory, "Application_Setting3.json");
            string settingDescriptionJson5 = File.ReadAllText(jsonSettingFilePath5);

            SingleInstance.Application applicationWithSetting5 = JsonConvert.DeserializeObject <SingleInstance.Application>(settingDescriptionJson5);

            string applicationTypeVersion7 = "v7";

            this.imageBuilder.BuildSingleInstanceApplicationForUpgrade(
                applicationWithSetting5,
                applicationTypeName,
                applicationTypeVersion6,
                applicationTypeVersion7,
                applicationId,
                applicationInstance6.Version,
                applicationName,
                true, //generateDNS
                TimeSpan.MaxValue,
                tempBuildPath,
                outputPath,
                false, //use open network
                false, //use localnat network
                "C:\\",
                new SingleInstance.GenerationConfig());

            ApplicationInstanceType applicationInstance7 = TestUtility.GetApplicationInstance(buildLayoutInfo, applicationId, 7);
            string servicePackageFile7 = storeLayoutSpec.GetServicePackageFile(applicationTypeName, applicationId, "myBackendServicePkg", applicationInstance7.ServicePackageRef[0].RolloutVersion);
            var    servicepackage7     = buildLayoutInfo.ImageStoreWrapper.GetFromStore <ServicePackageType>(servicePackageFile7, TestUtility.ImageStoreDefaultTimeout);

            Verify.AreEqual(servicepackage7.ManifestVersion, applicationTypeVersion7);

            // Code package version and config package version are set to target version applicationTypeVersion7
            foreach (var codePackage in servicepackage7.DigestedCodePackage)
            {
                Verify.AreEqual(applicationTypeVersion7, codePackage.CodePackage.Version);
            }
            foreach (var configPackage in servicepackage7.DigestedConfigPackage)
            {
                Verify.AreEqual(applicationTypeVersion7, configPackage.ConfigPackage.Version);
            }

            string rolloutVersion7 = servicepackage7.RolloutVersion;

            Verify.AreNotEqual(rolloutVersion6, rolloutVersion7);
            TestUtility.VerifyStoreLayout(buildLayoutInfo);
        }
Пример #26
0
Файл: Basic.cs Проект: i2ali/RAD
        public void CreateSlicerFactory()
        {
            // This function creates a bitmap from a system bitmap
            Func <SystemBitmap, Bitmap> createBitmap = (SystemBitmap argSystemBitmap) =>
            {
                Bitmap bitmap = new Bitmap((int)argSystemBitmap.Width, (int)argSystemBitmap.Height);

                // Convert from RGBA to BGRA
                uint currentScanLine = 0;

                for (uint y = 0; y < argSystemBitmap.Height; ++y)
                {
                    uint currentPixel = currentScanLine;

                    for (uint x = 0; x < argSystemBitmap.Width; ++x)
                    {
                        bitmap.SetPixel(
                            (int)x,
                            (int)y,
                            Color.FromArgb(
                                argSystemBitmap.Data[currentPixel + 3],
                                argSystemBitmap.Data[currentPixel + 0],
                                argSystemBitmap.Data[currentPixel + 1],
                                argSystemBitmap.Data[currentPixel + 2]));

                        currentPixel += 4;
                    }

                    currentScanLine += argSystemBitmap.Stride;
                }

                return(bitmap);
            };


            SlicerFactory slicerFactory = null;
            IGdiSlicer    gdiSlicer     = null;
            IDwmSlicer    dwmSlicer     = null;

            // Test creating a slicer factory
            int retval = SlicerFactory.Create(out slicerFactory, ComputeShaderModel.None);

            Verify.AreEqual(0, retval, String.Format("SlicerFactory.Create: {0:X08}", retval));
            Verify.IsNotNull(slicerFactory);

            // Put the SlicerFactory object in a "using" block so that we test
            // what happens when the SlicerFactory's resources are freed.
            using (slicerFactory)
            {
                // Test creating a GDI slicer
                retval = slicerFactory.CreateGdiSlicer(out gdiSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateGdiSlicer: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicer);

                // Test creating a DWM slicer
                retval = slicerFactory.CreateDwmSlicer(out dwmSlicer);

                Verify.AreEqual(0, retval, String.Format("CreateDwmSlicer: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicer);
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and GDI slicer after the slcier factory has been
            // destroyed
            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(gdiSlicerBitmap).Save("gdiSlicerTestManaged.1.0.bmp", ImageFormat.Bmp);
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(gdiSlicerBitmapLeft).Save("gdiSlicerTestManaged.2.0.bmp", ImageFormat.Bmp);
            }

            {
                retval = gdiSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap gdiSlicerBitmapLeft  = null;
                SystemBitmap gdiSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = gdiSlicer.EndCapture(ref framesCaptured, out gdiSlicerBitmapLeft, out gdiSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("gdiSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(gdiSlicerBitmapLeft);
                Verify.IsNotNull(gdiSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(gdiSlicerBitmapLeft).Save("gdiSlicerTestManaged.3.0.bmp", ImageFormat.Bmp);
                createBitmap(gdiSlicerBitmapRight).Save("gdiSlicerTestManaged.3.1.bmp", ImageFormat.Bmp);
            }


            // Test EndCapture without StartCapture
            {
                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreNotEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
            }

            // Test using DWM and DWM slicer after the slcier factory has been
            // destroyed
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmap = null;
                uint         framesCaptured  = 0;
                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmap);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmap);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(dwmSlicerBitmap).Save("dwmSlicerTestManaged.1.0.bmp", ImageFormat.Bmp);
            }

            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(dwmSlicerBitmapLeft).Save("dwmSlicerTestManaged.2.0.bmp", ImageFormat.Bmp);
            }

            // Note: Windows 8 Bugs #11553 and Windows Blue Bugs #22133
            // Capture left and right channels
            {
                retval = dwmSlicer.StartCapture(0, 0, 100, 100, 10, 0, Channel.LeftAndRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.StartCapture: {0:X08}", retval));

                Thread.Sleep(3000);

                SystemBitmap dwmSlicerBitmapLeft  = null;
                SystemBitmap dwmSlicerBitmapRight = null;
                uint         framesCaptured       = 0;

                retval = dwmSlicer.EndCapture(ref framesCaptured, out dwmSlicerBitmapLeft, out dwmSlicerBitmapRight);
                Verify.AreEqual(0, retval, String.Format("dwmSlicer.EndCapture: {0:X08}", retval));
                Verify.IsNotNull(dwmSlicerBitmapLeft);
                Verify.IsNotNull(dwmSlicerBitmapRight);

                Log.Comment(String.Format("Frames captured: {0}", framesCaptured));

                createBitmap(dwmSlicerBitmapLeft).Save("dwmSlicerTestManaged.3.0.bmp", ImageFormat.Bmp);
                createBitmap(dwmSlicerBitmapRight).Save("dwmSlicerTestManaged.3.1.bmp", ImageFormat.Bmp);
            }
        }
        void VerifyLights(CoreApplicationView whichView, bool forceLightAttachDuringLayout, bool resetWindowContent)
        {
            if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2))
            {
                Log.Warning("Lights don't work on RS1 and earlier, nothing to verify.");
                return;
            }

            AutoResetEvent popupOpened = null;
            Popup          myPopup     = null;
            StackPanel     mySPRoot    = null;

            RunOnUIThread.Execute(whichView, () =>
            {
                mySPRoot = new StackPanel();

                // Lights will be created when the first RevealBrush enters the tree
                if (!forceLightAttachDuringLayout)
                {
                    Button myButton = new Button();
                    myButton.Width  = 75;
                    myButton.Height = 50;
                    myButton.Style  = Application.Current.Resources["ButtonRevealStyle"] as Style;
                    mySPRoot.Children.Add(myButton);
                }
                else
                {
                    string popupWithGridview = TestUtilities.ProcessTestXamlForRepo(
                        @"<Popup xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:controls='using:Microsoft.UI.Xaml.Controls' x:Name='MarkupPopup' IsOpen='False'>
                        <Popup.Resources>
                            <Style TargetType='GridViewItem' x:Key='RevealExampleGridViewItem'>
                                <Setter Property='Background' Value='Transparent' />
                                <Setter Property='HorizontalContentAlignment' Value='Center' />
                                <Setter Property='VerticalContentAlignment' Value='Center' />
                                <Setter Property='Template'>
                                    <Setter.Value>
                                        <ControlTemplate TargetType='GridViewItem'>
                                            <controls:RevealListViewItemPresenter ContentTransitions='{TemplateBinding ContentTransitions}'
                                        SelectionCheckMarkVisualEnabled='{ThemeResource GridViewItemSelectionCheckMarkVisualEnabled}'
                                        CheckBrush='Transparent'
                                        CheckBoxBrush='Transparent'
                                        DragBackground='{ThemeResource GridViewItemDragBackground}'
                                        DragForeground='{ThemeResource GridViewItemDragForeground}'
                                        FocusBorderBrush='{ThemeResource GridViewItemFocusBorderBrush}'
                                        FocusSecondaryBorderBrush='{ThemeResource GridViewItemFocusSecondaryBorderBrush}'
                                        PlaceholderBackground='Transparent'
                                        PointerOverBackground='Transparent'
                                        PointerOverForeground='{ThemeResource GridViewItemForegroundPointerOver}'
                                        SelectedBackground='Transparent'
                                        SelectedForeground='{ThemeResource GridViewItemForegroundSelected}'
                                        SelectedPointerOverBackground='Transparent'
                                        PressedBackground='Transparent'
                                        SelectedPressedBackground='Transparent'
                                        DisabledOpacity='{ThemeResource ListViewItemDisabledThemeOpacity}'
                                        DragOpacity='{ThemeResource ListViewItemDragThemeOpacity}'
                                        ReorderHintOffset='{ThemeResource GridViewItemReorderHintThemeOffset}'
                                        HorizontalContentAlignment='{TemplateBinding HorizontalContentAlignment}'
                                        VerticalContentAlignment='{TemplateBinding VerticalContentAlignment}'
                                        ContentMargin='{TemplateBinding Padding}'
                                        CheckMode='{ThemeResource GridViewItemCheckMode}' />
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </Style>

                            <DataTemplate x:Key='BackgroundBrushDataTemplate'>
                                <Grid Margin='5' Background='{Binding Value}' >
                                    <TextBlock
                                Margin='3'
                                FontSize='12'
                                MinWidth='200'
                                MinHeight='36'
                                MaxWidth='330'
                                TextWrapping='Wrap'
                                Text='{Binding Key}' />
                                </Grid>
                            </DataTemplate>
                            <DataTemplate x:Key='BorderBrushDataTemplate'>
                                <Border Margin='5' BorderBrush='{Binding Value}' BorderThickness='3'>
                                    <TextBlock
                                Margin='3'
                                FontSize='12'
                                MinWidth='200'
                                MinHeight='36'
                                MaxWidth='330'
                                TextWrapping='Wrap'
                                Text='{Binding Key}' />
                                </Border>
                            </DataTemplate>
                        </Popup.Resources>
                        <GridView Name='BackgroundList' ItemsSource='{Binding RevealBackgroundBrushes, Mode=OneWay}' ItemContainerStyle='{StaticResource RevealExampleGridViewItem}' ItemTemplate='{StaticResource BackgroundBrushDataTemplate}' MaxWidth='700' Margin='10' MaxHeight='200'/>
                    </Popup>");

                    myPopup             = XamlReader.Load(popupWithGridview) as Popup;
                    myPopup.DataContext = this;
                    mySPRoot.Children.Add(myPopup);
                }

                if (whichView != CoreApplication.MainView)
                {
                    Window.Current.Content = mySPRoot;
                }
                else
                {
                    MUXControlsTestApp.App.TestContentRoot = mySPRoot;
                }
            });
            IdleSynchronizer.Wait();

            if (resetWindowContent)
            {
                RunOnUIThread.Execute(whichView, () =>
                {
                    StackPanel newSPRoot = new StackPanel();
                    Button myButton      = new Button();
                    myButton.Width       = 75;
                    myButton.Height      = 50;
                    myButton.Style       = Application.Current.Resources["ButtonRevealStyle"] as Style;
                    newSPRoot.Children.Add(myButton);

                    if (whichView != CoreApplication.MainView)
                    {
                        Window.Current.Content = newSPRoot;
                    }
                    else
                    {
                        MUXControlsTestApp.App.TestContentRoot = newSPRoot;
                    }
                });
                IdleSynchronizer.Wait();
            }

            RunOnUIThread.Execute(whichView, () =>
            {
                if (forceLightAttachDuringLayout)
                {
                    myPopup.IsOpen = true;
                }

                // Find and store public Visual Root
                _visualRoot = GetTopParent(Window.Current.Content);

                popupOpened = new AutoResetEvent(false);
                // Make an unparented popup and open it so we can check that the popup root has lights set on it too.
                Popup popup   = new Popup();
                popup.Child   = new Grid();
                popup.Opened += (sender, args) =>
                {
                    // Find and store Popup Root
                    _popupRoot = GetTopParent(popup.Child);
                    Verify.AreNotEqual(_visualRoot, _popupRoot);
                    popup.IsOpen = false;
                    popupOpened.Set();
                };
                popup.IsOpen = true;
            });
            IdleSynchronizer.Wait();

            Verify.IsTrue(popupOpened.WaitOne(TimeSpan.FromMinutes(2)), "Waiting for popup to open ");
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(whichView, () =>
            {
                _mediaFullScreened = new AutoResetEvent(false);

                Log.Comment("Creating MediaPlayerElement and going to full screen.");
                _mpe = new MediaPlayerElement();
                _mpe.AreTransportControlsEnabled = true;
                mySPRoot.Children.Add(_mpe);
                _mpe.IsFullWindow = true;
                XamlControlsResources.EnsureRevealLights(_mpe.TransportControls);
                CompositionTarget.Rendering += CompositionTarget_Rendering;
            });

            Verify.IsTrue(_mediaFullScreened.WaitOne(TimeSpan.FromMinutes(2)), "Waiting for media player to go full screen");
            IdleSynchronizer.Wait();

            // Validate each root has the expected lights
            RunOnUIThread.Execute(whichView, () =>
            {
                _pollRetry                     = 0;
                _validationCompleted           = new AutoResetEvent(false);
                _lightValidationTimer          = new DispatcherTimer();
                _lightValidationTimer.Interval = _pollInterval;
                _lightValidationTimer.Tick    += PollTimer_Tick;
                _lightValidationTimer.Start();
            });

            Verify.IsTrue(_validationCompleted.WaitOne(TimeSpan.FromMinutes(2)), "Waiting for light validation to complete");
            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(whichView, () =>
            {
                if (whichView == CoreApplication.MainView)
                {
                    MUXControlsTestApp.App.TestContentRoot = null;
                }
                else
                {
                    Window.Current.Content = null;
                }
            });
            IdleSynchronizer.Wait();

            _cleanupVerified = new AutoResetEvent(false);
            RunOnUIThread.Execute(whichView, () =>
            {
                // RevealBrush cleans itself up in a CompositionTarget.Rendering callback. Put the cleanup validation in CT.R
                // as well to let the cleanup code run.
                CompositionTarget.Rendering += CTR_CheckCleanup;
            });

            Verify.IsTrue(_cleanupVerified.WaitOne(TimeSpan.FromMinutes(1)), "Waiting for cleanup validation");
        }
        public void HideAndShowWindow()
        {
            if (!OnRS2OrGreater())
            {
                return;
            }

            using (var setup = new TestSetupHelper(new[] { "Acrylic Tests", "navigateToBasicAcrylic" }))
            {
                ChooseFromComboBox("TestNameComboBox", "HideAndShowWindow");

                if (PlatformConfiguration.IsDevice(DeviceType.Phone))
                {
                    Log.Warning("Test is disabled on phone.");
                    return;
                }

                Button runTestButton;
                var    result = new Edit(FindElement.ById("TestResult"));
                using (var waiter = new ValueChangedEventWaiter(result))
                {
                    runTestButton = new Button(FindElement.ById("RunTestButton"));
                    runTestButton.Invoke();
                    LogBrushSate();
                    waiter.Wait();
                }

                if (result.Value.Equals("HideAndShowWindow: Skipped"))
                {
                    Log.Error("Error: FallbackBrush in use - expecting effect brush");
                    return;
                }
                else if (TestEnvironment.Application.ApplicationFrameWindow == null)
                {
                    Log.Comment("Skipping test: No ApplicationFrameWindow (likely unsupported platform)");
                    return;
                }
                else
                {
                    Thread waiterThread = new Thread(HideAndShowWindow_WaiterThreadProc);
                    waiterThread.Name = " HideAndShowWindow_WaiterThread";
                    waiterThread.Start();

                    Window            window             = new Window(TestEnvironment.Application.ApplicationFrameWindow);
                    WindowVisualState initialVisualState = window.WindowVisualState;
                    Verify.AreNotEqual(initialVisualState, WindowVisualState.Minimized);

                    // Minimize the app, which will also trigger it to supsend. Wait for Suspending event from app.
                    Log.Comment("Minimizing the window...");
                    window.SetWindowVisualState(WindowVisualState.Minimized);
                    HideAndShowWindow_GotWindowHiddenEvent.WaitOne();

                    // Restore the app. Wait for VisibilityChanged -> Visible event from app.
                    Log.Comment("Restoring the window...");
                    window.SetWindowVisualState(initialVisualState);
                    HideAndShowWindow_GotWindowVisibleEvent.WaitOne();

                    // Trigger test to validate that noise has been recreated (see Bug 11144540)
                    using (var waiter = new ValueChangedEventWaiter(result))
                    {
                        runTestButton.Invoke();
                        waiter.Wait();
                    }

                    // Read off validation result and complete the test
                    Verify.AreEqual(result.Value, "HideAndShowWindow: Passed");

                    Wait.ForIdle();
                }
            }
        }