Esempio n. 1
0
        public void ProviderPatternTest()
        {
            DockProviderLabel         label    = new DockProviderLabel();
            IRawElementProviderSimple provider = ProviderFactory.GetProvider(label);

            object dockPattern = provider.GetPatternProvider(DockPatternIdentifiers.Pattern.Id);

            Assert.IsNotNull(dockPattern, "DockPattern.");

            IDockProvider dockProvider = dockPattern as IDockProvider;

            Assert.IsNotNull(dockProvider, "IDockProvider ");

            Assert.AreEqual(provider.HostRawElementProvider, label, "HostRawElementProvider");
            Assert.AreEqual(ProviderOptions.ServerSideProvider, provider.ProviderOptions, "ProviderOptions");

            Assert.AreEqual(DockStyle.Top.ToString(),
                            provider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id),
                            "NameProperty");

            dockProvider.SetDockPosition(DockPosition.Right);
            Assert.AreEqual(DockStyle.Right.ToString(),
                            provider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id),
                            "NameProperty");
        }
Esempio n. 2
0
        public bool SupportsProperty(AutomationProperty property)
        {
            ArgumentCheck.NotNull(property, "property");

            object val = provider.GetPropertyValue(property.Id);

            return(val != null && val != AEIds.NotSupported);
        }
        public override void LabeledByAndNamePropertyTest()
        {
            ToolStripLabel menuItem = new ToolStripLabel();

            menuItem.Text = "My menu item";
            IRawElementProviderSimple provider = ProviderFactory.GetProvider(menuItem);

            Assert.AreEqual(menuItem.Text,
                            provider.GetPropertyValue(AEIds.NameProperty.Id) as string,
                            "Name");
            Assert.IsNull(provider.GetPropertyValue(AEIds.LabeledByProperty.Id),
                          "LabeledBy");
        }
Esempio n. 4
0
        protected override void TestEditPatterns(IRawElementProviderSimple provider)
        {
            // LAMESPEC: Edit must always support ITextProvider, but this *is not true* in Edit Cells
            Assert.IsTrue((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsValuePatternAvailableProperty.Id),
                          "Edit ControlType in DataGrid must support IValueProvider");
            Assert.IsFalse((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsRangeValuePatternAvailableProperty.Id),
                           "Edit ControlType in DataGrid MUST NOT support IRangeValueProvider");

            Assert.AreEqual(Catalog.GetString("edit"),
                            provider.GetPropertyValue(AutomationElementIdentifiers.LocalizedControlTypeProperty.Id),
                            "LocalizedControlTypeProperty");

            TestValuePattern_All(provider);
        }
        protected override void TestEditPatterns(IRawElementProviderSimple provider)
        {
            // LAMESPEC: We should implement ITextProvider instead of IValueProvider

            Assert.IsTrue((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsValuePatternAvailableProperty.Id),
                          "Edit ControlType must support ITextProvider");
            Assert.IsFalse((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsRangeValuePatternAvailableProperty.Id),
                           "Edit ControlType MUST NOT support IRangeValueProvider");
            Assert.IsFalse((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsTextPatternAvailableProperty.Id),
                           "Edit ControlType MUST NOT support ITextProvider");

            TestValuePattern_ValuePropertyEvent(provider);
            TestValuePattern_IsReadOnlyPropertyEvent(provider);
        }
Esempio n. 6
0
        public void Bug456336Test()
        {
            // Verify with ComboBoxStyle.DropDown that the TextBox
            // is focused, not the combo
            ComboBox combobox = GetComboBox();

            combobox.Items.Add("dummy 0");
            combobox.DropDownStyle = ComboBoxStyle.DropDown;
            Form.Controls.Add(combobox);
            Form.Show();

            combobox.Focus();

            IRawElementProviderFragmentRoot rootProvider
                = (IRawElementProviderFragmentRoot)GetProviderFromControl(combobox);

            TestProperty(rootProvider,
                         AutomationElementIdentifiers.ControlTypeProperty,
                         ControlType.ComboBox.Id);

            Assert.IsFalse(
                (bool)rootProvider.GetPropertyValue(
                    AutomationElementIdentifiers.HasKeyboardFocusProperty.Id),
                "ComboBox has keyboard focus when it shouldn't");

            IRawElementProviderSimple textBoxProvider
                = rootProvider.Navigate(NavigateDirection.FirstChild);

            Assert.IsTrue(
                (bool)textBoxProvider.GetPropertyValue(
                    AutomationElementIdentifiers.HasKeyboardFocusProperty.Id),
                "TextBox does not have keyboard focus when it should");
        }
Esempio n. 7
0
        public TextBoxEntryView(IRawElementProviderSimple provider) : base(provider)
        {
            if (IsTableCell)
            {
                Role = Atk.Role.TableCell;
            }
            else
            {
                Role = Atk.Role.Text;
            }

            if (provider.GetPatternProvider(TextPatternIdentifiers.Pattern.Id) == null &&
                provider.GetPatternProvider(ValuePatternIdentifiers.Pattern.Id) == null)
            {
                throw new ArgumentException("Provider for TextBox should either implement IValue or IText");
            }

            textExpert = TextImplementorFactory.GetImplementor(this, provider);
            if ((int)provider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id)
                == ControlType.Document.Id)
            {
                multiLine = true;
            }

            editableTextExpert = new EditableTextImplementorHelper(this, this, textExpert);
        }
Esempio n. 8
0
        public SplitContainer(IRawElementProviderSimple provider) : base(provider)
        {
            Role = Atk.Role.SplitPane;
            rangeValueProvider = (IRangeValueProvider)provider.GetPatternProvider(RangeValuePatternIdentifiers.Pattern.Id);
            object o = provider.GetPropertyValue(AutomationElementIdentifiers.OrientationProperty.Id);

            if (o is OrientationType)
            {
                orientation = (OrientationType)o;
            }
            else
            {
                IDockProvider dockProvider = (IDockProvider)provider.GetPatternProvider(DockPatternIdentifiers.Pattern.Id);
                if (dockProvider != null)
                {
                    orientation = (dockProvider.DockPosition == DockPosition.Top || dockProvider.DockPosition == DockPosition.Bottom)?
                                  OrientationType.Horizontal:
                                  OrientationType.Vertical;
                }
                else
                {
                    Log.Warn("SplitContainer: Couldn't get orientation for splitter.  Does not support DockProvider.");
                    orientation = OrientationType.Horizontal;
                }
            }
        }
Esempio n. 9
0
        internal void RaiseStructureChangedEvent(IRawElementProviderSimple provider,
                                                 StructureChangedEventArgs e)
        {
            if (provider == null)
            {
                return;
            }
            var wrapper = AutomationBridge.Instance.FindWrapperByProvider(provider);

            if (wrapper == null)
            {
                Log.Error("[UiaDbusBridge.RaiseStructureChangedEvent] Inconsistent provider -> wrapper mapping state",
                          provider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id));
                return;
            }
            lock (structureEventHandlers) {
                foreach (AutomationEventHandlerData handler in structureEventHandlers)
                {
                    if (IsProviderInScope(provider, handler.Provider, handler.Scope))
                    {
                        OnStructureChanged(handler.HandlerId, handler.EventId, wrapper.Path,
                                           e.StructureChangeType);
                    }
                }
            }
        }
Esempio n. 10
0
        public MenuItem(IRawElementProviderSimple provider) : base(provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            if ((provider as IRawElementProviderFragment) == null)
            {
                throw new ArgumentException("Provider for ParentMenu should be IRawElementProviderFragment");
            }

            textExpert = TextImplementorFactory.GetImplementor(this, provider);

            Role = Atk.Role.MenuItem;

            string name = (string)provider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id);

            if (!String.IsNullOrEmpty(name))
            {
                Name = name;
            }

            invokeProvider = (IInvokeProvider)
                             provider.GetPatternProvider(InvokePatternIdentifiers.Pattern.Id);
            toggleProvider = (IToggleProvider)
                             provider.GetPatternProvider(TogglePatternIdentifiers.Pattern.Id);
            selectionItemProvider = (ISelectionItemProvider)
                                    provider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);
            expandCollapseProvider = (IExpandCollapseProvider)
                                     provider.GetPatternProvider(ExpandCollapsePatternIdentifiers.Pattern.Id);

            actionExpert.Add("click", "click", null, DoClick);
        }
Esempio n. 11
0
        private bool IsRootWindow(IRawElementProviderSimple simpleProvider)
        {
            var controlTypeId = (int)simpleProvider.GetPropertyValue(AEIds.ControlTypeProperty.Id);

            if (controlTypeId != ControlType.Window.Id)
            {
                return(false);
            }

            var fragmentProvider = simpleProvider as IRawElementProviderFragment;

            if (fragmentProvider == null)
            {
                return(false);
            }

            var parentProvider      = fragmentProvider.Navigate(NavigateDirection.Parent);          // This will be Desktop semi-provider or owner form provider. Not `null`!
            var parentControlTypeId = (int)parentProvider.GetPropertyValue(AEIds.ControlTypeProperty.Id);

            if (parentControlTypeId == ControlType.Pane.Id)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 12
0
        private void HandleElementRemoval(IRawElementProviderSimple provider)
        {
            if (!providerWrapperMapping.TryGetValue(provider, out ProviderElementWrapper element))
            {
                return;
            }

            int controlTypeId = (int)provider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id);

            if (controlTypeId == ControlType.Window.Id)
            {
                app.RemoveRootElement(element);
            }

            lock (pointerProviderMapping) {
                IntPtr providerHandle = IntPtr.Zero;
                foreach (IntPtr pointer in pointerProviderMapping.Keys)
                {
                    if (provider == pointerProviderMapping [pointer])
                    {
                        providerHandle = pointer;
                        break;
                    }
                }
                if (providerHandle != IntPtr.Zero)
                {
                    pointerProviderMapping.Remove(providerHandle);
                }
            }

            element.Unregister();
            lock (providerWrapperMapping)
                providerWrapperMapping.Remove(provider);
            app.RemoveProvider(provider);
        }
Esempio n. 13
0
        public new void IsEnabledPropertyTest()
        {
            MenuItem menuItem = new MenuItem();
            IRawElementProviderSimple provider = ProviderFactory.GetProvider(menuItem);

            bridge.ResetEventLists();

            object initialVal =
                provider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id);

            Assert.IsNotNull(initialVal, "Property returns null");
            Assert.IsTrue((bool)initialVal, "Should initialize to true");

            menuItem.Enabled = false;

            Assert.IsFalse((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id),
                           "Toggle to false");

            AutomationPropertyChangedEventTuple tuple
                = bridge.GetAutomationPropertyEventFrom(provider,
                                                        AutomationElementIdentifiers.IsEnabledProperty.Id);

            Assert.IsNotNull(tuple, "Tuple missing");
            Assert.AreEqual(initialVal,
                            tuple.e.OldValue,
                            string.Format("1st. Old value should be true: '{0}'", tuple.e.OldValue));
            Assert.AreEqual(false,
                            tuple.e.NewValue,
                            string.Format("1st. New value should be true: '{0}'", tuple.e.NewValue));

            bridge.ResetEventLists();

            menuItem.Enabled = true;
            Assert.IsTrue((bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id),
                          "Toggle to true");

            tuple
                = bridge.GetAutomationPropertyEventFrom(provider,
                                                        AutomationElementIdentifiers.IsEnabledProperty.Id);
            Assert.IsNotNull(tuple, "Tuple missing");
            Assert.AreEqual(false,
                            tuple.e.OldValue,
                            string.Format("2nd. Old value should be false: '{0}'", tuple.e.OldValue));
            Assert.AreEqual(true,
                            tuple.e.NewValue,
                            string.Format("2nd. New value should be true: '{0}'", tuple.e.NewValue));
        }
Esempio n. 14
0
 public static void TestAutomationProperty(IRawElementProviderSimple provider,
                                           AutomationProperty property,
                                           object expectedValue)
 {
     Assert.AreEqual(expectedValue,
                     provider.GetPropertyValue(property.Id),
                     property.ProgrammaticName);
 }
Esempio n. 15
0
        public Window(IRawElementProviderSimple provider) : base(provider)
        {
            if (provider != null)
            {
                Role = Atk.Role.Frame;
            }

            balloonWindow = (bool)(provider.GetPropertyValue(AutomationElementIdentifiers.IsNotifyIconProperty.Id) != null);
            rootProvider  = (IRawElementProviderFragmentRoot)provider;

            if (rootProvider != null && balloonWindow)
            {
                Role = Atk.Role.Alert;
                Name = (string)provider.GetPropertyValue(AutomationElementIdentifiers.HelpTextProperty.Id);
            }

            transformProvider = (ITransformProvider)provider.GetPatternProvider(TransformPatternIdentifiers.Pattern.Id);
            windowProvider    = (IWindowProvider)provider.GetPatternProvider(WindowPatternIdentifiers.Pattern.Id);
        }
 // If a child control is ControlType.RadioButton, this provider
 // needs to provide SelectionPattern behavior.
 private void CheckForRadioButtonChild(IRawElementProviderSimple childProvider)
 {
     if (GetBehavior(SelectionPatternIdentifiers.Pattern) == null &&
         childProvider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id) != null &&
         (int)childProvider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) == ControlType.RadioButton.Id)
     {
         RB.SelectionProviderBehavior selectionProvider =
             new RB.SelectionProviderBehavior(this);
         SetBehavior(SelectionPatternIdentifiers.Pattern,
                     selectionProvider);
         hasRadioButtonChild = true;
     }
 }
Esempio n. 17
0
        public void IsSelectedTest()
        {
            RadioButton r1 = new RadioButton();

            r1.Checked = false;

            IRawElementProviderSimple provider1      = ProviderFactory.GetProvider(r1);
            ISelectionItemProvider    selectionItem1 = (ISelectionItemProvider)
                                                       provider1.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id);

            Assert.IsFalse(selectionItem1.IsSelected, "Unchecked");
            Assert.AreEqual(selectionItem1.IsSelected,
                            provider1.GetPropertyValue(SelectionItemPatternIdentifiers.IsSelectedProperty.Id),
                            "Property value should match GetPropertyValue");

            r1.Checked = true;

            Assert.IsTrue(selectionItem1.IsSelected, "Checked");
            Assert.AreEqual(selectionItem1.IsSelected,
                            provider1.GetPropertyValue(SelectionItemPatternIdentifiers.IsSelectedProperty.Id),
                            "Property value should match GetPropertyValue");
        }
Esempio n. 18
0
        private double DistanceFrom(IRawElementProviderSimple otherProvider)
        {
            Rect bounds      = (Rect)GetPropertyValue(AutomationElementIdentifiers.BoundingRectangleProperty.Id);
            Rect otherBounds = (Rect)otherProvider.GetPropertyValue(AutomationElementIdentifiers.BoundingRectangleProperty.Id);

            if (control != null && control.RightToLeft == SWF.RightToLeft.Yes)
            {
                return(Distance(bounds.TopRight, otherBounds.TopRight));
            }
            else
            {
                return(Distance(bounds.TopLeft, otherBounds.TopLeft));
            }
        }
Esempio n. 19
0
        //tested with UIAVerify, the bridge depends on this behaviour
        public override void IsKeyboardFocusablePropertyTest()
        {
            IRawElementProviderSimple provider =
                ProviderFactory.GetProvider(toolBarButton);

            TestProperty(provider,
                         AutomationElementIdentifiers.IsKeyboardFocusableProperty,
                         false);

            object hasKbFocus = provider.GetPropertyValue(AutomationElementIdentifiers.HasKeyboardFocusProperty.Id);

            Assert.IsNotNull(hasKbFocus);
            Assert.IsTrue(hasKbFocus is bool);
            Assert.IsFalse((bool)hasKbFocus);
        }
Esempio n. 20
0
        private void TestFocus()
        {
            var toolbar = (ToolBar)GetControlInstanceWithButton();
            IRawElementProviderSimple provider =
                ProviderFactory.GetProvider(toolbar);

            TestProperty(provider,
                         AutomationElementIdentifiers.IsKeyboardFocusableProperty,
                         false);

            object hasKbFocus = provider.GetPropertyValue(AutomationElementIdentifiers.HasKeyboardFocusProperty.Id);

            Assert.IsNotNull(hasKbFocus);
            Assert.IsTrue(hasKbFocus is bool);
            Assert.IsFalse((bool)hasKbFocus);
        }
Esempio n. 21
0
        // <Snippet106>
        /// <summary>
        /// Responds to an InvokePattern.Invoke by simulating a MouseDown event.
        /// </summary>
        /// <remarks>
        /// ProviderControl is a button control object that also implements
        /// IRawElementProviderSimple.
        /// </remarks>
        void IInvokeProvider.Invoke()
        {
            // If the control is not enabled, we're responsible for letting UIAutomation know.
            // It catches the exception and then throws it to the client.
            if (false == (bool)rawElementProvider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id))
            {
                throw new ElementNotEnabledException();
            }

            // Create arguments for the event. The parameters aren't used.
            MouseEventArgs mouseArgs = new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0);

            // Invoke the MouseDown handler. We cannot call MyControl_MouseDown directly,
            // because it is illegal to update the UI from a different thread.
            MouseEventHandler onMouseEvent = ProviderControl.RootButtonControl_MouseDown;

            ProviderControl.BeginInvoke(onMouseEvent, new object[] { this, mouseArgs });
        }
Esempio n. 22
0
        internal void RaiseAutomationEvent(AutomationEvent eventId,
                                           IRawElementProviderSimple provider,
                                           AutomationEventArgs e)
        {
            if (provider == null)
            {
                return;
            }
            var wrapper = AutomationBridge.Instance.FindWrapperByProvider(provider);

            if (wrapper == null)
            {
                Log.Error("[UiaDbusBridge.RaiseAutomationEvent] Inconsistent provider -> wrapper mapping state");
                return;
            }
            lock (automationEventHandlers) {
                foreach (AutomationEventHandlerData handler in automationEventHandlers)
                {
                    if (handler.EventId == eventId.Id &&
                        IsProviderInScope(provider, handler.Provider, handler.Scope))
                    {
                        OnAutomationEvent(handler.HandlerId, handler.EventId, wrapper.Path);
                    }
                }
            }
            if (eventId == AutomationElementIdentifiers.AutomationFocusChangedEvent)
            {
                var valueObj = provider.GetPropertyValue(
                    AutomationElementIdentifiers.HasKeyboardFocusProperty.Id);
                bool hasFocus = false;
                try { hasFocus = (bool)valueObj; } catch {}
                if (hasFocus && focusedElementPath != wrapper.Path)
                {
                    focusedElementPath = wrapper.Path;
                    OnFocusChanged(focusedElementPath);
                }
                else if (!hasFocus && focusedElementPath == wrapper.Path)
                {
                    focusedElementPath = string.Empty;
                    OnFocusChanged(focusedElementPath);
                }
            }
        }
        public Atk.Object RefSelection(int i)
        {
            IRawElementProviderSimple[] selectedElements =
                GetSelection();
            if (selectedElements.Length == 0 || (i < 0 || i >= selectedElements.Length))
            {
                return(null);
            }
            IRawElementProviderSimple provider = selectedElements [i];

            if (provider == null)
            {
                return(null);
            }
            if (provider is IRawElementProviderFragment && (int)provider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id) == ControlType.DataItem.Id)
            {
                provider = ((IRawElementProviderFragment)provider).Navigate(NavigateDirection.FirstChild);
            }
            return(AutomationBridge.GetAdapterForProviderSemiLazy(provider));
        }
Esempio n. 24
0
        /// <summary>
        /// Responds to an InvokePattern.Invoke by simulating a MouseDown event.
        /// </summary>
        void IInvokeProvider.Invoke()
        {
            // If the control is not enabled, we're responsible for letting UI Automation know.
            // It catches the exception and then throws it to the client.
            IRawElementProviderSimple provider = this as IRawElementProviderSimple;

            if (false == (bool)provider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id))
            {
                throw new ElementNotEnabledException();
            }

            // Create arguments for the click event. The parameters aren't used.
            MouseEventArgs mouseArgs = new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0);

            // Simulate a mouse click. We cannot call RespondToClick directly,
            // because it is illegal to update the UI from a different thread.
            MouseEventHandler handler = CustomButton_MouseDown;

            BeginInvoke(handler, new object[] { this, mouseArgs });
        }
Esempio n. 25
0
        public void SelectionContainerTest()
        {
            IRawElementProviderSimple formProvider = FormProvider;

            RadioButton r1 = new RadioButton();

            r1.Checked = false;

            RadioButton r2 = new RadioButton();

            r2.Checked = false;

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

            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);

            Assert.AreEqual(formProvider,
                            selectionItem1.SelectionContainer,
                            "SelectionContainer should be parent provider");
            Assert.AreEqual(selectionItem1.SelectionContainer,
                            provider1.GetPropertyValue(SelectionItemPatternIdentifiers.SelectionContainerProperty.Id),
                            "Property value should match GetPropertyValue");
            Assert.AreEqual(formProvider,
                            selectionItem2.SelectionContainer,
                            "SelectionContainer should be parent provider");
            Assert.AreEqual(selectionItem2.SelectionContainer,
                            provider2.GetPropertyValue(SelectionItemPatternIdentifiers.SelectionContainerProperty.Id),
                            "Property value should match GetPropertyValue");
        }
Esempio n. 26
0
        public void NamePropertyTest()
        {
            CheckBox checkbox = new CheckBox();
            IRawElementProviderSimple provider = ProviderFactory.GetProvider(checkbox);

            checkbox.Text = "first";

            bridge.ResetEventLists();

            string oldState = checkbox.Text;;
            string newState = "second";

            checkbox.Text = newState;

            // Test NameProperty
            Assert.AreEqual(newState,
                            provider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id),
                            "NameProperty");

            // Test event was fired as expected
            Assert.AreEqual(1,
                            bridge.AutomationPropertyChangedEvents.Count,
                            "event count");

            AutomationPropertyChangedEventArgs eventArgs =
                bridge.AutomationPropertyChangedEvents [0].e;

            Assert.AreEqual(AutomationElementIdentifiers.NameProperty,
                            eventArgs.Property,
                            "event args property");
            Assert.AreEqual(oldState,
                            eventArgs.OldValue,
                            "old value");
            Assert.AreEqual(newState,
                            eventArgs.NewValue,
                            "new value");
        }
Esempio n. 27
0
        public ComboBoxItem(IRawElementProviderSimple provider) : base(provider)
        {
            int controlType = (int)provider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id);

            selectionItemProvider = (ISelectionItemProvider)provider.GetPatternProvider(
                SelectionItemPatternIdentifiers.Pattern.Id);
            if (selectionItemProvider == null)
            {
                throw new ArgumentException(
                          String.Format("Provider for ComboBoxItem (control type {0}) should implement ISelectionItemProvider", controlType));
            }

            textExpert = TextImplementorFactory.GetImplementor(this, provider);

            //FIXME: take in account ComboBox style changes at runtime
            if (ParentIsSimple())
            {
                Role = Atk.Role.TableCell;
            }
            else
            {
                Role = Atk.Role.MenuItem;
            }
        }
Esempio n. 28
0
 public string HeaderValue(IRawElementProviderSimple element)
 {
     return(element.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id).ToString());
 }
        public void ListTest()
        {
            // This format should have 8 parts
            picker.Format     = DateTimePickerFormat.Long;
            picker.ShowUpDown = false;
            picker.Value      = awesome;

            IRawElementProviderSimple child
                = ((IRawElementProviderFragmentRoot)pickerProvider)
                  .Navigate(NavigateDirection.FirstChild);
            int i = 0;

            do
            {
                if (long_pattern_part_type[i] == PartType.List)
                {
                    TestProperty(child,
                                 AutomationElementIdentifiers.ControlTypeProperty,
                                 ControlType.List.Id);

                    ISelectionProvider prov
                        = (ISelectionProvider)child.GetPatternProvider(
                              SelectionPatternIdentifiers.Pattern.Id);
                    Assert.IsNotNull(prov);

                    IRawElementProviderSimple[] items;

                    string name = (string)child.GetPropertyValue(
                        AutomationElementIdentifiers.NameProperty.Id);
                    if (name == "Tuesday")
                    {
                        items = prov.GetSelection();
                        Assert.IsNotNull(items, "Should never return null");
                        Assert.AreEqual(1, items.Length, "Too many or too few items returned");

                        name = (string)items[0].GetPropertyValue(
                            AutomationElementIdentifiers.NameProperty.Id);
                        Assert.AreEqual("Tuesday", name,
                                        "GetSelection () isn't returning Tuesday");

                        bridge.ResetEventLists();

                        picker.Value = awesome.AddDays(3);

                        Assert.AreEqual(1, bridge.GetAutomationPropertyEventCount(
                                            SelectionPatternIdentifiers.SelectionProperty),
                                        "SelectionProperty Event count");

                        items = prov.GetSelection();
                        Assert.IsNotNull(items, "Should never return null");
                        Assert.AreEqual(1, items.Length, "Too many or too few items returned");

                        name = (string)items[0].GetPropertyValue(
                            AutomationElementIdentifiers.NameProperty.Id);
                        Assert.AreEqual("Friday", name,
                                        "GetSelection () isn't returning Friday");
                    }
                    else if (name == "January")
                    {
                        items = prov.GetSelection();
                        Assert.IsNotNull(items, "Should never return null");
                        Assert.AreEqual(1, items.Length, "Too many or too few items returned");

                        name = (string)items[0].GetPropertyValue(
                            AutomationElementIdentifiers.NameProperty.Id);
                        Assert.AreEqual("January", name,
                                        "GetSelection () isn't returning January");

                        bridge.ResetEventLists();

                        picker.Value = awesome.AddMonths(3);

                        // Month will change, so will the day
                        Assert.AreEqual(2, bridge.GetAutomationPropertyEventCount(
                                            SelectionPatternIdentifiers.SelectionProperty),
                                        "SelectionProperty Event count");

                        // Focus shouldn't change when we alter the value
                        Assert.AreEqual(0, bridge.GetAutomationPropertyEventCount(
                                            AutomationElementIdentifiers.HasKeyboardFocusProperty),
                                        "HasKeyboardFocusProperty Event count");

                        items = prov.GetSelection();
                        Assert.IsNotNull(items, "Should never return null");
                        Assert.AreEqual(1, items.Length, "Too many or too few items returned");

                        name = (string)items[0].GetPropertyValue(
                            AutomationElementIdentifiers.NameProperty.Id);
                        Assert.AreEqual("April", name,
                                        "GetSelection () isn't returning April");
                    }
                }

                i++;
                child = ((IRawElementProviderFragment)child)
                        .Navigate(NavigateDirection.NextSibling);
            } while (child != null && i < long_pattern_num_parts);
        }
Esempio n. 30
0
 object?IRawElementProviderSimple.GetPropertyValue(UIA propertyID)
 => publicIRawElementProviderSimple.GetPropertyValue(propertyID);