/// <summary> /// The do implementation. /// </summary> /// <exception cref="TestAutomationException"> /// No automation peer found for + element.GetType().FullName /// or /// No invoke pattern found for + element.GetType().FullName /// </exception> protected override void DoImpl() { var element = GetUIElement(); if (element == null) { SendNotFoundResult("Couldn't find element " + this.AutomationIdentifier.ElementName); return; } // automate the click var peer = FrameworkElementAutomationPeer.CreatePeerForElement(element); if (peer == null) { throw new TestAutomationException("No automation peer found for " + element.GetType().FullName); } if (TryTogglePatternAutomation(peer, element) || TryInvokePatternAutomation(peer)) { SendSuccessResult(); return; } throw new TestAutomationException("No invoke pattern found for " + element.GetType().FullName); }
protected override List <AutomationPeer> GetChildrenCore() { TreeView owner = OwnerTreeView; ItemCollection items = owner.Items; if (items.Count <= 0) { return(null); } List <AutomationPeer> peers = new List <AutomationPeer>(items.Count); for (int i = 0; i < items.Count; i++) { TreeViewItem element = owner.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewItem; if (element != null) { peers.Add( FrameworkElementAutomationPeer.FromElement(element) ?? FrameworkElementAutomationPeer.CreatePeerForElement(element)); } } return(peers); }
public virtual void TimeUpDownPeerOnlySupportsValuePattern() { TimeUpDown item = new TimeUpDown(); TimeUpDownAutomationPeer peer = null; TestAsync( item, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(item) as TimeUpDownAutomationPeer, () => Assert.IsNull(peer.GetPattern(PatternInterface.Dock), "TimeUpDownAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.ExpandCollapse), "TimeUpDownAutomationPeer should not support the ExpandCollapse pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Grid), "TimeUpDownAutomationPeer should not support the Grid pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.GridItem), "TimeUpDownAutomationPeer should not support the GridItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Invoke), "TimeUpDownAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.MultipleView), "TimeUpDownAutomationPeer should not support the MultipleView pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.RangeValue), "TimeUpDownAutomationPeer should not support the RangeValue pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Scroll), "TimeUpDownAutomationPeer should not support the Scroll pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.ScrollItem), "TimeUpDownAutomationPeer should not support the ScrollItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Selection), "TimeUpDownAutomationPeer should not support the Selection pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Table), "TimeUpDownAutomationPeer should not support the Table pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.TableItem), "TimeUpDownAutomationPeer should not support the TableItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Toggle), "TimeUpDownAutomationPeer should not support the Toggle pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Transform), "TimeUpDownAutomationPeer should not support the Transform pattern!"), () => Assert.IsNotNull(peer.GetPattern(PatternInterface.Value), "TimeUpDownAutomationPeer should support the Value pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Window), "TimeUpDownAutomationPeer should not support the Window pattern!")); }
public override void GetName_AttachedProperty1() { TabControl tabControl = new TabControl(); TabItem tabItem = new TabItem(); CreateAsyncTest(tabControl, () => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem); string textblockName = "Hello world:"; string nameProperty = "TextBox name"; TextBlock textblock = new TextBlock(); textblock.Text = textblockName; tabItem.SetValue(AutomationProperties.NameProperty, nameProperty); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #0"); tabItem.SetValue(AutomationProperties.LabeledByProperty, textblock); Assert.AreEqual(textblockName, peer.GetName(), "GetName #1"); textblock.Text = null; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #2"); textblock.Text = string.Empty; Assert.AreEqual(string.Empty, peer.GetName(), "GetName #3"); tabItem.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #4"); tabItem.SetValue(AutomationProperties.LabeledByProperty, null); Assert.AreEqual(string.Empty, peer.GetName(), "GetName #5"); }); }
/// <inheritdoc /> protected override object GetPatternCore(PatternInterface patternInterface) { object pattern = null; if (patternInterface == PatternInterface.Value) { pattern = this; } else if (patternInterface == PatternInterface.ExpandCollapse) { pattern = this; } else if (patternInterface == PatternInterface.Selection) { AutomationPeer selectionPeer = FrameworkElementAutomationPeer.CreatePeerForElement(this.AutoCompleteBox.suggestionsControl) as AutomationPeer; if (selectionPeer != null) { pattern = selectionPeer.GetPattern(patternInterface); } } if (pattern == null) { pattern = base.GetPatternCore(patternInterface); } return(pattern); }
public static void InvokeAutomationPeer <TTargetType, TPatternProvider>(this FrameworkElement element, PatternInterface patternInterface, Action <TPatternProvider> invokeAction) where TPatternProvider : class { var targetElement = element.FindSelfOrParentOfType <TTargetType>(); if (targetElement == null) { throw new TestAutomationException("No appropriate target parent found for " + element.GetType().FullName); } // automate the click var peer = FrameworkElementAutomationPeer.CreatePeerForElement(element); if (peer == null) { throw new TestAutomationException("No automation peer found for " + targetElement.GetType().FullName); } TPatternProvider patternProvider; if (!TryGetAutomationPattern(peer, patternInterface, out patternProvider)) { throw new TestAutomationException("Pattern interface not found for " + targetElement.GetType().FullName); } invokeAction(patternProvider); }
public override void GetAutomationControlType() { TabItem tabItem = CreateConcreteFrameworkElement() as TabItem; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem) as AutomationPeer; Assert.AreEqual(AutomationControlType.TabItem, peer.GetAutomationControlType(), "#0"); }
internal void AutomationUpdatePeerIfExists(int itemIndex) { if (_hasPeerBeenCreated) { AutomationPeer spAutomationPeer; LoopingSelectorItemAutomationPeer spLSIAP; LoopingSelectorItemAutomationPeer pLSIAP; UIElement spThisAsUI; //wrl.ComPtr<xaml_automation_peers.FrameworkElementAutomationPeerStatics> spAutomationPeerStatics; //QueryInterface(__uuidof(UIElement), &spThisAsUI); spThisAsUI = this; //(wf.GetActivationFactory( // wrl_wrappers.Hstring(RuntimeClass_Microsoft_UI_Xaml_Automation_Peers_FrameworkElementAutomationPeer), // &spAutomationPeerStatics)); // CreatePeerForElement does not always create one - if there is one associated with this UIElement it will reuse that. // We do not want to end up creating a bunch of peers for the same element causing Narrator to get confused. //spAutomationPeerStatics.CreatePeerForElement(spThisAsUI, &spAutomationPeer); spAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(spThisAsUI); //spAutomationPeer.As(spLSIAP); spLSIAP = spAutomationPeer as LoopingSelectorItemAutomationPeer; pLSIAP = spLSIAP; pLSIAP.UpdateEventSource(); pLSIAP.UpdateItemIndex(itemIndex); } }
public void PerformClick() { var peer = FrameworkElementAutomationPeer.FromElement(this) ?? FrameworkElementAutomationPeer.CreatePeerForElement(this); var provider = (IInvokeProvider)peer.GetPattern(PatternInterface.Invoke); provider.Invoke(); }
public virtual void AccordionPeerGetSelectionChanged() { Accordion acc = new Accordion(); acc.SelectionMode = AccordionSelectionMode.ZeroOrMore; AccordionItem first = new AccordionItem { Header = "First", Content = "a" }; AccordionItem second = new AccordionItem { Header = "Second", Content = "b" }; acc.Items.Add(first); acc.Items.Add(second); ISelectionProvider provider = null; IRawElementProviderSimple[] selection = null; TestAsync( acc, () => second.IsSelected = true, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(acc) as ISelectionProvider, () => FrameworkElementAutomationPeer.CreatePeerForElement(second), () => selection = provider.GetSelection(), () => Assert.AreEqual(1, selection.Length, "Expected a selection!"), () => second.IsSelected = false, () => selection = provider.GetSelection(), () => Assert.IsNotNull(selection, "An empty selection was expected!"), () => Assert.AreEqual(0, selection.Length, "No items should be selected!")); }
private void OnselectionModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "SelectedIndices") { bool?oldValue = IsSelected; var indexPath = GetIndexPath(); bool?newValue = IsRealized(indexPath) ? SelectionModel.IsSelectedAt(indexPath) : false; if (oldValue != newValue) { IsSelected = newValue; bool oldValueAsBool = oldValue.HasValue && oldValue.Value; bool newValueAsBool = newValue.HasValue && newValue.Value; if (oldValueAsBool != newValueAsBool) { // AutomationEvents.PropertyChanged is used as a value that means dont raise anything AutomationEvents eventToRaise = oldValueAsBool ? (SelectionModel.SingleSelect ? AutomationEvents.PropertyChanged : AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection) : (SelectionModel.SingleSelect ? AutomationEvents.SelectionItemPatternOnElementSelected : AutomationEvents.SelectionItemPatternOnElementAddedToSelection); if (eventToRaise != AutomationEvents.PropertyChanged && AutomationPeer.ListenerExists(eventToRaise)) { var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this); peer.RaiseAutomationEvent(eventToRaise); } } } } }
public virtual void RatingPeerGetSelectionChanged() { Rating acc = new Rating(); acc.ItemsSource = null; RatingItem first = new RatingItem(); RatingItem second = new RatingItem(); acc.Items.Add(first); acc.Items.Add(second); ISelectionProvider provider = null; IRawElementProviderSimple[] selection = null; TestAsync( acc, () => acc.Value = 1.0, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(acc) as ISelectionProvider, () => FrameworkElementAutomationPeer.CreatePeerForElement(second), () => selection = provider.GetSelection(), () => Assert.AreEqual(1, selection.Length, "Expected a selection!"), () => acc.Value = 0.0, () => selection = provider.GetSelection(), () => Assert.IsNotNull(selection, "An empty selection was expected!"), () => Assert.AreEqual(0, selection.Length, "No items should be selected!")); }
public virtual void RatingPeerOnlySupportsSelectionAndValue() { Rating view = new Rating(); RatingAutomationPeer peer = null; TestAsync( view, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(view) as RatingAutomationPeer, () => Assert.IsNull(peer.GetPattern(PatternInterface.Dock), "RatingAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.ExpandCollapse), "RatingAutomationPeer should not support the ExpandCollapse pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Grid), "RatingAutomationPeer should not support the Grid pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.GridItem), "RatingAutomationPeer should not support the GridItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Invoke), "RatingAutomationPeer should not support the Dock pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.MultipleView), "RatingAutomationPeer should not support the MultipleView pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.RangeValue), "RatingAutomationPeer should not support the RangeValue pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.ScrollItem), "RatingAutomationPeer should not support the ScrollItem pattern!"), () => Assert.IsNotNull(peer.GetPattern(PatternInterface.Selection), "RatingAutomationPeer should support the Selection pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.SelectionItem), "RatingAutomationPeer should not support the SelectionItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Table), "RatingAutomationPeer should not support the Table pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.TableItem), "RatingAutomationPeer should not support the TableItem pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Toggle), "RatingAutomationPeer should not support the Toggle pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Transform), "RatingAutomationPeer should not support the Transform pattern!"), () => Assert.IsNotNull(peer.GetPattern(PatternInterface.Value), "RatingAutomationPeer should support the Value pattern!"), () => Assert.IsNull(peer.GetPattern(PatternInterface.Window), "RatingAutomationPeer should not support the Window pattern!")); }
protected override List <AutomationPeer> GetChildrenCore() { RadMenuItem owner = this.OwnerAsRadMenuItem(); ItemCollection items = owner.Items; if (items.Count > 0) { List <AutomationPeer> list = new List <AutomationPeer>(items.Count); for (int i = 0; i < items.Count; i++) { UIElement element = owner.ItemContainerGenerator.ContainerFromIndex(i) as UIElement; if (element != null) { AutomationPeer peer = FrameworkElementAutomationPeer.FromElement(element); if (peer == null) { peer = FrameworkElementAutomationPeer.CreatePeerForElement(element); } if (peer != null) { list.Add(peer); } } } return(list); } return(null); }
public virtual void AccordionItemPeerRemoveSelectionNoAccordion() { 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, () => first.IsSelected = true, () => provider = FrameworkElementAutomationPeer.CreatePeerForElement(first) as ISelectionItemProvider, () => provider.RemoveFromSelection(), () => Thread.Sleep(40), () => Assert.IsFalse(first.IsSelected, "Item should be not selected!")); }
public async Task ShouldConfigureTokenizingTextBoxAutomationPeerAsync() { await App.DispatcherQueue.EnqueueAsync(async() => { const string expectedAutomationName = "MyAutomationName"; const string expectedName = "MyName"; const string expectedValue = "Wor"; var items = new ObservableCollection <TokenizingTextBoxTestItem> { new() { Title = "Hello" }, new() { Title = "World" } }; var tokenizingTextBox = new TokenizingTextBox { ItemsSource = items }; await SetTestContentAsync(tokenizingTextBox); var tokenizingTextBoxAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(tokenizingTextBox) as TokenizingTextBoxAutomationPeer; Assert.IsNotNull(tokenizingTextBoxAutomationPeer, "Verify that the AutomationPeer is TokenizingTextBoxAutomationPeer."); // Asserts the automation peer name based on the Automation Property Name value. tokenizingTextBox.SetValue(AutomationProperties.NameProperty, expectedAutomationName); Assert.IsTrue(tokenizingTextBoxAutomationPeer.GetName().Contains(expectedAutomationName), "Verify that the UIA name contains the given AutomationProperties.Name of the TokenizingTextBox."); // Asserts the automation peer name based on the element Name property. tokenizingTextBox.Name = expectedName; Assert.IsTrue(tokenizingTextBoxAutomationPeer.GetName().Contains(expectedName), "Verify that the UIA name contains the given Name of the TokenizingTextBox."); tokenizingTextBoxAutomationPeer.SetValue(expectedValue); Assert.IsTrue(tokenizingTextBoxAutomationPeer.Value.Equals(expectedValue), "Verify that the Value contains the given Text of the TokenizingTextBox."); }); }
private void OnselectionModelChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "SelectedIndices") { bool oldValue = IsSelected; var groupIndex = GetGroupIndex(); bool newValue = groupIndex >= 0 ? SelectionModel.IsSelected(groupIndex, RepeatedIndex).Value : false; if (oldValue != newValue) { IsSelected = newValue; // AutomationEvents.PropertyChanged is used as a value that means dont raise anything AutomationEvents eventToRaise = oldValue ? (SelectionModel.SingleSelect ? AutomationEvents.PropertyChanged : AutomationEvents.SelectionItemPatternOnElementRemovedFromSelection) : (SelectionModel.SingleSelect ? AutomationEvents.SelectionItemPatternOnElementSelected : AutomationEvents.SelectionItemPatternOnElementAddedToSelection); if (eventToRaise != AutomationEvents.PropertyChanged && AutomationPeer.ListenerExists(eventToRaise)) { var peer = FrameworkElementAutomationPeer.CreatePeerForElement(this); peer.RaiseAutomationEvent(eventToRaise); } } } }
private static void OnIsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { var item = d as RadialMenuItem; var newValue = (bool)e.NewValue; var oldValue = (bool)e.OldValue; if (item.IsInternalPropertyChange) { return; } if (oldValue == newValue || !RadialMenuModel.CanChangeSelection(item, newValue)) { item.ChangePropertyInternally(RadialMenuItem.IsSelectedProperty, oldValue); } if (item.Owner != null) { item.Owner.OnSelectionChanged(item); var contentSegment = item.Owner.GetContentSegment(item); if (contentSegment != null) { var radialMenuItemControl = contentSegment.Visual as RadialMenuItemControl; if (radialMenuItemControl != null) { var peer = FrameworkElementAutomationPeer.CreatePeerForElement(radialMenuItemControl) as RadialMenuItemControlAutomationPeer; if (peer != null) { peer.RaiseToggleStatePropertyChangedEvent((bool)e.OldValue, (bool)e.NewValue); } } } } }
public void VerifyEmptyLocalizedLandMarkTypealidWithNoLandmarkType() { var rule = new LocalizedLandMarkTypeRule(); var peer = FrameworkElementAutomationPeer.CreatePeerForElement(new Button()); Assert.IsTrue(rule.IsValid(null, peer)); }
/// <inheritdoc /> protected override IList <AutomationPeer> GetChildrenCore() { List <AutomationPeer> list = new List <AutomationPeer>(); IEnumerable <DependencyObject> childElements = ElementTreeHelper.EnumVisualDescendants(this.Owner, descendand => descendand is ChartElementPresenter); foreach (ChartElementPresenter child in childElements) { AutomationPeer item = FrameworkElementAutomationPeer.FromElement(child); if (item == null) { item = FrameworkElementAutomationPeer.CreatePeerForElement(child); } if (item != null) { list.Add(item); } } var emptyContentPresenter = ElementTreeHelper.EnumVisualDescendants(this.Owner, descendand => descendand is ContentPresenter) .Where(presenter => presenter.Equals(this.OwningChart.emptyContentPresenter)).SingleOrDefault() as ContentPresenter; if (emptyContentPresenter != null) { list.Add(FrameworkElementAutomationPeer.CreatePeerForElement(emptyContentPresenter)); } return(list); }
public override void GetClassName() { TabItem tabItem = CreateConcreteFrameworkElement() as TabItem; AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(tabItem) as AutomationPeer; Assert.AreEqual("TabItem", peer.GetClassName(), "#0"); }
private void NavigationView_PaneClosed(Microsoft.UI.Xaml.Controls.NavigationView sender, object args) { if (!navigationViewInitialStateProcessed) { navigationViewInitialStateProcessed = true; return; } var peer = FrameworkElementAutomationPeer.FromElement(sender); if (peer == null) { peer = FrameworkElementAutomationPeer.CreatePeerForElement(sender); } if (AutomationPeer.ListenerExists(AutomationEvents.MenuClosed)) { var loader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); peer.RaiseNotificationEvent( AutomationNotificationKind.ActionCompleted, AutomationNotificationProcessing.ImportantMostRecent, loader.GetString("Shell_NavigationMenu_Announce_Collapse"), "navigationMenuPaneClosed"); } }
/// <summary> /// Sets the value of an element. /// </summary> /// <param name="element">The element.</param> /// <param name="value">The value to set the element's value to.</param> private static void SetValue(UIElement element, string value) { FrameworkElementAutomationPeer elementPeer = FrameworkElementAutomationPeer.CreatePeerForElement(element) as FrameworkElementAutomationPeer; IValueProvider elementValueProvider = elementPeer.GetPattern(PatternInterface.Value) as IValueProvider; elementValueProvider.SetValue(value); }
private void EnsureAutomationPeer() { if (scrollPresenterAutomationPeer == null) { scrollPresenterAutomationPeer = FrameworkElementAutomationPeer.CreatePeerForElement(scrollPresenter) as IScrollProvider; } }
/// <summary> /// ISelectionProvider implementation. /// </summary> public IRawElementProviderSimple[] GetSelection() { var providerSamples = new List <IRawElementProviderSimple>(); var radialMenuModel = this.RadRadialMenuOwner.model; if (radialMenuModel != null && radialMenuModel.contentRing != null && radialMenuModel.contentRing.Segments != null) { var radialMenuItems = radialMenuModel.contentRing.Segments.OfType <RadialSegment>(); if (radialMenuItems != null) { foreach (var item in radialMenuItems) { var radialMenuItemControl = item.Visual as RadialMenuItemControl; if (radialMenuItemControl != null && item.TargetItem != null && item.TargetItem.IsSelected) { var radialMenuItemControlPeer = FrameworkElementAutomationPeer.CreatePeerForElement(radialMenuItemControl) as RadialMenuItemControlAutomationPeer; if (radialMenuItemControlPeer != null) { providerSamples.Add(this.ProviderFromPeer(radialMenuItemControlPeer)); } } } } } return(providerSamples.ToArray()); }
/// <summary> /// Retrieves a UI Automation provider for each child element that is selected. /// </summary> public IRawElementProviderSimple[] GetSelection() { List <IRawElementProviderSimple> providerSamples = new List <IRawElementProviderSimple>(); foreach (object selected in this.ListViewOwner.SelectedItems) { ItemInfo?info = this.ListViewOwner.Model.FindItemInfo(selected); if (!info.HasValue) { continue; } GeneratedItemModel generatedModel = this.ListViewOwner.Model.GetDisplayedElement(info.Value.Slot, info.Value.Id); RadListViewItem container = null; if (generatedModel != null) { container = generatedModel.Container as RadListViewItem; } if (container == null) { continue; } AutomationPeer itemPeer = (RadListViewItemAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(container); if (itemPeer != null) { providerSamples.Add(this.ProviderFromPeer(itemPeer)); } } return(providerSamples.ToArray()); }
public void VerifyElementsWithAutomationNameNotMarked() { VerifyControlMarked(new Button() { Content = "Text" }); VerifyControlMarked(new TextBlock() { Text = "Text" }); VerifyControlMarked(new TextBox() { PlaceholderText = "Text" }); VerifyControlMarked(new TextBox() { Header = "Text" }); void VerifyControlMarked(FrameworkElement element) { App.Content = element; var peer = FrameworkElementAutomationPeer.CreatePeerForElement(element); var rule = new ControlNonEmptyNameRule(); Assert.IsTrue(rule.IsValid(element, peer)); } }
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!")); }
/// <summary> /// ITableProvider implementation. /// </summary> public IRawElementProviderSimple[] GetRowHeaders() { var groupHeadersHost = this.OwnerDataGrid.GroupHeadersHost as Panel; if (groupHeadersHost != null && groupHeadersHost.Children.Count > 0) { var dataGridContentLayerPanel = groupHeadersHost.Children.Where(a => a is DataGridContentLayerPanel).FirstOrDefault() as DataGridContentLayerPanel; if (dataGridContentLayerPanel != null) { IRawElementProviderSimple[] providers = new IRawElementProviderSimple[dataGridContentLayerPanel.Children.Count]; for (int i = 0; i < dataGridContentLayerPanel.Children.Count; i++) { var groupColumn = dataGridContentLayerPanel.Children[i] as DataGridGroupHeader; if (groupColumn != null) { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(groupColumn); if (peer != null) { providers[i] = this.ProviderFromPeer(peer); } } } return(providers); } } return(null); }
public override void ContentTest() { Assert.IsTrue(IsContentPropertyElement(), "TextBlock ContentElement."); bool textBlockLoaded = false; TextBlock textBlock = CreateConcreteFrameworkElement() as TextBlock; textBlock.Loaded += (o, e) => textBlockLoaded = true; TestPanel.Children.Add(textBlock); EnqueueConditional(() => textBlockLoaded, "TextBlock #0"); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(textBlock); Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement"); Assert.IsNull(peer.GetChildren(), "GetChildren #0"); textBlock.Text = "Hello world!"; }); // We add the text Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(textBlock); Assert.IsNull(peer.GetChildren(), "GetChildren #1"); // Remove text textBlock.Text = string.Empty; Assert.IsNull(peer.GetChildren(), "GetChildren #2"); }); EnqueueTestComplete(); }