diff options
author | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 01:47:58 +0000 |
---|---|---|
committer | kinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 01:47:58 +0000 |
commit | 0e7842ea75600bff6ab719a5bf196b3c5f973d88 (patch) | |
tree | 3bb16be280b7968527b72d6bd33bb6e70c80d068 /webkit/fileapi/file_system_context_unittest.cc | |
parent | c5f29a5ef0ab3cf90faf97f7ae75cf14969fa2fa (diff) | |
download | chromium_src-0e7842ea75600bff6ab719a5bf196b3c5f973d88.zip chromium_src-0e7842ea75600bff6ab719a5bf196b3c5f973d88.tar.gz chromium_src-0e7842ea75600bff6ab719a5bf196b3c5f973d88.tar.bz2 |
Remove FileSystemQuotaManager class
Now that we have SpecialStoragePolicy class and are going to have QuotaFileSystemUtil, I think we're ready to get rid of this class.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6609009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_context_unittest.cc')
-rw-r--r-- | webkit/fileapi/file_system_context_unittest.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/webkit/fileapi/file_system_context_unittest.cc b/webkit/fileapi/file_system_context_unittest.cc new file mode 100644 index 0000000..55dfcd9 --- /dev/null +++ b/webkit/fileapi/file_system_context_unittest.cc @@ -0,0 +1,89 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "webkit/fileapi/file_system_context.h" + +#include "base/basictypes.h" +#include "base/file_path.h" +#include "base/logging.h" +#include "base/message_loop_proxy.h" +#include "base/scoped_ptr.h" +#include "base/string_number_conversions.h" +#include "googleurl/src/gurl.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "webkit/quota/special_storage_policy.h" + +using namespace fileapi; + +namespace { + +static const char* const kTestOrigins[] = { + "https://a.com/", + "http://b.com/", + "http://c.com:1/", + "file:///", +}; + +class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy { + public: + virtual bool IsStorageProtected(const GURL& origin) { + return false; + } + + virtual bool IsStorageUnlimited(const GURL& origin) { + return origin == GURL(kTestOrigins[1]); + } +}; + +scoped_refptr<FileSystemContext> NewFileSystemContext( + bool allow_file_access, + bool unlimited_quota, + scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy) { + return new FileSystemContext(base::MessageLoopProxy::CreateForCurrentThread(), + base::MessageLoopProxy::CreateForCurrentThread(), + special_storage_policy, + FilePath(), false /* is_incognito */, + allow_file_access, unlimited_quota); +} + +} // anonymous namespace + +TEST(FileSystemContextTest, IsStorageUnlimited) { + // Regular cases. + scoped_refptr<FileSystemContext> context( + NewFileSystemContext(false, false, NULL)); + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { + SCOPED_TRACE(testing::Message() << "IsStorageUnlimited w/o policy #" + << i << " " << kTestOrigins[i]); + EXPECT_FALSE(context->IsStorageUnlimited(GURL(kTestOrigins[i]))); + } + + // With allow_file_access=true cases. + context = NewFileSystemContext(true, false, NULL); + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { + SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w " + "allow_file_access=true #" << i << " " << kTestOrigins[i]); + GURL origin(kTestOrigins[i]); + EXPECT_EQ(origin.SchemeIsFile(), context->IsStorageUnlimited(origin)); + } + + // With unlimited_quota=true cases. + context = NewFileSystemContext(false, true, NULL); + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { + SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w " + "unlimited_quota=true #" << i << " " << kTestOrigins[i]); + EXPECT_TRUE(context->IsStorageUnlimited(GURL(kTestOrigins[i]))); + } + + // With SpecialStoragePolicy. + scoped_refptr<TestSpecialStoragePolicy> policy(new TestSpecialStoragePolicy); + context = NewFileSystemContext(false, false, policy); + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestOrigins); ++i) { + SCOPED_TRACE(testing::Message() << "IsStorageUnlimited /w policy #" + << i << " " << kTestOrigins[i]); + GURL origin(kTestOrigins[i]); + EXPECT_EQ(policy->IsStorageUnlimited(origin), + context->IsStorageUnlimited(origin)); + } +} |