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

Side by Side Diff: webkit/dom_storage/dom_storage_cached_area_unittest.cc

Issue 13219005: Replace string16 with base::string16 in src/webkit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 <list> 5 #include <list>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "webkit/dom_storage/dom_storage_cached_area.h" 10 #include "webkit/dom_storage/dom_storage_cached_area.h"
(...skipping 12 matching lines...) Expand all
23 // DomStorageProxy interface for use by DomStorageCachedArea. 23 // DomStorageProxy interface for use by DomStorageCachedArea.
24 24
25 virtual void LoadArea(int connection_id, ValuesMap* values, 25 virtual void LoadArea(int connection_id, ValuesMap* values,
26 const CompletionCallback& callback) OVERRIDE { 26 const CompletionCallback& callback) OVERRIDE {
27 pending_callbacks_.push_back(callback); 27 pending_callbacks_.push_back(callback);
28 observed_load_area_ = true; 28 observed_load_area_ = true;
29 observed_connection_id_ = connection_id; 29 observed_connection_id_ = connection_id;
30 *values = load_area_return_values_; 30 *values = load_area_return_values_;
31 } 31 }
32 32
33 virtual void SetItem(int connection_id, const string16& key, 33 virtual void SetItem(int connection_id, const base::string16& key,
34 const string16& value, const GURL& page_url, 34 const base::string16& value, const GURL& page_url,
35 const CompletionCallback& callback) OVERRIDE { 35 const CompletionCallback& callback) OVERRIDE {
36 pending_callbacks_.push_back(callback); 36 pending_callbacks_.push_back(callback);
37 observed_set_item_ = true; 37 observed_set_item_ = true;
38 observed_connection_id_ = connection_id; 38 observed_connection_id_ = connection_id;
39 observed_key_ = key; 39 observed_key_ = key;
40 observed_value_ = value; 40 observed_value_ = value;
41 observed_page_url_ = page_url; 41 observed_page_url_ = page_url;
42 } 42 }
43 43
44 virtual void RemoveItem(int connection_id, const string16& key, 44 virtual void RemoveItem(int connection_id, const base::string16& key,
45 const GURL& page_url, 45 const GURL& page_url,
46 const CompletionCallback& callback) OVERRIDE { 46 const CompletionCallback& callback) OVERRIDE {
47 pending_callbacks_.push_back(callback); 47 pending_callbacks_.push_back(callback);
48 observed_remove_item_ = true; 48 observed_remove_item_ = true;
49 observed_connection_id_ = connection_id; 49 observed_connection_id_ = connection_id;
50 observed_key_ = key; 50 observed_key_ = key;
51 observed_page_url_ = page_url; 51 observed_page_url_ = page_url;
52 } 52 }
53 53
54 virtual void ClearArea(int connection_id, 54 virtual void ClearArea(int connection_id,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 typedef std::list<CompletionCallback> CallbackList; 87 typedef std::list<CompletionCallback> CallbackList;
88 88
89 ValuesMap load_area_return_values_; 89 ValuesMap load_area_return_values_;
90 CallbackList pending_callbacks_; 90 CallbackList pending_callbacks_;
91 bool observed_load_area_; 91 bool observed_load_area_;
92 bool observed_set_item_; 92 bool observed_set_item_;
93 bool observed_remove_item_; 93 bool observed_remove_item_;
94 bool observed_clear_area_; 94 bool observed_clear_area_;
95 int observed_connection_id_; 95 int observed_connection_id_;
96 string16 observed_key_; 96 base::string16 observed_key_;
97 string16 observed_value_; 97 base::string16 observed_value_;
98 GURL observed_page_url_; 98 GURL observed_page_url_;
99 99
100 private: 100 private:
101 virtual ~MockProxy() {} 101 virtual ~MockProxy() {}
102 }; 102 };
103 } // namespace 103 } // namespace
104 104
105 class DomStorageCachedAreaTest : public testing::Test { 105 class DomStorageCachedAreaTest : public testing::Test {
106 public: 106 public:
107 DomStorageCachedAreaTest() 107 DomStorageCachedAreaTest()
108 : kNamespaceId(10), 108 : kNamespaceId(10),
109 kOrigin("http://dom_storage/"), 109 kOrigin("http://dom_storage/"),
110 kKey(ASCIIToUTF16("key")), 110 kKey(ASCIIToUTF16("key")),
111 kValue(ASCIIToUTF16("value")), 111 kValue(ASCIIToUTF16("value")),
112 kPageUrl("http://dom_storage/page") { 112 kPageUrl("http://dom_storage/page") {
113 } 113 }
114 114
115 const int64 kNamespaceId; 115 const int64 kNamespaceId;
116 const GURL kOrigin; 116 const GURL kOrigin;
117 const string16 kKey; 117 const base::string16 kKey;
118 const string16 kValue; 118 const base::string16 kValue;
119 const GURL kPageUrl; 119 const GURL kPageUrl;
120 120
121 virtual void SetUp() { 121 virtual void SetUp() {
122 mock_proxy_ = new MockProxy(); 122 mock_proxy_ = new MockProxy();
123 } 123 }
124 124
125 bool IsPrimed(DomStorageCachedArea* cached_area) { 125 bool IsPrimed(DomStorageCachedArea* cached_area) {
126 return cached_area->map_.get(); 126 return cached_area->map_.get();
127 } 127 }
128 128
129 bool IsIgnoringAllMutations(DomStorageCachedArea* cached_area) { 129 bool IsIgnoringAllMutations(DomStorageCachedArea* cached_area) {
130 return cached_area->ignore_all_mutations_; 130 return cached_area->ignore_all_mutations_;
131 } 131 }
132 132
133 bool IsIgnoringKeyMutations(DomStorageCachedArea* cached_area, 133 bool IsIgnoringKeyMutations(DomStorageCachedArea* cached_area,
134 const string16& key) { 134 const base::string16& key) {
135 return cached_area->should_ignore_key_mutation(key); 135 return cached_area->should_ignore_key_mutation(key);
136 } 136 }
137 137
138 void ResetAll(DomStorageCachedArea* cached_area) { 138 void ResetAll(DomStorageCachedArea* cached_area) {
139 cached_area->Reset(); 139 cached_area->Reset();
140 mock_proxy_->ResetObservations(); 140 mock_proxy_->ResetObservations();
141 mock_proxy_->pending_callbacks_.clear(); 141 mock_proxy_->pending_callbacks_.clear();
142 } 142 }
143 143
144 void ResetCacheOnly(DomStorageCachedArea* cached_area) { 144 void ResetCacheOnly(DomStorageCachedArea* cached_area) {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area, kKey)); 340 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area, kKey));
341 341
342 // A failed set item operation should Reset the cache. 342 // A failed set item operation should Reset the cache.
343 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); 343 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl));
344 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area, kKey)); 344 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area, kKey));
345 mock_proxy_->CompleteOnePendingCallback(false); 345 mock_proxy_->CompleteOnePendingCallback(false);
346 EXPECT_FALSE(IsPrimed(cached_area)); 346 EXPECT_FALSE(IsPrimed(cached_area));
347 } 347 }
348 348
349 } // namespace dom_storage 349 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698