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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_util_posix.cc ('k') | base/files/file_path.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #include <shlobj.h> 10 #include <shlobj.h>
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after
2312 file_util::VerifyPathControlledByUser( 2312 file_util::VerifyPathControlledByUser(
2313 base_dir_, sub_dir_, uid_, ok_gids_)); 2313 base_dir_, sub_dir_, uid_, ok_gids_));
2314 EXPECT_TRUE( 2314 EXPECT_TRUE(
2315 file_util::VerifyPathControlledByUser( 2315 file_util::VerifyPathControlledByUser(
2316 base_dir_, text_file_, uid_, ok_gids_)); 2316 base_dir_, text_file_, uid_, ok_gids_));
2317 EXPECT_TRUE( 2317 EXPECT_TRUE(
2318 file_util::VerifyPathControlledByUser( 2318 file_util::VerifyPathControlledByUser(
2319 sub_dir_, text_file_, uid_, ok_gids_)); 2319 sub_dir_, text_file_, uid_, ok_gids_));
2320 } 2320 }
2321 2321
2322 #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
2323 TEST_F(FileUtilTest, ContentUriTest) {
2324 // Get the test image path.
2325 FilePath data_dir;
2326 ASSERT_TRUE(PathService::Get(base::DIR_TEST_DATA, &data_dir));
2327 data_dir = data_dir.AppendASCII("file_util");
2328 ASSERT_TRUE(base::PathExists(data_dir));
2329 FilePath image_file = data_dir.Append(FILE_PATH_LITERAL("red.png"));
2330
2331 // Insert the image into MediaStore. MediaStore will do some conversions, and
2332 // return the content URI.
2333 base::FilePath path = file_util::InsertImageIntoMediaStore(image_file);
2334 EXPECT_TRUE(path.IsContentUri());
2335 EXPECT_TRUE(base::PathExists(path));
2336 // The file size may not equal to the input image as MediaStore may convert
2337 // the image.
2338 int64 size;
2339 file_util::GetFileSize(path, &size);
2340 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
2341
2342 // We should be able to read the file.
2343 char* buffer = new char[size];
2344 EXPECT_EQ(-1, file_util::ReadFile(path, buffer, size));
2345 }
2346 #endif
2347
2322 #endif // defined(OS_POSIX) 2348 #endif // defined(OS_POSIX)
2323 2349
2324 } // namespace 2350 } // namespace
OLDNEW
« 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