OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 // Declared to shorten the variable names. | 34 // Declared to shorten the variable names. |
35 const storage::StorageType kTemporary = storage::kStorageTypeTemporary; | 35 const storage::StorageType kTemporary = storage::kStorageTypeTemporary; |
36 const storage::StorageType kPersistent = storage::kStorageTypePersistent; | 36 const storage::StorageType kPersistent = storage::kStorageTypePersistent; |
37 | 37 |
38 } // namespace | 38 } // namespace |
39 | 39 |
40 class FileSystemQuotaClientTest : public testing::Test { | 40 class FileSystemQuotaClientTest : public testing::Test { |
41 public: | 41 public: |
42 FileSystemQuotaClientTest() | 42 FileSystemQuotaClientTest() |
43 : weak_factory_(this), | 43 : additional_callback_count_(0), |
44 additional_callback_count_(0), | 44 deletion_status_(storage::kQuotaStatusUnknown), |
45 deletion_status_(storage::kQuotaStatusUnknown) {} | 45 weak_factory_(this) {} |
46 | 46 |
47 void SetUp() override { | 47 void SetUp() override { |
48 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 48 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
49 file_system_context_ = CreateFileSystemContextForTesting( | 49 file_system_context_ = CreateFileSystemContextForTesting( |
50 NULL, data_dir_.path()); | 50 NULL, data_dir_.path()); |
51 } | 51 } |
52 | 52 |
53 struct TestFile { | 53 struct TestFile { |
54 bool isDirectory; | 54 bool isDirectory; |
55 const char* name; | 55 const char* name; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 ++additional_callback_count_; | 223 ++additional_callback_count_; |
224 } | 224 } |
225 | 225 |
226 void OnDeleteOrigin(storage::QuotaStatusCode status) { | 226 void OnDeleteOrigin(storage::QuotaStatusCode status) { |
227 deletion_status_ = status; | 227 deletion_status_ = status; |
228 } | 228 } |
229 | 229 |
230 base::ScopedTempDir data_dir_; | 230 base::ScopedTempDir data_dir_; |
231 base::MessageLoop message_loop_; | 231 base::MessageLoop message_loop_; |
232 scoped_refptr<storage::FileSystemContext> file_system_context_; | 232 scoped_refptr<storage::FileSystemContext> file_system_context_; |
233 base::WeakPtrFactory<FileSystemQuotaClientTest> weak_factory_; | |
234 int64 usage_; | 233 int64 usage_; |
235 int additional_callback_count_; | 234 int additional_callback_count_; |
236 std::set<GURL> origins_; | 235 std::set<GURL> origins_; |
237 storage::QuotaStatusCode deletion_status_; | 236 storage::QuotaStatusCode deletion_status_; |
| 237 base::WeakPtrFactory<FileSystemQuotaClientTest> weak_factory_; |
238 | 238 |
239 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClientTest); | 239 DISALLOW_COPY_AND_ASSIGN(FileSystemQuotaClientTest); |
240 }; | 240 }; |
241 | 241 |
242 TEST_F(FileSystemQuotaClientTest, NoFileSystemTest) { | 242 TEST_F(FileSystemQuotaClientTest, NoFileSystemTest) { |
243 scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); | 243 scoped_ptr<FileSystemQuotaClient> quota_client(NewQuotaClient(false)); |
244 | 244 |
245 EXPECT_EQ(0, GetOriginUsage(quota_client.get(), kDummyURL1, kTemporary)); | 245 EXPECT_EQ(0, GetOriginUsage(quota_client.get(), kDummyURL1, kTemporary)); |
246 } | 246 } |
247 | 247 |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 GetOriginUsage(quota_client.get(), | 557 GetOriginUsage(quota_client.get(), |
558 "https://bar.com/", | 558 "https://bar.com/", |
559 kPersistent)); | 559 kPersistent)); |
560 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, | 560 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, |
561 GetOriginUsage(quota_client.get(), | 561 GetOriginUsage(quota_client.get(), |
562 "https://bar.com/", | 562 "https://bar.com/", |
563 kTemporary)); | 563 kTemporary)); |
564 } | 564 } |
565 | 565 |
566 } // namespace content | 566 } // namespace content |
OLD | NEW |