Skip to content

Commit

Permalink
Release 1.1.0 (#41)
Browse files Browse the repository at this point in the history
* Switched out the UI Server to our own implementation (and uiautomator 2.0). This change require an installation of two new APKs (should happen automatically).
* New method in SettingsService to enable/disable bluetooth
* Fixed UiAutomatorServer so it's thread safe.
* Fixed GetPackages() in ActivityService so it return the result correctly.
* Improved xml comments
  • Loading branch information
MilleBo authored Jun 26, 2017
1 parent 5b787e6 commit b1b084e
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 159 deletions.
4 changes: 2 additions & 2 deletions src/Testura.Android.PageObject/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.1.1.0")]
[assembly: AssemblyFileVersion("1.1.1.0")]
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
using System.Collections.Generic;
using System.Runtime.Remoting.Messaging;
using NUnit.Framework;
using Testura.Android.Device;
using NUnit.Framework;
using Testura.Android.Device.Configurations;
using Testura.Android.Device.Ui.Search;
using Testura.Android.Device.Ui.Server;
using Testura.Android.Util.Terminal;
using Testura.Android.Util.Walker;
using Testura.Android.Util.Walker.Cases;
using Assert = NUnit.Framework.Assert;

namespace Testura.Android.Tests.Integration.Device.UiAutomator.Server
{
[TestFixture]
[Ignore("Integration")]
[TestFixture]
public class UiAutomatorServerTests
{
private UiAutomatorServer _server;
Expand Down
25 changes: 0 additions & 25 deletions src/Testura.Android/Dependencies/LICENSE.txt

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file removed src/Testura.Android/Dependencies/testura-helper.apk
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 5 additions & 10 deletions src/Testura.Android/Device/Configurations/DeviceConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ namespace Testura.Android.Device.Configurations
public class DeviceConfiguration
{
/// <summary>
/// Name of the UI automator stub file.
/// </summary>
public const string UiAutomatorStub = "uiautomator-stub.jar";

/// <summary>
/// Name of the UI automator sub bundle file.
/// Name of the Testura helper APK file.
/// </summary>
public const string UiAutomatorStubBundle = "uiautomator-stub-bundle.jar";
public const string ServerApkName = "Testura.Android.Server.apk";

/// <summary>
/// Name of the Testura helper APK file.
/// Name of the Testura server APK file.
/// </summary>
public const string HelperApkName = "testura-helper.apk";
public const string ServerUiAutomatorApkName = "Testura.Android.Server-UiAutomator.apk";

/// <summary>
/// Initializes a new instance of the <see cref="DeviceConfiguration"/> class.
Expand Down Expand Up @@ -60,7 +55,7 @@ public DeviceConfiguration()
public string DependenciesDirectory { get; set; }

/// <summary>
/// Gets or sets the local port to the device.
/// Gets or sets the local port.
/// </summary>
public int Port { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public string GetCurrent()
/// <returns>A list with all installed packages</returns>
public IList<string> GetPackages()
{
var packages = Device.Adb.Shell("pm list packages").Split(new[] { "\r\r\n" }, StringSplitOptions.RemoveEmptyEntries);
var packages = Device.Adb.Shell("pm list packages").Split(new[] { "\r\r\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
return packages.Select(p => p.Replace("package:", string.Empty)).ToList();
}

Expand Down
18 changes: 16 additions & 2 deletions src/Testura.Android/Device/Services/Default/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ namespace Testura.Android.Device.Services.Default
/// </summary>
public class SettingsService : Service, ISettingsService
{
private const string PackageName = "com.testura.server";

/// <summary>
/// Enable or disable wifi
/// </summary>
Expand All @@ -16,8 +18,20 @@ public void Wifi(State state)
{
DeviceLogger.Log("Changing wifi state");
Device.Adb.Shell(state == State.Enable
? "am startservice -n com.testura.helper/.service.setting.WifiService -e enable 1"
: "am startservice -n com.testura.helper/.service.setting.WifiService -e enable 0");
? $"am startservice -n {PackageName}/{PackageName}.services.settings.WifiService -e enable 1"
: $"am startservice -n {PackageName}/{PackageName}.services.settings.WifiService -e enable 0");
}

/// <summary>
/// Enable or disable bluetooth.
/// </summary>
/// <param name="state">Wanted state of bluetooth.</param>
public void Bluetooth(State state)
{
DeviceLogger.Log("Changing wifi state");
Device.Adb.Shell(state == State.Enable
? $"am startservice -n {PackageName}/{PackageName}.services.settings.BluetoothService -e enable 1"
: $"am startservice -n {PackageName}/{PackageName}.services.settings.BluetoothService -e enable 0");
}

/// <summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Testura.Android/Device/Services/ISettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ public interface ISettingsService
/// <param name="state">Wanted state of wifi.</param>
void Wifi(State state);

/// <summary>
/// Enable or disable bluetooth.
/// </summary>
/// <param name="state">Wanted state of bluetooth.</param>
void Bluetooth(State state);

/// <summary>
/// Enable or disable gps.
/// </summary>
Expand Down
10 changes: 9 additions & 1 deletion src/Testura.Android/Device/Ui/Nodes/ScreenDumper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,16 @@ private string GetDump()
if (tries > 0)
{
DeviceLogger.Log($"Failed to dump UI, trying {tries} more times");
Thread.Sleep(1500);
Thread.Sleep(750);
tries--;

if (tries == 0)
{
/* In some cases we get stuck and the server is alive
but we can't dump the UI. So lets stop it once to be safe. */
_server.Stop();
}

continue;
}

Expand Down
Loading

0 comments on commit b1b084e

Please sign in to comment.