Skip to content

Commit

Permalink
test: Fix When_Commerce_Backbutton for android
Browse files Browse the repository at this point in the history
  • Loading branch information
eriklimakc committed Aug 28, 2024
1 parent 306eeda commit 6b2617f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
2 changes: 1 addition & 1 deletion testing/TestHarness/TestHarness.UITest/AppExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static async Task TapAndWait(this IApp app, string elementToTap, string e
await Task.Delay(UIWaitTimeInMilliseconds);
}

public static async Task SelectListViewIndexAndWait(this IApp app, string listName, string indexToSelect, string elementToWaitFor)
public static async Task SelectElementIndexAndWait(this IApp app, string listName, string indexToSelect, string elementToWaitFor)
{
app.WaitElement(listName);
await Task.Delay(UIWaitTimeInMilliseconds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@ public async Task When_Commerce_Backbutton()
await App.TapAndWait("DealsTabBarItem", "DealsNavigationBar");

// Select a deal
await App.TapAndWait("DealsPage_DealsTabBarItem", "DealsListView");
await App.SelectElementIndexAndWait("DealsTabBar", "0", "DealsListView");

await App.SelectListViewIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar");
await App.SelectElementIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar");

// Go back to list of deals
await App.TapAndWait("DetailsBackButton", "DealsListView");
App.WaitThenTap("DetailsBackButton");

await App.SelectElementIndexAndWait("DealsTabBar", "0", "DealsListView");

// Select another deal
await App.SelectListViewIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar");
await App.SelectElementIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar");

// Go back to list of deals
await App.TapAndWait("DetailsBackButton", "DealsListView");
Expand Down Expand Up @@ -66,14 +67,14 @@ public async Task When_Commerce_Responsive()
// Select a deal
await App.TapAndWait("DealsTabBarItem", "DealsListView");

await App.SelectListViewIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar");
await App.SelectElementIndexAndWait("DealsListView", "1", "ProductDetailsNavigationBar");

await App.TapAndWait("DetailsBackButton", "DealsNavigationBar");

// Select a product
await App.TapAndWait("ProductsTabBarItem", "ProductsListView");

await App.SelectListViewIndexAndWait("ProductsListView", "2", "ProductDetailsNavigationBar");
await App.SelectElementIndexAndWait("ProductsListView", "2", "ProductDetailsNavigationBar");

await App.TapAndWait("DetailsBackButton", "ProductsNavigationBar");

Expand Down Expand Up @@ -106,14 +107,14 @@ public async Task When_Commerce_Responsive()
// Select a deal
await App.TapAndWait("DealsNavigationViewItem", "DealsListView");

await App.SelectListViewIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar");
await App.SelectElementIndexAndWait("DealsListView", "2", "ProductDetailsNavigationBar");
App.WaitElement("DealsNavigationBar");


// Select a product
await App.TapAndWait("ProductsNavigationViewItem", "ProductsListView");

await App.SelectListViewIndexAndWait("ProductsListView", "1", "ProductDetailsNavigationBar");
await App.SelectElementIndexAndWait("ProductsListView", "1", "ProductDetailsNavigationBar");
App.WaitElement("ProductsNavigationBar");

// Log out
Expand All @@ -123,7 +124,6 @@ public async Task When_Commerce_Responsive()

}


[Test]
public async Task When_ViewModelInstance()
{
Expand Down Expand Up @@ -177,7 +177,6 @@ public async Task When_ViewModelInstance()

}


[Test]
public async Task When_BackgroundThread()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static Func<IAppQuery, IAppQuery> WaitThenTap(this IApp app, string marke
public static IAppResult[] WaitElement(this IApp app, string marked, string timeoutMessage = "Timed out waiting for element '{0}'...", TimeSpan? timeout = null, TimeSpan? retryFrequency = null, TimeSpan? postTimeout = null)
{
Console.WriteLine($"Waiting for '{marked}'");
return app.WaitForElement(q => q.All().Marked(marked), string.Format(timeoutMessage,marked), timeout, retryFrequency, postTimeout);
return app.WaitForElement(q => q.All().Marked(marked), string.Format(timeoutMessage, marked), timeout, retryFrequency, postTimeout);
}

public static QueryEx MarkedAnywhere(this IApp app, string marked)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,18 @@
<VisualStateGroup>
<VisualState x:Name="Wide">
<VisualState.StateTriggers>
<triggers:ControlSizeTrigger MinWidth="{StaticResource WideMinWindowWidth}"
TargetElement="{Binding ElementName=ParentGrid}" />
<triggers:ControlSizeTrigger MinWidth="{StaticResource WideMinWindowWidth}" TargetElement="{Binding ElementName=ParentGrid}" />
</VisualState.StateTriggers>
<VisualState.Setters>
<!--<Setter Target="DealsListView.SelectionMode"
Value="Single" />
<Setter Target="DealsListView.IsItemClickEnabled"
Value="False" />-->
<Setter Target="DealsColumn.Width"
Value="*" />
<Setter Target="DealsColumn.MinWidth"
Value="300" />
<Setter Target="DetailsColumn.Width"
Value="2*" />
<Setter Target="DetailsGrid.Visibility"
Value="Visible" />
<Setter Target="Details.(uen:Region.Attached)"
Value="true" />
<Setter Target="DealsColumn.Width" Value="*" />
<Setter Target="DealsColumn.MinWidth" Value="300" />
<Setter Target="DetailsColumn.Width" Value="2*" />
<Setter Target="DetailsGrid.Visibility" Value="Visible" />
<Setter Target="Details.(uen:Region.Attached)" Value="true" />
</VisualState.Setters>
</VisualState>
<VisualState x:Name="Narrow">
Expand All @@ -56,18 +50,15 @@
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<utu:NavigationBar AutomationProperties.AutomationId="DealsNavigationBar"
Content="Deals" />
<utu:NavigationBar AutomationProperties.AutomationId="DealsNavigationBar" Content="Deals" />
<TextBlock AutomationProperties.AutomationId="DealsViewModelIdTextBlock"
Text="{Binding ViewModelId}"
FontWeight="Bold" />

<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"
x:Name="DealsColumn" />
<ColumnDefinition Width="0"
x:Name="DetailsColumn" />
<ColumnDefinition Width="*" x:Name="DealsColumn" />
<ColumnDefinition Width="0" x:Name="DetailsColumn" />
</Grid.ColumnDefinitions>
<Grid uen:Region.Attached="True">
<Grid.RowDefinitions>
Expand All @@ -86,7 +77,9 @@
Content="Product Details"
Click="{x:Bind ViewModel.ShowProduct}" />
</StackPanel>
<utu:TabBar uen:Region.Attached="True" Grid.Row="1">
<utu:TabBar uen:Region.Attached="True"
Grid.Row="1"
AutomationProperties.AutomationId="DealsTabBar">
<utu:TabBarItem x:Uid="DealsPage_DealsTab"
AutomationProperties.AutomationId="DealsPage_DealsTabBarItem"
Content="Deals"
Expand All @@ -110,8 +103,7 @@
uen:Navigation.Request="DealsProduct">
<ListView.ItemTemplate>
<DataTemplate x:DataType="local:CommerceProduct">
<TextBlock Text="{x:Bind Name}"
FontSize="30" />
<TextBlock Text="{x:Bind Name}" FontSize="30" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Expand Down

0 comments on commit 6b2617f

Please sign in to comment.