public void ExpandCollapseProvider_Methods() { bool concreteLoaded = false; bool concreteLayoutUpdated = false; ComboBoxConcrete concrete = CreateConcreteFrameworkElement() as ComboBoxConcrete; concrete.Loaded += (o, e) => concreteLoaded = true; concrete.LayoutUpdated += (o, e) => concreteLayoutUpdated = true; concrete.Items.Add(new ComboBoxItem() { Content = "1" }); concrete.Items.Add(new ComboBoxItem() { Content = "2" }); concrete.Width = 300; TestPanel.Children.Add(concrete); EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => concrete.ApplyTemplate()); Enqueue(() => { IExpandCollapseProvider expandCollapse = GetExpandCollapseProvider(concrete); Assert.AreEqual(ExpandCollapseState.Collapsed, expandCollapse.ExpandCollapseState, "ExpandCollapseState #0"); concreteLayoutUpdated = false; expandCollapse.Expand(); }); EnqueueConditional(() => concreteLayoutUpdated, "ConcreteLayoutUpdated #0"); Enqueue(() => { // Test event IExpandCollapseProvider expandCollapse = GetExpandCollapseProvider(concrete); Assert.AreEqual(ExpandCollapseState.Expanded, expandCollapse.ExpandCollapseState, "ExpandCollapseState #1"); concreteLayoutUpdated = false; expandCollapse.Collapse(); }); EnqueueConditional(() => concreteLayoutUpdated, "ConcreteLayoutUpdated #1"); Enqueue(() => { // Test event IExpandCollapseProvider expandCollapse = GetExpandCollapseProvider(concrete); Assert.AreEqual(ExpandCollapseState.Collapsed, expandCollapse.ExpandCollapseState, "ExpandCollapseState #2"); concreteLayoutUpdated = false; }); EnqueueTestComplete(); }
protected override void ContentTest_Template(Selector selectorConcrete) { Assert.IsTrue(IsContentPropertyElement(), "ComboBox ContentElement."); bool concreteLoaded = false; bool expanded = false; ComboBoxConcrete concrete = (ComboBoxConcrete)selectorConcrete; concrete.Width = 300; concrete.Loaded += (o, e) => concreteLoaded = true; concrete.DropDownOpened += (o, e) => expanded = true; TestPanel.Children.Add(concrete); concrete.Items.Add("Item 0"); concrete.Items.Add("Item 1"); EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => concrete.ApplyTemplate()); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(concrete); Assert.IsNotNull(peer, "FrameworkElementAutomationPeer.CreatePeerForElement"); Assert.AreEqual(concrete.Template == null, peer.GetChildren() != null, "GetChildren #0"); }); Enqueue(() => concrete.IsDropDownOpen = true); EnqueueConditional(() => expanded, "Expanded #0"); Enqueue(() => concrete.IsDropDownOpen = false); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(concrete); Assert.IsNotNull(peer.GetChildren(), "GetChildren #1"); Assert.AreEqual(2, peer.GetChildren().Count, "GetChildren.Count #1"); }); Enqueue(() => concrete.Items.Add(new TextBlock() { Text = "Item 2" })); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(concrete); Assert.IsNotNull(peer.GetChildren(), "GetChildren #2"); Assert.AreEqual(3, peer.GetChildren().Count, "GetChildren.Count #2"); }); EnqueueTestComplete(); }
public void ValueProvider_Methods() { bool concreteLoaded = false; ComboBoxConcrete concrete = CreateConcreteFrameworkElement() as ComboBoxConcrete; concrete.Loaded += (o, e) => concreteLoaded = true; concrete.Items.Add(new ComboBoxItem() { Content = "1" }); concrete.Items.Add(new ComboBoxItem() { Content = "2" }); concrete.Width = 300; TestPanel.Children.Add(concrete); EnqueueConditional(() => concreteLoaded, "ConcreteLoaded #0"); Enqueue(() => concrete.ApplyTemplate()); Enqueue(() => { AutomationPeer peer = FrameworkElementAutomationPeer.CreatePeerForElement(concrete); Assert.IsNotNull(peer, "CreatePeerForElement #0"); IValueProvider value = peer.GetPattern(PatternInterface.Value) as IValueProvider; // Yes is returning null! Assert.IsNull(value, "ValueProvider #0"); // We are going to try again using explicit cast value = peer as IValueProvider; Assert.IsNotNull(value, "ValueProvider #1"); // We can't change the value anyway Assert.IsTrue(value.IsReadOnly, "IsReadOnly #0"); Assert.Throws <InvalidOperationException> (delegate { value.SetValue("1"); }, "SetValue #0"); }); EnqueueTestComplete(); }
public ComboBoxAutomationPeerConcrete (ComboBoxConcrete owner) : base (owner) { }
public ComboBoxAutomationPeerConcrete(ComboBoxConcrete owner) : base(owner) { }