Inheritance: EventHandlerBase
Example #1
0
        public void TestInvokeEvent()
        {
            AutomationElement  startButton = AutomationElementTest.GetStartButton();
            BasicChangeHandler handler     = new BasicChangeHandler();

            Automation.AddAutomationEventHandler(
                InvokePattern.InvokedEvent,
                startButton,
                TreeScope.Element,
                new AutomationEventHandler(handler.HandleEvent));
            handler.Start();
            InvokePattern invoke = (InvokePattern)startButton.GetCurrentPattern(InvokePattern.Pattern);

            invoke.Invoke();
            System.Windows.Forms.SendKeys.SendWait("{ESC}");
            Assert.IsTrue(handler.Confirm());
            Assert.IsNotNull(handler.EventSource);
            Automation.RemoveAutomationEventHandler(
                InvokePattern.InvokedEvent,
                startButton,
                new AutomationEventHandler(handler.HandleEvent));
        }
Example #2
0
 public void TestInvokeEvent()
 {
     AutomationElement startButton = AutomationElementTest.GetStartButton();
     BasicChangeHandler handler = new BasicChangeHandler();
     Automation.AddAutomationEventHandler(
         InvokePattern.InvokedEvent,
         startButton,
         TreeScope.Element,
         new AutomationEventHandler(handler.HandleEvent));
     handler.Start();
     InvokePattern invoke = (InvokePattern)startButton.GetCurrentPattern(InvokePattern.Pattern);
     invoke.Invoke();
     System.Windows.Forms.SendKeys.SendWait("{ESC}");
     Assert.IsTrue(handler.Confirm());
     Assert.IsNotNull(handler.EventSource);
     Automation.RemoveAutomationEventHandler(
         InvokePattern.InvokedEvent,
         startButton,
         new AutomationEventHandler(handler.HandleEvent));
 }