public virtual void ShouldChangeVisualStateWhenContainerIsSet() { TimePicker tip = new TimePicker(); TimePickerPopup tpp = DefaultTimePickerPopupToTest; TestVisualStateManager vsmTpp = new TestVisualStateManager(); bool tipIsLoaded = false; tip.Loaded += delegate { tipIsLoaded = true; }; bool tppIsLoaded = false; tpp.Loaded += delegate { tppIsLoaded = true; }; // Add the element to the test surface and wait until it's loaded EnqueueCallback(() => TestPanel.Children.Add(tip)); EnqueueCallback(() => TestPanel.Children.Add(tpp)); EnqueueConditional(() => tipIsLoaded); EnqueueConditional(() => tppIsLoaded); EnqueueCallback(() => { FrameworkElement root2 = tpp.GetVisualDescendents().First() as FrameworkElement; VisualStateManager.SetCustomVisualStateManager(root2, vsmTpp); }); EnqueueCallback(() => { TestPanel.Children.Remove(tpp); tip.Popup = tpp; }); EnqueueCallback(() => Assert.IsTrue(vsmTpp.ChangedStates.Contains("Contained"))); EnqueueTestComplete(); }
public virtual void PickerPeerOnlySupportsCorrectPatterns() { TimePickerPopup instance = TimePickerPopupInstance; TimePickerPopupAutomationPeer peer = null; TestAsync( instance, () => peer = (TimePickerPopupAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(instance), () => { int index = 0; while (Enum.IsDefined(typeof(PatternInterface), index)) { PatternInterface currentInterface = (PatternInterface)Enum.ToObject(typeof(PatternInterface), index); object implementation = peer.GetPattern(currentInterface); if (ExpectedPatterns.Contains(currentInterface)) { Assert.IsNotNull(implementation); } else { Assert.IsNull(implementation); } index++; } }); }
public virtual void CreateTimePickerPopupPeer() { TimePickerPopup tpp = TimePickerPopupInstance; TimePickerPopupAutomationPeer peer = GetTimePickerPopupAutomationPeer(tpp); Assert.IsNotNull(peer); }
public virtual void TimePickerPopupCreatesCorrectAutomationPeer() { TimePickerPopup tpp = TimePickerPopupInstance; TimePickerPopupAutomationPeer peer = null; TestAsync( tpp, () => peer = FrameworkElementAutomationPeer.CreatePeerForElement(tpp) as TimePickerPopupAutomationPeer, () => Assert.IsNotNull(peer, "TimePickerPopup peer should not be null!"), () => Assert.AreEqual(tpp, peer.Owner, "TimePickerPopup should be owner of the peer!")); }
public virtual void ShouldRevertToLastValidValueWhenSetOutsideRange() { TimePickerPopup tpp = DefaultTimePickerPopupToTest; tpp.Value = new DateTime(2100, 1, 1, 15, 0, 0); tpp.Minimum = new DateTime(2100, 1, 1, 14, 0, 0); tpp.Maximum = new DateTime(2100, 1, 1, 16, 0, 0); tpp.Value = new DateTime(2100, 1, 1, 10, 0, 0); Assert.AreEqual(new DateTime(2100, 1, 1, 15, 0, 0), tpp.Value.Value); }
public virtual void ShouldDisregardDatePartWhenCoercing() { TimePickerPopup tpp = DefaultTimePickerPopupToTest; tpp.Value = new DateTime(2100, 1, 1, 15, 0, 0); tpp.Minimum = new DateTime(2100, 1, 1, 14, 0, 0); tpp.Maximum = new DateTime(2100, 1, 1, 16, 0, 0); tpp.Value = tpp.Value.Value.AddDays(2); tpp.Maximum = tpp.Maximum.Value.AddMinutes(-90); Assert.AreEqual(new DateTime(2100, 1, 3, 14, 30, 0), tpp.Value.Value); tpp.Value = tpp.Value.Value.AddYears(-1); Assert.AreEqual(new DateTime(2099, 1, 3, 14, 30, 0), tpp.Value.Value); }
public virtual void ShouldCorrelateReadOnlyToIsEnabledInAutomationPeer() { TimePickerPopup item = TimePickerPopupInstance; item.Value = new DateTime(1900, 1, 1, 3, 45, 12); TimePickerPopupAutomationPeer peer = null; IValueProvider provider = null; TestAsync( item, () => peer = (TimePickerPopupAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(item), () => provider = (IValueProvider)peer.GetPattern(PatternInterface.Value), () => Assert.IsFalse(provider.IsReadOnly), () => item.IsEnabled = false, () => Assert.IsTrue(provider.IsReadOnly)); }
public virtual void ShouldBeAbleToGetValueThroughAutomationPeer() { TimePickerPopup item = TimePickerPopupInstance; item.Culture = new CultureInfo("nl-NL"); item.Format = new CustomTimeFormat("HH:mm:ss"); item.Value = new DateTime(1900, 1, 1, 3, 45, 12); TimePickerPopupAutomationPeer peer = null; IValueProvider provider = null; TestAsync( item, () => peer = (TimePickerPopupAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(item), () => provider = (IValueProvider)peer.GetPattern(PatternInterface.Value), () => Assert.AreEqual(provider.Value, "03:45:12")); }
public virtual void ShouldBeAbleToSetValueThroughAutomationPeer() { TimePickerPopup item = TimePickerPopupInstance; item.Culture = new CultureInfo("nl-NL"); item.Format = new CustomTimeFormat("HH:mm:ss"); TimePickerPopupAutomationPeer peer = null; IValueProvider provider = null; TestAsync( item, () => peer = (TimePickerPopupAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(item), () => provider = (IValueProvider)peer.GetPattern(PatternInterface.Value), () => provider.SetValue("03:30:00"), // take care to set a time that is not snapped () => Assert.AreEqual(item.Value.Value.TimeOfDay, new DateTime(1900, 1, 1, 3, 30, 00).TimeOfDay)); }
public virtual void ShouldCoerceMinimumMaximumAndValue() { TimePickerPopup tpp = DefaultTimePickerPopupToTest; tpp.Value = new DateTime(2100, 1, 1, 14, 0, 0); tpp.Minimum = new DateTime(2100, 1, 1, 14, 0, 0); tpp.Maximum = new DateTime(2100, 1, 1, 16, 0, 0); tpp.Minimum = tpp.Minimum.Value.AddMinutes(30.0); Assert.AreEqual(new DateTime(2100, 1, 1, 14, 30, 0), tpp.Minimum.Value); Assert.AreEqual(tpp.Minimum, tpp.Value); tpp.Value = tpp.Maximum.Value; tpp.Maximum = tpp.Maximum.Value.AddMinutes(-30.0); Assert.AreEqual(new DateTime(2100, 1, 1, 15, 30, 0), tpp.Maximum.Value); Assert.AreEqual(tpp.Maximum, tpp.Value); }
public virtual void ShouldBeAbleToSetInvalidBoundaries() { TimePickerPopup tpp = DefaultTimePickerPopupToTest; tpp.Value = new DateTime(2100, 1, 1, 14, 0, 0); tpp.Minimum = new DateTime(2100, 1, 1, 14, 0, 0); tpp.Maximum = new DateTime(2100, 1, 1, 16, 0, 0); tpp.Maximum = new DateTime(2100, 1, 1, 11, 0, 0); Assert.AreEqual(new DateTime(2100, 1, 1, 11, 0, 0), tpp.Minimum); Assert.AreEqual(new DateTime(2100, 1, 1, 11, 0, 0), tpp.Maximum); Assert.AreEqual(new DateTime(2100, 1, 1, 11, 0, 0), tpp.Value); tpp.Minimum = new DateTime(2100, 1, 1, 13, 0, 0); Assert.AreEqual(new DateTime(2100, 1, 1, 13, 0, 0), tpp.Minimum); Assert.AreEqual(new DateTime(2100, 1, 1, 13, 0, 0), tpp.Maximum); Assert.AreEqual(new DateTime(2100, 1, 1, 13, 0, 0), tpp.Value); }
/// <summary> /// Gets an automation. /// </summary> /// <param name="picker">The picker.</param> /// <returns>A ListTimePickerAutomationPeer for the picker.</returns> protected override TimePickerPopupAutomationPeer GetTimePickerPopupAutomationPeer(TimePickerPopup picker) { return new ListTimePickerPopupAutomationPeer((ListTimePickerPopup) picker); }
/// <summary> /// Gets an automation. /// </summary> /// <param name="picker">The picker.</param> /// <returns>A RangeTimePickerPopupAutomationPeer for this picker.</returns> protected override TimePickerPopupAutomationPeer GetTimePickerPopupAutomationPeer(TimePickerPopup picker) { return(new RangeTimePickerPopupAutomationPeer((RangeTimePickerPopup)picker)); }
/// <summary> /// Gets an automation peer for this picker. /// </summary> /// <param name="picker">The picker.</param> /// <returns>An AutomationPeer for the picker.</returns> protected abstract TimePickerPopupAutomationPeer GetTimePickerPopupAutomationPeer(TimePickerPopup picker);
/// <summary> /// Initializes a new instance of the /// <see cref="TimePickerPopupAutomationPeer"/> class. /// </summary> /// <param name="owner">The TimePickerPopup that is associated to this /// AutomationPeer.</param> protected TimePickerPopupAutomationPeer(TimePickerPopup owner) : base(owner) { }