public override void GetName() { ToggleButton toggleButton = CreateConcreteFrameworkElement() as ToggleButton; FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(toggleButton); Assert.AreEqual(String.Empty, feap.GetName(), "GetName"); Assert.AreEqual(String.Empty, feap.GetNameCore_(), "GetName"); string name = "Yarr!"; toggleButton.Content = new TextBlock { Text = name }; Assert.AreEqual(name, feap.GetName(), "GetName #1"); Assert.AreEqual(name, feap.GetNameCore_(), "GetNameCore #1"); name = "En Garde!"; toggleButton.Content = name; Assert.AreEqual(name, feap.GetName(), "GetName #2"); Assert.AreEqual(name, feap.GetNameCore_(), "GetNameCore #2"); toggleButton.Content = String.Empty; Assert.AreEqual(String.Empty, feap.GetName(), "GetName #2"); Assert.AreEqual(String.Empty, feap.GetNameCore_(), "GetNameCore #2"); toggleButton.Content = null; Assert.AreEqual(String.Empty, feap.GetName(), "GetName #3"); Assert.AreEqual(String.Empty, feap.GetNameCore_(), "GetNameCore #3"); }
public override void GetAutomationControlType() { FrameworkElementAutomationPeerContract feap = FrameworkElementAutomationPeer.CreatePeerForElement(CreateConcreteFrameworkElement()) as FrameworkElementAutomationPeerContract; Assert.AreEqual(AutomationControlType.List, feap.GetAutomationControlType(), "GetAutomationControlType"); Assert.AreEqual(AutomationControlType.List, feap.GetAutomationControlTypeCore_(), "GetAutomationControlTypeCore"); }
public override void GetClassName() { FrameworkElementAutomationPeerContract feap = FrameworkElementAutomationPeer.CreatePeerForElement(CreateConcreteFrameworkElement()) as FrameworkElementAutomationPeerContract; Assert.AreEqual("ListBox", feap.GetClassName(), "GetClassNameCore"); Assert.AreEqual("ListBox", feap.GetClassNameCore_(), "GetClassNameCoreCore"); }
public virtual void ToggleProvider_Toggle() { ToggleButton toggleButton = CreateConcreteFrameworkElement() as ToggleButton; FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(toggleButton); toggleButton.IsEnabled = false; IToggleProvider toggleProvider = feap as IToggleProvider; try { toggleProvider.Toggle(); Assert.Fail("Should throw ElementNotEnabledException"); } catch (ElementNotEnabledException) { } toggleButton.IsEnabled = true; // TODO: Test eventing // Test two-state toggling toggleButton.IsThreeState = false; toggleButton.IsChecked = false; Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Start two-state toggle: Unchecked"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "First two-state toggle: Checked"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Second two-state toggle: Unchecked"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "Third two-state toggle: Checked"); // Test three-state toggling toggleButton.IsThreeState = true; toggleButton.IsChecked = true; Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "Start three-state Checked"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.Indeterminate, toggleProvider.ToggleState, "First three-state toggle: Indeterminate"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Second three-state Off: Intermediate"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "Third three-state toggle: Checked"); }
public virtual void ToggleProvider_ToggleState() { ToggleButton toggleButton = CreateConcreteFrameworkElement() as ToggleButton; FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(toggleButton); IToggleProvider toggleProvider = feap as IToggleProvider; // Test two-state toggling toggleButton.IsThreeState = false; toggleButton.IsChecked = false; Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Start two-state toggle: Unchecked"); toggleButton.IsChecked = true; Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "First two-state toggle: Checked"); toggleButton.IsChecked = false; Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Second two-state toggle: Unchecked"); toggleButton.IsChecked = true; Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "Third two-state toggle: Checked"); // Test three-state toggling toggleButton.IsThreeState = true; toggleButton.IsChecked = true; Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "Start three-state Checked"); toggleButton.IsChecked = false; Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "First three-state toggle: Unchecked"); toggleButton.IsChecked = null; Assert.AreEqual(ToggleState.Indeterminate, toggleProvider.ToggleState, "Second three-state toggle: Intermediate"); toggleButton.IsChecked = true; Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "Third three-state toggle: Checked"); }
public override void GetName_AttachedProperty0() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.AreEqual(string.Empty, feap.GetName(), "GetName"); Assert.AreEqual(string.Empty, feap.GetNameCore_(), "GetNameCore"); string name = "Attached Name"; fe.SetValue(AutomationProperties.NameProperty, name); Assert.AreEqual(string.Empty, feap.GetName(), "GetName #1"); Assert.AreEqual(string.Empty, feap.GetNameCore_(), "GetNameCore #1"); fe.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, feap.GetName(), "GetName #2"); Assert.AreEqual(string.Empty, feap.GetNameCore_(), "GetNameCore #2"); }
public override void GetItemType_AttachedProperty() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.AreEqual(string.Empty, feap.GetItemType(), "GetItemType"); Assert.AreEqual(string.Empty, feap.GetItemTypeCore_(), "GetItemTypeCore"); string itemType = "My Item Type"; fe.SetValue(AutomationProperties.ItemTypeProperty, itemType); Assert.AreEqual(string.Empty, feap.GetItemType(), "GetItemType #1"); Assert.AreEqual(string.Empty, feap.GetItemTypeCore_(), "GetItemTypeCore #1"); fe.SetValue(AutomationProperties.ItemTypeProperty, null); Assert.AreEqual(string.Empty, feap.GetItemType(), "GetItemType #2"); Assert.AreEqual(string.Empty, feap.GetItemTypeCore_(), "GetItemTypeCore #2"); }
public override void ToggleProvider_Toggle() { RadioButton radioButton = CreateConcreteFrameworkElement() as RadioButton; FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(radioButton); radioButton.IsEnabled = false; IToggleProvider toggleProvider = feap as IToggleProvider; try { toggleProvider.Toggle(); Assert.Fail("Should throw ElementNotEnabledException"); } catch (ElementNotEnabledException) { } radioButton.IsEnabled = true; // Test two-state toggling radioButton.IsThreeState = false; radioButton.IsChecked = false; Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Start two-state toggle: Unchecked"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "First two-state toggle: Checked"); // Test three-state toggling radioButton.IsThreeState = true; radioButton.IsChecked = false; Assert.AreEqual(ToggleState.Off, toggleProvider.ToggleState, "Start three-state Checked"); toggleProvider.Toggle(); Assert.AreEqual(ToggleState.On, toggleProvider.ToggleState, "First three-state toggle: Checked"); // NOTE: I don't think it will ever be indeterminate }
public override void GetLabeledBy_AttachedProperty() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore"); TextBlock labeledBy = new TextBlock(); labeledBy.Text = "LabeledBy text"; AutomationPeer labeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy); fe.SetValue(AutomationProperties.LabeledByProperty, labeledBy); Assert.AreSame(labeledByPeer, feap.GetLabeledBy(), "GetLabeledBy #1"); Assert.AreSame(labeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore #1"); fe.SetValue(AutomationProperties.LabeledByProperty, null); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy #2"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore #2"); }
public override void GetName_AttachedProperty1() { FrameworkElement element = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract tbap = CreateConcreteFrameworkElementAutomationPeer(element); string textblockName = "Hello world:"; string nameProperty = "TextBox name"; TextBlock textblock = new TextBlock(); textblock.Text = textblockName; element.SetValue(AutomationProperties.NameProperty, nameProperty); Assert.AreEqual(string.Empty, tbap.GetName(), "GetName #0"); Assert.AreEqual(string.Empty, tbap.GetNameCore_(), "GetNameCore #0"); element.SetValue(AutomationProperties.LabeledByProperty, textblock); Assert.AreEqual(textblockName, tbap.GetName(), "GetName #1"); Assert.AreEqual(string.Empty, tbap.GetNameCore_(), "GetNameCore #1"); textblock.Text = null; Assert.AreEqual(string.Empty, tbap.GetName(), "GetName #2"); Assert.AreEqual(string.Empty, tbap.GetNameCore_(), "GetNameCore #2"); textblock.Text = string.Empty; Assert.AreEqual(string.Empty, tbap.GetName(), "GetName #3"); Assert.AreEqual(string.Empty, tbap.GetNameCore_(), "GetNameCore #3"); element.SetValue(AutomationProperties.NameProperty, null); Assert.AreEqual(string.Empty, tbap.GetName(), "GetName #4"); Assert.AreEqual(string.Empty, tbap.GetNameCore_(), "GetNameCore #4"); element.SetValue(AutomationProperties.LabeledByProperty, null); Assert.AreEqual(string.Empty, tbap.GetName(), "GetName #5"); Assert.AreEqual(string.Empty, tbap.GetNameCore_(), "GetNameCore #5"); }
public override void GetLabeledBy_AttachedProperty() { FrameworkElement fe = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract feap = CreateConcreteFrameworkElementAutomationPeer(fe); Assert.IsNull(feap.GetLabeledBy(), "GetLabeledBy"); Assert.IsNull(feap.GetLabeledByCore_(), "GetLabeledByCore"); FrameworkElement labeledBy = CreateConcreteFrameworkElement(); FrameworkElementAutomationPeerContract labeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy) as FrameworkElementAutomationPeerContract; fe.SetValue(AutomationProperties.LabeledByProperty, labeledBy); Assert.AreNotSame(labeledByPeer, feap.GetLabeledBy(), "GetLabeledBy NotSame #1"); Assert.AreNotSame(labeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore NotSame #1"); Assert.IsNotNull(feap.GetLabeledBy(), "GetLabeledBy NotNull #2"); Assert.IsNotNull(feap.GetLabeledByCore_(), "GetLabeledByCore NotNull #2"); AutomationPeer realLabeledByPeer = FrameworkElementAutomationPeer.CreatePeerForElement(labeledBy); Assert.AreSame(realLabeledByPeer, feap.GetLabeledBy(), "GetLabeledBy Same #3"); Assert.AreSame(realLabeledByPeer, feap.GetLabeledByCore_(), "GetLabeledByCore Same #3"); }