Skip to content

Commit

Permalink
Merge pull request #93 from MADE-Apps/feature/ios-support
Browse files Browse the repository at this point in the history
Added iOS support for Uno Platform app testing
  • Loading branch information
jamesmcroft authored Apr 7, 2022
2 parents 37c84ec + 5f37423 commit ce48c98
Show file tree
Hide file tree
Showing 36 changed files with 214 additions and 455 deletions.
2 changes: 1 addition & 1 deletion docs/articles/elements/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var isAcceptIndeterminate = AcceptCheckBox.IsIndeterminate;
|-|-|
| Windows | ✓ |
| Android | ✓ |
| iOS | ✗ |
| iOS | ✓ |
| WebAssembly | ✓ |

## Properties
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/elements/combobox.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var selectedItem = ColorComboBox.SelectedItem;
|-|-|
| Windows | ✓ |
| Android | ✓ |
| iOS | ✗ |
| iOS | ✓ |
| WebAssembly | ✓ |

## Properties
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/elements/commandbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var moreButton = RichEditCommandBar.MoreButton;
|-|-|
| Windows | ✓ |
| Android | ✓ |
| iOS | ✗ |
| iOS | ✓ |
| WebAssembly | ✓ |

## Properties
Expand Down
2 changes: 1 addition & 1 deletion docs/articles/elements/textbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var isReadonly = UsernameTextBox.IsReadonly;
|-|-|
| Windows | ✓ |
| Android | ✓ |
| iOS | ✗ |
| iOS | ✓ |
| WebAssembly | ✓ |

## Properties
Expand Down
64 changes: 37 additions & 27 deletions docs/articles/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,48 @@ namespace UnoAppTests
{
public const string AndroidApplication = "com.made.myunoapp";
public const string AndroidApplicationActivity = $"{AndroidApplication}.MainActivity";
public const string IOSApplication = "com.made.myunoapp";
public const string WasmApplication = "http://localhost:5000";
public const string WindowsApplication = "com.madeapps.myunoapp_7mzr475ysvhxg!App";

protected BaseTestClass(AppManagerOptions options) : base(options) { }

static IEnumerable<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
new AndroidAppManagerOptions
{
AppId = AndroidApplication,
AppActivity = AndroidApplicationActivity,
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = true
},
new IOSAppManagerOptions
{
AppId = IOSApplication,
DeviceName = "iPhone SE (3rd generation) Simulator",
DeviceId = "56755E6F-741B-478F-BB1B-A48E05ACFE8A",
OSVersion = "15.4",
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = false
},
new WebAppManagerOptions(
WebAppDriverType.EdgeChromium,
Path.Combine(Environment.CurrentDirectory))
{
Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(5)
},
new WebAppManagerOptions(
WebAppDriverType.Chrome,
Path.Combine(Environment.CurrentDirectory))
{
Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(5)
},
new WindowsAppManagerOptions(WindowsApplication)
{
DriverUri = "http://127.0.0.1:4723", LaunchWinAppDriver = true
}
};

[SetUp]
public override void StartApp()
{
Expand Down Expand Up @@ -77,33 +114,6 @@ namespace UnoAppTests
{
public HomePageTests(AppManagerOptions options) : base(options) { }

static IEnumerable<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
new AndroidAppManagerOptions
{
AppId = AndroidApplication,
AppActivity = AndroidApplicationActivity,
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = true
},
new WebAppManagerOptions(
WebAppDriverType.EdgeChromium,
Path.Combine(Environment.CurrentDirectory))
{
Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(5)
},
new WebAppManagerOptions(
WebAppDriverType.Chrome,
Path.Combine(Environment.CurrentDirectory))
{
Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(5)
},
new WindowsAppManagerOptions(WindowsApplication)
{
DriverUri = "http://127.0.0.1:4723", LaunchWinAppDriver = true
}
};

[Test]
public void ShouldLoadHomePageContent()
{
Expand Down
16 changes: 13 additions & 3 deletions docs/articles/page-object-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace UnoAppTests.Pages
return this.App switch
{
AndroidDriver<AndroidElement> _ => ByExtras.AndroidXamlAutomationId(automationId),
IOSDriver<IOSElement> _ => ByExtras.IOSXamlAutomationId(automationId),
WindowsDriver<WindowsElement> _ => WindowsByExtras.AutomationId(automationId),
_ => ByExtras.WebXamlAutomationId(automationId)
};
Expand Down Expand Up @@ -110,21 +111,30 @@ namespace UnoAppTests.Tests
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = true
},
new IOSAppManagerOptions
{
AppId = IOSApplication,
DeviceName = "iPhone SE (3rd generation) Simulator",
DeviceId = "56755E6F-741B-478F-BB1B-A48E05ACFE8A",
OSVersion = "15.4",
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = false
},
new WebAppManagerOptions(
WebAppDriverType.EdgeChromium,
Path.Combine(Environment.CurrentDirectory))
{
Maximize = true, Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(10)
Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(5)
},
new WebAppManagerOptions(
WebAppDriverType.Chrome,
Path.Combine(Environment.CurrentDirectory))
{
Maximize = true, Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(10)
Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(5)
},
new WindowsAppManagerOptions(WindowsApplication)
{
DriverUri = "http://127.0.0.1:4723", LaunchWinAppDriver = true, Maximize = true
DriverUri = "http://127.0.0.1:4723", LaunchWinAppDriver = true
}
};

Expand Down
12 changes: 12 additions & 0 deletions docs/articles/prepare-uno-platform-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,15 @@ Uno.UI.FeatureConfiguration.UIElement.AssignDOMXamlProperties = true;
```

More information on this can be found in the [Uno Platform docs](https://platform.uno/docs/articles/uno-development/debugging-inspect-visual-tree.html#web).

## Providing additional XAML automation properties for Android and iOS

To get the most out of your app's XAML automation properties, you want to provide additional XAML automation properties to support interactions with Android and iOS.

Adding the following additional property to your XAML elements will provide the correct XAML automation ID for elements that have content. This is required to ensure that the content isn't displayed as the element name.

```xml
AutomationProperties.AccessibilityView="Raw"
```

See [Uno Platform's tips](https://platform.uno/docs/articles/features/working-with-accessibility.html#tips) on why this is needed.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@
AutomationProperties.AutomationId="SampleCheckBox"
AutomationProperties.AccessibilityView="Raw"
Content="Two-state CheckBox" />
<CheckBox
x:Name="SampleIndeterminateCheckBox"
x:Uid="SampleIndeterminateCheckBox"
Margin="0,0,0,12"
IsThreeState="True"
AutomationProperties.AutomationId="SampleIndeterminateCheckBox"
AutomationProperties.AccessibilityView="Raw"
Content="Three-state CheckBox" />
<ComboBox
x:Name="SampleComboBox"
x:Uid="SampleComboBox"
Expand Down
32 changes: 16 additions & 16 deletions samples/UnoSampleApp/UnoSampleApp/UnoSampleApp.iOS/Info.plist
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<dict>
<key>CFBundleDisplayName</key>
<string>UnoSampleApp</string>
<key>CFBundleIdentifier</key>
<string>com.companyname.UnoSampleApp</string>
<string>com.madeapps.UnoSampleApp</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
Expand All @@ -16,32 +16,32 @@
<string>8.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>arm64</string>
<string>armv7</string>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIAppFonts</key>
<array>
<string>Fonts/uno-fluentui-assets.ttf</string>
<string>Fonts/uno-fluentui-assets.ttf</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Expand All @@ -53,5 +53,5 @@
<string>{320, 568}</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</dict>
</plist>
44 changes: 44 additions & 0 deletions samples/UnoSampleAppTests/BaseTestClass.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
namespace UnoSampleAppTests
{
using System;
using System.Collections.Generic;
using System.IO;
using Legerity;
using Legerity.Android;
using Legerity.IOS;
using Legerity.Uno;
using Legerity.Web;
using Legerity.Windows;
using NUnit.Framework;

public abstract class BaseTestClass : UnoTestClass
Expand All @@ -11,6 +17,8 @@ public abstract class BaseTestClass : UnoTestClass

public const string AndroidApplicationActivity = $"{AndroidApplication}.MainActivity";

public const string IOSApplication = "com.madeapps.UnoSampleApp";

public const string WasmApplication = "http://localhost:5000";

public const string WindowsApplication = "com.madeapps.unosampleapp_7mzr475ysvhxg!App";
Expand All @@ -19,6 +27,42 @@ protected BaseTestClass(AppManagerOptions options) : base(options)
{
}

protected static IEnumerable<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
new AndroidAppManagerOptions
{
AppId = AndroidApplication,
AppActivity = AndroidApplicationActivity,
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = false
},
new IOSAppManagerOptions
{
AppId = IOSApplication,
DeviceName = "iPhone SE (3rd generation) Simulator",
DeviceId = "56755E6F-741B-478F-BB1B-A48E05ACFE8A",
OSVersion = "15.4",
DriverUri = "http://192.168.86.172:4723/wd/hub",
LaunchAppiumServer = false
},
new WebAppManagerOptions(
WebAppDriverType.EdgeChromium,
Path.Combine(Environment.CurrentDirectory))
{
Maximize = true, Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(10)
},
new WebAppManagerOptions(
WebAppDriverType.Chrome,
Path.Combine(Environment.CurrentDirectory))
{
Maximize = true, Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(10)
},
new WindowsAppManagerOptions(WindowsApplication)
{
DriverUri = "http://127.0.0.1:4723", LaunchWinAppDriver = true, Maximize = true
}
};

[SetUp]
public override void StartApp()
{
Expand Down
34 changes: 0 additions & 34 deletions samples/UnoSampleAppTests/Tests/AppBarButtonTests.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
namespace UnoSampleAppTests.Tests
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Legerity;
using Legerity.Android;
using Legerity.Web;
using Legerity.Windows;
using NUnit.Framework;
using Pages;

Expand All @@ -18,33 +11,6 @@ public AppBarButtonTests(AppManagerOptions options) : base(options)
{
}

static IEnumerable<AppManagerOptions> TestPlatformOptions => new List<AppManagerOptions>
{
new AndroidAppManagerOptions
{
AppId = AndroidApplication,
AppActivity = AndroidApplicationActivity,
DriverUri = "http://localhost:4723/wd/hub",
LaunchAppiumServer = false
},
new WebAppManagerOptions(
WebAppDriverType.EdgeChromium,
Path.Combine(Environment.CurrentDirectory))
{
Maximize = true, Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(10)
},
new WebAppManagerOptions(
WebAppDriverType.Chrome,
Path.Combine(Environment.CurrentDirectory))
{
Maximize = true, Url = WasmApplication, ImplicitWait = TimeSpan.FromSeconds(10)
},
new WindowsAppManagerOptions(WindowsApplication)
{
DriverUri = "http://127.0.0.1:4723", LaunchWinAppDriver = true, Maximize = true
}
};

[Test]
public void ShouldClickAppBarButtonByAutomationId()
{
Expand Down
Loading

0 comments on commit ce48c98

Please sign in to comment.