Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2838)

Unified Diff: base/file_util_unittest.cc

Issue 46303005: Fix chrome upload with content uri (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding unittests Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/file_util_posix.cc ('k') | base/files/file_path.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « base/file_util_posix.cc ('k') | base/files/file_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698