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

Side by Side Diff: content/renderer/dom_storage/dom_storage_cached_area_unittest.cc

Issue 22297005: Move webkit/{browser,common}/dom_storage into content/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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 (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 "content/renderer/dom_storage/dom_storage_cached_area.h" 5 #include "content/renderer/dom_storage/dom_storage_cached_area.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "content/renderer/dom_storage/dom_storage_proxy.h" 11 #include "content/renderer/dom_storage/dom_storage_proxy.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 namespace { 16 namespace {
17 // A mock implementation of the DomStorageProxy interface. 17 // A mock implementation of the DomStorageProxy interface.
18 class MockProxy : public DomStorageProxy { 18 class MockProxy : public DomStorageProxy {
19 public: 19 public:
20 MockProxy() { 20 MockProxy() {
21 ResetObservations(); 21 ResetObservations();
22 } 22 }
23 23
24 // DomStorageProxy interface for use by DomStorageCachedArea. 24 // DomStorageProxy interface for use by DomStorageCachedArea.
25 25
26 virtual void LoadArea(int connection_id, 26 virtual void LoadArea(int connection_id,
27 dom_storage::ValuesMap* values, 27 DOMStorageValuesMap* values,
28 const CompletionCallback& callback) OVERRIDE { 28 const CompletionCallback& callback) OVERRIDE {
29 pending_callbacks_.push_back(callback); 29 pending_callbacks_.push_back(callback);
30 observed_load_area_ = true; 30 observed_load_area_ = true;
31 observed_connection_id_ = connection_id; 31 observed_connection_id_ = connection_id;
32 *values = load_area_return_values_; 32 *values = load_area_return_values_;
33 } 33 }
34 34
35 virtual void SetItem(int connection_id, 35 virtual void SetItem(int connection_id,
36 const base::string16& key, 36 const base::string16& key,
37 const base::string16& value, 37 const base::string16& value,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 } 84 }
85 85
86 void CompleteOnePendingCallback(bool success) { 86 void CompleteOnePendingCallback(bool success) {
87 ASSERT_TRUE(!pending_callbacks_.empty()); 87 ASSERT_TRUE(!pending_callbacks_.empty());
88 pending_callbacks_.front().Run(success); 88 pending_callbacks_.front().Run(success);
89 pending_callbacks_.pop_front(); 89 pending_callbacks_.pop_front();
90 } 90 }
91 91
92 typedef std::list<CompletionCallback> CallbackList; 92 typedef std::list<CompletionCallback> CallbackList;
93 93
94 dom_storage::ValuesMap load_area_return_values_; 94 DOMStorageValuesMap load_area_return_values_;
95 CallbackList pending_callbacks_; 95 CallbackList pending_callbacks_;
96 bool observed_load_area_; 96 bool observed_load_area_;
97 bool observed_set_item_; 97 bool observed_set_item_;
98 bool observed_remove_item_; 98 bool observed_remove_item_;
99 bool observed_clear_area_; 99 bool observed_clear_area_;
100 int observed_connection_id_; 100 int observed_connection_id_;
101 base::string16 observed_key_; 101 base::string16 observed_key_;
102 base::string16 observed_value_; 102 base::string16 observed_value_;
103 GURL observed_page_url_; 103 GURL observed_page_url_;
104 104
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 mock_proxy_->CompleteOnePendingCallback(true); // remove completion 346 mock_proxy_->CompleteOnePendingCallback(true); // remove completion
347 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); 347 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey));
348 348
349 // A failed set item operation should Reset the cache. 349 // A failed set item operation should Reset the cache.
350 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); 350 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl));
351 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); 351 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey));
352 mock_proxy_->CompleteOnePendingCallback(false); 352 mock_proxy_->CompleteOnePendingCallback(false);
353 EXPECT_FALSE(IsPrimed(cached_area.get())); 353 EXPECT_FALSE(IsPrimed(cached_area.get()));
354 } 354 }
355 355
356 } // namespace dom_storage 356 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698