Skip to content

Commit

Permalink
test: Fixed many runtime tests for CalendarView
Browse files Browse the repository at this point in the history
  • Loading branch information
carldebilly committed Jun 3, 2021
1 parent 4d5b4a9 commit c9a73aa
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ await TestServices.RunOnUIThread(()=>
{
rootPanel = XamlReader.Load(
"<Grid xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' " +
" Width='400' Height='400' VerticalAlignment='Top' HorizontalAlignment='Left' Background='Navy'/> ")
" Width='400' Height='400' VerticalAlignment='Top' HorizontalAlignment='Left' Background='Navy'/>")
as Grid;

TestServices.WindowHelper.WindowContent = rootPanel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using Windows.Foundation;
using System;
using Windows.Devices.Input;
using Windows.Foundation;
using Windows.System;
using Windows.UI.Core;
using Windows.UI.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Input;

namespace Private.Infrastructure
{
Expand Down Expand Up @@ -29,18 +35,18 @@ public static void MoveMouse(UIElement element)

public static void Tap(UIElement element)
{
throw new System.NotImplementedException();
#if !NETFX_CORE
var args = new TappedEventArgs(PointerDeviceType.Touch, default, 1);
element.SafeRaiseEvent(UIElement.TappedEvent, new TappedRoutedEventArgs(element, args));
#endif
}

public static void ScrollMouseWheel(CalendarView cv, int i)
{
throw new System.NotImplementedException();
}

public static void LeftMouseClick(UIElement element)
{
throw new System.NotImplementedException();
}
public static void LeftMouseClick(UIElement element) => Tap(element);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static class KeyboardHelper
{
public static void PressKeySequence(string keys)
{
throw new System.NotImplementedException();
throw new System.NotImplementedException("PressKeySequence(string keys)");
}

public static void Down()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ public static void THROW_IF_NULL_WITH_MSG(object value, string msg)
Assert.IsNotNull(value, msg);
}

public static void VERIFY_IS_TRUE(bool value)
public static void VERIFY_IS_TRUE(bool value, string message = null)
{
Assert.IsTrue(value);
Assert.IsTrue(value, message);
}

public static void VERIFY_IS_FALSE(bool value)
public static void VERIFY_IS_FALSE(bool value, string message = null)
{
Assert.IsFalse(value);
Assert.IsFalse(value, message);
}

public static void VERIFY_IS_LESS_THAN(double actual, double expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ protected static Task RunOnUIThread(Action action)
return TestServices.RunOnUIThread(action);
}

protected static void VERIFY_IS_TRUE(bool value)
protected static void VERIFY_IS_TRUE(bool value, string message = null)
{
TestServices.VERIFY_IS_TRUE(value);
TestServices.VERIFY_IS_TRUE(value, message);
}

protected static void VERIFY_IS_FALSE(bool value)
protected static void VERIFY_IS_FALSE(bool value, string message = null)
{
TestServices.VERIFY_IS_FALSE(value);
TestServices.VERIFY_IS_FALSE(value, message);
}

protected static void VERIFY_ARE_EQUAL<T>(T actual, T expected)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Windows.UI.Xaml.Markup;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Tests.Common;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Private.Infrastructure;
Expand Down Expand Up @@ -356,7 +357,9 @@ await RunOnUIThread(() =>
// Note: below string contains invisible unicode characters (BiDi characters),
// you should always use copy&paste to get the string, directly
// type the string will cause the string comparison fails.
VERIFY_IS_TRUE(dateText.Text == "‎10‎/‎21‎/‎2000");
//VERIFY_IS_TRUE(dateText.Text == "‎10‎/‎21‎/‎2000");

dateText.Text.Should().Be("10/21/2000"); // UNO: Those BiDi characters are not emitted by Uno
});

await RunOnUIThread(() =>
Expand Down Expand Up @@ -499,7 +502,7 @@ await RunOnUIThread(() =>
cp.CalendarIdentifier = Windows.Globalization.CalendarIdentifiers.Taiwan;

LOG_OUTPUT("actual text: %s.", dateText.Text);
VERIFY_IS_TRUE(dateText.Text == "Monday, January 1, 90");
VERIFY_ARE_EQUAL("Monday, January 1, 90", dateText.Text);
});

}
Expand Down Expand Up @@ -806,7 +809,7 @@ await RunOnUIThread(() =>
{
LOG_OUTPUT("actual text: %s.", dateText.Text);
// clear the Date property will display placehoder text.
VERIFY_IS_TRUE(dateText.Text == cp.PlaceholderText);
VERIFY_ARE_EQUAL(dateText.Text, cp.PlaceholderText);

VERIFY_ARE_EQUAL(calendarView.SelectedDates.Count, 0);
});
Expand Down Expand Up @@ -925,6 +928,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("FlyoutHelper.ValidateOpenFlyoutOverlayBrush() not implemented yet.")]
public async Task ValidateOverlayBrush()
{
TestCleanupWrapper cleanup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ void TestCleanup()
//}

[TestMethod]
[Ignore("Test using AutomationPeers not implemented yet on Uno")]
public async Task VerifyDayItemRowHeaders()
{
TestCleanupWrapper cleanup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("TestServices.InputHelper.DynamicPressCenter() / TestServices.InputHelper.DynamicRelease() not implemented yet")]
public async Task CanNotSelectBlackoutDate()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -612,6 +613,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("Test deactivate in Uno")]
public async Task CanNotSelectMoreDates()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -799,6 +801,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("Not Implemented")]
public async Task TestCICEvents()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -923,7 +926,7 @@ await RunOnUIThread(() =>
});

await cicEvent.WaitForDefault();
VERIFY_IS_TRUE(cicEvent.HasFired());
VERIFY_IS_TRUE(cicEvent.HasFired(), "Event not fired");
}


Expand Down Expand Up @@ -999,17 +1002,17 @@ public async Task ValidateNumberOfWeeksInViewRange()
await RunOnUIThread(() =>
{
StackPanel rootPanel = XamlReader.Load(
@"(<StackPanel Width=""400"" Height=""400"" xmlns =""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
@"<StackPanel Width=""400"" Height=""400"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
HorizontalAlignment=""Center"" VerticalAlignment=""Center"">
<CalendarView x:Name=""calendarview"" HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" Margin=""50"" NumberOfWeeksInView =""2"" / >
</StackPanel>)") as StackPanel;
<CalendarView x:Name=""calendarview"" HorizontalAlignment=""Stretch"" VerticalAlignment=""Stretch"" Margin=""50"" NumberOfWeeksInView=""2"" />
</StackPanel>") as StackPanel;

VERIFY_THROWS_WINRT<Exception>(() => XamlReader.Load(
@"(<CalendarView xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" NumberOfWeeksInView =""1"" />)"),
@"<CalendarView xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" NumberOfWeeksInView=""1"" />"),
"Should not be able to set NumberOfWeeksInView to a value smaller than 2.");

VERIFY_THROWS_WINRT<Exception>(() => XamlReader.Load(
@"(<CalendarView xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" NumberOfWeeksInView = ""9""/>)"),
@"(<CalendarView xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" NumberOfWeeksInView=""9""/>"),
"Should not be able to set NumberOfWeeksInView to a value greater than 8.");

calendarView = rootPanel.FindName("calendarview") as CalendarView;
Expand Down Expand Up @@ -1708,6 +1711,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("TestServices.KeyboardHelper.PressKeySequence() not supported yet")]
public async Task CanSwitchDisplayModeByCtrlUpAfterLoaded()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -1743,6 +1747,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("TestServices.KeyboardHelper.PressKeySequence() not supported yet")]
public async Task KeyboardNavigationTestNavigationKeyTest()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -2009,6 +2014,7 @@ await RunOnUIThread(() =>
//}

[TestMethod]
[Ignore("TestServices.KeyboardHelper.PressKeySequence() not supported yet")]
public async Task KeyboardNavigationTestCanTryToNavigateOutOfBoundary()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -2218,6 +2224,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("TestServices.KeyboardHelper.PressKeySequence() not supported yet")]
public async Task KeyboardNavigationTestSpaceEnterTest()
{
TestCleanupWrapper cleanup;
Expand Down Expand Up @@ -3018,6 +3025,7 @@ await RunOnUIThread(() =>
}

[TestMethod]
[Ignore("ControlHelper.ValidateUIElementTree() not supported yet.")]
public async Task ValidateUIElementTree()
{
await ControlHelper.ValidateUIElementTree(
Expand Down Expand Up @@ -3234,6 +3242,7 @@ public async Task CanChangeYearCalendarIdentifier()
}

[TestMethod]
[Ignore("TestServices.KeyboardHelper.PressKeySequence() not supported yet")]
public async Task CanChangeDecadeCalendarIdentifier()
{
await VerifyChangingCalendarIdentifier(CalendarViewDisplayMode.Decade);
Expand Down

0 comments on commit c9a73aa

Please sign in to comment.