Inheritance: EventHandlerBase
Exemplo n.º 1
0
        public void TestFocusChange()
        {
            // Launch a notepad and set focus to it
            using (AppHost host1 = new AppHost("notepad.exe", ""))
            {
                host1.Element.SetFocus();

                FocusChangeHandler handler = new FocusChangeHandler();
                Automation.AddAutomationFocusChangedEventHandler(
                    new AutomationFocusChangedEventHandler(handler.HandleEvent));
                handler.Start();

                // Launch a new notepad and set focus to it
                using (AppHost host2 = new AppHost("notepad.exe", ""))
                {
                    host2.Element.SetFocus();

                    Assert.IsTrue(handler.Confirm());
                    Assert.IsNotNull(handler.EventSource);
                }

                Automation.RemoveAutomationFocusChangedEventHandler(
                    new AutomationFocusChangedEventHandler(handler.HandleEvent));
            }
        }
Exemplo n.º 2
0
        public void TestFocusChange()
        {
            // Launch a notepad and set focus to it
            using (AppHost host1 = new AppHost("notepad.exe", ""))
            {
                host1.Element.SetFocus();

                FocusChangeHandler handler = new FocusChangeHandler();
                Automation.AddAutomationFocusChangedEventHandler(
                    new AutomationFocusChangedEventHandler(handler.HandleEvent));
                handler.Start();

                // Launch a new notepad and set focus to it
                using (AppHost host2 = new AppHost("notepad.exe", ""))
                {
                    host2.Element.SetFocus();

                    Assert.IsTrue(handler.Confirm());
                    Assert.IsNotNull(handler.EventSource);
                }

                Automation.RemoveAutomationFocusChangedEventHandler(
                    new AutomationFocusChangedEventHandler(handler.HandleEvent));
            }
        }