/// <inheritdoc/>
        public bool IsValid(FrameworkElement element, AutomationPeer peer)
        {
            var type = peer?.GetAutomationControlType();

            // These types are ignored
            if (type == AutomationControlType.AppBar ||
                type == AutomationControlType.Custom ||
                type == AutomationControlType.DataItem ||
                type == AutomationControlType.Group ||
                type == AutomationControlType.Image ||
                type == AutomationControlType.Header ||
                type == AutomationControlType.List ||
                type == AutomationControlType.MenuBar ||
                type == AutomationControlType.Pane ||
                type == AutomationControlType.ScrollBar ||
                type == AutomationControlType.SemanticZoom ||
                type == AutomationControlType.Separator ||
                type == AutomationControlType.StatusBar ||
                type == AutomationControlType.TitleBar ||
                type == AutomationControlType.Thumb ||
                type == AutomationControlType.Text ||
                type == AutomationControlType.ToolBar ||
                type == AutomationControlType.ToolTip ||
                type == AutomationControlType.Window)
            {
                return(true);
            }

            return(!peer.IsEnabled() || peer.IsKeyboardFocusable());
        }
コード例 #2
0
 public override void IsKeyboardFocusable()
 {
     CreateAsyncTest(calendar,
                     () => {
         List <AutomationPeer> buttonChildren = GetButtonChildren();
         AutomationPeer peer = buttonChildren [0];
         Assert.IsFalse(peer.IsKeyboardFocusable(), "IsKeyboardFocusable");
     });
 }
コード例 #3
0
        public override void IsKeyboardFocusable()
        {
            TabControl tabControl = CreateConcreteFrameworkElement() as TabControl;

            CreateAsyncTest(tabControl,
                            () => {
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabControl);
                Assert.IsFalse(peer.IsKeyboardFocusable(), "#0");
            });
        }
コード例 #4
0
        public void IsKeyboardFocusableNoParent()
        {
            TabControl tabControl = new TabControl();
            TabItem    tabItem    = new TabItem();

            CreateAsyncTest(tabControl,
                            () => {
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem);
                Assert.IsNotNull(peer, "#0");
                Assert.IsFalse(peer.IsKeyboardFocusable(), "#1");
            });
        }
コード例 #5
0
        /// <inheritdoc/>
        public bool IsValid(FrameworkElement element, AutomationPeer peer)
        {
            var type = peer?.GetAutomationControlType();

            if (type == AutomationControlType.Header ||
                type == AutomationControlType.SemanticZoom ||
                type == AutomationControlType.ScrollBar)
            {
                return(!peer.IsKeyboardFocusable());
            }
            return(true);
        }
コード例 #6
0
 /// <inheritdoc/>
 public bool IsValid(FrameworkElement element, AutomationPeer peer)
 {
     if (peer != null)
     {
         if (peer.GetAutomationControlType() == AutomationControlType.Text ||
             peer.GetAutomationControlType() == AutomationControlType.Image ||
             peer.IsKeyboardFocusable())
         {
             return(!string.IsNullOrWhiteSpace(peer.GetName()));
         }
     }
     return(true);
 }
コード例 #7
0
        public override void IsKeyboardFocusable()
        {
            TabControl tabControl = new TabControl();
            TabItem    tabItem    = new TabItem();

            tabControl.Items.Add(tabItem);

            CreateAsyncTest(tabControl,
                            () => {
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem);
                Assert.IsNotNull(peer, "#0");
                Assert.IsTrue(peer.IsKeyboardFocusable(), "#1");
            });
        }
コード例 #8
0
        public void AllTests()
        {
            DataGridColumnHeader fe   = CreateConcreteFrameworkElement() as DataGridColumnHeader;
            AutomationPeer       peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);

            // GetAutomationControlType
            Assert.AreEqual(AutomationControlType.HeaderItem, peer.GetAutomationControlType(), "GetAutomationControlType");

            // GetBoundingRectangle
            Rect boundingRectangle = peer.GetBoundingRectangle();

            Assert.AreNotEqual(0, boundingRectangle.X, "GetBoundingRectangle X");
            Assert.AreNotEqual(0, boundingRectangle.Y, "GetBoundingRectangle Y");
            Assert.AreNotEqual(0, boundingRectangle.Width, "GetBoundingRectangle Width");
            Assert.AreNotEqual(0, boundingRectangle.Height, "GetBoundingRectangle Height");

            // GetChildren
            List <AutomationPeer> children = peer.GetChildren();

            Assert.IsNotNull(children, "#0");
            Assert.AreEqual(1, children.Count, "#1");

            // IsKeyboardFocusable
            Assert.IsFalse(peer.IsKeyboardFocusable(), "IsKeyboardFocusable");

            // GetClassName
            Assert.AreEqual("DataGridColumnHeader", peer.GetClassName(), "#0");

            // IsContentElement
            Assert.IsFalse(peer.IsContentElement(), "#0");

            // GetName
            Assert.AreEqual(fe.Content, peer.GetName(), "GetName");

            // GetClickablePoint
            Point p = peer.GetClickablePoint();

            Assert.IsFalse(double.IsNaN(p.X), "#0");
            Assert.IsFalse(double.IsNaN(p.Y), "#1");

            // GetParent
            Assert.IsNotNull(peer.GetParent(), "GetParent");

            // IsOffscreen
            Assert.IsFalse(peer.IsOffscreen(), "IsOffScreen");
        }
コード例 #9
0
        protected override bool IsKeyboardFocusableCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();

            return((wrapperPeer != null) && wrapperPeer.IsKeyboardFocusable());
        }
コード例 #10
0
        public override void IsKeyboardFocusable_Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

            DataGridColumnHeader         control = CreateConcreteFrameworkElement() as DataGridColumnHeader;
            AutomationPeer               peer    = FrameworkElementAutomationPeer.CreatePeerForElement(control);
            AutomationPropertyEventTuple tuple   = null;

            Assert.IsFalse(peer.IsKeyboardFocusable(), "IsKeyboardFocusable #1");
            EventsManager.Instance.Reset();
            control.IsEnabled = false;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNull(tuple, "#0");

            EventsManager.Instance.Reset();
            control.IsEnabled = true;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNull(tuple, "#1");

            EventsManager.Instance.Reset();
            control.Visibility = Visibility.Collapsed;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNull(tuple, "#2");

            EventsManager.Instance.Reset();
            control.Visibility = Visibility.Visible;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNull(tuple, "#3");

            EventsManager.Instance.Reset();
            control.IsTabStop = false;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNull(tuple, "#4");

            EventsManager.Instance.Reset();
            control.IsTabStop = true;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNotNull(tuple, "#5");
            Assert.IsFalse((bool)tuple.OldValue, "OldValue #0");
            Assert.IsTrue((bool)tuple.NewValue, "NewValue #0");

            EventsManager.Instance.Reset();
            control.IsTabStop = false;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                  AutomationElementIdentifiers.IsKeyboardFocusableProperty);
            Assert.IsNotNull(tuple, "#6");
            Assert.IsTrue((bool)tuple.OldValue, "OldValue #1");
            Assert.IsFalse((bool)tuple.NewValue, "NewValue #1");
        }