aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-22 03:10:44 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-04-22 03:10:44 +0000
commit66d9d692a318390ba984f4265d1ab42b68b6a5e0 (patch)
tree34a81af095a69c5e94e06bc4bdedd0b0a9238b82
parent73ed770a6cee871e2901e9b36675502891b577a7 (diff)
parentd95541c03fd0e6606fd8a4fc53ae84a39ee2a958 (diff)
downloadcsuite-android13-qpr1-release.tar.gz
Change-Id: I2b44635044d6653df5e82b453512df3867f6214a
-rw-r--r--test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java32
1 files changed, 19 insertions, 13 deletions
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 7cd1718..d08d2e3 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
@@ -110,13 +110,14 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
public void testAppLaunch()
throws DeviceNotAvailableException, ApkInstallerException, IOException {
AssertionError lastError = null;
-
// Try the latest webview version
- installWebview(mOrderedWebviewApks.get(0));
+ WebviewPackage lastWebviewInstalled = installWebview(mOrderedWebviewApks.get(0));
try {
assertAppLaunchNoCrash();
} catch (AssertionError e) {
lastError = e;
+ } finally {
+ uninstallWebview();
}
// If the app doesn't crash, complete the test.
@@ -126,7 +127,6 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
// If the app crashes, try the app with the original webview version that comes with the
// device.
- uninstallWebview();
try {
assertAppLaunchNoCrash();
} catch (AssertionError newError) {
@@ -138,13 +138,14 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
}
for (int idx = 1; idx < mOrderedWebviewApks.size(); idx++) {
- uninstallWebview();
- installWebview(mOrderedWebviewApks.get(idx));
+ lastWebviewInstalled = installWebview(mOrderedWebviewApks.get(idx));
try {
assertAppLaunchNoCrash();
} catch (AssertionError e) {
lastError = e;
continue;
+ } finally {
+ uninstallWebview();
}
break;
}
@@ -152,7 +153,7 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
throw new AssertionError(
String.format(
"Package %s crashed since webview version %s",
- mPackageName, getCurrentWebviewPackage().getVersion()),
+ mPackageName, lastWebviewInstalled.getVersion()),
lastError);
}
@@ -166,8 +167,6 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
deviceUtils.unfreezeRotation();
mApkInstaller.uninstallAllInstalledPackages();
-
- uninstallWebview();
printWebviewVersion();
}
@@ -187,13 +186,18 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
});
}
+ private void printWebviewVersion(WebviewPackage currentWebview)
+ throws DeviceNotAvailableException {
+ CLog.i("Current webview implementation: %s", currentWebview.getPackageName());
+ CLog.i("Current webview version: %s", currentWebview.getVersion());
+ }
+
private void printWebviewVersion() throws DeviceNotAvailableException {
- WebviewPackage impl = getCurrentWebviewPackage();
- CLog.i("Current webview implementation: %s", impl.getPackageName());
- CLog.i("Current webview version: %s", impl.getVersion());
+ WebviewPackage currentWebview = getCurrentWebviewPackage();
+ printWebviewVersion(currentWebview);
}
- private void installWebview(File apk)
+ private WebviewPackage installWebview(File apk)
throws ApkInstallerException, IOException, DeviceNotAvailableException {
ApkInstaller.getInstance(getDevice()).install(apk.toPath());
CommandResult res =
@@ -202,7 +206,9 @@ public class WebviewAppLaunchTest extends BaseHostJUnit4Test {
"cmd webviewupdate set-webview-implementation com.android.webview");
Assert.assertEquals(
"Failed to set webview update: " + res, res.getStatus(), CommandStatus.SUCCESS);
- printWebviewVersion();
+ WebviewPackage currentWebview = getCurrentWebviewPackage();
+ printWebviewVersion(currentWebview);
+ return currentWebview;
}
private void uninstallWebview() throws DeviceNotAvailableException {