2014-01-11 4 views
1

com.android.cts.aadb.TestDeviceFuncTest # testSyncFiles_normal СБОЙAndroid 4.3_r2 CTS com.android.cts.aadb.TestDeviceFuncTest # testSyncFiles_normal СБОЙ

junit.framework.AssertionFailedError 
at junit.framework.Assert.fail(Assert.java:48) 
at junit.framework.Assert.assertTrue(Assert.java:20) 
at junit.framework.Assert.assertTrue(Assert.java:27) 
at com.android.cts.aadb.TestDeviceFuncTest.doTestSyncFiles(TestDeviceFuncTest.java:290) 
at com.android.cts.aadb.TestDeviceFuncTest.testSyncFiles_normal(TestDeviceFuncTest.java:234) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
at java.lang.reflect.Method.invoke(Method.java:597) 

Исходный код:

[http://androidxref.com/4.3_r2.1/xref/cts/hostsidetests/aadb/src/com/android/cts/aadb/TestDeviceFuncTest.java][1] 

База на мой отладочный контент tempFile не синхронизируется с устройством, хотя возвращаемое значение syncFiles истинно.

http://source.android.com/reference/com/android/tradefed/device/ITestDevice.html#syncFiles(java.io.File, java.lang.String)

Любой орган может дать мне посоветуете? Большое спасибо.

ответ

0

Да, это active, unresolved defect с CTS 4.3 r2, r3 и 4.4. Это непрозрачный тест, который использует 10-minute timestamp modification для запуска ожидаемой синхронизации файлов (см. Ниже). Если параметры телефона & не совпадают, это не удастся. Вы должны уклониться от 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); 
    } 
}