Index: base/file_util_unittest.cc |
diff --git a/base/file_util_unittest.cc b/base/file_util_unittest.cc |
index 1ca70b4f899d45e4b9db03d64bbafc6f0cc408e1..edc8f7d5a6bb71a05fb332492a6fa150d526f580 100644 |
--- a/base/file_util_unittest.cc |
+++ b/base/file_util_unittest.cc |
@@ -2319,6 +2319,32 @@ TEST_F(VerifyPathControlledByUserTest, WriteBitChecks) { |
sub_dir_, text_file_, uid_, ok_gids_)); |
} |
+#if defined(OS_ANDROID) |
mmenke
2013/11/07 16:31:55
Test suggestion: Test the case where we get an er
mmenke
2013/11/07 16:31:55
Test suggestion: I'd like a net test that uses a
qinmin
2013/11/08 23:03:03
Done.
qinmin
2013/11/08 23:03:03
added a test in net/ for file_stream.
On 2013/11/0
|
+TEST_F(FileUtilTest, ContentUriTest) { |
+ // Get the test image path. |
+ FilePath data_dir; |
+ ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir)); |
+ data_dir = data_dir.AppendASCII("file_util"); |
+ ASSERT_TRUE(base::PathExists(data_dir)); |
+ FilePath image_file = data_dir.Append(FILE_PATH_LITERAL("red.png")); |
+ |
+ // Insert the image into MediaStore. MediaStore will do some conversions, and |
+ // return the content URI. |
+ base::FilePath path = file_util::InsertImageIntoMediaStore(image_file); |
+ EXPECT_TRUE(path.IsContentUri()); |
+ EXPECT_TRUE(base::PathExists(path)); |
+ // The file size may not equal to the input image as MediaStore may convert |
+ // the image. |
+ int64 size; |
+ file_util::GetFileSize(path, &size); |
+ EXPECT_LT(0, size); |
mmenke
2013/11/07 16:31:55
Suggest reading a non-zero size file and checking
qinmin
2013/11/08 23:03:03
The android mediastore won't accept empty file. Ad
|
+ |
+ // We should be able to read the file. |
+ char* buffer = new char[size]; |
+ EXPECT_EQ(-1, file_util::ReadFile(path, buffer, size)); |
+} |
+#endif |
+ |
#endif // defined(OS_POSIX) |
} // namespace |