aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRakib M. Hasan <rmhasan@google.com>2023-03-20 21:33:09 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2023-03-20 21:33:09 +0000
commit4ec83ec4e0c2d0ed3fc6733e8b7ad03e6d4b9d21 (patch)
treeb00c20d8c8344fc92fe0b2ef5b8e5d110b5aa4b7
parentaff87353780fdf65864b779c55671c44882d5850 (diff)
parent5da47c3bc15ba3b3d40b003ddbd01e2b84a4c8bf (diff)
downloadcsuite-4ec83ec4e0c2d0ed3fc6733e8b7ad03e6d4b9d21.tar.gz
Webview: Retrieve the test device from the TestInformation instance am: 08ea0137c6 am: 8e63ce468a am: 5da47c3bc1
Original change: https://android-review.googlesource.com/c/platform/test/app_compat/csuite/+/2494735 Change-Id: Ifc3313bc4808f272c328028ba8c812b3448ad3cd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--test_scripts/src/main/java/com/android/webview/lib/WebviewInstallerToolPreparer.java4
-rw-r--r--test_scripts/src/main/java/com/android/webview/lib/WebviewUtils.java23
-rw-r--r--test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java2
3 files changed, 14 insertions, 15 deletions
diff --git a/test_scripts/src/main/java/com/android/webview/lib/WebviewInstallerToolPreparer.java b/test_scripts/src/main/java/com/android/webview/lib/WebviewInstallerToolPreparer.java
index 8cc82f2..349cd78 100644
--- a/test_scripts/src/main/java/com/android/webview/lib/WebviewInstallerToolPreparer.java
+++ b/test_scripts/src/main/java/com/android/webview/lib/WebviewInstallerToolPreparer.java
@@ -18,7 +18,6 @@ package com.android.webview.tests;
import com.android.tradefed.config.Option;
import com.android.tradefed.config.Option.Importance;
-import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.targetprep.ITargetPreparer;
import com.android.tradefed.targetprep.TargetSetupError;
@@ -67,7 +66,6 @@ public class WebviewInstallerToolPreparer implements ITargetPreparer {
public static CommandResult runWebviewInstallerToolCommand(
TestInformation testInformation,
- ITestDevice device,
@Nullable String webviewVersion,
@Nullable String releaseChannel,
List<String> extraArgs) {
@@ -80,7 +78,7 @@ public class WebviewInstallerToolPreparer implements ITargetPreparer {
getWebviewInstallerToolPath(testInformation),
"--non-next",
"--serial",
- device.getSerialNumber(),
+ testInformation.getDevice().getSerialNumber(),
"-vvv",
"--gsutil",
Paths.get(
diff --git a/test_scripts/src/main/java/com/android/webview/lib/WebviewUtils.java b/test_scripts/src/main/java/com/android/webview/lib/WebviewUtils.java
index 0774b23..2d47066 100644
--- a/test_scripts/src/main/java/com/android/webview/lib/WebviewUtils.java
+++ b/test_scripts/src/main/java/com/android/webview/lib/WebviewUtils.java
@@ -17,7 +17,6 @@
package com.android.webview.tests;
import com.android.tradefed.device.DeviceNotAvailableException;
-import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.invoker.TestInformation;
import com.android.tradefed.log.LogUtil.CLog;
import com.android.tradefed.util.CommandResult;
@@ -35,11 +34,9 @@ import java.util.Arrays;
import java.util.List;
public class WebviewUtils {
- private ITestDevice mTestDevice;
private TestInformation mTestInformation;
- public WebviewUtils(ITestDevice device, TestInformation testInformation) {
- mTestDevice = device;
+ public WebviewUtils(TestInformation testInformation) {
mTestInformation = testInformation;
}
@@ -65,7 +62,7 @@ public class WebviewUtils {
}
CommandResult commandResult =
WebviewInstallerToolPreparer.runWebviewInstallerToolCommand(
- mTestInformation, mTestDevice, webviewVersion, releaseChannel, extraArgs);
+ mTestInformation, webviewVersion, releaseChannel, extraArgs);
Assert.assertEquals(
"The WebView installer tool failed to install WebView:\n"
@@ -102,23 +99,27 @@ public class WebviewUtils {
webviewPackage,
preInstalledWebviewPackage);
updateWebviewImplementation(preInstalledWebviewPackage.getPackageName());
- mTestDevice.executeAdbCommand("uninstall", webviewPackage.getPackageName());
+ mTestInformation
+ .getDevice()
+ .executeAdbCommand("uninstall", webviewPackage.getPackageName());
printWebviewVersion();
}
private void updateWebviewImplementation(String webviewPackageName)
throws DeviceNotAvailableException {
CommandResult res =
- mTestDevice.executeShellV2Command(
- String.format(
- "cmd webviewupdate set-webview-implementation %s",
- webviewPackageName));
+ mTestInformation
+ .getDevice()
+ .executeShellV2Command(
+ String.format(
+ "cmd webviewupdate set-webview-implementation %s",
+ webviewPackageName));
Assert.assertEquals(
"Failed to set webview update: " + res, res.getStatus(), CommandStatus.SUCCESS);
}
public WebviewPackage getCurrentWebviewPackage() throws DeviceNotAvailableException {
- String dumpsys = mTestDevice.executeShellCommand("dumpsys webviewupdate");
+ String dumpsys = mTestInformation.getDevice().executeShellCommand("dumpsys webviewupdate");
return WebviewPackage.buildFromDumpsys(dumpsys);
}
diff --git a/test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java b/test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java
index c285308..a8f72d1 100644
--- a/test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java
+++ b/test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java
@@ -93,7 +93,7 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
mWebviewVersionToTest != null || mReleaseChannel != null);
mApkInstaller = ApkInstaller.getInstance(getDevice());
- mWebviewUtils = new WebviewUtils(getDevice(), getTestInformation());
+ mWebviewUtils = new WebviewUtils(getTestInformation());
mPreInstalledWebview = mWebviewUtils.getCurrentWebviewPackage();
for (File apkPath : mApkPaths) {