void ISelectionItemProvider.AddToSelection() { if (!IsEnabled()) { throw new ElementNotEnabledException(); } ISelectionProvider selectionProvider = SelectionProvider; if (selectionProvider == null) { return; } ISelectionItemProvider selectionItemProvider = (ISelectionItemProvider)this; if (!selectionProvider.CanSelectMultiple) { IRawElementProviderSimple[] selection = selectionProvider.GetSelection(); if (selection == null || selection.Length == 0) { selectionItemProvider.Select(); } else { throw new InvalidOperationException(); } } else { selectionItemProvider.Select(); } }
public void SelectionItemProvider_Select() { RadioButton rb1 = CreateConcreteFrameworkElement() as RadioButton; RadioButton rb2 = CreateConcreteFrameworkElement() as RadioButton; rb1.GroupName = rb2.GroupName = "Fruit"; StackPanel stackPanel = new StackPanel(); stackPanel.Children.Add(rb1); stackPanel.Children.Add(rb2); TestPanel.Children.Add(stackPanel); Enqueue(() => { AutomationPeer radioPeer1 = FrameworkElementAutomationPeer.CreatePeerForElement(rb1); AutomationPeer radioPeer2 = FrameworkElementAutomationPeer.CreatePeerForElement(rb2); ISelectionItemProvider selectionItem1 = radioPeer1.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Assert.IsNotNull(selectionItem1); ISelectionItemProvider selectionItem2 = radioPeer2.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Assert.IsNotNull(selectionItem2); rb1.IsEnabled = false; try { selectionItem1.Select(); Assert.Fail("ElementNotEnabledException not raised when disabled"); } catch (ElementNotEnabledException) { } rb1.IsEnabled = true; selectionItem1.Select(); Assert.IsTrue(rb1.IsChecked == true, "Select didn't check rb1"); Assert.IsTrue(rb2.IsChecked == false, "rb2 is selected when rb1 should be"); // This shouldn't raise any exceptions selectionItem1.Select(); selectionItem2.Select(); Assert.IsTrue(rb2.IsChecked == true, "Select didn't check rb2"); Assert.IsTrue(rb1.IsChecked == false, "rb1 is selected when rb2 should be"); }); EnqueueTestComplete(); }
public override bool DoAction(int action) { if (action != 0) { return(false); } bool enabled = (bool)Provider.GetPropertyValue(AutomationElementIdentifiers.IsEnabledProperty.Id); if (!enabled) { return(false); } if (!selProvider.IsSelected) { try { selProvider.Select(); } catch (ElementNotEnabledException e) { Log.Debug(e); return(false); } } return(true); }
public virtual void AccordionItemPeerSelectAlreadySelected() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.One; AccordionItem first = new AccordionItem { Header = "First" }; AccordionItem second = new AccordionItem { Header = "Second" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => second.IsSelected = true, () => Assert.IsFalse(first.IsSelected, "First item should not be selected!"), () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Thread.Sleep(40), () => Assert.IsTrue(first.IsSelected, "First item should be selected!"), () => Assert.IsFalse(second.IsSelected, "Second item should not be selected!")); }
public void ISelectionItemProviderTest() { IRawElementProviderSimple childProvider = ProviderFactory.GetProvider(tabPage1); ISelectionItemProvider sel_item_prov = (ISelectionItemProvider)childProvider.GetPatternProvider( SelectionItemPatternIdentifiers.Pattern.Id); Assert.IsNotNull(sel_item_prov, "Not returning SelectionItemPatternIdentifiers"); // Test IsSelected property tabControl.SelectTab(0); Assert.IsTrue(sel_item_prov.IsSelected, "IsSelected should return true when tab is selected"); tabControl.SelectTab(1); Assert.IsFalse(sel_item_prov.IsSelected, "IsSelected should return false when tab is not selected"); // Test .Select method and eventing bridge.ResetEventLists(); sel_item_prov.Select(); Assert.IsTrue(sel_item_prov.IsSelected, "IsSelected should return true when tab is selected through ISelectionItem interface"); Assert.AreEqual(1, bridge.AutomationPropertyChangedEvents.Count, "No events fired for selection changed"); Assert.AreEqual(1, bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent), "IsSelected property change not fired"); }
public DirectoryTree2() { #region ContextMenu this.AddHandler(TreeViewItem.MouseRightButtonUpEvent, new MouseButtonEventHandler( (MouseButtonEventHandler) delegate(object sender, MouseButtonEventArgs args) { TreeViewItem sourceItem = UITools.GetParentTreeViewItem(args.OriginalSource as FrameworkElement); if (sourceItem != null) { if (!sourceItem.IsSelected) { TreeViewItemAutomationPeer peer = new TreeViewItemAutomationPeer(sourceItem); ISelectionItemProvider invokeProv = peer.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; invokeProv.Select(); } if (sourceItem.IsSelected) { if (ContextMenuCommand != null && ContextMenuCommand.CanExecute(this.SelectedItem)) { ContextMenuCommand.Execute(this.SelectedItem); } } } })); #endregion W7TreeViewItemUtils.SetIsEnabled(this, true); }
public static async Task <bool> SimulateSelectItemAsync( this ComboBox comboBox, JoinableTaskFactory joinableTaskFactory, string itemText, bool mustExist = true ) { await joinableTaskFactory.SwitchToMainThreadAsync(); if (comboBox.Text == itemText) { return(true); } if (!await comboBox.SimulateExpandAsync(joinableTaskFactory)) { return(false); } var peer = new ComboBoxAutomationPeer(comboBox); var children = peer.GetChildren().OfType <ListBoxItemAutomationPeer>().ToList(); var existingItem = children.Find(x => x.GetName() == itemText); if (existingItem is null) { if (mustExist) { throw new InvalidOperationException( $"Item '{itemText}' was not found in the combo box." ); } // Collapse the combo box, and then set the value explicitly if ( !await comboBox.SimulateCollapseAsync(joinableTaskFactory) || !await comboBox.SimulateSetTextAsync(joinableTaskFactory, itemText) ) { return(false); } return(true); } else { ISelectionItemProvider selectionItemProvider = existingItem; selectionItemProvider.Select(); // Wait for changes to propagate await Task.Yield(); if (!await comboBox.SimulateCollapseAsync(joinableTaskFactory)) { return(false); } return(true); } }
public virtual void AccordionItemPeerSelectNoAccordion() { AccordionItem item = new AccordionItem(); ISelectionItemProvider provider = null; TestAsync( item, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(item) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(item.IsSelected, "Item should be selected!")); }
/// <summary>Clears any selection and then selects the current element.</summary> /// <exception cref="T:System.Windows.Automation.ElementNotAvailableException">UI Automation element is no longer available.</exception> // Token: 0x06002876 RID: 10358 RVA: 0x000BC730 File Offset: 0x000BA930 void ISelectionItemProvider.Select() { TreeViewItemAutomationPeer treeViewItemAutomationPeer = this.GetWrapperPeer() as TreeViewItemAutomationPeer; if (treeViewItemAutomationPeer != null) { ISelectionItemProvider selectionItemProvider = treeViewItemAutomationPeer; selectionItemProvider.Select(); return; } base.ThrowElementNotAvailableException(); }
public bool DoAction(int i) { if (i == 0) { try { selectionItemProvider.Select(); return(true); } catch (ElementNotEnabledException e) { Log.Debug(e); } } return(false); }
/// <summary> /// Selects this element, removing any other element from the selection. /// </summary> void ISelectionItemProvider.Select() { TreeViewItemAutomationPeer wrapperPeer = GetWrapperPeer() as TreeViewItemAutomationPeer; if (wrapperPeer != null) { ISelectionItemProvider iSelectionItemProvider = wrapperPeer as ISelectionItemProvider; iSelectionItemProvider.Select(); } else { ThrowElementNotAvailableException(); } }
public void SelectTest() { Form f = new Form(); RadioButton r1 = new RadioButton(); r1.Checked = false; f.Controls.Add(r1); IRawElementProviderSimple provider1 = ProviderFactory.GetProvider(r1); ISelectionItemProvider selectionItem1 = (ISelectionItemProvider) provider1.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id); selectionItem1.Select(); Assert.IsTrue(r1.Checked, "Selecting 1/1, initially unchecked"); RadioButton r2 = new RadioButton(); r2.Checked = false; f.Controls.Add(r2); IRawElementProviderSimple provider2 = ProviderFactory.GetProvider(r2); ISelectionItemProvider selectionItem2 = (ISelectionItemProvider) provider2.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id); selectionItem1.Select(); Assert.IsTrue(r1.Checked, "Selecting 1/2, 1 intially checked, should check 1"); Assert.IsFalse(r2.Checked, "Selecting 1/2, 2 intially unchecked, should uncheck 2"); selectionItem2.Select(); Assert.IsTrue(r2.Checked, "Selecting 2/2, 1 initially checked, should check 2"); Assert.IsFalse(r1.Checked, "Selecting 2/2, 1 initially checked, should uncheck 1"); selectionItem1.Select(); Assert.IsTrue(r1.Checked, "Selecting 1/2, 1 intially unchecked, should check 1"); Assert.IsFalse(r2.Checked, "Selecting 1/2, 2 intially checked, should uncheck 2"); }
internal virtual bool DoClick() { if (selectionItemProvider == null) { return(false); } try { selectionItemProvider.Select(); return(true); } catch (ElementNotEnabledException e) { Log.Debug(e); return(false); } }
/// Realization for TabItem is tied to selection, bringing item into view for realizing the element /// as done for controls like ListBox doesn't make sense for TabControl. internal override void RealizeCore() { ISelectionItemProvider selectionItemProvider = this as ISelectionItemProvider; Selector parentSelector = (Selector)(ItemsControlAutomationPeer.Owner); if (parentSelector != null && selectionItemProvider != null) { if (parentSelector.CanSelectMultiple) { selectionItemProvider.AddToSelection(); } else { selectionItemProvider.Select(); } } }
public void ElementSelectedEventTest() { RadioButton r1 = new RadioButton(); r1.Checked = false; RadioButton r2 = new RadioButton(); r2.Checked = false; GroupBox gbox = new GroupBox(); gbox.Controls.Add(r1); gbox.Controls.Add(r2); Form.Controls.Add(gbox); IRawElementProviderSimple provider1 = ProviderFactory.GetProvider(r1); ISelectionItemProvider selectionItem1 = (ISelectionItemProvider) provider1.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id); IRawElementProviderSimple provider2 = ProviderFactory.GetProvider(r2); ISelectionItemProvider selectionItem2 = (ISelectionItemProvider) provider2.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id); bridge.ResetEventLists(); Assert.AreEqual(0, bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent), "Provider not selected"); selectionItem1.Select(); Assert.AreEqual(1, bridge.GetAutomationEventCount(SelectionItemPatternIdentifiers.ElementSelectedEvent), "Provider not selected"); AutomationEventTuple tuple = bridge.GetAutomationEventFrom(provider1, SelectionItemPatternIdentifiers.ElementSelectedEvent.Id); Assert.IsNotNull(tuple, "Selected Item should be the provider calling Select"); Assert.IsTrue(selectionItem1.IsSelected, "Radio Button 1 is selected"); Assert.IsFalse(selectionItem2.IsSelected, "Radio Button 2 is not selected"); }
public override void TestHasKeyboardFocusAfterPattern() { ToggleButton fe = CreateConcreteFrameworkElement() as ToggleButton; fe.Content = "Radiobutton"; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(fe); ISelectionItemProvider provider = null; CreateAsyncTest(fe, () => { provider = (ISelectionItemProvider)peer.GetPattern(PatternInterface.SelectionItem); Assert.IsNotNull(provider, "#0"); }, () => provider.Select(), () => Assert.IsTrue(peer.HasKeyboardFocus(), "#1")); }
public virtual void RatingItemPeerSelect() { Rating acc = new Rating(); acc.ItemsSource = null; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(first.DisplayValue == 1.0, "First item should have been selected!")); }
public bool AddSelection(int i) { AutomationPeer childPeer = GetChildAt(i); if (childPeer == null) { return(false); } ISelectionItemProvider childItem = childPeer.GetPattern( PatternInterface.SelectionItem) as ISelectionItemProvider; if (childItem == null) { return(false); } if (selectionProvider.CanSelectMultiple) { try { childItem.AddToSelection(); } catch (InvalidOperationException e) { Log.Debug(e); return(false); } } else { try { childItem.Select(); } catch (ElementNotEnabledException e) { Log.Debug(e); return(false); } catch (InvalidOperationException e) { Log.Debug(e); return(false); } } return(true); }
public virtual void TreeViewItemPeerSelect() { TreeView view = new TreeView(); TreeViewItem first = new TreeViewItem { Header = "First" }; TreeViewItem second = new TreeViewItem { Header = "Second" }; view.Items.Add(first); view.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( view, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(first.IsSelected, "First item should have been selected!")); }
public virtual void AccordionItemPeerSelect() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.ZeroOrMore; AccordionItem first = new AccordionItem { Header = "First" }; AccordionItem second = new AccordionItem { Header = "Second" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionItemProvider provider = null; TestAsync( acc, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.Select(), () => Assert.IsTrue(first.IsSelected, "First item should have been selected!")); }
// https://bugzilla.novell.com/show_bug.cgi?id=475529 public void MWFSelectionEventsRaisedTest() { ComboBox combobox = GetComboBox(); combobox.DropDownStyle = ComboBoxStyle.DropDownList; combobox.Items.Add("item1"); combobox.Items.Add("item2"); combobox.SelectedIndex = 0; var cbProvider = GetProviderFromControl(combobox); ISelectionItemProvider item1SelectionItem = null; ISelectionItemProvider item2SelectionItem = null; IRawElementProviderFragment listProvider = null; var childProvider = cbProvider.Navigate(NavigateDirection.FirstChild); while (childProvider != null) { if (ControlType.List.Id.Equals(childProvider.GetPropertyValue(AutomationElementIdentifiers.ControlTypeProperty.Id))) { listProvider = childProvider; break; } childProvider = childProvider.Navigate(NavigateDirection.NextSibling); } childProvider = listProvider.Navigate(NavigateDirection.FirstChild); while (childProvider != null) { if ((bool)childProvider.GetPropertyValue(AutomationElementIdentifiers.IsSelectionItemPatternAvailableProperty.Id)) { string name = (string) childProvider.GetPropertyValue(AutomationElementIdentifiers.NameProperty.Id); var selectionItemProvider = (ISelectionItemProvider) childProvider.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id); if (name == "item1") { item1SelectionItem = selectionItemProvider; } else if (name == "item2") { item2SelectionItem = selectionItemProvider; } } childProvider = childProvider.Navigate(NavigateDirection.NextSibling); } Assert.IsNotNull(item1SelectionItem, "Could not find item1 SelectionItem"); Assert.IsNotNull(item2SelectionItem, "Could not find item2 SelectionItem"); bool selectedIndexChanged = false; bool selectedValueChanged = false; bool selectionChangeCommitted = false; combobox.SelectedIndexChanged += delegate { selectedIndexChanged = true; }; combobox.SelectedValueChanged += delegate { selectedValueChanged = true; }; combobox.SelectionChangeCommitted += delegate { selectionChangeCommitted = true; }; item2SelectionItem.Select(); Assert.IsTrue(selectedIndexChanged, "SelectedIndexChanged event expected"); Assert.IsTrue(selectedValueChanged, "SelectedValueChanged event expected"); Assert.IsTrue(selectionChangeCommitted, "SelectionChangeCommitted event expected"); }
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"); }); }
public void ISelectionItemProvider_Methods() { TabControl tabControl = new TabControl(); TabItem item0 = new TabItem() { Header = "Item0" }; TabItem item1 = new TabItem() { Header = "Item1" }; TabItem item2 = new TabItem() { Header = "Item2" }; 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; CreateAsyncTest(tabControl, () => { AutomationPeer tabControlPeer = FrameworkElementAutomationPeer.CreatePeerForElement(tabControl); List <AutomationPeer> children = tabControlPeer.GetChildren(); Assert.IsNotNull(children, "GetChildren #0"); Assert.AreEqual(3, children.Count, "GetChildren #1"); peer0 = FrameworkElementAutomationPeer.CreatePeerForElement(item0); peer1 = FrameworkElementAutomationPeer.CreatePeerForElement(item1); peer2 = FrameworkElementAutomationPeer.CreatePeerForElement(item2); 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"); Assert.IsTrue(selectionItemProvider0.IsSelected, "IsSelected #1"); Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #2"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #3"); }, () => { selectionItemProvider1.AddToSelection(); }, () => { Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #4"); Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #5"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #6"); }, () => { selectionItemProvider1.Select(); }, // Nothing changes, is already selected () => { Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #7"); Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #8"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #9"); }, () => { selectionItemProvider1.RemoveFromSelection(); }, // Nothing happens, Remove does nothing. () => { Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #10"); Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #11"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #12"); }, () => { selectionItemProvider2.AddToSelection(); }, // Doesn't throw exception () => { Assert.IsFalse(selectionItemProvider0.IsSelected, "IsSelected #13"); Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #14"); Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #15"); }, () => { selectionItemProvider0.Select(); }, () => { Assert.IsTrue(selectionItemProvider0.IsSelected, "IsSelected #16"); Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #17"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #18"); }); }
/// <summary> /// Sets the current element as the selection /// This clears the selection from other elements in the container. /// </summary> void ISelectionItemProvider.Select() => publicISelectionItemProvider.Select();
public void ItemsNavigationTest() { DomainUpDown domainUpDown = (DomainUpDown)GetControlInstance(); domainUpDown.Items.Add("First"); domainUpDown.Items.Add("Second"); domainUpDown.Items.Add("Third"); domainUpDown.Items.Add("Fourth"); Form.Controls.Add(domainUpDown); IRawElementProviderFragmentRoot rootProvider; IRawElementProviderFragment childProvider; rootProvider = (IRawElementProviderFragmentRoot)GetProviderFromControl(domainUpDown); // Skip over the Forward and Backward buttons childProvider = rootProvider.Navigate(NavigateDirection.FirstChild); childProvider = childProvider.Navigate(NavigateDirection.NextSibling); childProvider = childProvider.Navigate(NavigateDirection.NextSibling); IValueProvider item_val_prov = (IValueProvider)childProvider.GetPatternProvider( ValuePatternIdentifiers.Pattern.Id); Assert.AreEqual("First", item_val_prov.Value); // Ensure the parent is set correctly Assert.AreEqual(childProvider.Navigate(NavigateDirection.Parent), rootProvider); childProvider = childProvider.Navigate(NavigateDirection.NextSibling); item_val_prov = (IValueProvider)childProvider.GetPatternProvider( ValuePatternIdentifiers.Pattern.Id); Assert.AreEqual("Second", item_val_prov.Value); // Try to select the Second item ISelectionItemProvider sel_item_prov = (ISelectionItemProvider)childProvider.GetPatternProvider( SelectionItemPatternIdentifiers.Pattern.Id); Assert.IsNotNull(sel_item_prov); sel_item_prov.Select(); Assert.AreEqual(1, domainUpDown.SelectedIndex); // Verify that the SelectionProvider reflects the new // selection ISelectionProvider sel_prov = (ISelectionProvider)rootProvider.GetPatternProvider( SelectionPatternIdentifiers.Pattern.Id); Assert.IsNotNull(sel_prov); IRawElementProviderSimple[] children = sel_prov.GetSelection(); Assert.IsNotNull(children); Assert.AreEqual(1, children.Length); IValueProvider val_prov = (IValueProvider)children[0].GetPatternProvider( ValuePatternIdentifiers.Pattern.Id); Assert.AreEqual("Second", val_prov.Value); }
public void ListItemISelectionItemProvider_Complex() { calendar.MinDate = new DateTime(2000, 12, 1); calendar.SelectionRange = new SelectionRange(new DateTime(2000, 12, 3), new DateTime(2000, 12, 3)); calendar.MaxSelectionCount = 5; IRawElementProviderFragmentRoot dataGridProvider; IRawElementProviderFragment listItem, secondItem; GetDataGridAndFirstListItem(out dataGridProvider, out listItem); // Advance until we hit a date in this month, so that // we don't jump and invalidate all of our items DateTime date = calendar.GetDisplayRange(false).Start; while (listItem != null) { if (date == calendar.MinDate) { break; } date = date.AddDays(1); listItem = listItem.Navigate( NavigateDirection.NextSibling); } ISelectionItemProvider firstItemProvider = listItem.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id) as ISelectionItemProvider; Assert.IsFalse(firstItemProvider.IsSelected, "Item reporting to be selected when it shouldn't be"); firstItemProvider.Select(); Assert.IsTrue(firstItemProvider.IsSelected, "Item is reporting not selected when it should be"); Assert.AreEqual(calendar.SelectionStart, date, "Calendar returning different start than we just set"); Assert.AreEqual(calendar.SelectionEnd, date, "Calendar returning different end than we just set"); secondItem = listItem.Navigate(NavigateDirection.NextSibling); Assert.IsNotNull(secondItem, "First item has no next sibling"); ISelectionItemProvider secondItemProvider = secondItem.GetPatternProvider(SelectionItemPatternIdentifiers.Pattern.Id) as ISelectionItemProvider; Assert.IsNotNull(secondItemProvider, "Second item does not implement ISelectionItemProvider"); secondItemProvider.AddToSelection(); Assert.IsTrue(secondItemProvider.IsSelected, "Second item not selected when it should be"); firstItemProvider.RemoveFromSelection(); Assert.IsFalse(firstItemProvider.IsSelected, "Item reporting to be selected when it shouldn't be"); Assert.IsTrue(secondItemProvider.IsSelected, "Second item not selected when it should be"); }
public void ISelectionItemProvider_Methods() { AutomationPeer calendarAutomationPeer = null; AutomationPeer peer = null; ISelectionItemProvider selectionItem = null; ISelectionItemProvider selectionItem2 = null; DateTime date = new DateTime(2000, 2, 1); calendar.DisplayMode = CalendarMode.Year; calendar.DisplayDate = date; calendar.SelectedDate = null; List <AutomationPeer> buttonChildren = null; CreateAsyncTest(calendar, () => { calendarAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(calendar); Assert.IsNotNull(calendarAutomationPeer, "#0"); buttonChildren = GetButtonChildren(); Assert.IsNotNull(buttonChildren.Count, "#1"); Assert.AreEqual(12, buttonChildren.Count, "#2"); }, () => { peer = (from c in buttonChildren where c.GetName() == "Jan" // DateTime (2000, 2, 1); select c).FirstOrDefault(); Assert.IsNotNull(peer, "#3"); }, () => { selectionItem = (ISelectionItemProvider)peer.GetPattern(PatternInterface.SelectionItem); Assert.IsNotNull(selectionItem, "#4"); Assert.IsFalse(selectionItem.IsSelected, "#5"); Assert.AreEqual(calendarAutomationPeer, new PeerFromProvider().GetPeerFromProvider(selectionItem.SelectionContainer), "#6"); }, () => selectionItem.AddToSelection(), () => { Assert.IsFalse(selectionItem.IsSelected, "#6"); selectionItem.Select(); }, () => { Assert.IsTrue(selectionItem.IsSelected, "#7"); AutomationPeer nextPeer = buttonChildren[buttonChildren.IndexOf(peer) + 1]; Assert.IsNotNull(nextPeer, "#8"); selectionItem2 = (ISelectionItemProvider)nextPeer.GetPattern(PatternInterface.SelectionItem); Assert.IsNotNull(selectionItem2, "#9"); Assert.IsFalse(selectionItem2.IsSelected, "#10"); }, () => selectionItem2.AddToSelection(), () => { Assert.IsFalse(selectionItem2.IsSelected, "#11"); Assert.IsTrue(selectionItem.IsSelected, "#12"); }, () => selectionItem2.Select(), () => { Assert.IsTrue(selectionItem2.IsSelected, "#13"); Assert.IsFalse(selectionItem.IsSelected, "#14"); }, // no changes () => selectionItem2.RemoveFromSelection(), () => { Assert.IsTrue(selectionItem2.IsSelected, "#13"); Assert.IsFalse(selectionItem.IsSelected, "#14"); }, () => TestPanel.Children.Remove(calendar)); }
public void TestHasKeyboardFocusAfterPattern() { ListBox listbox = new ListBox(); listbox.Items.Add("Item 0"); listbox.Items.Add("Item 1"); AutomationPeer peer1 = null; AutomationPeer peer2 = null; ISelectionItemProvider selectionItemProvider1 = null; ISelectionItemProvider selectionItemProvider2 = null; AutomationPeer listboxPeer = null; CreateAsyncTest(listbox, () => { listboxPeer = FrameworkElementAutomationPeer.CreatePeerForElement(listbox); peer1 = listboxPeer.GetChildren()[0]; peer2 = listboxPeer.GetChildren()[1]; selectionItemProvider1 = peer1.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Assert.IsNotNull(selectionItemProvider1, "SelectionItem Provider #0"); selectionItemProvider2 = peer2.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Assert.IsNotNull(selectionItemProvider2, "SelectionItem Provider #1"); // By default both are not selected Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #0"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #1"); }, () => selectionItemProvider1.Select(), () => { Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #2"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #3"); }, () => { Assert.IsTrue(peer1.HasKeyboardFocus(), "#1"); Assert.IsFalse(peer2.HasKeyboardFocus(), "#2"); Assert.IsFalse(listboxPeer.HasKeyboardFocus(), "#3"); }, () => { selectionItemProvider2.Select(); }, () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #4"); Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #5"); }, () => { Assert.IsFalse(peer1.HasKeyboardFocus(), "#4"); Assert.IsTrue(peer2.HasKeyboardFocus(), "#5"); Assert.IsFalse(listboxPeer.HasKeyboardFocus(), "#6"); }, () => { selectionItemProvider2.RemoveFromSelection(); }, () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #6"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #7"); }, () => { Assert.IsTrue(peer1.HasKeyboardFocus(), "#7"); Assert.IsFalse(peer2.HasKeyboardFocus(), "#8"); Assert.IsFalse(listboxPeer.HasKeyboardFocus(), "#9"); }); }
protected void ISelectionItemProvider_Methods(List <object> items) { ListBox listbox = new ListBox(); foreach (object item in items) { listbox.Items.Add(item); } AutomationPeer peer1 = null; AutomationPeer peer2 = null; ISelectionItemProvider selectionItemProvider1 = null; ISelectionItemProvider selectionItemProvider2 = null; CreateAsyncTest(listbox, () => { AutomationPeer listboxPeer = FrameworkElementAutomationPeer.CreatePeerForElement(listbox); peer1 = listboxPeer.GetChildren()[0]; peer2 = listboxPeer.GetChildren()[1]; selectionItemProvider1 = peer1.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Assert.IsNotNull(selectionItemProvider1, "SelectionItem Provider #0"); selectionItemProvider2 = peer2.GetPattern(PatternInterface.SelectionItem) as ISelectionItemProvider; Assert.IsNotNull(selectionItemProvider2, "SelectionItem Provider #1"); // By default both are not selected Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #0"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #1"); }, () => { selectionItemProvider1.AddToSelection(); }, () => { Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #2"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #3"); }, () => { selectionItemProvider1.Select(); }, // Nothing really changes () => { 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"); }, () => { selectionItemProvider1.RemoveFromSelection(); }, () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #8"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #9"); }, () => { selectionItemProvider2.AddToSelection(); }, () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #10"); Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #11"); }, () => { selectionItemProvider2.Select(); }, // Nothing really changes () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #12"); Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #13"); }, () => { selectionItemProvider2.RemoveFromSelection(); }, () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #14"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #15"); }, () => { selectionItemProvider1.Select(); }, () => { Assert.IsTrue(selectionItemProvider1.IsSelected, "IsSelected #16"); Assert.IsFalse(selectionItemProvider2.IsSelected, "IsSelected #17"); }, () => { selectionItemProvider2.Select(); }, () => { Assert.IsFalse(selectionItemProvider1.IsSelected, "IsSelected #18"); Assert.IsTrue(selectionItemProvider2.IsSelected, "IsSelected #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"); }); }