Esempio n. 1
0
        public void SetVisualStateTest()
        {
            using (Form f = new Form()) {
                IRawElementProviderFragment provider = (IRawElementProviderFragment)ProviderFactory.GetProvider(f);
                IWindowProvider             pattern  = (IWindowProvider)provider.GetPatternProvider(WindowPatternIdentifiers.Pattern.Id);

                //f.Show ();
                //Application.DoEvents ();

                Assert.AreEqual(FormWindowState.Normal, f.WindowState, "Form should initially be 'normal'");

                bridge.ResetEventLists();
                pattern.SetVisualState(WindowVisualState.Maximized);
                Assert.IsNotNull(bridge.GetAutomationPropertyEventFrom(provider,
                                                                       WindowPatternIdentifiers.WindowVisualStateProperty.Id),
                                 "SetVisualState.0");

                //System.Threading.Thread.Sleep (1000);
                //Application.DoEvents ();
                //System.Threading.Thread.Sleep (1000);
                Assert.AreEqual(FormWindowState.Maximized, f.WindowState, "Form should maximize");

                bridge.ResetEventLists();
                pattern.SetVisualState(WindowVisualState.Minimized);
                Assert.IsNotNull(bridge.GetAutomationPropertyEventFrom(provider,
                                                                       WindowPatternIdentifiers.WindowVisualStateProperty.Id),
                                 "SetVisualState.1");
                //System.Threading.Thread.Sleep (1000);
                //Application.DoEvents ();
                //System.Threading.Thread.Sleep (1000);
                Assert.AreEqual(FormWindowState.Minimized, f.WindowState, "Form should minimize");

                bridge.ResetEventLists();
                pattern.SetVisualState(WindowVisualState.Normal);
                Assert.IsNotNull(bridge.GetAutomationPropertyEventFrom(provider,
                                                                       WindowPatternIdentifiers.WindowVisualStateProperty.Id),
                                 "SetVisualState.2");
                //System.Threading.Thread.Sleep (1000);
                //Application.DoEvents ();
                //System.Threading.Thread.Sleep (1000);
                Assert.AreEqual(FormWindowState.Normal, f.WindowState, "Form should return to 'normal'");
            }
        }
Esempio n. 2
0
 public void SetVisualState(WindowVisualState state)
 {
     provider.SetVisualState(state);
 }