Skip to content

Commit c4d33c2

Browse files
committed
Merge branch 'main' into winui
# Conflicts: # UITests/UITests.App/App.AppService.xaml.cs # UITests/UITests.App/UITests.App.csproj # UITests/UITests.Tests.Shared/Controls/TextBoxMaskTest.cs # UITests/UITests.Tests.Shared/Examples/SimpleTest.cs # UITests/UITests.Tests.Shared/TestAssembly.cs # UITests/UITests.Tests.Shared/UITestBase.cs # UITests/UITests.Tests.TAEF/UITests.Tests.TAEF.csproj # azure-pipelines.yml
2 parents bc58341 + fe30893 commit c4d33c2

17 files changed

+528
-171
lines changed

UITests/UITests.App/App.AppService.xaml.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ namespace UITests.App
1919
/// </summary>
2020
public sealed partial class App
2121
{
22+
private static readonly OpenPageReply BadResult = new() { Status = "BAD" };
23+
private static readonly OpenPageReply OkResult = new() { Status = "OK" };
24+
2225
private Task _host;
2326

2427
private async void InitAppService()
@@ -34,26 +37,21 @@ private async void InitAppService()
3437

3538
public class AppServiceServer : AppService.AppServiceBase
3639
{
37-
internal static BlockingCollection<LogUpdate> LogUpdates;
40+
internal static BlockingCollection<LogUpdate> LogUpdates { get; private set; }
3841

3942
public AppServiceServer(BlockingCollection<LogUpdate> logUpdates)
4043
{
4144
LogUpdates = logUpdates;
4245
}
4346

44-
public override async Task<StartReply> Start(StartRequest request, ServerCallContext context)
47+
public override async Task<OpenPageReply> OpenPage(OpenPageRequest request, ServerCallContext context)
4548
{
4649
Log.Comment("Received request for Page: {0}", request.PageName);
4750

4851
// We await the OpenPage method to ensure the navigation has finished.
49-
if (await WeakReferenceMessenger.Default.Send(new RequestPageMessage(request.PageName)))
50-
{
51-
return new StartReply { Status = "OK" };
52-
}
53-
else
54-
{
55-
return new StartReply { Status = "BAD" };
56-
}
52+
var pageResponse = await WeakReferenceMessenger.Default.Send(new RequestPageMessage(request.PageName));
53+
54+
return pageResponse ? OkResult : BadResult;
5755
}
5856

5957
public override async Task SubscribeLog(SubscribeLogRequest request, IServerStreamWriter<LogUpdate> responseStream, ServerCallContext context)

UITests/UITests.App/HomePage.xaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Page x:Class="UITests.App.HomePage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
5+
<TextBlock HorizontalAlignment="Center"
6+
VerticalAlignment="Center"
7+
Text="No test loaded." />
8+
</Page>

UITests/UITests.App/HomePage.xaml.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.UI.Xaml.Controls;
6+
7+
namespace UITests.App
8+
{
9+
/// <summary>
10+
/// An empty page that can be used on its own or navigated to within a Frame.
11+
/// </summary>
12+
public sealed partial class HomePage
13+
{
14+
public HomePage()
15+
{
16+
this.InitializeComponent();
17+
}
18+
}
19+
}

UITests/UITests.App/MainTestHost.xaml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,35 @@
66
xmlns:testhelpers="using:AppTestAutomationHelpers"
77
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
88
mc:Ignorable="d">
9+
<Page.Resources>
10+
<Style x:Key="AutomationHelperStyle"
11+
TargetType="Control">
12+
<Setter Property="IsTabStop" Value="False" />
13+
<Setter Property="IsHitTestVisible" Value="False" />
14+
<Setter Property="Width" Value="0" />
15+
<Setter Property="Height" Value="0" />
16+
<Setter Property="Opacity" Value="0" />
17+
</Style>
18+
</Page.Resources>
919

1020
<Grid>
1121
<testhelpers:TestAutomationHelpersPanel />
12-
22+
<StackPanel Width="0"
23+
Height="0"
24+
HorizontalAlignment="Stretch"
25+
VerticalAlignment="Top"
26+
Orientation="Horizontal">
27+
<Button x:Name="GoBackInvokerButton"
28+
AutomationProperties.AutomationId="__GoBackInvoker"
29+
Click="GoBackInvokerButton_Click"
30+
Style="{StaticResource AutomationHelperStyle}" />
31+
<Button x:Name="CloseAppInvokerButton"
32+
AutomationProperties.AutomationId="__CloseAppInvoker"
33+
Click="CloseAppInvokerButton_Click"
34+
Style="{StaticResource AutomationHelperStyle}" />
35+
</StackPanel>
1336
<Frame x:Name="navigationFrame"
37+
IsNavigationStackEnabled="False"
1438
Navigated="NavigationFrame_Navigated"
1539
NavigationFailed="NavigationFrame_NavigationFailed" />
1640
</Grid>

UITests/UITests.App/MainTestHost.xaml.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,17 @@ private void NavigationFrame_NavigationFailed(object sender, Microsoft.UI.Xaml.N
109109
Log.Error("Failed to navigate to page {0}", e.SourcePageType.FullName);
110110
_loadingStateTask.SetResult(false);
111111
}
112+
113+
private void GoBackInvokerButton_Click(object sender, RoutedEventArgs e)
114+
{
115+
Log.Comment("Go Back Clicked. Navigating to Page...");
116+
navigationFrame.Navigate(typeof(HomePage));
117+
Log.Comment("Navigated to Page.");
118+
}
119+
120+
private void CloseAppInvokerButton_Click(object sender, RoutedEventArgs e)
121+
{
122+
App.Current.Exit();
123+
}
112124
}
113125
}

UITests/UITests.App/UITests.App.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
<CsWinRTIncludes>AppTestAutomationHelpers</CsWinRTIncludes>
1616
<CsWinRTWindowsMetadata>10.0.19041.0</CsWinRTWindowsMetadata>
1717

18-
<LangVersion>9.0</LangVersion>
1918
<NoWarn>$(NoWarn);CS0108</NoWarn>
2019
<IsTestHost>true</IsTestHost>
20+
<LangVersion>9.0</LangVersion>
2121
</PropertyGroup>
2222

2323
<ItemGroup>
@@ -77,6 +77,10 @@
7777
<Project>{daeb9cec-c817-33b2-74b2-bc379380db72}</Project>
7878
<Name>CommunityToolkit.WinUI.UI.Controls.DataGrid</Name>
7979
</ProjectReference>
80+
<ProjectReference Include="..\..\CommunityToolkit.WinUI.UI.Controls.Input\CommunityToolkit.WinUI.UI.Controls.Input.csproj">
81+
<Project>{af1be4e9-e2e1-4729-b076-b3725d8e21ee}</Project>
82+
<Name>CommunityToolkit.WinUI.UI.Controls.Input</Name>
83+
</ProjectReference>
8084
<ProjectReference Include="..\..\CommunityToolkit.WinUI.UI.Controls.Layout\CommunityToolkit.WinUI.UI.Controls.Layout.csproj">
8185
<Project>{cb444381-18ba-4a51-bb32-3a498bcc1e99}</Project>
8286
<Name>CommunityToolkit.WinUI.UI.Controls.Layout</Name>

UITests/UITests.Tests.MSTest/UITests.Tests.MSTest.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<TargetFramework>net5.0-windows10.0.18362</TargetFramework>
66
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
7-
<LangVersion>8.0</LangVersion>
7+
<LangVersion>9.0</LangVersion>
88

99
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1010
<PlatformTarget>x86</PlatformTarget>

UITests/UITests.Tests.Shared/AppService.proto

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ option csharp_namespace = "UITests.App.Protos";
55
package UITestsAppService;
66

77
service AppService {
8-
rpc Start (StartRequest) returns (StartReply);
8+
rpc OpenPage (OpenPageRequest) returns (OpenPageReply);
99
rpc SubscribeLog (SubscribeLogRequest) returns (stream LogUpdate);
1010
}
1111

12-
message StartRequest {
12+
message OpenPageRequest {
1313
string pageName = 1;
1414
}
1515

16-
message StartReply {
16+
message OpenPageReply {
1717
string status = 1;
1818
}
1919

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.UI.Xaml.Tests.MUXControls.InteractionTests.Common;
6+
using Microsoft.UI.Xaml.Tests.MUXControls.InteractionTests.Infra;
7+
using Microsoft.Windows.Apps.Test.Foundation.Controls;
8+
9+
#if USING_TAEF
10+
using WEX.Logging.Interop;
11+
using WEX.TestExecution;
12+
using WEX.TestExecution.Markup;
13+
#else
14+
using Microsoft.VisualStudio.TestTools.UnitTesting;
15+
#endif
16+
17+
namespace UITests.Tests
18+
{
19+
20+
[TestClass]
21+
public class RangeSelectorTest : UITestBase
22+
{
23+
[ClassInitialize]
24+
[TestProperty("RunAs", "User")]
25+
[TestProperty("Classification", "ScenarioTestSuite")]
26+
[TestProperty("Platform", "Any")]
27+
public static void ClassInitialize(TestContext testContext)
28+
{
29+
TestEnvironment.Initialize(testContext, UITestsAppSampleApp);
30+
}
31+
32+
[TestMethod]
33+
[TestPage("RangeSelectorTestPage")]
34+
public void SimpleTestMethod2()
35+
{
36+
var inputStepFrequency = new Edit(FindElement.ById("inputStepFrequency"));
37+
var inputMinimum = new Edit(FindElement.ById("inputMinimum"));
38+
var inputRangeStart = new Edit(FindElement.ById("inputRangeStart"));
39+
var inputRangeEnd = new Edit(FindElement.ById("inputRangeEnd"));
40+
var inputMaximum = new Edit(FindElement.ById("inputMaximum"));
41+
42+
var submitStepFrequency = new Button(FindElement.ById("submitStepFrequency"));
43+
var submitMinimum = new Button(FindElement.ById("submitMinimum"));
44+
var submitRangeStart = new Button(FindElement.ById("submitRangeStart"));
45+
var submitRangeEnd = new Button(FindElement.ById("submitRangeEnd"));
46+
var submitMaximum = new Button(FindElement.ById("submitMaximum"));
47+
var submitAll = new Button(FindElement.ById("submitAll"));
48+
49+
KeyboardHelper.EnterText(inputStepFrequency, "1");
50+
KeyboardHelper.EnterText(inputMinimum, "0");
51+
KeyboardHelper.EnterText(inputRangeStart, "10");
52+
KeyboardHelper.EnterText(inputRangeEnd, "90");
53+
KeyboardHelper.EnterText(inputMaximum, "100");
54+
55+
submitAll.Click();
56+
Wait.ForIdle();
57+
58+
var currentStepFrequency = new TextBlock(FindElement.ById("currentStepFrequency"));
59+
var currentMinimum = new TextBlock(FindElement.ById("currentMinimum"));
60+
var currentRangeStart = new TextBlock(FindElement.ById("currentRangeStart"));
61+
var currentRangeEnd = new TextBlock(FindElement.ById("currentRangeEnd"));
62+
var currentMaximum = new TextBlock(FindElement.ById("currentMaximum"));
63+
64+
Verify.AreEqual("1", currentStepFrequency.GetText());
65+
Verify.AreEqual("0", currentMinimum.GetText());
66+
Verify.AreEqual("10", currentRangeStart.GetText());
67+
Verify.AreEqual("90", currentRangeEnd.GetText());
68+
Verify.AreEqual("100", currentMaximum.GetText());
69+
}
70+
}
71+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<Page x:Class="UITests.App.Pages.RangeSelectorTestPage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
xmlns:sys="using:System"
8+
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
9+
mc:Ignorable="d">
10+
<Grid HorizontalAlignment="Center"
11+
VerticalAlignment="Center">
12+
<Grid.RowDefinitions>
13+
<RowDefinition Height="Auto" />
14+
<RowDefinition Height="5" />
15+
<RowDefinition Height="Auto" />
16+
<RowDefinition Height="5" />
17+
<RowDefinition Height="Auto" />
18+
<RowDefinition Height="5" />
19+
<RowDefinition Height="Auto" />
20+
</Grid.RowDefinitions>
21+
<Grid.ColumnDefinitions>
22+
<ColumnDefinition MinWidth="100" />
23+
<ColumnDefinition Width="5" />
24+
<ColumnDefinition MinWidth="100" />
25+
<ColumnDefinition Width="5" />
26+
<ColumnDefinition MinWidth="100" />
27+
<ColumnDefinition Width="5" />
28+
<ColumnDefinition MinWidth="100" />
29+
<ColumnDefinition Width="5" />
30+
<ColumnDefinition MinWidth="100" />
31+
<ColumnDefinition Width="5" />
32+
<ColumnDefinition MinWidth="100" />
33+
</Grid.ColumnDefinitions>
34+
35+
<!-- Input -->
36+
<TextBox x:Name="inputStepFrequency"
37+
Grid.Row="0"
38+
Grid.Column="0"
39+
Header="Step Frequency" />
40+
<Button x:Name="submitStepFrequency"
41+
Grid.Row="2"
42+
Grid.Column="0"
43+
Click="SubmitStepFrequency_Click"
44+
Content="Submit" />
45+
46+
<TextBox x:Name="inputMinimum"
47+
Grid.Row="0"
48+
Grid.Column="2"
49+
Header="Minimum" />
50+
<Button x:Name="submitMinimum"
51+
Grid.Row="2"
52+
Grid.Column="2"
53+
Click="SubmitMinimum_Click"
54+
Content="Submit" />
55+
56+
<TextBox x:Name="inputRangeStart"
57+
Grid.Row="0"
58+
Grid.Column="4"
59+
Header="RangeStart" />
60+
<Button x:Name="submitRangeStart"
61+
Grid.Row="2"
62+
Grid.Column="4"
63+
Click="SubmitRangeStart_Click"
64+
Content="Submit" />
65+
66+
<TextBox x:Name="inputRangeEnd"
67+
Grid.Row="0"
68+
Grid.Column="6"
69+
Header="RangeEnd" />
70+
<Button x:Name="submitRangeEnd"
71+
Grid.Row="2"
72+
Grid.Column="6"
73+
Click="SubmitRangeEnd_Click"
74+
Content="Submit" />
75+
76+
<TextBox x:Name="inputMaximum"
77+
Grid.Row="0"
78+
Grid.Column="8"
79+
Header="Maximum" />
80+
<Button x:Name="submitMaximum"
81+
Grid.Row="2"
82+
Grid.Column="8"
83+
Click="SubmitMaximum_Click"
84+
Content="Submit" />
85+
86+
<Button x:Name="submitAll"
87+
Grid.Row="0"
88+
Grid.RowSpan="3"
89+
Grid.Column="10"
90+
Click="SubmitAll_Click"
91+
Content="Submit All" />
92+
93+
<controls:RangeSelector x:Name="rangeSelector"
94+
Grid.Row="4"
95+
Grid.ColumnSpan="11" />
96+
97+
<!-- Results -->
98+
<TextBlock x:Name="currentStepFrequency"
99+
Grid.Row="6"
100+
Grid.Column="0"
101+
Text="{x:Bind rangeSelector.StepFrequency, Mode=OneWay}" />
102+
103+
<TextBlock x:Name="currentMinimum"
104+
Grid.Row="6"
105+
Grid.Column="2"
106+
Text="{x:Bind rangeSelector.Minimum, Mode=OneWay}" />
107+
108+
<TextBlock x:Name="currentRangeStart"
109+
Grid.Row="6"
110+
Grid.Column="4"
111+
Text="{x:Bind rangeSelector.RangeStart, Mode=OneWay}" />
112+
113+
<TextBlock x:Name="currentRangeEnd"
114+
Grid.Row="6"
115+
Grid.Column="6"
116+
Text="{x:Bind rangeSelector.RangeEnd, Mode=OneWay}" />
117+
118+
<TextBlock x:Name="currentMaximum"
119+
Grid.Row="6"
120+
Grid.Column="8"
121+
Text="{x:Bind rangeSelector.Maximum, Mode=OneWay}" />
122+
</Grid>
123+
</Page>

0 commit comments

Comments
 (0)