Yep, this is an active, unresolved defect with CTS 4.3 r2, r3, and 4.4. It's a flaky test that uses a 10-minute timestamp modification to trigger the expected file sync (see below). If phone & host time zone settings aren't the same, this will fail. You should be able to circumvent by setting your phone to match your host's GMT time zone.
/**
* Test syncing a single file using {@link TestDevice#syncFiles(File, String)}.
*/
public void doTestSyncFiles(String externalStorePath) throws Exception {
String expectedDeviceFilePath = null;
// create temp dir with one temp file
File tmpDir = FileUtil.createTempDir("tmp");
try {
File tmpFile = createTempTestFile(tmpDir);
// set last modified to 10 minutes ago
tmpFile.setLastModified(System.currentTimeMillis() - 10*60*1000);
assertNotNull(externalStorePath);
expectedDeviceFilePath = String.format("%s/%s/%s", externalStorePath,
tmpDir.getName(), tmpFile.getName());
assertTrue(mTestDevice.syncFiles(tmpDir, externalStorePath));
assertTrue(mTestDevice.doesFileExist(expectedDeviceFilePath));
// get 'ls -l' attributes of file which includes timestamp
String origTmpFileStamp = mTestDevice.executeShellCommand(String.format("ls -l %s",
expectedDeviceFilePath));
// now create another file and verify that is synced
File tmpFile2 = createTempTestFile(tmpDir);
tmpFile2.setLastModified(System.currentTimeMillis() - 10*60*1000);
assertTrue(mTestDevice.syncFiles(tmpDir, externalStorePath));
String expectedDeviceFilePath2 = String.format("%s/%s/%s", externalStorePath,
tmpDir.getName(), tmpFile2.getName());
assertTrue(mTestDevice.doesFileExist(expectedDeviceFilePath2));
// verify 1st file timestamp did not change
String unchangedTmpFileStamp = mTestDevice.executeShellCommand(String.format("ls -l %s",
expectedDeviceFilePath));
assertEquals(origTmpFileStamp, unchangedTmpFileStamp);
// now modify 1st file and verify it does change remotely
String testString = "blah";
FileOutputStream stream = new FileOutputStream(tmpFile);
stream.write(testString.getBytes());
stream.close();
assertTrue(mTestDevice.syncFiles(tmpDir, externalStorePath));
String tmpFileContents = mTestDevice.executeShellCommand(String.format("cat %s",
expectedDeviceFilePath));
assertTrue(tmpFileContents.contains(testString));
} finally {
if (expectedDeviceFilePath != null && externalStorePath != null) {
// note that expectedDeviceFilePath has externalStorePath prepended at definition
mTestDevice.executeShellCommand(String.format("rm -r %s", expectedDeviceFilePath));
}
FileUtil.recursiveDelete(tmpDir);
}
}