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

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

Issue 10855039: Cleanup: Remove FileSystemFileUtil::{Directory,Path}Exists (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 8 years, 4 months 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 // This test checks the entire behavior of FileSystem usage and quota, such as: 5 // This test checks the entire behavior of FileSystem usage and quota, such as:
6 // 1) the actual size of files on disk, 6 // 1) the actual size of files on disk,
7 // 2) the described size in .usage, and 7 // 2) the described size in .usage, and
8 // 3) the result of QuotaManager::GetUsageAndQuota. 8 // 3) the result of QuotaManager::GetUsageAndQuota.
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/message_loop.h" 14 #include "base/message_loop.h"
15 #include "base/platform_file.h" 15 #include "base/platform_file.h"
16 #include "base/scoped_temp_dir.h" 16 #include "base/scoped_temp_dir.h"
17 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "webkit/fileapi/file_system_usage_cache.h" 19 #include "webkit/fileapi/file_system_usage_cache.h"
20 #include "webkit/fileapi/file_system_util.h" 20 #include "webkit/fileapi/file_system_util.h"
21 #include "webkit/fileapi/file_util_helper.h"
21 #include "webkit/fileapi/local_file_system_operation.h" 22 #include "webkit/fileapi/local_file_system_operation.h"
22 #include "webkit/fileapi/local_file_system_test_helper.h" 23 #include "webkit/fileapi/local_file_system_test_helper.h"
23 #include "webkit/quota/quota_manager.h" 24 #include "webkit/quota/quota_manager.h"
24 25
25 namespace fileapi { 26 namespace fileapi {
26 27
27 const int kFileOperationStatusNotSet = 1; 28 const int kFileOperationStatusNotSet = 1;
28 29
29 namespace { 30 namespace {
30 31
31 void AssertFileErrorEq(base::PlatformFileError expected, 32 void AssertFileErrorEq(base::PlatformFileError expected,
32 base::PlatformFileError actual) { 33 base::PlatformFileError actual) {
33 ASSERT_EQ(expected, actual); 34 ASSERT_EQ(expected, actual);
34 } 35 }
35 36
36 } // namespace 37 } // namespace
37 38
38 class LocalFileSystemQuotaTest 39 class LocalFileSystemQuotaTest
39 : public testing::Test, 40 : public testing::Test,
40 public base::SupportsWeakPtr<LocalFileSystemQuotaTest> { 41 public base::SupportsWeakPtr<LocalFileSystemQuotaTest> {
41 public: 42 public:
42 LocalFileSystemQuotaTest() 43 LocalFileSystemQuotaTest()
43 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 44 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
44 next_unique_path_suffix_(0), 45 next_unique_path_suffix_(0),
45 status_(kFileOperationStatusNotSet), 46 status_(kFileOperationStatusNotSet),
46 quota_status_(quota::kQuotaStatusUnknown), 47 quota_status_(quota::kQuotaStatusUnknown),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 quota_manager_->GetUsageAndQuota( 95 quota_manager_->GetUsageAndQuota(
95 test_helper_.origin(), test_helper_.storage_type(), 96 test_helper_.origin(), test_helper_.storage_type(),
96 base::Bind(&LocalFileSystemQuotaTest::OnGetUsageAndQuota, 97 base::Bind(&LocalFileSystemQuotaTest::OnGetUsageAndQuota,
97 weak_factory_.GetWeakPtr())); 98 weak_factory_.GetWeakPtr()));
98 MessageLoop::current()->RunAllPending(); 99 MessageLoop::current()->RunAllPending();
99 } 100 }
100 101
101 bool FileExists(const FilePath& virtual_path) { 102 bool FileExists(const FilePath& virtual_path) {
102 FileSystemURL path = test_helper_.CreateURL(virtual_path); 103 FileSystemURL path = test_helper_.CreateURL(virtual_path);
103 scoped_ptr<FileSystemOperationContext> context(NewContext()); 104 scoped_ptr<FileSystemOperationContext> context(NewContext());
104 return file_util()->PathExists(context.get(), path); 105 return FileUtilHelper::PathExists(context.get(), file_util(), path);
105 } 106 }
106 107
107 bool DirectoryExists(const FilePath& virtual_path) { 108 bool DirectoryExists(const FilePath& virtual_path) {
108 FileSystemURL path = test_helper_.CreateURL(virtual_path); 109 FileSystemURL path = test_helper_.CreateURL(virtual_path);
109 scoped_ptr<FileSystemOperationContext> context(NewContext()); 110 scoped_ptr<FileSystemOperationContext> context(NewContext());
110 return file_util()->DirectoryExists(context.get(), path); 111 return FileUtilHelper::DirectoryExists(context.get(), file_util(), path);
111 } 112 }
112 113
113 FilePath CreateUniqueFileInDir(const FilePath& virtual_dir_path) { 114 FilePath CreateUniqueFileInDir(const FilePath& virtual_dir_path) {
114 FilePath file_name = FilePath::FromUTF8Unsafe( 115 FilePath file_name = FilePath::FromUTF8Unsafe(
115 "tmpfile-" + base::IntToString(next_unique_path_suffix_++)); 116 "tmpfile-" + base::IntToString(next_unique_path_suffix_++));
116 FileSystemURL url = test_helper_.CreateURL( 117 FileSystemURL url = test_helper_.CreateURL(
117 virtual_dir_path.Append(file_name)); 118 virtual_dir_path.Append(file_name));
118 119
119 scoped_ptr<FileSystemOperationContext> context(NewContext()); 120 scoped_ptr<FileSystemOperationContext> context(NewContext());
120 bool created; 121 bool created;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 340
340 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, ActualFileSize()); 341 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, ActualFileSize());
341 EXPECT_EQ(expected_usage, SizeByQuotaUtil()); 342 EXPECT_EQ(expected_usage, SizeByQuotaUtil());
342 GetUsageAndQuotaFromQuotaManager(); 343 GetUsageAndQuotaFromQuotaManager();
343 EXPECT_EQ(quota::kQuotaStatusOk, quota_status()); 344 EXPECT_EQ(quota::kQuotaStatusOk, quota_status());
344 EXPECT_EQ(expected_usage, usage()); 345 EXPECT_EQ(expected_usage, usage());
345 ASSERT_LT(expected_usage, quota()); 346 ASSERT_LT(expected_usage, quota());
346 } 347 }
347 348
348 } // namespace fileapi 349 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_system_operation_unittest.cc ('k') | webkit/fileapi/local_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698