コード例 #1
0
 public UIA2AutomationEventHandler(FrameworkAutomationElementBase frameworkElement, EventId @event, Action <AutomationElement, EventId> callAction) : base(frameworkElement, @event, callAction)
 {
     EventHandler = HandleAutomationEvent;
 }
コード例 #2
0
 public TestBasicEventHandler(AutomationBase automation, Action <AutomationElement, EventId> callAction) : base(automation, callAction)
 {
     EventHandler = HandleAutomationEvent;
 }
コード例 #3
0
ファイル: AutomationTest.cs プロジェクト: ABEMBARKA/monoUI
        public void RemoveAutomationEventHandlerTest()
        {
            int     eventCount = 0;
            Process p          = BaseTest.StartApplication(@"SampleForm.exe", string.Empty);

            potentiallyRunningProcesses.Add(p);
            SWA.AutomationEventHandler handler = (o, e) => eventCount++;
            Thread.Sleep(2000);              // Waiting a little bit for the application to show up

            SWA.AutomationElement testFormElement
                = SWA.AutomationElement.RootElement.FindFirst(SWA.TreeScope.Children,
                                                              new SWA.PropertyCondition(AEIds.ProcessIdProperty, p.Id));
            Assert.IsNotNull(testFormElement, "window");

            SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.AsyncContentLoadedEvent,
                                                        testFormElement,
                                                        handler);

            BaseTest.AssertRaises <ArgumentException> (
                () => SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.AutomationFocusChangedEvent,
                                                                  testFormElement,
                                                                  handler),
                "SWA.AutomationElementIdentifiers.AutomationFocusChangedEvent");

            BaseTest.AssertRaises <ArgumentException> (
                () => SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.AutomationPropertyChangedEvent,
                                                                  testFormElement,
                                                                  handler),
                "SWA.AutomationElementIdentifiers.AutomationPropertyChangedEvent");

            SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.LayoutInvalidatedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.MenuClosedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.MenuOpenedEvent,
                                                        testFormElement,
                                                        handler);

            BaseTest.AssertRaises <ArgumentException> (
                () => SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.StructureChangedEvent,
                                                                  testFormElement,
                                                                  handler),
                "SWA.AutomationElementIdentifiers.StructureChangedEvent");

            SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.ToolTipClosedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.AutomationElementIdentifiers.ToolTipOpenedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.InvokePatternIdentifiers.InvokedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.SelectionItemPatternIdentifiers.ElementAddedToSelectionEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.SelectionItemPatternIdentifiers.ElementRemovedFromSelectionEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.SelectionItemPatternIdentifiers.ElementSelectedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.SelectionPatternIdentifiers.InvalidatedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.TextPatternIdentifiers.TextChangedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.TextPatternIdentifiers.TextSelectionChangedEvent,
                                                        testFormElement,
                                                        handler);
            SWA.Automation.RemoveAutomationEventHandler(SWA.WindowPatternIdentifiers.WindowOpenedEvent,
                                                        testFormElement,
                                                        handler);

            p.Kill();
        }