Skip to content

Commit

Permalink
chore: Deprecate legacy app management helpers (#608)
Browse files Browse the repository at this point in the history
* chore: Deprecate legacy app management helpers

* chore: add link and clearer info on the Obsolete message
  • Loading branch information
Dor-bl authored Apr 29, 2023
1 parent c1ae724 commit 940fd06
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
8 changes: 6 additions & 2 deletions src/Appium.Net/Appium/AppiumCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,18 @@ public class AppiumCommand
"/session/{sessionId}/appium/getPerformanceData"),
new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.GetPerformanceDataTypes,
"/session/{sessionId}/appium/performanceData/types"),

#region (Deprecated) legacy app management

new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.LaunchApp,
"/session/{sessionId}/appium/app/launch"),
new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.CloseApp,
"/session/{sessionId}/appium/app/close"),
new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.ResetApp,
"/session/{sessionId}/appium/app/reset"),

#endregion (Deprecated) legacy app management

new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.BackgroundApp,
"/session/{sessionId}/appium/app/background"),
new AppiumCommand(HttpCommandInfo.PostCommand, AppiumDriverCommand.EndTestCoverage,
Expand All @@ -144,8 +150,6 @@ public class AppiumCommand
"/session/{sessionId}/appium/device/finger_print"),

#endregion Driver Commands



#region (Deprecated) Touch Commands
// TODO: Remove this region once we deprecate the touch actions
Expand Down
5 changes: 3 additions & 2 deletions src/Appium.Net/Appium/AppiumDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,11 @@ public void PushFile(string pathOnDevice, byte[] base64Data) =>
public void PushFile(string pathOnDevice, FileInfo file) =>
AppiumCommandExecutionHelper.PushFile(this, pathOnDevice, file);

[Obsolete("The LaunchApp API is deprecated and will be removed in future versions. Please use ActivateApp instead \r\n See https://github.com/appium/appium/issues/15807")]
public void LaunchApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.LaunchApp);

[Obsolete("The CloseApp API is deprecated and will be removed in future versions. Please use TerminateApp instead \r\n See https://github.com/appium/appium/issues/15807")]
public void CloseApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.CloseApp);

[Obsolete("The ResetApp API is deprecated and will be removed in future versions. Please use TerminateApp & ActivateApp instead \r\n See https://github.com/appium/appium/issues/15807")]
public void ResetApp() => ((IExecuteMethod)this).Execute(AppiumDriverCommand.ResetApp);

public void FingerPrint(int fingerprintId) =>
Expand Down
4 changes: 4 additions & 0 deletions src/Appium.Net/Appium/AppiumDriverCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public class AppiumDriverCommand
/// </summary>
public const string ToggleLocationServices = "toggleLocationServices";

#region (Deprecated) legacy app management

/// <summary>
/// Launch App Command.
/// </summary>
Expand All @@ -158,6 +160,8 @@ public class AppiumDriverCommand
/// </summary>
public const string ResetApp = "resetApp";

#endregion (Deprecated) legacy app management

/// <summary>
/// Background App Command.
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions src/Appium.Net/Appium/Windows/WindowsDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,19 @@ public void PressKeyCode(int keyCode, int metastate = -1) =>

public void LongPressKeyCode(int keyCode, int metastate = -1) =>
AppiumCommandExecutionHelper.LongPressKeyCode(this, keyCode, metastate);

#region App management

public new void LaunchApp()
{
((IExecuteMethod)this).Execute(AppiumDriverCommand.LaunchApp);
}

public new void CloseApp()
{
((IExecuteMethod)this).Execute(AppiumDriverCommand.CloseApp);
}

#endregion App management
}
}
19 changes: 10 additions & 9 deletions test/integration/Android/ActivityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ActivityTest
{
private AndroidDriver _driver;
private const string ContactsActivity = ".activities.PeopleActivity";
private const string AppId = "io.appium.android.apis";

[OneTimeSetUp]
public void BeforeAll()
Expand All @@ -20,41 +21,41 @@ public void BeforeAll()
var serverUri = Env.ServerIsRemote() ? AppiumServers.RemoteServerUri : AppiumServers.LocalServiceUri;
_driver = new AndroidDriver(serverUri, capabilities, Env.InitTimeoutSec);
_driver.Manage().Timeouts().ImplicitWait = Env.ImplicitTimeoutSec;
_driver.CloseApp();
_driver.TerminateApp(AppId);
}

[SetUp]
public void SetUp()
{
_driver?.LaunchApp();
_driver?.ActivateApp(AppId);
}

[TearDown]
public void TearDowwn()
{
_driver?.CloseApp();
_driver.TerminateApp(AppId);
}

[Test]
public void StartActivityInThisAppTestCase()
{
_driver.StartActivity("io.appium.android.apis", ".ApiDemos");
_driver.StartActivity(AppId, ".ApiDemos");

Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");

_driver.StartActivity("io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity");
_driver.StartActivity(AppId, ".accessibility.AccessibilityNodeProviderActivity");

Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");
}

[Test]
public void StartActivityWithWaitingAppTestCase()
{
_driver.StartActivity("io.appium.android.apis", ".ApiDemos", "io.appium.android.apis", ".ApiDemos");
_driver.StartActivity(AppId, ".ApiDemos", AppId, ".ApiDemos");

Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");

_driver.StartActivity("io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity",
_driver.StartActivity(AppId, ".accessibility.AccessibilityNodeProviderActivity",
"io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity");

Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");
Expand All @@ -63,7 +64,7 @@ public void StartActivityWithWaitingAppTestCase()
[Test]
public void StartActivityInNewAppTestCase()
{
_driver.StartActivity("io.appium.android.apis", ".ApiDemos");
_driver.StartActivity(AppId, ".ApiDemos");

Assert.AreEqual(_driver.CurrentActivity, ".ApiDemos");

Expand All @@ -77,7 +78,7 @@ public void StartActivityInNewAppTestCase()
[Test]
public void StartActivityInNewAppTestCaseWithoutClosingApp()
{
_driver.StartActivity("io.appium.android.apis", ".accessibility.AccessibilityNodeProviderActivity");
_driver.StartActivity(AppId, ".accessibility.AccessibilityNodeProviderActivity");

Assert.AreEqual(_driver.CurrentActivity, ".accessibility.AccessibilityNodeProviderActivity");

Expand Down

0 comments on commit 940fd06

Please sign in to comment.