OLD | NEW |
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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
11 #include "base/platform_file.h" | 11 #include "base/platform_file.h" |
12 #include "googleurl/src/gurl.h" | 12 #include "googleurl/src/gurl.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "webkit/fileapi/external_mount_points.h" | |
15 #include "webkit/fileapi/file_system_context.h" | 14 #include "webkit/fileapi/file_system_context.h" |
16 #include "webkit/fileapi/file_system_operation_context.h" | 15 #include "webkit/fileapi/file_system_operation_context.h" |
17 #include "webkit/fileapi/file_system_quota_client.h" | 16 #include "webkit/fileapi/file_system_quota_client.h" |
18 #include "webkit/fileapi/file_system_task_runners.h" | |
19 #include "webkit/fileapi/file_system_types.h" | 17 #include "webkit/fileapi/file_system_types.h" |
20 #include "webkit/fileapi/file_system_usage_cache.h" | 18 #include "webkit/fileapi/file_system_usage_cache.h" |
21 #include "webkit/fileapi/file_system_util.h" | 19 #include "webkit/fileapi/file_system_util.h" |
22 #include "webkit/fileapi/mock_file_system_options.h" | 20 #include "webkit/fileapi/mock_file_system_context.h" |
23 #include "webkit/fileapi/obfuscated_file_util.h" | 21 #include "webkit/fileapi/obfuscated_file_util.h" |
24 #include "webkit/fileapi/sandbox_mount_point_provider.h" | 22 #include "webkit/fileapi/sandbox_mount_point_provider.h" |
25 #include "webkit/quota/quota_types.h" | 23 #include "webkit/quota/quota_types.h" |
26 | 24 |
27 namespace fileapi { | 25 namespace fileapi { |
28 namespace { | 26 namespace { |
29 | 27 |
30 const char kDummyURL1[] = "http://www.dummy.org"; | 28 const char kDummyURL1[] = "http://www.dummy.org"; |
31 const char kDummyURL2[] = "http://www.example.com"; | 29 const char kDummyURL2[] = "http://www.example.com"; |
32 const char kDummyURL3[] = "http://www.bleh"; | 30 const char kDummyURL3[] = "http://www.bleh"; |
33 | 31 |
34 // Declared to shorten the variable names. | 32 // Declared to shorten the variable names. |
35 const quota::StorageType kTemporary = quota::kStorageTypeTemporary; | 33 const quota::StorageType kTemporary = quota::kStorageTypeTemporary; |
36 const quota::StorageType kPersistent = quota::kStorageTypePersistent; | 34 const quota::StorageType kPersistent = quota::kStorageTypePersistent; |
37 | 35 |
38 } // namespace | 36 } // namespace |
39 | 37 |
40 class FileSystemQuotaClientTest : public testing::Test { | 38 class FileSystemQuotaClientTest : public testing::Test { |
41 public: | 39 public: |
42 FileSystemQuotaClientTest() | 40 FileSystemQuotaClientTest() |
43 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 41 : weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
44 additional_callback_count_(0), | 42 additional_callback_count_(0), |
45 deletion_status_(quota::kQuotaStatusUnknown) { | 43 deletion_status_(quota::kQuotaStatusUnknown) { |
46 } | 44 } |
47 | 45 |
48 virtual void SetUp() { | 46 virtual void SetUp() { |
49 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 47 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
50 file_system_context_ = | 48 file_system_context_ = CreateFileSystemContextForTesting( |
51 new FileSystemContext( | 49 NULL, data_dir_.path()); |
52 FileSystemTaskRunners::CreateMockTaskRunners(), | |
53 ExternalMountPoints::CreateRefCounted().get(), | |
54 NULL, NULL, | |
55 data_dir_.path(), | |
56 CreateDisallowFileAccessOptions()); | |
57 } | 50 } |
58 | 51 |
59 struct TestFile { | 52 struct TestFile { |
60 bool isDirectory; | 53 bool isDirectory; |
61 const char* name; | 54 const char* name; |
62 int64 size; | 55 int64 size; |
63 const char* origin_url; | 56 const char* origin_url; |
64 quota::StorageType type; | 57 quota::StorageType type; |
65 }; | 58 }; |
66 | 59 |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 GetOriginUsage(quota_client.get(), | 579 GetOriginUsage(quota_client.get(), |
587 "https://bar.com/", | 580 "https://bar.com/", |
588 kPersistent)); | 581 kPersistent)); |
589 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, | 582 EXPECT_EQ(64 + file_paths_cost_temporary_bar_https, |
590 GetOriginUsage(quota_client.get(), | 583 GetOriginUsage(quota_client.get(), |
591 "https://bar.com/", | 584 "https://bar.com/", |
592 kTemporary)); | 585 kTemporary)); |
593 } | 586 } |
594 | 587 |
595 } // namespace fileapi | 588 } // namespace fileapi |
OLD | NEW |