예제 #1
0
        public void InvokedEventTest()
        {
            IRawElementProviderSimple provider = GetProvider();

            bridge.ResetEventLists();

            //we cannot do this, there's no PerformClick() API in toolbarButton:
            //toolBarButton.PerformClick ();
            //so we use the provider:
            IInvokeProvider invokeProvider =
                (IInvokeProvider)provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);

            invokeProvider.Invoke();

            Assert.AreEqual(1,
                            bridge.AutomationEvents.Count,
                            "event count");

            AutomationEventTuple eventInfo =
                bridge.AutomationEvents [0];

            Assert.AreEqual(InvokePatternIdentifiers.InvokedEvent,
                            eventInfo.eventId,
                            "event type");
            Assert.AreEqual(provider,
                            eventInfo.provider,
                            "event element");
            Assert.AreEqual(InvokePatternIdentifiers.InvokedEvent,
                            eventInfo.e.EventId,
                            "event args event type");
        }
        public void InvokedEventTest()
        {
            IRawElementProviderSimple provider
                = ProviderFactory.GetProvider(button);

            bridge.ResetEventLists();

            button.PerformClick();

            Assert.AreEqual(1,
                            bridge.AutomationEvents.Count,
                            "event count");

            AutomationEventTuple eventInfo =
                bridge.AutomationEvents [0];

            Assert.AreEqual(InvokePatternIdentifiers.InvokedEvent,
                            eventInfo.eventId,
                            "event type");
            Assert.AreEqual(provider,
                            eventInfo.provider,
                            "event element");
            Assert.AreEqual(InvokePatternIdentifiers.InvokedEvent,
                            eventInfo.e.EventId,
                            "event args event type");
        }
예제 #3
0
        public void ElementSelectedEventTest()
        {
            RadioButton r1 = new RadioButton();

            r1.Checked = false;

            RadioButton r2 = new RadioButton();

            r2.Checked = false;

            GroupBox gbox = new GroupBox();

            gbox.Controls.Add(r1);
            gbox.Controls.Add(r2);

            Form.Controls.Add(gbox);

            IRawElementProviderSimple provider1 = ProviderFactory.GetProvider(r1);

            ISelectionItemProvider selectionItem1 = (ISelectionItemProvider)
                                                    provider1.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);

            IRawElementProviderSimple provider2      = ProviderFactory.GetProvider(r2);
            ISelectionItemProvider    selectionItem2 = (ISelectionItemProvider)
                                                       provider2.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);

            bridge.ResetEventLists();

            Assert.AreEqual(0,
                            bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent),
                            "Provider not selected");
            selectionItem1.Select();
            Assert.AreEqual(1,
                            bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent),
                            "Provider not selected");

            AutomationEventTuple tuple
                = bridge.GetAutomationEventFrom(provider1,
                                                SelectionItemPatternIdentifiers.ElementSelectedEvent.Id);

            Assert.IsNotNull(tuple, "Selected Item should be the provider calling Select");

            Assert.IsTrue(selectionItem1.IsSelected, "Radio Button 1 is selected");
            Assert.IsFalse(selectionItem2.IsSelected, "Radio Button 2 is not selected");
        }
예제 #4
0
        public void StatusBarPanelNamePropertyChangedEventTest()
        {
            StatusBar statusBar = new StatusBar();
            IRawElementProviderFragmentRoot rootProvider =
                (IRawElementProviderFragmentRoot)GetProviderFromControl(statusBar);

            string         panelName = "original panel name";
            StatusBarPanel panel     = new StatusBarPanel();

            panel.Text = panelName;

            statusBar.Panels.Add(panel);
            IRawElementProviderFragment childProvider =
                rootProvider.Navigate(NavigateDirection.FirstChild);

            TestProperty(childProvider,
                         AutomationElementIdentifiers.NameProperty,
                         panelName);

            bridge.ResetEventLists();

            string newPanelName = "new panel name";

            panel.Text = newPanelName;

            TestProperty(childProvider,
                         AutomationElementIdentifiers.NameProperty,
                         newPanelName);

            Assert.AreEqual(1,
                            bridge.AutomationPropertyChangedEvents.Count,
                            "Name property change event expected");
            AutomationPropertyChangedEventTuple eventTuple =
                bridge.AutomationPropertyChangedEvents [0];

            Assert.AreEqual(childProvider,
                            eventTuple.element,
                            "event sender");
            Assert.AreEqual(AutomationElementIdentifiers.NameProperty,
                            eventTuple.e.Property,
                            "event property");
            Assert.AreEqual(newPanelName,
                            eventTuple.e.NewValue,
                            "event new value");
            Assert.AreEqual(panelName,
                            eventTuple.e.OldValue,
                            "event old value");

            Assert.AreEqual(1,
                            bridge.AutomationEvents.Count,
                            "TextPattern text change event expected");
            AutomationEventTuple eventTuple2 =
                bridge.AutomationEvents [0];

            Assert.AreEqual(childProvider,
                            eventTuple2.provider,
                            "event sender");
            Assert.AreEqual(TextPatternIdentifiers.TextChangedEvent,
                            eventTuple2.eventId,
                            "event id");
            Assert.AreEqual(TextPatternIdentifiers.TextChangedEvent,
                            eventTuple2.e.EventId,
                            "event id");
        }