Skip to content

Commit

Permalink
chore: Adjust tests for android limitations
Browse files Browse the repository at this point in the history
Revert "chore: Adjust tests for android limitations"

This reverts commit 237528f.

chore: fixup tests

ci: copy ios test results
  • Loading branch information
eriklimakc authored and kazo0 committed Aug 16, 2024
1 parent f14c9f0 commit 33d9f18
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 50 deletions.
18 changes: 10 additions & 8 deletions build/ci/scripts/ios-uitest-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ export UNO_UITEST_PROJECT=$BUILD_SOURCESDIRECTORY/testing/TestHarness/TestHarnes
export UNO_UITEST_LOGFILE=$BUILD_ARTIFACTSTAGINGDIRECTORY/screenshots/ios/nunit-log.txt
export UNO_UITEST_IOS_PROJECT=$BUILD_SOURCESDIRECTORY/testing/TestHarness/TestHarness
export UITEST_TEST_TIMEOUT=90m

export UNO_UITEST_SIMULATOR_VERSION="com.apple.CoreSimulator.SimRuntime.iOS-16-1"
export UNO_UITEST_SIMULATOR_VERSION="com.apple.CoreSimulator.SimRuntime.iOS-17-2"
export UNO_UITEST_SIMULATOR_NAME="iPad Pro (12.9-inch) (6th generation)"

echo "Lising iOS simulators"
echo "Listing iOS simulators"
xcrun simctl list devices --json

/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator &
Expand All @@ -28,10 +27,10 @@ dotnet build -p:UnoTargetFrameworkOverride=net8.0-ios -r iossimulator-x64 -c Rel
## Pre-install the application to avoid https://github.com/microsoft/appcenter/issues/2389
##

## Install iOS 16.1 simulators
xcodes runtimes install --keep-archive 'iOS 16.1' || true
## Install iOS 17.2 simulators
xcodes runtimes install --keep-archive 'iOS 17.2' || true

# Wait while ios runtime 16.1 is not having simulators. The install process may
# Wait while ios runtime 17.2 is not having simulators. The install process may
# take a few seconds and "simctl list devices" may not return devices.
while true; do
export UITEST_IOSDEVICE_ID=`xcrun simctl list -j | jq -r --arg sim "$UNO_UITEST_SIMULATOR_VERSION" --arg name "$UNO_UITEST_SIMULATOR_NAME" '.devices[$sim] | .[] | select(.name==$name) | .udid'`
Expand Down Expand Up @@ -82,10 +81,13 @@ dotnet test \
-v m \
|| true


cp $BUILD_SOURCESDIRECTORY/build/TestResult.xml" $UNO_UITEST_SCREENSHOT_PATH
# export the simulator logs
export LOG_FILEPATH=$UNO_UITEST_SCREENSHOT_PATH/_logs
export TMP_LOG_FILEPATH=/tmp/DeviceLog-`date +"%Y%m%d%H%M%S"`.logarchive
export LOG_FILEPATH_FULL=$LOG_FILEPATH/DeviceLog-`date +"%Y%m%d%H%M%S"`.txt
xcrun simctl spawn booted log collect --output $TMP_LOG_FILEPATH
log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH_FULL
# xcrun simctl spawn booted log collect --output $TMP_LOG_FILEPATH
# log show --style syslog $TMP_LOG_FILEPATH > $LOG_FILEPATH_FULL
3 changes: 1 addition & 2 deletions testing/TestHarness/TestHarness.UITest/AppExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public static async Task SelectListViewIndexAndWait(this IApp app, string listNa
{
app.WaitElement(listName);
await Task.Delay(UIWaitTimeInMilliseconds);

var list = app.Marked(listName);
var list = new QueryEx(q => q.All().Marked(listName));
list.SetDependencyPropertyValue("SelectedIndex", indexToSelect);
await Task.Delay(UIWaitTimeInMilliseconds);

Expand Down
6 changes: 3 additions & 3 deletions testing/TestHarness/TestHarness.UITest/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ namespace TestHarness.UITest;
public class Constants
{
public readonly static string WebAssemblyDefaultUri = "https://localhost:57208";
public readonly static string iOSAppName = "uno.platform.extensions.demo";
public readonly static string AndroidAppName = "uno.platform.extensions.demo";
public readonly static string iOSAppName = "com.companyname.TestHarness";
public readonly static string AndroidAppName = "com.companyname.TestHarness";
public readonly static string iOSDeviceNameOrId = "iPad Pro (12.9-inch) (4th generation)";

public readonly static Platform CurrentPlatform = Platform.Browser;
public readonly static Platform CurrentPlatform = Platform.Android;
public const int DefaultPixelTolerance = 100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ public async Task When_ViewModelInstance()
/// Tap through each navigation view item
await App.TapAndWait("DealsNavigationViewItem", "DealsNavigationBar");
var dealsId = App
.Marked("DealsViewModelIdTextBlock")
.MarkedAnywhere("DealsViewModelIdTextBlock")
.WaitUntilExists()
.GetDependencyPropertyValue<string>("Text");
dealsId.Should().NotBeNull();

await App.TapAndWait("ProductsNavigationViewItem", "ProductsNavigationBar");
var productsId = App
.Marked("ProductsViewModelIdTextBlock")
.MarkedAnywhere("ProductsViewModelIdTextBlock")
.WaitUntilExists()
.GetDependencyPropertyValue<string>("Text");
productsId.Should().NotBeNull();
Expand All @@ -161,15 +161,15 @@ public async Task When_ViewModelInstance()
// Now go back to Deals and Products page and validate the Ids are the same (ie same instance of the viewmodel)
await App.TapAndWait("DealsNavigationViewItem", "DealsNavigationBar");
var newDealsId = App
.Marked("DealsViewModelIdTextBlock")
.MarkedAnywhere("DealsViewModelIdTextBlock")
.WaitUntilExists()
.GetDependencyPropertyValue<string>("Text");
newDealsId.Should().NotBeNull();
newDealsId.Should().BeEquivalentTo(dealsId);

await App.TapAndWait("ProductsNavigationViewItem", "ProductsNavigationBar");
var newProductsId = App
.Marked("ProductsViewModelIdTextBlock")
.MarkedAnywhere("ProductsViewModelIdTextBlock")
.WaitUntilExists()
.GetDependencyPropertyValue<string>("Text");
newProductsId.Should().NotBeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public async Task When_MessageDialogFromXAML()
ImageAssert.AreNotEqual(screenBefore, screenAfter);

App
.Marked("CloseMessageDialogToggleButton")
.MarkedAnywhere("CloseMessageDialogToggleButton")
.SetDependencyPropertyValue("IsChecked", true.ToString());


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public abstract class NavigationTestBase : TestBase
{
protected void InitTestSection(TestSections section)
{
var theListView = App.Marked(TestHarness.Constants.TestSectionsListView);
var theListView = App.MarkedAnywhere(TestHarness.Constants.TestSectionsListView);
App.WaitForElement(theListView);

theListView.SetDependencyPropertyValue("SelectedIndex", ((int)section).ToString());

App.WaitForElement(q => q.Marked(TestHarness.Constants.NavigationRoot));
App.WaitForElement(q => q.All().Marked(TestHarness.Constants.NavigationRoot));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,39 @@ public async Task When_NavigationView()

private void CheckProductsVisible()
{
var text = App.Marked("CurrentNavigationViewItemTextBlock").GetText();
var text = App.MarkedAnywhere("CurrentNavigationViewItemTextBlock").GetText();
text.Should().Be("Products");
var isVisible = App.Marked("ProductsStackPanel").IsVisible();
var isVisible = App.MarkedAnywhere("ProductsStackPanel").IsVisible();
isVisible.Should().Be(true);
isVisible = App.Marked("DealsStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("DealsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("ProfileStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("ProfileStackPanel").IsVisible();
isVisible.Should().Be(false);
}

private void CheckDealsVisible()
{
var text = App.Marked("CurrentNavigationViewItemTextBlock").GetText();
var text = App.MarkedAnywhere("CurrentNavigationViewItemTextBlock").GetText();
text.Should().Be("Deals");
var isVisible = App.Marked("ProductsStackPanel").IsVisible();
var isVisible = App.MarkedAnywhere("ProductsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("DealsStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("DealsStackPanel").IsVisible();
isVisible.Should().Be(true);
isVisible = App.Marked("ProfileStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("ProfileStackPanel").IsVisible();
isVisible.Should().Be(false);

}


private void CheckProfileVisible()
{
var text = App.Marked("CurrentNavigationViewItemTextBlock").GetText();
var text = App.MarkedAnywhere("CurrentNavigationViewItemTextBlock").GetText();
text.Should().Be("Profile");
var isVisible = App.Marked("ProductsStackPanel").IsVisible();
var isVisible = App.MarkedAnywhere("ProductsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("DealsStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("DealsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("ProfileStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("ProfileStackPanel").IsVisible();
isVisible.Should().Be(true);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public async Task When_Navigation_Responsive()
App.WaitElement("ResponsiveHomeNavigationBar");


var widgetsListView = App.Marked("WidgetsListView");
var widgetsListView = App.MarkedAnywhere("WidgetsListView");
App.WaitElement("WidgetsListView");

// Select the narrow layout
Expand All @@ -32,7 +32,7 @@ public async Task When_Navigation_Responsive()

await Task.Yield();

widgetsListView = App.Marked("WidgetsListView");
widgetsListView = App.MarkedAnywhere("WidgetsListView");
visibility = widgetsListView.WaitUntilExists().GetDependencyPropertyValue("Visibility");
visibility.Should().NotBeNull();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,26 @@ public async Task When_TabBar()
private void CheckProductsVisible()
{
App.WaitElement("ProductsDealsButton");
var text = App.Marked("CurrentTabBarItemTextBlock").GetText();
var text = App.MarkedAnywhere("CurrentTabBarItemTextBlock").GetText();
text.Should().Be("Products");
var isVisible = App.Marked("ProductsStackPanel").IsVisible();
var isVisible = App.MarkedAnywhere("ProductsStackPanel").IsVisible();
isVisible.Should().Be(true);
isVisible = App.Marked("DealsStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("DealsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("ProfileStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("ProfileStackPanel").IsVisible();
isVisible.Should().Be(false);
}

private void CheckDealsVisible()
{
App.WaitElement("DealsProductsButton");
var text = App.Marked("CurrentTabBarItemTextBlock").GetText();
var text = App.MarkedAnywhere("CurrentTabBarItemTextBlock").GetText();
text.Should().Be("Deals");
var isVisible = App.Marked("ProductsStackPanel").IsVisible();
var isVisible = App.MarkedAnywhere("ProductsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("DealsStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("DealsStackPanel").IsVisible();
isVisible.Should().Be(true);
isVisible = App.Marked("ProfileStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("ProfileStackPanel").IsVisible();
isVisible.Should().Be(false);

}
Expand All @@ -83,13 +83,13 @@ private void CheckDealsVisible()
private void CheckProfileVisible()
{
App.WaitElement("ProfileProductsButton");
var text = App.Marked("CurrentTabBarItemTextBlock").GetText();
var text = App.MarkedAnywhere("CurrentTabBarItemTextBlock").GetText();
text.Should().Be("Profile");
var isVisible = App.Marked("ProductsStackPanel").IsVisible();
var isVisible = App.MarkedAnywhere("ProductsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("DealsStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("DealsStackPanel").IsVisible();
isVisible.Should().Be(false);
isVisible = App.Marked("ProfileStackPanel").IsVisible();
isVisible = App.MarkedAnywhere("ProfileStackPanel").IsVisible();
isVisible.Should().Be(true);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ 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(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)
{
return new QueryEx(q => q.All().Marked(marked));
}

public static QueryEx ToQueryEx(this Func<IAppQuery, IAppQuery> query) => new QueryEx(query);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static void WaitForText(this IApp app, QueryEx element, string expectedTe
/// </summary>
public static void WaitForText(this IApp app, string elementName, string expectedText, TimeSpan? timeout = null)
{
var element = app.Marked(elementName);
var element = app.MarkedAnywhere(elementName);
app.WaitForElement(element, timeout: timeout);
app.WaitForText(element, expectedText);
}
Expand All @@ -25,7 +25,7 @@ public static void WaitForText(this IApp app, string elementName, string expecte
/// </summary>
public static void WaitForFocus(this IApp app, string elementName)
{
var element = app.Marked(elementName);
var element = app.MarkedAnywhere(elementName);
app.WaitForElement(element);
app.WaitForDependencyPropertyValue(element, "FocusState", "Pointer");
}
Expand Down Expand Up @@ -68,7 +68,7 @@ public static bool IsVisible(this QueryEx element)
/// </summary>
public static string GetText(this IApp app, string elementName)
{
var element = app.Marked(elementName);
var element = app.MarkedAnywhere(elementName);
app.WaitForElement(element);
return element.GetText();
}
Expand Down

0 comments on commit 33d9f18

Please sign in to comment.