summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Fuller <nfuller@google.com>2017-11-22 21:43:19 +0000
committerNeil Fuller <nfuller@google.com>2017-11-27 09:38:32 +0000
commit8ee1a59b6cc83513b1e1d3e59594940cbef8bed4 (patch)
tree6a241367f6d0c4e05a2737f7d345dfd478075157
parentf40c3b96f2188b5e010cc0a6c53328912e36e22f (diff)
downloadTimeZoneData-8ee1a59b6cc83513b1e1d3e59594940cbef8bed4.tar.gz
Address TODOs and deflake TimeZoneUpdateHostTest
This commit removes a couple of TODOs that were previously awaiting an AOSP push. The delay on conditions has also been increased as the test appears to be flaky and particularly unreliable on eng builds. Test: Ran PtsTimeZoneTestCases internally / built on AOSP Test: atest PtsTimeZoneTestCases Bug: 64015928 Bug: 68868666 Bug: 67833617 Change-Id: I6ca599cd0554f8a44c3e17ecd05bd33920da5ec0
-rw-r--r--testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java57
1 files changed, 35 insertions, 22 deletions
diff --git a/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java b/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
index 68fabc1..85c6019 100644
--- a/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
+++ b/testing/xts/src/com/android/timezone/xts/TimeZoneUpdateHostTest.java
@@ -20,13 +20,24 @@ import com.android.tradefed.build.IBuildInfo;
import com.android.tradefed.config.Option;
import com.android.tradefed.device.ITestDevice;
import com.android.tradefed.log.LogUtil;
-import com.android.tradefed.testtype.DeviceTestCase;
+import com.android.tradefed.testtype.DeviceJUnit4ClassRunner;
import com.android.tradefed.testtype.IBuildReceiver;
+import com.android.tradefed.testtype.IDeviceTest;
import com.android.tradefed.util.FileUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.File;
import java.util.function.BooleanSupplier;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Class for host-side tests that the time zone rules update feature works as intended. This is
* intended to give confidence to OEMs that they have implemented / configured the OEM parts of the
@@ -49,9 +60,8 @@ import java.util.function.BooleanSupplier;
* This test attempts to handle both of these cases.
*
*/
-// TODO(nfuller): Switch this to JUnit4 when HostTest supports @Option with JUnit4.
-// http://b/64015928
-public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildReceiver {
+@RunWith(DeviceJUnit4ClassRunner.class)
+public class TimeZoneUpdateHostTest implements IDeviceTest, IBuildReceiver {
// These must match equivalent values in RulesManagerService dumpsys code.
private static final String STAGED_OPERATION_NONE = "None";
@@ -60,6 +70,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
private static final String INSTALL_STATE_INSTALLED = "Installed";
private IBuildInfo mBuildInfo;
+ private ITestDevice mDevice;
private File mTempDir;
@Option(name = "oem-data-app-package-name",
@@ -90,28 +101,34 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
}
@Override
+ public void setDevice(ITestDevice device) {
+ mDevice = device;
+ }
+
+ @Override
+ public ITestDevice getDevice() {
+ return mDevice;
+ }
+
+ @Before
public void setUp() throws Exception {
- super.setUp();
createTempDir();
resetDeviceToClean();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
resetDeviceToClean();
deleteTempDir();
- super.tearDown();
}
- // @Before
- public void createTempDir() throws Exception {
+ private void createTempDir() throws Exception {
mTempDir = File.createTempFile("timeZoneUpdateTest", null);
assertTrue(mTempDir.delete());
assertTrue(mTempDir.mkdir());
}
- // @After
- public void deleteTempDir() throws Exception {
+ private void deleteTempDir() throws Exception {
FileUtil.recursiveDelete(mTempDir);
}
@@ -119,9 +136,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
* Reset the device to having no installed time zone data outside of the /system/priv-app
* version that came with the system image.
*/
- // @Before
- // @After
- public void resetDeviceToClean() throws Exception {
+ private void resetDeviceToClean() throws Exception {
// If this fails the data app isn't present on device. No point in starting.
assertTrue(getTimeZoneDataPackageName() + " not installed",
isPackageInstalled(getTimeZoneDataPackageName()));
@@ -160,7 +175,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
assertEquals(STAGED_OPERATION_NONE, getStagedOperationType());
}
- // @Test
+ @Test
public void testInstallNewerRulesVersion() throws Exception {
// This information must match the rules version in test1: IANA version=2030a, revision=1
String test1VersionInfo = "2030a,1";
@@ -186,7 +201,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
assertEquals(test1VersionInfo, getCurrentInstalledVersion());
}
- // @Test
+ @Test
public void testInstallNewerRulesVersion_secondaryUser() throws Exception {
ITestDevice device = getDevice();
if (!device.isMultiUserSupported()) {
@@ -228,7 +243,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
}
}
- // @Test
+ @Test
public void testInstallOlderRulesVersion() throws Exception {
File appFile = getTimeZoneDataApkFile("test2");
getDevice().installPackage(appFile, true /* reinstall */);
@@ -331,7 +346,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
private static void waitForCondition(BooleanSupplier condition) throws Exception {
int count = 0;
boolean lastResult;
- while (!(lastResult = condition.getAsBoolean()) && count++ < 30) {
+ while (!(lastResult = condition.getAsBoolean()) && count++ < 120) {
Thread.sleep(1000);
}
// Some conditions may not be stable so using the lastResult instead of
@@ -389,9 +404,7 @@ public class TimeZoneUpdateHostTest extends DeviceTestCase implements IBuildRece
private File getTimeZoneDataApkFile(String testId) throws Exception {
CompatibilityBuildHelper buildHelper = new CompatibilityBuildHelper(mBuildInfo);
String fileName = getTimeZoneDataApkName(testId);
-
- // TODO(nfuller): Replace with getTestFile(fileName) when it's available in aosp/master.
- return new File(buildHelper.getTestsDir(), fileName);
+ return buildHelper.getTestFile(fileName);
}
private boolean isPackageInstalled(String pkg) throws Exception {