OMS: stabilize unit tests

- Add hasCode=false to overlay packages as a workaround for b/124375490

- Sprinkle Thread.sleeps in InstallOverlayTests in an attempt to make
  the tests less flakey when executed on emulator

Test: atest OverlayDeviceTests OverlayHostTests
Change-Id: I745a8477ed5e72db572737a0af0e59478893e42b
This commit is contained in:
Mårten Kongstad 2019-02-22 10:10:14 +01:00 committed by Todd Kennedy
parent 01f07e5fb7
commit bf08f0a4eb
13 changed files with 26 additions and 0 deletions

View File

@ -16,6 +16,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="test.overlay">
<application android:hasCode="false"/>
<overlay
android:targetPackage="test.target"
android:targetName="TestResources"/>

View File

@ -16,6 +16,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="test.overlay.system">
<application android:hasCode="false"/>
<overlay
android:targetPackage="test.target"
android:targetName="TestResources"/>

View File

@ -16,6 +16,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="test.overlay.system.invalid">
<application android:hasCode="false"/>
<overlay
android:targetPackage="test.target"
android:targetName="TestResources"/>

View File

@ -16,6 +16,7 @@
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="test.overlay.system">
<application android:hasCode="false"/>
<overlay
android:targetPackage="test.target"
android:targetName="TestResources"/>

View File

@ -18,5 +18,6 @@
package="com.android.overlaytest.app_overlay_one"
android:versionCode="1"
android:versionName="1.0">
<application android:hasCode="false" />
<overlay android:targetPackage="com.android.overlaytest" android:priority="1" />
</manifest>

View File

@ -18,5 +18,6 @@
package="com.android.overlaytest.app_overlay_two"
android:versionCode="1"
android:versionName="1.0">
<application android:hasCode="false" />
<overlay android:targetPackage="com.android.overlaytest" android:priority="2" />
</manifest>

View File

@ -18,5 +18,6 @@
package="com.android.overlaytest.framework"
android:versionCode="1"
android:versionName="1.0">
<application android:hasCode="false" />
<overlay android:targetPackage="android" android:priority="1" />
</manifest>

View File

@ -155,12 +155,26 @@ public class InstallOverlayTests extends BaseHostJUnit4Test {
}
}
private void delay() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
private void installPackage(String pkg) throws Exception {
super.installPackage(pkg);
delay();
}
private void setPackageEnabled(String pkg, boolean enabled) throws Exception {
getDevice().executeShellCommand("cmd package " + (enabled ? "enable " : "disable ") + pkg);
delay();
}
private void setOverlayEnabled(String pkg, boolean enabled) throws Exception {
getDevice().executeShellCommand("cmd overlay " + (enabled ? "enable " : "disable ") + pkg);
delay();
}
private boolean overlayManagerContainsPackage(String pkg) throws Exception {

View File

@ -16,5 +16,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.server.om.hosttest.signature_overlay">
<application android:hasCode="false" />
<overlay android:targetPackage="android" />
</manifest>

View File

@ -16,5 +16,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.server.om.hosttest.signature_overlay">
<application android:hasCode="false" />
<overlay android:targetPackage="android" android:isStatic="true" />
</manifest>

View File

@ -16,5 +16,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.server.om.hosttest.app_overlay">
<application android:hasCode="false" />
<overlay android:targetPackage="com.android.server.om.hosttest.update_overlay_test" />
</manifest>

View File

@ -16,6 +16,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.server.om.hosttest.app_overlay">
<application android:hasCode="false" />
<overlay android:targetPackage="com.android.server.om.hosttest.update_overlay_test"
android:category="android.theme" />
</manifest>

View File

@ -16,5 +16,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.server.om.hosttest.framework_overlay">
<application android:hasCode="false" />
<overlay android:targetPackage="android" />
</manifest>