예제 #1
0
        public override void IsOffScreen_Event1()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

            DataGridColumnHeader fe   = CreateConcreteFrameworkElement() as DataGridColumnHeader;
            AutomationPeer       peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);

            AutomationPropertyEventTuple tuple = null;

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

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

            // Testing when our parent is not Visible
            EventsManager.Instance.Reset();
            canvas.Visibility = Visibility.Collapsed;

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
            Assert.IsNotNull(tuple, "IsOffscreen #1");
            Assert.IsTrue((bool)tuple.NewValue, "IsOffscreen #2");
            Assert.IsFalse((bool)tuple.OldValue, "IsOffscreen #3");
        }
예제 #2
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

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

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

            EventsManager.Instance.Reset();
            columnHeader.SetValue(AutomationProperties.NameProperty, "Attached Name");
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNull(tuple, "#1");

            EventsManager.Instance.Reset();
            columnHeader.SetValue(AutomationProperties.NameProperty, "Name");
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNull(tuple, "#2");

            EventsManager.Instance.Reset();
            columnHeader.SetValue(AutomationProperties.NameProperty, null);
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNull(tuple, "#3");
        }
예제 #3
0
        public override void GetName_AttachedProperty1Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

            FrameworkElement             fe    = CreateConcreteFrameworkElement();
            AutomationPeer               peer  = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            AutomationPropertyEventTuple tuple = null;

            TextBlock textblock = new TextBlock()
            {
                Text = "Hello world:"
            };
            AutomationPeer textblockPeer = FrameworkElementAutomationPeer.CreatePeerForElement(textblock);

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

            EventsManager.Instance.Reset();
            fe.SetValue(AutomationProperties.NameProperty, "My name");
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNull(tuple, "#1");

            EventsManager.Instance.Reset();
            fe.SetValue(AutomationProperties.LabeledByProperty, textblock);
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNotNull(tuple, "#2");
            Assert.AreEqual("Hello world:", (string)tuple.NewValue, "#3");
            Assert.AreEqual(string.Empty, (string)tuple.OldValue, "#4");

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.LabeledByProperty);
            Assert.IsNotNull(tuple, "#5");
            Assert.AreEqual(textblock, tuple.NewValue, "#6");
            Assert.AreEqual(null, tuple.OldValue, "#7");

            EventsManager.Instance.Reset();
            textblock.Text = null;
            tuple          = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNotNull(tuple, "#8");
            Assert.AreEqual(string.Empty, (string)tuple.NewValue, "#9");
            Assert.AreEqual("Hello world:", (string)tuple.OldValue, "#10");

            tuple = EventsManager.Instance.GetAutomationEventFrom(textblockPeer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNotNull(tuple, "#11");
            Assert.AreEqual(string.Empty, (string)tuple.NewValue, "#12");
            Assert.AreEqual("Hello world:", (string)tuple.OldValue, "#13");

            EventsManager.Instance.Reset();
            fe.SetValue(AutomationProperties.LabeledByProperty, null);
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNull(tuple, "#14");

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.LabeledByProperty);
            Assert.IsNotNull(tuple, "#15");
            Assert.AreEqual(null, tuple.NewValue, "#16");
            Assert.AreEqual(textblock, tuple.OldValue, "#17");
        }
예제 #4
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

            AutomationPropertyEventTuple tuple = null;

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

            EventsManager.Instance.Reset();
            fe.SetValue(AutomationProperties.NameProperty, "Attached Name");
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNotNull(tuple, "#1");
            Assert.AreEqual("Attached Name", (string)tuple.NewValue, "#2");
            Assert.AreEqual(((Calendar)fe).DisplayDate.ToString(), tuple.OldValue, "#3");

            EventsManager.Instance.Reset();
            fe.SetValue(AutomationProperties.NameProperty, "Name");
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNotNull(tuple, "#4");
            Assert.AreEqual("Name", (string)tuple.NewValue, "#5");
            Assert.AreEqual("Attached Name", (string)tuple.OldValue, "#6");

            EventsManager.Instance.Reset();
            fe.SetValue(AutomationProperties.NameProperty, null);
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
            Assert.IsNotNull(tuple, "#7");
            Assert.AreEqual(((Calendar)fe).DisplayDate.ToString(), (string)tuple.NewValue, "#8");
            Assert.AreEqual("Name", (string)tuple.OldValue, "#9");
        }
예제 #5
0
        public override void GetName_AttachedProperty1Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            TabControl tabControl = new TabControl();
            TabItem    tabItem    = new TabItem();

            CreateAsyncTest(tabControl,
                            () => {
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem);
                AutomationPropertyEventTuple tuple = null;

                TextBlock textblock = new TextBlock()
                {
                    Text = "Hello world:"
                };
                AutomationPeer textblockPeer = FrameworkElementAutomationPeer.CreatePeerForElement(textblock);

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

                EventsManager.Instance.Reset();
                tabItem.SetValue(AutomationProperties.NameProperty, "My name");
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#1");

                EventsManager.Instance.Reset();
                tabItem.SetValue(AutomationProperties.LabeledByProperty, textblock);
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#2");

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

                EventsManager.Instance.Reset();
                textblock.Text = null;
                tuple          = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#4");

                tuple = EventsManager.Instance.GetAutomationEventFrom(textblockPeer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#5");

                EventsManager.Instance.Reset();
                tabItem.SetValue(AutomationProperties.LabeledByProperty, null);
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#6");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.LabeledByProperty);
                Assert.IsNotNull(tuple, "#7");
            });
        }
예제 #6
0
        public override void IsOffScreen_Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

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

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

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

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

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

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

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

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

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
            Assert.IsNotNull(tuple, "IsOffscreen #2");

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

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
            Assert.IsNotNull(tuple, "#8");

            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
            Assert.IsNotNull(tuple, "IsOffscreen #5");
        }
예제 #7
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            CreateAsyncTest(calendar,
                            () => {
                List <AutomationPeer> buttonChildren = GetButtonChildren();
                FrameworkElement fe = ((FrameworkElementAutomationPeer)buttonChildren [0]).Owner as FrameworkElement;
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
                AutomationPropertyEventTuple tuple = null;

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

                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Attached Name");
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#1");
                Assert.AreEqual("Attached Name", (string)tuple.NewValue, "#2");
                Assert.AreEqual(CURRENT_MONTH, tuple.OldValue, "#3");

                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Name");
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#4");
                Assert.AreEqual("Name", (string)tuple.NewValue, "#5");
                Assert.AreEqual("Attached Name", (string)tuple.OldValue, "#6");

                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, null);
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#7");
                Assert.AreEqual(CURRENT_MONTH, (string)tuple.NewValue, "#8");
                Assert.AreEqual("Name", (string)tuple.OldValue, "#9");
            });
        }
예제 #8
0
        public void ValueProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            PasswordBox    passwordbox = CreateConcreteFrameworkElement() as PasswordBox;
            AutomationPeer peer
                = CreateConcreteFrameworkElementAutomationPeer(passwordbox) as AutomationPeer;
            AutomationPropertyEventTuple tuple = null;

            // IsReadOnly, never changes

            CreateAsyncTest(passwordbox,
                            // Value
                            () => {
                passwordbox.Password = string.Empty;
                EventsManager.Instance.Reset();
                passwordbox.Password = "******";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.ValueProperty);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #1");
                Assert.AreEqual("hello world", tuple.NewValue, "GetAutomationEventFrom.NewValue #1");
                Assert.AreEqual(string.Empty, tuple.OldValue, "GetAutomationEventFrom.NewValue #1");
            },
                            () => {
                EventsManager.Instance.Reset();
                passwordbox.Password = "******";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.ValueProperty);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #2");
                Assert.AreEqual("changed", tuple.NewValue, "GetAutomationEventFrom.NewValue #2");
                Assert.AreEqual("hello world", tuple.OldValue, "GetAutomationEventFrom.NewValue #2");
            });
        }
예제 #9
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            TabControl tabControl = new TabControl();
            TabItem    tabItem    = new TabItem();

            CreateAsyncTest(tabControl,
                            () => {
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem);
                AutomationPropertyEventTuple tuple = null;

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

                EventsManager.Instance.Reset();
                tabItem.SetValue(AutomationProperties.NameProperty, "Attached Name");
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#1");

                EventsManager.Instance.Reset();
                tabItem.SetValue(AutomationProperties.NameProperty, "Name");
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#4");

                EventsManager.Instance.Reset();
                tabItem.SetValue(AutomationProperties.NameProperty, null);
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#7");
            });
        }
예제 #10
0
        public virtual void ISelectionProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            Selector selector = CreateConcreteFrameworkElement() as Selector;

            selector.Width  = 300;
            selector.Height = 400;

            selector.Items.Add(new TextBlock()
            {
                Text = "Item0"
            });
            selector.Items.Add(new TextBlock()
            {
                Text = "Item1"
            });

            AutomationPeer peer      = null;
            AutomationPeer childPeer = null;

            IRawElementProviderSimple[]  selection         = null;
            AutomationPropertyEventTuple propertyTuple     = null;
            ISelectionProvider           selectionProvider = null;

            CreateAsyncTest(selector,
                            () => {
                peer = FrameworkElementAutomationPeer.CreatePeerForElement(selector);

                selectionProvider = peer.GetPattern(PatternInterface.Selection) as ISelectionProvider;
                Assert.IsNotNull(selectionProvider, "Selection Provider");

                Assert.IsFalse(selectionProvider.CanSelectMultiple, "CanSelectMultiple #0");
                Assert.IsFalse(selectionProvider.IsSelectionRequired, "IsSelectionRequired #0");

                selection = selectionProvider.GetSelection();
                Assert.IsNull(selection, "GetSelection #0");
            },
                            () => {
                EventsManager.Instance.Reset();
                selector.SelectedIndex = 1;
            },
                            () => {
                selection = selectionProvider.GetSelection();
                Assert.IsNotNull(selection, "GetSelection #1");
                Assert.AreEqual(1, selection.Length, "GetSelection #2");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #0");
                Assert.IsNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #0");
                Assert.IsNotNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #0");

                childPeer = new PeerFromProvider().GetPeerFromProvider(selection [0]);
            },
                            () => {
                EventsManager.Instance.Reset();
                selector.Items.Add(new TextBlock()
                {
                    Text = "Item1"
                });
                selector.SelectedIndex = 0;
            },
                            () => {
                selection = selectionProvider.GetSelection();
                Assert.IsNotNull(selection, "GetSelection #3");
                Assert.AreEqual(1, selection.Length, "GetSelection #4");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #1");
                Assert.IsNotNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #1");
                Assert.IsNotNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #1");

                Assert.AreNotEqual(selection [0], childPeer, "GetSelection #5");
            },
                            () => {
                EventsManager.Instance.Reset();
                selector.SelectedIndex = -1;
            },
                            () => {
                selection = selectionProvider.GetSelection();
                Assert.IsNull(selection, "GetSelection #6");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #2");
                Assert.IsNotNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #2");
                Assert.IsNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #2");
            });
        }
예제 #11
0
        public override void IsOffScreen_Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            Popup fe = CreateConcreteFrameworkElement() as Popup;

            fe.SetValue(Canvas.TopProperty, (double)10);
            fe.SetValue(Canvas.LeftProperty, (double)30);
            fe.SetValue(Canvas.WidthProperty, (double)150);
            fe.SetValue(Canvas.HeightProperty, (double)230);

            AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(fe,
                            () => {
                EventsManager.Instance.Reset();
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
                Assert.IsNull(tuple, "#0");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #0");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Visibility = Visibility.Visible;
            },
                            () => {
                EventsManager.Instance.Reset();
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
                Assert.IsNull(tuple, "#1");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #1");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Visibility = Visibility.Collapsed;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
                Assert.IsNotNull(tuple, "#2");
                Rect newValue = (Rect)tuple.NewValue;

                Assert.AreEqual(0, newValue.X, "#4");
                Assert.AreEqual(0, newValue.Y, "#5");
                Assert.AreEqual(0, newValue.Width, "#6");
                Assert.AreEqual(0, newValue.Height, "#7");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #2");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Visibility = Visibility.Visible;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
                Assert.IsNull(tuple, "#8");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.IsOpen = true;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
                Assert.IsNotNull(tuple, "#9");
                Rect newValue = (Rect)tuple.NewValue;
                Rect oldValue = (Rect)tuple.OldValue;

                Assert.AreNotEqual(newValue.X, oldValue.X, "#10");
                Assert.AreNotEqual(newValue.Y, oldValue.Y, "#11");
                Assert.AreNotEqual(newValue.Width, oldValue.Width, "#12");
                Assert.AreNotEqual(newValue.Height, oldValue.Height, "#13");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNotNull(tuple, "IsOffscreen #3");
                Assert.IsFalse((bool)tuple.NewValue, "IsOffscreen #4");
                Assert.IsTrue((bool)tuple.OldValue, "IsOffscreen #5");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.IsOpen = false;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.BoundingRectangleProperty);
                Assert.IsNotNull(tuple, "#14");
                Rect newValue = (Rect)tuple.NewValue;
                Rect oldValue = (Rect)tuple.OldValue;

                Assert.AreNotEqual(newValue.X, oldValue.X, "#15");
                Assert.AreNotEqual(newValue.Y, oldValue.Y, "#16");
                Assert.AreNotEqual(newValue.Width, oldValue.Width, "#17");
                Assert.AreNotEqual(newValue.Height, oldValue.Height, "#18");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNotNull(tuple, "IsOffscreen #6");
                Assert.IsTrue((bool)tuple.NewValue, "IsOffscreen #7");
                Assert.IsFalse((bool)tuple.OldValue, "IsOffscreen #8");
            });
        }
예제 #12
0
        public override void IsOffScreen_Event1()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            Canvas parent0 = new Canvas();

            parent0.Height = 100;
            parent0.Width  = 100;

            StackPanel parent1 = new StackPanel();

            parent1.Height = 200;
            parent1.Width  = 100;

            parent0.Children.Add(parent1);

            FrameworkElement fe = CreateConcreteFrameworkElement();

            fe.SetValue(Canvas.WidthProperty, (double)150);
            fe.SetValue(Canvas.HeightProperty, (double)230);
            parent1.Children.Add(fe);

            AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(parent0,
                            () => {
                EventsManager.Instance.Reset();
                parent0.Visibility = Visibility.Visible;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #4");
            },
                            () => {
                // Testing when our parent is not Visible
                EventsManager.Instance.Reset();
                parent0.Visibility = Visibility.Collapsed;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #1");
            },
                            () => {
                EventsManager.Instance.Reset();
                parent1.Visibility = Visibility.Collapsed;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #4");
            },
                            () => {
                EventsManager.Instance.Reset();
                parent0.Visibility = Visibility.Visible;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #5");
            },
                            () => {
                EventsManager.Instance.Reset();
                parent1.Visibility = Visibility.Visible;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.IsOffscreenProperty);
                Assert.IsNull(tuple, "IsOffscreen #7");
            });
        }
예제 #13
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            TextBox        fe   = CreateConcreteFrameworkElement() as TextBox;
            AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(fe,
                            () => {
                EventsManager.Instance.Reset();
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#0");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Attached Name");
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#1");
                Assert.AreEqual("Attached Name", (string)tuple.NewValue, "#2");
                Assert.AreEqual(string.Empty, tuple.OldValue, "#3");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Name");
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#4");
                Assert.AreEqual("Name", (string)tuple.NewValue, "#5");
                Assert.AreEqual("Attached Name", (string)tuple.OldValue, "#6");
            },
                            () => {
                // Even if TextBox.Name changes the value will be the same
                EventsManager.Instance.Reset();
                fe.Text = "New value";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#7");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, null);
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#8");
                Assert.AreEqual("New value", (string)tuple.NewValue, "#9");
                Assert.AreEqual("Name", (string)tuple.OldValue, "#10");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Text = "What's up?";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#11");
                Assert.AreEqual("What's up?", (string)tuple.NewValue, "#12");
                Assert.AreEqual("New value", (string)tuple.OldValue, "#13");
            });
        }
예제 #14
0
        public void ValueProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            TextBox        textbox = CreateConcreteFrameworkElement() as TextBox;
            AutomationPeer peer
                = FrameworkElementAutomationPeer.CreatePeerForElement(textbox);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(textbox,
                            // IsReadOnly
                            () => {
                EventsManager.Instance.Reset();
                textbox.IsReadOnly = true;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.IsReadOnlyProperty);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #0");
                Assert.IsTrue((bool)tuple.NewValue, "GetAutomationEventFrom.NewValue #0");
                Assert.IsFalse((bool)tuple.OldValue, "GetAutomationEventFrom.NewValue #0");
            },
                            () => {
                EventsManager.Instance.Reset();
                textbox.IsEnabled = false;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.IsReadOnlyProperty);
                Assert.IsNull(tuple, "GetAutomationEventFrom #1");
            },
                            () => {
                EventsManager.Instance.Reset();
                textbox.IsReadOnly = false;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.IsReadOnlyProperty);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #2");
                Assert.IsFalse((bool)tuple.NewValue, "GetAutomationEventFrom.NewValue #2");
                Assert.IsTrue((bool)tuple.OldValue, "GetAutomationEventFrom.NewValue #2");
            },
                            () => {
                EventsManager.Instance.Reset();
                textbox.IsEnabled = true;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.IsReadOnlyProperty);
                Assert.IsNull(tuple, "GetAutomationEventFrom #3");
            },
                            // Value
                            () => {
                textbox.Text = string.Empty;
                EventsManager.Instance.Reset();
                textbox.Text = "hello world";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.ValueProperty);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #4");
                Assert.AreEqual("hello world", tuple.NewValue, "GetAutomationEventFrom.NewValue #4");
                Assert.AreEqual(string.Empty, tuple.OldValue, "GetAutomationEventFrom.NewValue #4");
            },
                            () => {
                EventsManager.Instance.Reset();
                textbox.Text = string.Empty;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, ValuePatternIdentifiers.ValueProperty);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #5");
                Assert.AreEqual(string.Empty, tuple.NewValue, "GetAutomationEventFrom.NewValue #5");
                Assert.AreEqual("hello world", tuple.OldValue, "GetAutomationEventFrom.NewValue #5");
            });
        }
예제 #15
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");
        }
예제 #16
0
        public void RangeValueProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                return;
            }

            RangeBaseConcrete rangeBase = new RangeBaseConcrete();
            AutomationPeer    peer      = FrameworkElementAutomationPeer.CreatePeerForElement(rangeBase);

            IRangeValueProvider provider
                = (IRangeValueProvider)peer.GetPattern(PatternInterface.RangeValue);

            Assert.IsNotNull(provider, "GetPattern #0");

            provider.SetValue(0);              // Setting old value
            EventsManager.Instance.Reset();
            AutomationPropertyEventTuple tuple
                = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.ValueProperty);

            Assert.IsNull(tuple, "GetAutomationEventFrom #0");

            provider.SetValue(0.9);
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.ValueProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #1");
            Assert.AreEqual((double)tuple.OldValue, 0, "OldValue #1");
            Assert.AreEqual((double)tuple.NewValue, 0.9, "NewValue #1");

            EventsManager.Instance.Reset();
            provider.SetValue(0.5);
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.ValueProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #2");
            Assert.AreEqual((double)tuple.OldValue, 0.9, "OldValue #2");
            Assert.AreEqual((double)tuple.NewValue, 0.5, "NewValue #2");

            EventsManager.Instance.Reset();
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.IsReadOnlyProperty);
            Assert.IsNull(tuple, "GetAutomationEventFrom #3");

            rangeBase.IsEnabled = false;
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.IsReadOnlyProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #4");
            Assert.IsTrue((bool)tuple.OldValue, "OldValue #4");
            Assert.IsFalse((bool)tuple.NewValue, "NewValue #4");

            EventsManager.Instance.Reset();
            rangeBase.IsEnabled = true;
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.IsReadOnlyProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #5");
            Assert.IsFalse((bool)tuple.OldValue, "OldValue #5");
            Assert.IsTrue((bool)tuple.NewValue, "NewValue #5");

            EventsManager.Instance.Reset();
            rangeBase.Maximum = 10.0;
            tuple             = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.MaximumProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #6");
            Assert.AreEqual(1d, (double)tuple.OldValue, "OldValue #6");
            Assert.AreEqual(10d, (double)tuple.NewValue, "NewValue #6");

            EventsManager.Instance.Reset();
            rangeBase.Minimum = 5.0;
            tuple             = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.MinimumProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #7");
            Assert.AreEqual(0d, (double)tuple.OldValue, "OldValue #7");
            Assert.AreEqual(5d, (double)tuple.NewValue, "NewValue #7");

            EventsManager.Instance.Reset();
            rangeBase.LargeChange = 2.0;
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.LargeChangeProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #8");
            Assert.AreEqual(1d, (double)tuple.OldValue, "OldValue #8");
            Assert.AreEqual(2d, (double)tuple.NewValue, "NewValue #8");

            EventsManager.Instance.Reset();
            rangeBase.SmallChange = 1.0;
            tuple = EventsManager.Instance.GetAutomationEventFrom(peer, RangeValuePatternIdentifiers.SmallChangeProperty);
            Assert.IsNotNull(tuple, "GetAutomationEventFrom #9");
            Assert.AreEqual(0.1d, (double)tuple.OldValue, "OldValue #9");
            Assert.AreEqual(1d, (double)tuple.NewValue, "NewValue #9");
        }
예제 #17
0
        public virtual void ToggleProvider_ToggleEvents()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            ToggleButton   toggleButton = CreateConcreteFrameworkElement() as ToggleButton;
            AutomationPeer peer
                = FrameworkElementAutomationPeer.CreatePeerForElement(toggleButton);
            AutomationPropertyEventTuple tuple = null;
            IToggleProvider toggleProvider     = (IToggleProvider)peer;

            CreateAsyncTest(toggleButton,
                            () => {
                EventsManager.Instance.Reset();
                toggleButton.IsThreeState = false;
                toggleButton.IsChecked    = false;
            },
                            // Test two-state toggling
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNull(tuple, "#0");
                Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState,
                                "Start two-state toggle: Unchecked");
            },
                            () => {
                EventsManager.Instance.Reset();
                toggleProvider.Toggle();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNotNull(tuple, "#1");
                Assert.AreEqual(ToggleState.Off,
                                (ToggleState)tuple.OldValue,
                                "#2");
                Assert.AreEqual(ToggleState.On,
                                (ToggleState)tuple.NewValue,
                                "#3");
            },
                            () => {
                EventsManager.Instance.Reset();
                toggleProvider.Toggle();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNotNull(tuple, "#4");
                Assert.AreEqual(ToggleState.On,
                                (ToggleState)tuple.OldValue,
                                "#5");
                Assert.AreEqual(ToggleState.Off,
                                (ToggleState)tuple.NewValue,
                                "#6");
            },
                            // Test three-state toggling
                            () => {
                EventsManager.Instance.Reset();
                toggleButton.IsThreeState = true;
                toggleButton.IsChecked    = true;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNotNull(tuple, "#7");
                Assert.AreEqual(ToggleState.Off,
                                (ToggleState)tuple.OldValue,
                                "#8");
                Assert.AreEqual(ToggleState.On,
                                (ToggleState)tuple.NewValue,
                                "#9");
            },
                            () => {
                EventsManager.Instance.Reset();
                toggleProvider.Toggle();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNotNull(tuple, "#10");
                Assert.AreEqual(ToggleState.On,
                                (ToggleState)tuple.OldValue,
                                "#11");
                Assert.AreEqual(ToggleState.Indeterminate,
                                (ToggleState)tuple.NewValue,
                                "#12");
            },
                            () => {
                EventsManager.Instance.Reset();
                toggleProvider.Toggle();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNotNull(tuple, "#13");
                Assert.AreEqual(ToggleState.Indeterminate,
                                (ToggleState)tuple.OldValue,
                                "#14");
                Assert.AreEqual(ToggleState.Off,
                                (ToggleState)tuple.NewValue,
                                "#15");
            },
                            () => {
                EventsManager.Instance.Reset();
                toggleProvider.Toggle();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      TogglePatternIdentifiers.ToggleStateProperty);
                Assert.IsNotNull(tuple, "#16");
                Assert.AreEqual(ToggleState.Off,
                                (ToggleState)tuple.OldValue,
                                "#17");
                Assert.AreEqual(ToggleState.On,
                                (ToggleState)tuple.NewValue,
                                "#18");
            });
        }
예제 #18
0
        public void ExpandCollapseProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            bool     expanded       = false;
            bool     concreteLoaded = false;
            bool     collapsed      = false;
            ComboBox combobox       = CreateConcreteFrameworkElement() as ComboBox;

            combobox.Width           = 300;
            combobox.Height          = 400;
            combobox.Loaded         += (o, e) => concreteLoaded = true;
            combobox.DropDownOpened += (o, e) => expanded = true;
            combobox.DropDownClosed += (o, e) => collapsed = true;

            combobox.Items.Add(new TextBlock()
            {
                Text = "Item0"
            });
            combobox.Items.Add(new TextBlock()
            {
                Text = "Item1"
            });

            AutomationPeer peer = null;
            AutomationPropertyEventTuple propertyTuple = null;

            EventsManager.Instance.Reset();
            TestPanel.Children.Add(combobox);

            EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0");
            Enqueue(() => combobox.ApplyTemplate());
            Enqueue(() => {
                peer          = FrameworkElementAutomationPeer.CreatePeerForElement(combobox);
                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty);
                Assert.IsNull(propertyTuple, "GetAutomationPropertyEventFrom #0");
            });
            Enqueue(() => {
                EventsManager.Instance.Reset();
                combobox.IsDropDownOpen = true;
            });
            EnqueueConditional(() => expanded, "Expanded #0");
            Enqueue(() => {
                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #1");
                Assert.AreEqual((ExpandCollapseState)propertyTuple.OldValue,
                                ExpandCollapseState.Collapsed,
                                "GetPropertyAutomationEventFrom.OldValue #0");
                Assert.AreEqual((ExpandCollapseState)propertyTuple.NewValue,
                                ExpandCollapseState.Expanded,
                                "GetPropertyAutomationEventFrom.NewValue #0");
            });
            Enqueue(() => {
                EventsManager.Instance.Reset();
                combobox.IsDropDownOpen = false;
            });
            EnqueueConditional(() => collapsed, "Collapsed #0");
            Enqueue(() => {
                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, ExpandCollapsePatternIdentifiers.ExpandCollapseStateProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #2");
                Assert.AreEqual((ExpandCollapseState)propertyTuple.OldValue,
                                ExpandCollapseState.Expanded,
                                "GetPropertyAutomationEventFrom.OldValue #1");
                Assert.AreEqual((ExpandCollapseState)propertyTuple.NewValue,
                                ExpandCollapseState.Collapsed,
                                "GetPropertyAutomationEventFrom.NewValue #1");
            });
            EnqueueTestComplete();
        }
예제 #19
0
        public void SelectionItemProvider_IsSelectedEvent()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            RadioButton    radioButton = CreateConcreteFrameworkElement() as RadioButton;
            AutomationPeer peer
                = FrameworkElementAutomationPeer.CreatePeerForElement(radioButton);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(radioButton,
                            () => {
                EventsManager.Instance.Reset();
                radioButton.IsThreeState = false;
                radioButton.IsChecked    = false;
            },
                            // Test two-state toggling
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNull(tuple, "#0");
            },
                            () => {
                EventsManager.Instance.Reset();
                radioButton.IsChecked = true;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(tuple, "#1");
                Assert.IsFalse((bool)tuple.OldValue, "#2");
                Assert.IsTrue((bool)tuple.NewValue, "#3");
            },
                            () => {
                EventsManager.Instance.Reset();
                radioButton.IsChecked = false;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(tuple, "#4");
                Assert.IsTrue((bool)tuple.OldValue, "#5");
                Assert.IsFalse((bool)tuple.NewValue, "#6");
            },
                            // Test three-state toggling
                            () => {
                EventsManager.Instance.Reset();
                radioButton.IsThreeState = true;
                radioButton.IsChecked    = true;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(tuple, "#7");
                Assert.IsFalse((bool)tuple.OldValue, "#8");
                Assert.IsTrue((bool)tuple.NewValue, "#9");
            },
                            () => {
                EventsManager.Instance.Reset();
                radioButton.IsChecked = null;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNull(tuple, "#10");
            },
                            () => {
                EventsManager.Instance.Reset();
                radioButton.IsChecked = false;
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer,
                                                                      SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(tuple, "#13");
                Assert.IsTrue((bool)tuple.OldValue, "#14");
                Assert.IsFalse((bool)tuple.NewValue, "#15");
            });
        }
예제 #20
0
        public override void ISelectionProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            bool     expanded       = false;
            bool     concreteLoaded = false;
            ComboBox combobox       = CreateConcreteFrameworkElement() as ComboBox;

            combobox.Width           = 300;
            combobox.Height          = 400;
            combobox.Loaded         += (o, e) => concreteLoaded = true;
            combobox.DropDownOpened += (o, e) => expanded = true;

            combobox.Items.Add(new TextBlock()
            {
                Text = "Item0"
            });
            combobox.Items.Add(new TextBlock()
            {
                Text = "Item1"
            });

            AutomationPeer peer      = null;
            AutomationPeer childPeer = null;

            IRawElementProviderSimple[]  selection         = null;
            AutomationPropertyEventTuple propertyTuple     = null;
            ISelectionProvider           selectionProvider = null;

            TestPanel.Children.Add(combobox);

            EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0");
            Enqueue(() => combobox.ApplyTemplate());
            Enqueue(() => combobox.IsDropDownOpen = true);
            EnqueueConditional(() => expanded, "Expanded #0");
            Enqueue(() => combobox.IsDropDownOpen = false);
            Enqueue(() => {
                peer = FrameworkElementAutomationPeer.CreatePeerForElement(combobox);

                selectionProvider = peer.GetPattern(PatternInterface.Selection) as ISelectionProvider;
                Assert.IsNotNull(selectionProvider, "Selection Provider");

                Assert.IsFalse(selectionProvider.CanSelectMultiple, "CanSelectMultiple #0");
                Assert.IsFalse(selectionProvider.IsSelectionRequired, "IsSelectionRequired #0");

                selection = selectionProvider.GetSelection();
                Assert.IsNull(selection, "GetSelection #0");
            });
            Enqueue(() => {
                EventsManager.Instance.Reset();
                combobox.SelectedIndex = 1;
            });
            Enqueue(() => {
                selection = selectionProvider.GetSelection();
                Assert.IsNotNull(selection, "GetSelection #1");
                Assert.AreEqual(1, selection.Length, "GetSelection #2");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #0");
                Assert.IsNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #0");
                Assert.IsNotNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #0");

                childPeer = new PeerFromProvider().GetPeerFromProvider(selection [0]);
            });
            Enqueue(() => {
                EventsManager.Instance.Reset();
                combobox.Items.Add(new TextBlock()
                {
                    Text = "Item1"
                });
                combobox.SelectedIndex = 0;
            });
            Enqueue(() => {
                selection = selectionProvider.GetSelection();
                Assert.IsNotNull(selection, "GetSelection #3");
                Assert.AreEqual(1, selection.Length, "GetSelection #4");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #1");
                Assert.IsNotNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #1");
                Assert.IsNotNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #1");

                Assert.AreNotEqual(selection [0], childPeer, "GetSelection #5");
            });
            Enqueue(() => {
                EventsManager.Instance.Reset();
                combobox.SelectedIndex = -1;
            });
            Enqueue(() => {
                selection = selectionProvider.GetSelection();
                Assert.IsNull(selection, "GetSelection #6");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer, SelectionPatternIdentifiers.SelectionProperty);
                Assert.IsNotNull(propertyTuple, "GetAutomationPropertyEventFrom #2");
                Assert.IsNotNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #2");
                Assert.IsNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #2");
            });
            EnqueueTestComplete();
        }
예제 #21
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            ContentControl fe = CreateConcreteFrameworkElement() as ContentControl;

            fe.Content = null;

            AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(fe,
                            () => {
                EventsManager.Instance.Reset();
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#0");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Attached Name");
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#1");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, null);
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#2");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Content = "Hello!";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#3");
                Assert.AreEqual("Hello!", (string)tuple.NewValue, "#4");
                Assert.AreEqual(string.Empty, (string)tuple.OldValue, "#5");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Hi");
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#6");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Content = "Hey!";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#7");
                Assert.AreEqual("Hey!", (string)tuple.NewValue, "#8");
                Assert.AreEqual("Hello!", (string)tuple.OldValue, "#9");
            });
        }
예제 #22
0
        public void ISelectionItemProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            TabControl tabControl = new TabControl();
            TabItem    item0      = new TabItem()
            {
                Header = "Item0", Content = new TextBlock()
                {
                    Text = "Item 0"
                }
            };
            TabItem item1 = new TabItem()
            {
                Header = "Item1", Content = new TextBlock()
                {
                    Text = "Item 1"
                }
            };
            TabItem item2 = new TabItem()
            {
                Header = "Item2", Content = new TextBlock()
                {
                    Text = "Item 2"
                }
            };

            tabControl.Items.Add(item0);
            tabControl.Items.Add(item1);
            tabControl.Items.Add(item2);
            item0.IsSelected = true;

            AutomationPeer peer0 = null;
            AutomationPeer peer1 = null;
            AutomationPeer peer2 = null;

            ISelectionItemProvider selectionItemProvider0 = null;
            ISelectionItemProvider selectionItemProvider1 = null;
            ISelectionItemProvider selectionItemProvider2 = null;

            AutomationPropertyEventTuple propertyTuple = null;

            CreateAsyncTest(tabControl,
                            () => {
                AutomationPeer tabControlPeer
                    = FrameworkElementAutomationPeer.CreatePeerForElement(tabControl);

                List <AutomationPeer> children = tabControlPeer.GetChildren();
                Assert.IsNotNull(children, "GetChildren #0");

                peer0 = children [0];
                peer1 = children [1];
                peer2 = children [2];

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

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

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

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

                Assert.IsTrue(selectionItemProvider0.IsSelected, "IsSelected #1");
                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #2");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #3");

                EventsManager.Instance.Reset();
                selectionItemProvider0.Select();                  // Nothing really changes
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider1.AddToSelection();
            },
                            () => {
                Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #4");
                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #5");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #6");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer0,
                                                                              SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #0");
                Assert.IsTrue((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #0");
                Assert.IsFalse((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #0");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1,
                                                                              SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #1");
                Assert.IsFalse((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #1");
                Assert.IsTrue((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #1");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider1.Select();                  // Nothing really changes
            },
                            () => {
                Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #7");
                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #8");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #9");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1,
                                                                              SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNull(propertyTuple, "GetPropertyAutomationEventFrom #2");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider1.RemoveFromSelection();                  // Nothing really changes
            },
                            () => {
                Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #10");
                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #11");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #12");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1,
                                                                              SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNull(propertyTuple, "GetPropertyAutomationEventFrom #3");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider2.Select();
            },
                            () => {
                Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #13");
                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #14");
                Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #15");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1,
                                                                              SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #4");
                Assert.IsTrue((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #4");
                Assert.IsFalse((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #4");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2,
                                                                              SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #5");
                Assert.IsFalse((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #5");
                Assert.IsTrue((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #5");
            });
        }
예제 #23
0
        public override void GetName_AttachedProperty1Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            CreateAsyncTest(calendar,
                            () => {
                List <AutomationPeer> buttonChildren = GetButtonChildren();
                FrameworkElement fe = ((FrameworkElementAutomationPeer)buttonChildren [0]).Owner as FrameworkElement;
                AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
                AutomationPropertyEventTuple tuple = null;

                TextBlock textblock = new TextBlock()
                {
                    Text = "Hello world:"
                };
                AutomationPeer textblockPeer = FrameworkElementAutomationPeer.CreatePeerForElement(textblock);

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

                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "My name");
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#1");
                Assert.AreEqual("My name", (string)tuple.NewValue, "#2");
                Assert.AreEqual(CURRENT_MONTH, (string)tuple.OldValue, "#3");

                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.LabeledByProperty, textblock);
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#4");
                Assert.AreEqual("Hello world:", (string)tuple.NewValue, "#5");
                Assert.AreEqual("My name", (string)tuple.OldValue, "#6");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.LabeledByProperty);
                Assert.IsNotNull(tuple, "#7");
                Assert.AreEqual(textblock, tuple.NewValue, "#8");
                Assert.AreEqual(null, tuple.OldValue, "#9");

                EventsManager.Instance.Reset();
                textblock.Text = null;
                tuple          = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#10");
                Assert.AreEqual(string.Empty, (string)tuple.NewValue, "#11");
                Assert.AreEqual("Hello world:", (string)tuple.OldValue, "#12");

                tuple = EventsManager.Instance.GetAutomationEventFrom(textblockPeer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#13");
                Assert.AreEqual(string.Empty, (string)tuple.NewValue, "#14");
                Assert.AreEqual("Hello world:", (string)tuple.OldValue, "#15");

                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.LabeledByProperty, null);
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#16");
                Assert.AreEqual("My name", (string)tuple.NewValue, "#17");
                Assert.AreEqual(string.Empty, (string)tuple.OldValue, "#18");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.LabeledByProperty);
                Assert.IsNotNull(tuple, "#19");
                Assert.AreEqual(null, tuple.NewValue, "#20");
                Assert.AreEqual(textblock, tuple.OldValue, "#21");
            });
        }
예제 #24
0
        public override void GetName_AttachedProperty0Event()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            ButtonBase fe        = CreateConcreteFrameworkElement() as ButtonBase;
            TextBlock  textblock = new TextBlock()
            {
                Text = "Textblock"
            };

            fe.Content = textblock;

            AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe);
            AutomationPropertyEventTuple tuple = null;

            CreateAsyncTest(fe,
                            () => {
                EventsManager.Instance.Reset();
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#0");
            },
                            () => {
                EventsManager.Instance.Reset();
                textblock.Text = "Hi";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#1");
                Assert.AreEqual("Hi", (string)tuple.NewValue, "#2");
                Assert.AreEqual("Textblock", tuple.OldValue, "#3");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Attached Name");
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#4");
                Assert.AreEqual("Attached Name", (string)tuple.NewValue, "#5");
                Assert.AreEqual("Hi", tuple.OldValue, "#6");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, "Name");
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#7");
                Assert.AreEqual("Name", (string)tuple.NewValue, "#8");
                Assert.AreEqual("Attached Name", (string)tuple.OldValue, "#9");
            },
                            () => {
                // Even if change TextBlock.Text (our current Content) the value will be the same
                EventsManager.Instance.Reset();
                textblock.Text = "New value";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNull(tuple, "#10");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.SetValue(AutomationProperties.NameProperty, null);
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#11");
                Assert.AreEqual("New value", (string)tuple.NewValue, "#12");
                Assert.AreEqual("Name", (string)tuple.OldValue, "#13");
            },
                            () => {
                EventsManager.Instance.Reset();
                textblock.Text = "What's up?";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#14");
                Assert.AreEqual("What's up?", (string)tuple.NewValue, "#15");
                Assert.AreEqual("New value", (string)tuple.OldValue, "#16");
            },
                            () => {
                EventsManager.Instance.Reset();
                fe.Content = "Hola";
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationElementIdentifiers.NameProperty);
                Assert.IsNotNull(tuple, "#17");
                Assert.AreEqual("Hola", (string)tuple.NewValue, "#18");
                Assert.AreEqual("What's up?", (string)tuple.OldValue, "#19");
            });
        }
        public virtual void ISelectionItemProvider_Events()
        {
            if (!EventsManager.Instance.AutomationSingletonExists)
            {
                EnqueueTestComplete();
                return;
            }

            ListBox     listbox      = new ListBox();
            ListBoxItem selectorItem = CreateConcreteFrameworkElement() as ListBoxItem;

            selectorItem.Content = "1";
            ListBoxItem secondSelectorItem = new ListBoxItem()
            {
                Content = "2"
            };

            listbox.Items.Add(selectorItem);
            listbox.Items.Add(secondSelectorItem);

            AutomationPeer               peer  = null;
            AutomationPeer               peer1 = null;
            AutomationPeer               peer2 = null;
            ISelectionItemProvider       selectionItemProvider1 = null;
            ISelectionItemProvider       selectionItemProvider2 = null;
            AutomationEventTuple         tuple         = null;
            AutomationPropertyEventTuple propertyTuple = null;

            CreateAsyncTest(listbox,
                            () => {
                peer  = FrameworkElementAutomationPeer.CreatePeerForElement(listbox);
                peer1 = FrameworkElementAutomationPeer.CreatePeerForElement(selectorItem);
                peer2 = FrameworkElementAutomationPeer.CreatePeerForElement(secondSelectorItem);

                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");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider1.AddToSelection();
            },
                            () => {
                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #2");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #3");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #0");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #0");
                Assert.IsFalse((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #0");
                Assert.IsTrue((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #0");

                EventsManager.Instance.Reset();
                selectionItemProvider1.Select();                  // Nothing really changes
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #1");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNull(propertyTuple, "GetPropertyAutomationEventFrom #1");

                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #4");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #5");

                // Throws exception because an element is already selected
                Assert.Throws <InvalidOperationException>(delegate {
                    selectionItemProvider2.AddToSelection();
                }, "AddToSelection #0");

                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #6");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #7");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider1.RemoveFromSelection();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #2");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer2, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #3");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #2");
                Assert.IsTrue((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #1");
                Assert.IsFalse((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #1");

                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #8");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #9");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider2.AddToSelection();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #4");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer2, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #5");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #3");
                Assert.IsFalse((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #2");
                Assert.IsTrue((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #2");

                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #10");
                Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #11");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider2.Select();                  // Nothing really changes
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer2, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #6");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #7");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNull(propertyTuple, "GetPropertyAutomationEventFrom #4");

                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #12");
                Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #13");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider2.RemoveFromSelection();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer2, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #7");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #6");
                Assert.IsTrue((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #4");
                Assert.IsFalse((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #4");

                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #14");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #15");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider1.Select();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #8");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer2, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #9");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #7");
                Assert.IsFalse((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #5");
                Assert.IsTrue((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #5");

                Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #16");
                Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #17");
            },
                            () => {
                EventsManager.Instance.Reset();
                selectionItemProvider2.Select();
            },
                            () => {
                tuple = EventsManager.Instance.GetAutomationEventFrom(peer1, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNull(tuple, "GetAutomationEventFrom #10");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer2, AutomationEvents.SelectionItemPatternOnElementSelected);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #11");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #8");
                Assert.IsFalse((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #6");
                Assert.IsTrue((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #6");

                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer1, SelectionItemPatternIdentifiers.IsSelectedProperty);
                Assert.IsNotNull(propertyTuple, "GetPropertyAutomationEventFrom #9");
                Assert.IsTrue((bool)propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #7");
                Assert.IsFalse((bool)propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #7");

                Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #18");
                Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #19");
            },
                            () => {
                EventsManager.Instance.Reset();
                listbox.Items.Remove(secondSelectorItem);
            },
                            () => {
                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2, SelectionItemPatternIdentifiers.SelectionContainerProperty);
                Assert.IsNotNull(tuple, "GetPropertyAutomationEventFrom #10");
                Assert.AreEqual(new PeerFromProvider().GetPeerFromProvider((IRawElementProviderSimple)propertyTuple.OldValue),
                                peer,
                                "GetPropertyAutomationEventFrom.OldValue #8");
                Assert.IsNull(propertyTuple.NewValue, "GetPropertyAutomationEventFrom.NewValue #8");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.StructureChanged);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #12");
            },
                            () => {
                EventsManager.Instance.Reset();
                listbox.Items.Add(secondSelectorItem);
            },
                            () => {
                propertyTuple = EventsManager.Instance.GetAutomationEventFrom(peer2, SelectionItemPatternIdentifiers.SelectionContainerProperty);
                Assert.IsNotNull(tuple, "GetPropertyAutomationEventFrom #11");
                Assert.IsNull(propertyTuple.OldValue, "GetPropertyAutomationEventFrom.OldValue #9");
                Assert.AreEqual(new PeerFromProvider().GetPeerFromProvider((IRawElementProviderSimple)propertyTuple.NewValue),
                                peer,
                                "GetPropertyAutomationEventFrom.NewValue #9");

                tuple = EventsManager.Instance.GetAutomationEventFrom(peer, AutomationEvents.StructureChanged);
                Assert.IsNotNull(tuple, "GetAutomationEventFrom #13");
            });
        }