summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2012-08-16 16:33:40 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-08-16 16:33:40 -0700
commit050c87f87e2a48c7bc90f5b15fb6e4e37e667286 (patch)
tree814988aae175fa4081aa6d53a91161608cc3646f /core/tests
parentb18bcf13fd47102a2527e599cde0b1d59ab7c51e (diff)
parenta950daf5c14a0009c2c62e9c3e0e8d51eb0cf7d9 (diff)
downloadframeworks_base-050c87f87e2a48c7bc90f5b15fb6e4e37e667286.zip
frameworks_base-050c87f87e2a48c7bc90f5b15fb6e4e37e667286.tar.gz
frameworks_base-050c87f87e2a48c7bc90f5b15fb6e4e37e667286.tar.bz2
am a950daf5: Merge changes Ieb566a2a,I953057cd
* commit 'a950daf5c14a0009c2c62e9c3e0e8d51eb0cf7d9': Use Libcore's stat instead of FileUtils#getFileStatus Use Libcore.os.stat instead of FileUtils
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/src/android/os/FileUtilsTest.java64
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