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

Side by Side Diff: content/browser/dom_storage/dom_storage_context_impl_unittest.cc

Issue 259083002: Move mock_special_storage_policy from webkit/ to content/public/test/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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 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/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
12 #include "base/time/time.h" 12 #include "base/time/time.h"
13 #include "content/browser/dom_storage/dom_storage_area.h" 13 #include "content/browser/dom_storage/dom_storage_area.h"
14 #include "content/browser/dom_storage/dom_storage_context_impl.h" 14 #include "content/browser/dom_storage/dom_storage_context_impl.h"
15 #include "content/browser/dom_storage/dom_storage_namespace.h" 15 #include "content/browser/dom_storage/dom_storage_namespace.h"
16 #include "content/browser/dom_storage/dom_storage_task_runner.h" 16 #include "content/browser/dom_storage/dom_storage_task_runner.h"
17 #include "content/public/browser/local_storage_usage_info.h" 17 #include "content/public/browser/local_storage_usage_info.h"
18 #include "content/public/browser/session_storage_namespace.h" 18 #include "content/public/browser/session_storage_namespace.h"
19 #include "content/public/browser/session_storage_usage_info.h" 19 #include "content/public/browser/session_storage_usage_info.h"
20 #include "content/public/test/mock_special_storage_policy.h"
20 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
21 #include "webkit/browser/quota/mock_special_storage_policy.h"
22 22
23 using base::ASCIIToUTF16; 23 using base::ASCIIToUTF16;
24 24
25 namespace content { 25 namespace content {
26 26
27 class DOMStorageContextImplTest : public testing::Test { 27 class DOMStorageContextImplTest : public testing::Test {
28 public: 28 public:
29 DOMStorageContextImplTest() 29 DOMStorageContextImplTest()
30 : kOrigin(GURL("http://dom_storage/")), 30 : kOrigin(GURL("http://dom_storage/")),
31 kKey(ASCIIToUTF16("key")), 31 kKey(ASCIIToUTF16("key")),
32 kValue(ASCIIToUTF16("value")), 32 kValue(ASCIIToUTF16("value")),
33 kDontIncludeFileInfo(false), 33 kDontIncludeFileInfo(false),
34 kDoIncludeFileInfo(true) { 34 kDoIncludeFileInfo(true) {
35 } 35 }
36 36
37 const GURL kOrigin; 37 const GURL kOrigin;
38 const base::string16 kKey; 38 const base::string16 kKey;
39 const base::string16 kValue; 39 const base::string16 kValue;
40 const bool kDontIncludeFileInfo; 40 const bool kDontIncludeFileInfo;
41 const bool kDoIncludeFileInfo; 41 const bool kDoIncludeFileInfo;
42 42
43 virtual void SetUp() { 43 virtual void SetUp() {
44 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 44 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
45 storage_policy_ = new quota::MockSpecialStoragePolicy; 45 storage_policy_ = new MockSpecialStoragePolicy;
46 task_runner_ = 46 task_runner_ =
47 new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get()); 47 new MockDOMStorageTaskRunner(base::MessageLoopProxy::current().get());
48 context_ = new DOMStorageContextImpl(temp_dir_.path(), 48 context_ = new DOMStorageContextImpl(temp_dir_.path(),
49 base::FilePath(), 49 base::FilePath(),
50 storage_policy_.get(), 50 storage_policy_.get(),
51 task_runner_.get()); 51 task_runner_.get());
52 } 52 }
53 53
54 virtual void TearDown() { 54 virtual void TearDown() {
55 base::MessageLoop::current()->RunUntilIdle(); 55 base::MessageLoop::current()->RunUntilIdle();
56 } 56 }
57 57
58 void VerifySingleOriginRemains(const GURL& origin) { 58 void VerifySingleOriginRemains(const GURL& origin) {
59 // Use a new instance to examine the contexts of temp_dir_. 59 // Use a new instance to examine the contexts of temp_dir_.
60 scoped_refptr<DOMStorageContextImpl> context = 60 scoped_refptr<DOMStorageContextImpl> context =
61 new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(), 61 new DOMStorageContextImpl(temp_dir_.path(), base::FilePath(),
62 NULL, NULL); 62 NULL, NULL);
63 std::vector<LocalStorageUsageInfo> infos; 63 std::vector<LocalStorageUsageInfo> infos;
64 context->GetLocalStorageUsage(&infos, kDontIncludeFileInfo); 64 context->GetLocalStorageUsage(&infos, kDontIncludeFileInfo);
65 ASSERT_EQ(1u, infos.size()); 65 ASSERT_EQ(1u, infos.size());
66 EXPECT_EQ(origin, infos[0].origin); 66 EXPECT_EQ(origin, infos[0].origin);
67 } 67 }
68 68
69 protected: 69 protected:
70 base::MessageLoop message_loop_; 70 base::MessageLoop message_loop_;
71 base::ScopedTempDir temp_dir_; 71 base::ScopedTempDir temp_dir_;
72 scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy_; 72 scoped_refptr<MockSpecialStoragePolicy> storage_policy_;
73 scoped_refptr<MockDOMStorageTaskRunner> task_runner_; 73 scoped_refptr<MockDOMStorageTaskRunner> task_runner_;
74 scoped_refptr<DOMStorageContextImpl> context_; 74 scoped_refptr<DOMStorageContextImpl> context_;
75 DISALLOW_COPY_AND_ASSIGN(DOMStorageContextImplTest); 75 DISALLOW_COPY_AND_ASSIGN(DOMStorageContextImplTest);
76 }; 76 };
77 77
78 TEST_F(DOMStorageContextImplTest, Basics) { 78 TEST_F(DOMStorageContextImplTest, Basics) {
79 // This test doesn't do much, checks that the constructor 79 // This test doesn't do much, checks that the constructor
80 // initializes members properly and that invoking methods 80 // initializes members properly and that invoking methods
81 // on a newly created object w/o any data on disk do no harm. 81 // on a newly created object w/o any data on disk do no harm.
82 EXPECT_EQ(temp_dir_.path(), context_->localstorage_directory()); 82 EXPECT_EQ(temp_dir_.path(), context_->localstorage_directory());
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // Verify that the merge was successful. 367 // Verify that the merge was successful.
368 ASSERT_TRUE(alias_ns->alias_master_namespace() == target_ns); 368 ASSERT_TRUE(alias_ns->alias_master_namespace() == target_ns);
369 base::NullableString16 read_value = target_ns_area->GetItem(kKey); 369 base::NullableString16 read_value = target_ns_area->GetItem(kKey);
370 EXPECT_TRUE(!read_value.is_null() && read_value.string() == kValue2); 370 EXPECT_TRUE(!read_value.is_null() && read_value.string() == kValue2);
371 DOMStorageArea* alias_ns_area = alias_ns->OpenStorageArea(kOrigin); 371 DOMStorageArea* alias_ns_area = alias_ns->OpenStorageArea(kOrigin);
372 read_value = alias_ns_area->GetItem(kKey2); 372 read_value = alias_ns_area->GetItem(kKey2);
373 EXPECT_TRUE(!read_value.is_null() && read_value.string() == kKey2Value); 373 EXPECT_TRUE(!read_value.is_null() && read_value.string() == kKey2Value);
374 } 374 }
375 375
376 } // namespace content 376 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/database_tracker_unittest.cc ('k') | content/browser/fileapi/copy_or_move_file_validator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698