Exemplo n.º 1
0
        public void TestHasKeyboardFocusAfterPattern()
        {
            StackPanel panel = new StackPanel();
            ComboBox   fe    = CreateConcreteFrameworkElement() as ComboBox;

            fe.Items.Add("Item 0");
            fe.Items.Add("Item 1");

            Button button = new Button()
            {
                Content = "Button"
            };

            panel.Children.Add(fe);
            panel.Children.Add(button);

            AutomationPeer          buttonPeer = FrameworkElementAutomationPeer.CreatePeerForElement(button);
            AutomationPeer          peer       = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            IExpandCollapseProvider provider   = null;

            CreateAsyncTest(panel,
                            () => {
                provider = (IExpandCollapseProvider)peer.GetPattern(PatternInterface.ExpandCollapse);
                Assert.IsNotNull(provider, "#1");
            },
                            () => provider.Expand(),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#2"),
                            () => button.Focus(),
                            () => Assert.IsTrue(buttonPeer.HasKeyboardFocus(), "#3"),
                            () => provider.Collapse(),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#4")
                            );
        }
Exemplo n.º 2
0
        public override void TestHasKeyboardFocusAfterPattern()
        {
            Slider              fe       = CreateConcreteFrameworkElement() as Slider;
            AutomationPeer      peer     = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            IRangeValueProvider provider = null;

            CreateAsyncTest(fe,
                            () => {
                provider = (IRangeValueProvider)peer.GetPattern(PatternInterface.RangeValue);
                Assert.IsNotNull(provider, "#0");
            },
                            () => provider.SetValue(.5),
                            () => Assert.IsFalse(peer.HasKeyboardFocus(), "#1"));
        }
Exemplo n.º 3
0
        public void TestHasKeyboardFocusAfterPattern()
        {
            PasswordBox fe = CreateConcreteFrameworkElement() as PasswordBox;

            AutomationPeer peer     = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            IValueProvider provider = null;

            CreateAsyncTest(fe,
                            () => {
                provider = (IValueProvider)peer.GetPattern(PatternInterface.Value);
                Assert.IsNotNull(provider, "#0");
            },
                            () => provider.SetValue("Hello world"),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#1"));
        }
Exemplo n.º 4
0
        public override void TestHasKeyboardFocusAfterPattern()
        {
            IInvokeProvider provider = null;
            AutomationPeer  peer     = null;

            CreateAsyncTest(calendar,
                            () => {
                List <AutomationPeer> buttonChildren = GetButtonChildren();
                peer     = buttonChildren [0];
                provider = (IInvokeProvider)peer.GetPattern(PatternInterface.Invoke);
                Assert.IsNotNull(provider, "#0");
            },
                            () => provider.Invoke(),
                            () => Assert.IsFalse(peer.HasKeyboardFocus(), "#1"));
        }
Exemplo n.º 5
0
        public void TestHasKeyboardFocusAfterPattern()
        {
            HyperlinkButton fe = CreateConcreteFrameworkElement() as HyperlinkButton;

            AutomationPeer  peer     = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            IInvokeProvider provider = null;

            CreateAsyncTest(fe,
                            () => {
                provider = (IInvokeProvider)peer.GetPattern(PatternInterface.Invoke);
                Assert.IsNotNull(provider, "#0");
            },
                            () => provider.Invoke(),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#1"));
        }
Exemplo n.º 6
0
        public override void TestHasKeyboardFocusAfterPattern()
        {
            ToggleButton fe = CreateConcreteFrameworkElement()
                              as ToggleButton;

            fe.Content = "Radiobutton";

            AutomationPeer         peer     = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            ISelectionItemProvider provider = null;

            CreateAsyncTest(fe,
                            () => {
                provider = (ISelectionItemProvider)peer.GetPattern(PatternInterface.SelectionItem);
                Assert.IsNotNull(provider, "#0");
            },
                            () => provider.Select(),
                            () => Assert.IsTrue(peer.HasKeyboardFocus(), "#1"));
        }
Exemplo n.º 7
0
        public override void TestHasKeyboardFocusAfterPattern()
        {
            ProgressBar fe = CreateConcreteFrameworkElement() as ProgressBar;

            AutomationPeer      peer     = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            IRangeValueProvider provider = null;

            CreateAsyncTest(fe,
                            () => {
                provider = (IRangeValueProvider)peer.GetPattern(PatternInterface.RangeValue);
                Assert.IsNotNull(provider, "#0");
            },
                            () => {
                Assert.Throws <InvalidOperationException> (() => {
                    global::System.Console.WriteLine(">>>>>>>>>>>>>>>>>>>provider is {0}", provider.GetType());
                    provider.SetValue(.5);
                });
            },
                            () => Assert.IsFalse(peer.HasKeyboardFocus(), "#1"));
        }
        protected override bool HasKeyboardFocusCore()
        {
            AutomationPeer wrapperPeer = this.GetWrapperPeer();

            return((wrapperPeer != null) && (wrapperPeer.HasKeyboardFocus()));
        }
        public void TestHasKeyboardFocusAfterPattern()
        {
            ListBox listbox = new ListBox();

            listbox.Items.Add("Item 0");
            listbox.Items.Add("Item 1");

            AutomationPeer         peer1 = null;
            AutomationPeer         peer2 = null;
            ISelectionItemProvider selectionItemProvider1 = null;
            ISelectionItemProvider selectionItemProvider2 = null;
            AutomationPeer         listboxPeer            = null;

            CreateAsyncTest(listbox,
                            () => {
                listboxPeer = FrameworkElementAutomationPeer.CreatePeerForElement(listbox);

                peer1 = listboxPeer.GetChildren()[0];
                peer2 = listboxPeer.GetChildren()[1];

                selectionItemProvider1
                    = peer1.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider;
                Assert.IsNotNull(selectionItemProvider1, "SelectionItem Provider #0");

                selectionItemProvider2
                    = peer2.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider;
                Assert.IsNotNull(selectionItemProvider2, "SelectionItem Provider #1");

                // By default both are not selected
                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #0");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #1");
            },
                            () => selectionItemProvider1.Select(),
                            () => {
                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #2");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #3");
            },
                            () => {
                Assert.IsTrue(peer1.HasKeyboardFocus(), "#1");
                Assert.IsFalse(peer2.HasKeyboardFocus(), "#2");
                Assert.IsFalse(listboxPeer.HasKeyboardFocus(), "#3");
            },
                            () => { selectionItemProvider2.Select(); },
                            () => {
                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #4");
                Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #5");
            },
                            () => {
                Assert.IsFalse(peer1.HasKeyboardFocus(), "#4");
                Assert.IsTrue(peer2.HasKeyboardFocus(), "#5");
                Assert.IsFalse(listboxPeer.HasKeyboardFocus(), "#6");
            },
                            () => { selectionItemProvider2.RemoveFromSelection(); },
                            () => {
                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #6");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #7");
            },
                            () => {
                Assert.IsTrue(peer1.HasKeyboardFocus(), "#7");
                Assert.IsFalse(peer2.HasKeyboardFocus(), "#8");
                Assert.IsFalse(listboxPeer.HasKeyboardFocus(), "#9");
            });
        }