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

Side by Side Diff: webkit/fileapi/obfuscated_file_util_unittest.cc

Issue 11359217: Move scoped_temp_dir from base to base/files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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
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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h"
12 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop.h" 14 #include "base/message_loop.h"
14 #include "base/platform_file.h" 15 #include "base/platform_file.h"
15 #include "base/scoped_temp_dir.h"
16 #include "base/sys_string_conversions.h" 16 #include "base/sys_string_conversions.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "webkit/fileapi/file_system_context.h" 18 #include "webkit/fileapi/file_system_context.h"
19 #include "webkit/fileapi/file_system_operation_context.h" 19 #include "webkit/fileapi/file_system_operation_context.h"
20 #include "webkit/fileapi/file_system_task_runners.h" 20 #include "webkit/fileapi/file_system_task_runners.h"
21 #include "webkit/fileapi/file_system_usage_cache.h" 21 #include "webkit/fileapi/file_system_usage_cache.h"
22 #include "webkit/fileapi/file_util_helper.h" 22 #include "webkit/fileapi/file_util_helper.h"
23 #include "webkit/fileapi/local_file_system_test_helper.h" 23 #include "webkit/fileapi/local_file_system_test_helper.h"
24 #include "webkit/fileapi/mock_file_change_observer.h" 24 #include "webkit/fileapi/mock_file_change_observer.h"
25 #include "webkit/fileapi/mock_file_system_options.h" 25 #include "webkit/fileapi/mock_file_system_options.h"
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 EXPECT_TRUE(change_observer()->HasNoChange()); 488 EXPECT_TRUE(change_observer()->HasNoChange());
489 context.reset(NewContext(NULL)); 489 context.reset(NewContext(NULL));
490 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo( 490 EXPECT_EQ(base::PLATFORM_FILE_OK, ofu()->GetFileInfo(
491 context.get(), url, &file_info, &local_path)); 491 context.get(), url, &file_info, &local_path));
492 EXPECT_EQ(file_info.last_modified.ToTimeT(), last_modified_time.ToTimeT()); 492 EXPECT_EQ(file_info.last_modified.ToTimeT(), last_modified_time.ToTimeT());
493 if (is_file) // Directories in OFU don't support atime. 493 if (is_file) // Directories in OFU don't support atime.
494 EXPECT_EQ(file_info.last_accessed.ToTimeT(), last_access_time.ToTimeT()); 494 EXPECT_EQ(file_info.last_accessed.ToTimeT(), last_access_time.ToTimeT());
495 } 495 }
496 496
497 void TestCopyInForeignFileHelper(bool overwrite) { 497 void TestCopyInForeignFileHelper(bool overwrite) {
498 ScopedTempDir source_dir; 498 base::ScopedTempDir source_dir;
499 ASSERT_TRUE(source_dir.CreateUniqueTempDir()); 499 ASSERT_TRUE(source_dir.CreateUniqueTempDir());
500 FilePath root_file_path = source_dir.path(); 500 FilePath root_file_path = source_dir.path();
501 FilePath src_file_path = root_file_path.AppendASCII("file_name"); 501 FilePath src_file_path = root_file_path.AppendASCII("file_name");
502 FileSystemURL dest_url = CreateURLFromUTF8("new file"); 502 FileSystemURL dest_url = CreateURLFromUTF8("new file");
503 int64 src_file_length = 87; 503 int64 src_file_length = 87;
504 504
505 base::PlatformFileError error_code; 505 base::PlatformFileError error_code;
506 bool created = false; 506 bool created = false;
507 int file_flags = base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE; 507 int file_flags = base::PLATFORM_FILE_CREATE | base::PLATFORM_FILE_WRITE;
508 base::PlatformFile file_handle = 508 base::PlatformFile file_handle =
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 int64 ComputeCurrentUsage() { 627 int64 ComputeCurrentUsage() {
628 return test_helper().ComputeCurrentOriginUsage() - 628 return test_helper().ComputeCurrentOriginUsage() -
629 test_helper().ComputeCurrentDirectoryDatabaseUsage(); 629 test_helper().ComputeCurrentDirectoryDatabaseUsage();
630 } 630 }
631 631
632 const LocalFileSystemTestOriginHelper& test_helper() const { 632 const LocalFileSystemTestOriginHelper& test_helper() const {
633 return test_helper_; 633 return test_helper_;
634 } 634 }
635 635
636 private: 636 private:
637 ScopedTempDir data_dir_; 637 base::ScopedTempDir data_dir_;
638 MessageLoop message_loop_; 638 MessageLoop message_loop_;
639 ObfuscatedFileUtil* obfuscated_file_util_; 639 ObfuscatedFileUtil* obfuscated_file_util_;
640 scoped_refptr<quota::QuotaManager> quota_manager_; 640 scoped_refptr<quota::QuotaManager> quota_manager_;
641 scoped_refptr<FileSystemContext> file_system_context_; 641 scoped_refptr<FileSystemContext> file_system_context_;
642 GURL origin_; 642 GURL origin_;
643 fileapi::FileSystemType type_; 643 fileapi::FileSystemType type_;
644 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_; 644 base::WeakPtrFactory<ObfuscatedFileUtilTest> weak_factory_;
645 LocalFileSystemTestOriginHelper test_helper_; 645 LocalFileSystemTestOriginHelper test_helper_;
646 quota::QuotaStatusCode quota_status_; 646 quota::QuotaStatusCode quota_status_;
647 int64 usage_; 647 int64 usage_;
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 EXPECT_TRUE(DirectoryExists(dest_url)); 1405 EXPECT_TRUE(DirectoryExists(dest_url));
1406 context.reset(NewContext(NULL)); 1406 context.reset(NewContext(NULL));
1407 recursive = true; 1407 recursive = true;
1408 ASSERT_EQ(base::PLATFORM_FILE_OK, 1408 ASSERT_EQ(base::PLATFORM_FILE_OK,
1409 FileUtilHelper::Delete(context.get(), ofu(), 1409 FileUtilHelper::Delete(context.get(), ofu(),
1410 dest_url, recursive)); 1410 dest_url, recursive));
1411 EXPECT_FALSE(DirectoryExists(dest_url)); 1411 EXPECT_FALSE(DirectoryExists(dest_url));
1412 } 1412 }
1413 1413
1414 TEST_F(ObfuscatedFileUtilTest, TestMigration) { 1414 TEST_F(ObfuscatedFileUtilTest, TestMigration) {
1415 ScopedTempDir source_dir; 1415 base::ScopedTempDir source_dir;
1416 ASSERT_TRUE(source_dir.CreateUniqueTempDir()); 1416 ASSERT_TRUE(source_dir.CreateUniqueTempDir());
1417 FilePath root_path = source_dir.path().AppendASCII("chrome-pLmnMWXE7NzTFRsn"); 1417 FilePath root_path = source_dir.path().AppendASCII("chrome-pLmnMWXE7NzTFRsn");
1418 ASSERT_TRUE(file_util::CreateDirectory(root_path)); 1418 ASSERT_TRUE(file_util::CreateDirectory(root_path));
1419 1419
1420 test::SetUpRegularTestCases(root_path); 1420 test::SetUpRegularTestCases(root_path);
1421 1421
1422 EXPECT_TRUE(ofu()->MigrateFromOldSandbox(origin(), type(), root_path)); 1422 EXPECT_TRUE(ofu()->MigrateFromOldSandbox(origin(), type(), root_path));
1423 1423
1424 FilePath new_root = 1424 FilePath new_root =
1425 test_directory().AppendASCII("File System").AppendASCII("000").Append( 1425 test_directory().AppendASCII("File System").AppendASCII("000").Append(
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2270 ASSERT_EQ(base::PLATFORM_FILE_OK, 2270 ASSERT_EQ(base::PLATFORM_FILE_OK,
2271 ofu()->CreateOrOpen( 2271 ofu()->CreateOrOpen(
2272 AllowUsageIncrease(-length)->context(), file, 2272 AllowUsageIncrease(-length)->context(), file,
2273 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE, 2273 base::PLATFORM_FILE_OPEN_TRUNCATED | base::PLATFORM_FILE_WRITE,
2274 &file_handle, &created)); 2274 &file_handle, &created));
2275 ASSERT_EQ(0, ComputeTotalFileSize()); 2275 ASSERT_EQ(0, ComputeTotalFileSize());
2276 EXPECT_TRUE(base::ClosePlatformFile(file_handle)); 2276 EXPECT_TRUE(base::ClosePlatformFile(file_handle));
2277 } 2277 }
2278 2278
2279 } // namespace fileapi 2279 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/media/native_media_file_util_unittest.cc ('k') | webkit/fileapi/sandbox_mount_point_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698