| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/fileapi/file_system_context.h" | 5 #include "webkit/fileapi/file_system_context.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 TEST(FileSystemContextTest, IsStorageUnlimited) { | 42 TEST(FileSystemContextTest, IsStorageUnlimited) { |
| 43 // Regular cases. | 43 // Regular cases. |
| 44 scoped_refptr<FileSystemContext> context( | 44 scoped_refptr<FileSystemContext> context( |
| 45 NewFileSystemContext(false, false, NULL)); | 45 NewFileSystemContext(false, false, NULL)); |
| 46 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { | 46 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { |
| 47 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited w/o policy #" | 47 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited w/o policy #" |
| 48 << i << " " << kTestOrigins[i]); | 48 << i << " " << kTestOrigins[i]); |
| 49 EXPECT_FALSE(context->IsStorageUnlimited(GURL(kTestOrigins[i]))); | 49 EXPECT_FALSE(context->IsStorageUnlimited(GURL(kTestOrigins[i]))); |
| 50 } | 50 } |
| 51 | 51 |
| 52 // With allow_file_access=true cases. | |
| 53 context = NewFileSystemContext(true, false, NULL); | |
| 54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { | |
| 55 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w " | |
| 56 "allow_file_access=true #" << i << " " << kTestOrigins[i]); | |
| 57 GURL origin(kTestOrigins[i]); | |
| 58 EXPECT_EQ(origin.SchemeIsFile(), context->IsStorageUnlimited(origin)); | |
| 59 } | |
| 60 | |
| 61 // With unlimited_quota=true cases. | 52 // With unlimited_quota=true cases. |
| 62 context = NewFileSystemContext(false, true, NULL); | 53 context = NewFileSystemContext(false, true, NULL); |
| 63 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { | 54 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { |
| 64 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w " | 55 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w " |
| 65 "unlimited_quota=true #" << i << " " << kTestOrigins[i]); | 56 "unlimited_quota=true #" << i << " " << kTestOrigins[i]); |
| 66 EXPECT_TRUE(context->IsStorageUnlimited(GURL(kTestOrigins[i]))); | 57 EXPECT_TRUE(context->IsStorageUnlimited(GURL(kTestOrigins[i]))); |
| 67 } | 58 } |
| 68 | 59 |
| 69 // With SpecialStoragePolicy. | 60 // With SpecialStoragePolicy. |
| 70 scoped_refptr<quota::MockSpecialStoragePolicy> policy( | 61 scoped_refptr<quota::MockSpecialStoragePolicy> policy( |
| 71 new quota::MockSpecialStoragePolicy); | 62 new quota::MockSpecialStoragePolicy); |
| 72 policy->AddUnlimited(GURL(kTestOrigins[1])); | 63 policy->AddUnlimited(GURL(kTestOrigins[1])); |
| 73 | 64 |
| 74 context = NewFileSystemContext(false, false, policy); | 65 context = NewFileSystemContext(false, false, policy); |
| 75 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { | 66 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { |
| 76 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w policy #" | 67 SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w policy #" |
| 77 << i << " " << kTestOrigins[i]); | 68 << i << " " << kTestOrigins[i]); |
| 78 GURL origin(kTestOrigins[i]); | 69 GURL origin(kTestOrigins[i]); |
| 79 EXPECT_EQ(policy->IsStorageUnlimited(origin), | 70 EXPECT_EQ(policy->IsStorageUnlimited(origin), |
| 80 context->IsStorageUnlimited(origin)); | 71 context->IsStorageUnlimited(origin)); |
| 81 } | 72 } |
| 82 } | 73 } |
| 83 | 74 |
| 84 } // namespace fileapi | 75 } // namespace fileapi |
| OLD | NEW |