diff options
author | Kenny Root <kroot@google.com> | 2012-08-16 11:38:04 -0700 |
---|---|---|
committer | Kenny Root <kroot@google.com> | 2012-08-16 15:27:55 -0700 |
commit | 98e15e78934a00cf46f2be55472b7fd7a39ac0de (patch) | |
tree | 159a05b5baca8a5849aae3e6e5da484ab51719dd /core/tests/coretests | |
parent | 786cbcacd2efbd94476eb05a4d5b77211f20d434 (diff) | |
download | frameworks_base-98e15e78934a00cf46f2be55472b7fd7a39ac0de.zip frameworks_base-98e15e78934a00cf46f2be55472b7fd7a39ac0de.tar.gz frameworks_base-98e15e78934a00cf46f2be55472b7fd7a39ac0de.tar.bz2 |
Use Libcore's stat instead of FileUtils#getFileStatus
Remove the last user of FileUtils#getFileStatus and move it to
Libcore.os.stat instead. Then we can remove the JNI code that does the
equivalent of a stat.
Change-Id: Ieb566a2a8a17c2dd0150724b4eb3ac1cc41c823d
Diffstat (limited to 'core/tests/coretests')
-rw-r--r-- | core/tests/coretests/src/android/os/FileUtilsTest.java | 64 |
1 files changed, 1 insertions, 63 deletions
diff --git a/core/tests/coretests/src/android/os/FileUtilsTest.java b/core/tests/coretests/src/android/os/FileUtilsTest.java index f12cbe1..4d0b892 100644 --- a/core/tests/coretests/src/android/os/FileUtilsTest.java +++ b/core/tests/coretests/src/android/os/FileUtilsTest.java @@ -17,21 +17,13 @@ package android.os; import android.content.Context; -import android.os.FileUtils; -import android.os.FileUtils.FileStatus; import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; -import android.test.suitebuilder.annotation.SmallTest; import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileWriter; -import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.IOException; - -import junit.framework.Assert; +import java.io.FileWriter; public class FileUtilsTest extends AndroidTestCase { private static final String TEST_DATA = @@ -60,60 +52,6 @@ public class FileUtilsTest extends AndroidTestCase { if (mCopyFile.exists()) mCopyFile.delete(); } - @LargeTest - public void testGetFileStatus() { - final byte[] MAGIC = { 0xB, 0xE, 0x0, 0x5 }; - - try { - // truncate test file and write MAGIC (4 bytes) to it. - FileOutputStream os = new FileOutputStream(mTestFile, false); - os.write(MAGIC, 0, 4); - os.flush(); - os.close(); - } catch (FileNotFoundException e) { - Assert.fail("File was removed durning test" + e); - } catch (IOException e) { - Assert.fail("Unexpected IOException: " + e); - } - - Assert.assertTrue(mTestFile.exists()); - Assert.assertTrue(FileUtils.getFileStatus(mTestFile.getPath(), null)); - - FileStatus status1 = new FileStatus(); - FileUtils.getFileStatus(mTestFile.getPath(), status1); - - Assert.assertEquals(4, status1.size); - - // Sleep for at least one second so that the modification time will be different. - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - - try { - // append so we don't change the creation time. - FileOutputStream os = new FileOutputStream(mTestFile, true); - os.write(MAGIC, 0, 4); - os.flush(); - os.close(); - } catch (FileNotFoundException e) { - Assert.fail("File was removed durning test" + e); - } catch (IOException e) { - Assert.fail("Unexpected IOException: " + e); - } - - FileStatus status2 = new FileStatus(); - FileUtils.getFileStatus(mTestFile.getPath(), status2); - - Assert.assertEquals(8, status2.size); - Assert.assertTrue(status2.mtime > status1.mtime); - - mTestFile.delete(); - - Assert.assertFalse(mTestFile.exists()); - Assert.assertFalse(FileUtils.getFileStatus(mTestFile.getPath(), null)); - } - // TODO: test setPermissions(), getPermissions() @MediumTest |