diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-22 01:10:56 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-22 01:10:56 +0000 |
commit | 0c63d3937ca864a8a579e415a986247c1ca1d34c (patch) | |
tree | 34a81af095a69c5e94e06bc4bdedd0b0a9238b82 | |
parent | 286c85cbaaa06491ca28c35be01c1c51a74f0def (diff) | |
parent | 7f7af28681a0586da2e91b07586905cfa83fa4cf (diff) | |
download | csuite-0c63d3937ca864a8a579e415a986247c1ca1d34c.tar.gz |
Snap for 8486043 from 7f7af28681a0586da2e91b07586905cfa83fa4cf to tm-d1-releaseandroid-13.0.0_r9android-13.0.0_r15android-13.0.0_r14android-13.0.0_r13android-13.0.0_r11android-13.0.0_r10android13-d1-s3-releaseandroid13-d1-s2-releaseandroid13-d1-s1-releaseandroid13-d1-release
Change-Id: I0d59fc24f724a21419ed9aedcfe6c942e050e87b
-rw-r--r-- | test_scripts/src/main/java/com/android/webview/tests/WebviewAppLaunchTest.java | 32 |
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 { |