| OLD | NEW |
| 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/renderer/dom_storage/dom_storage_cached_area.h" |
| 11 #include "webkit/dom_storage/dom_storage_proxy.h" | 11 #include "webkit/renderer/dom_storage/dom_storage_proxy.h" |
| 12 | 12 |
| 13 namespace dom_storage { | 13 namespace dom_storage { |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 // A mock implementation of the DomStorageProxy interface. | 16 // A mock implementation of the DomStorageProxy interface. |
| 17 class MockProxy : public DomStorageProxy { | 17 class MockProxy : public DomStorageProxy { |
| 18 public: | 18 public: |
| 19 MockProxy() { | 19 MockProxy() { |
| 20 ResetObservations(); | 20 ResetObservations(); |
| 21 } | 21 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 cached_area->Reset(); | 145 cached_area->Reset(); |
| 146 } | 146 } |
| 147 | 147 |
| 148 protected: | 148 protected: |
| 149 scoped_refptr<MockProxy> mock_proxy_; | 149 scoped_refptr<MockProxy> mock_proxy_; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 TEST_F(DomStorageCachedAreaTest, Basics) { | 152 TEST_F(DomStorageCachedAreaTest, Basics) { |
| 153 EXPECT_TRUE(mock_proxy_->HasOneRef()); | 153 EXPECT_TRUE(mock_proxy_->HasOneRef()); |
| 154 scoped_refptr<DomStorageCachedArea> cached_area = | 154 scoped_refptr<DomStorageCachedArea> cached_area = |
| 155 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_); | 155 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 156 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); | 156 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); |
| 157 EXPECT_EQ(kOrigin, cached_area->origin()); | 157 EXPECT_EQ(kOrigin, cached_area->origin()); |
| 158 EXPECT_FALSE(mock_proxy_->HasOneRef()); | 158 EXPECT_FALSE(mock_proxy_->HasOneRef()); |
| 159 cached_area->ApplyMutation(NullableString16(kKey, false), | 159 cached_area->ApplyMutation(NullableString16(kKey, false), |
| 160 NullableString16(kValue, false)); | 160 NullableString16(kValue, false)); |
| 161 EXPECT_FALSE(IsPrimed(cached_area)); | 161 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 162 | 162 |
| 163 ResetAll(cached_area); | 163 ResetAll(cached_area.get()); |
| 164 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); | 164 EXPECT_EQ(kNamespaceId, cached_area->namespace_id()); |
| 165 EXPECT_EQ(kOrigin, cached_area->origin()); | 165 EXPECT_EQ(kOrigin, cached_area->origin()); |
| 166 | 166 |
| 167 const int kConnectionId = 1; | 167 const int kConnectionId = 1; |
| 168 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); | 168 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); |
| 169 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 169 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 170 EXPECT_EQ(1u, cached_area->GetLength(kConnectionId)); | 170 EXPECT_EQ(1u, cached_area->GetLength(kConnectionId)); |
| 171 EXPECT_EQ(kKey, cached_area->GetKey(kConnectionId, 0).string()); | 171 EXPECT_EQ(kKey, cached_area->GetKey(kConnectionId, 0).string()); |
| 172 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 172 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
| 173 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 173 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 174 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); | 174 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); |
| 175 } | 175 } |
| 176 | 176 |
| 177 TEST_F(DomStorageCachedAreaTest, Getters) { | 177 TEST_F(DomStorageCachedAreaTest, Getters) { |
| 178 const int kConnectionId = 7; | 178 const int kConnectionId = 7; |
| 179 scoped_refptr<DomStorageCachedArea> cached_area = | 179 scoped_refptr<DomStorageCachedArea> cached_area = |
| 180 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_); | 180 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 181 | 181 |
| 182 // GetLength, we expect to see one call to load in the proxy. | 182 // GetLength, we expect to see one call to load in the proxy. |
| 183 EXPECT_FALSE(IsPrimed(cached_area)); | 183 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 184 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); | 184 EXPECT_EQ(0u, cached_area->GetLength(kConnectionId)); |
| 185 EXPECT_TRUE(IsPrimed(cached_area)); | 185 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 186 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 186 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
| 187 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 187 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 188 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 188 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
| 189 EXPECT_TRUE(IsIgnoringAllMutations(cached_area)); | 189 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
| 190 mock_proxy_->CompleteAllPendingCallbacks(); | 190 mock_proxy_->CompleteAllPendingCallbacks(); |
| 191 EXPECT_FALSE(IsIgnoringAllMutations(cached_area)); | 191 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
| 192 | 192 |
| 193 // GetKey, expect the one call to load. | 193 // GetKey, expect the one call to load. |
| 194 ResetAll(cached_area); | 194 ResetAll(cached_area.get()); |
| 195 EXPECT_FALSE(IsPrimed(cached_area)); | 195 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 196 EXPECT_TRUE(cached_area->GetKey(kConnectionId, 2).is_null()); | 196 EXPECT_TRUE(cached_area->GetKey(kConnectionId, 2).is_null()); |
| 197 EXPECT_TRUE(IsPrimed(cached_area)); | 197 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 198 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 198 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
| 199 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 199 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 200 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 200 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
| 201 | 201 |
| 202 // GetItem, ditto. | 202 // GetItem, ditto. |
| 203 ResetAll(cached_area); | 203 ResetAll(cached_area.get()); |
| 204 EXPECT_FALSE(IsPrimed(cached_area)); | 204 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 205 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); | 205 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); |
| 206 EXPECT_TRUE(IsPrimed(cached_area)); | 206 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 207 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 207 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
| 208 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 208 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 209 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 209 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
| 210 } | 210 } |
| 211 | 211 |
| 212 TEST_F(DomStorageCachedAreaTest, Setters) { | 212 TEST_F(DomStorageCachedAreaTest, Setters) { |
| 213 const int kConnectionId = 7; | 213 const int kConnectionId = 7; |
| 214 scoped_refptr<DomStorageCachedArea> cached_area = | 214 scoped_refptr<DomStorageCachedArea> cached_area = |
| 215 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_); | 215 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 216 | 216 |
| 217 // SetItem, we expect a call to load followed by a call to set item | 217 // SetItem, we expect a call to load followed by a call to set item |
| 218 // in the proxy. | 218 // in the proxy. |
| 219 EXPECT_FALSE(IsPrimed(cached_area)); | 219 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 220 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 220 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 221 EXPECT_TRUE(IsPrimed(cached_area)); | 221 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 222 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 222 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
| 223 EXPECT_TRUE(mock_proxy_->observed_set_item_); | 223 EXPECT_TRUE(mock_proxy_->observed_set_item_); |
| 224 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 224 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 225 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); | 225 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); |
| 226 EXPECT_EQ(kKey, mock_proxy_->observed_key_); | 226 EXPECT_EQ(kKey, mock_proxy_->observed_key_); |
| 227 EXPECT_EQ(kValue, mock_proxy_->observed_value_); | 227 EXPECT_EQ(kValue, mock_proxy_->observed_value_); |
| 228 EXPECT_EQ(2u, mock_proxy_->pending_callbacks_.size()); | 228 EXPECT_EQ(2u, mock_proxy_->pending_callbacks_.size()); |
| 229 | 229 |
| 230 // Clear, we expect a just the one call to clear in the proxy since | 230 // Clear, we expect a just the one call to clear in the proxy since |
| 231 // there's no need to load the data prior to deleting it. | 231 // there's no need to load the data prior to deleting it. |
| 232 ResetAll(cached_area); | 232 ResetAll(cached_area.get()); |
| 233 EXPECT_FALSE(IsPrimed(cached_area)); | 233 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 234 cached_area->Clear(kConnectionId, kPageUrl); | 234 cached_area->Clear(kConnectionId, kPageUrl); |
| 235 EXPECT_TRUE(IsPrimed(cached_area)); | 235 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 236 EXPECT_TRUE(mock_proxy_->observed_clear_area_); | 236 EXPECT_TRUE(mock_proxy_->observed_clear_area_); |
| 237 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 237 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 238 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); | 238 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); |
| 239 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 239 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
| 240 | 240 |
| 241 // RemoveItem with nothing to remove, expect just one call to load. | 241 // RemoveItem with nothing to remove, expect just one call to load. |
| 242 ResetAll(cached_area); | 242 ResetAll(cached_area.get()); |
| 243 EXPECT_FALSE(IsPrimed(cached_area)); | 243 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 244 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 244 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 245 EXPECT_TRUE(IsPrimed(cached_area)); | 245 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 246 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 246 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
| 247 EXPECT_FALSE(mock_proxy_->observed_remove_item_); | 247 EXPECT_FALSE(mock_proxy_->observed_remove_item_); |
| 248 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 248 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 249 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); | 249 EXPECT_EQ(1u, mock_proxy_->pending_callbacks_.size()); |
| 250 | 250 |
| 251 // RemoveItem with something to remove, expect a call to load followed | 251 // RemoveItem with something to remove, expect a call to load followed |
| 252 // by a call to remove. | 252 // by a call to remove. |
| 253 ResetAll(cached_area); | 253 ResetAll(cached_area.get()); |
| 254 mock_proxy_->load_area_return_values_[kKey] = NullableString16(kValue, false); | 254 mock_proxy_->load_area_return_values_[kKey] = NullableString16(kValue, false); |
| 255 EXPECT_FALSE(IsPrimed(cached_area)); | 255 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 256 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 256 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 257 EXPECT_TRUE(IsPrimed(cached_area)); | 257 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 258 EXPECT_TRUE(mock_proxy_->observed_load_area_); | 258 EXPECT_TRUE(mock_proxy_->observed_load_area_); |
| 259 EXPECT_TRUE(mock_proxy_->observed_remove_item_); | 259 EXPECT_TRUE(mock_proxy_->observed_remove_item_); |
| 260 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); | 260 EXPECT_EQ(kConnectionId, mock_proxy_->observed_connection_id_); |
| 261 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); | 261 EXPECT_EQ(kPageUrl, mock_proxy_->observed_page_url_); |
| 262 EXPECT_EQ(kKey, mock_proxy_->observed_key_); | 262 EXPECT_EQ(kKey, mock_proxy_->observed_key_); |
| 263 EXPECT_EQ(2u, mock_proxy_->pending_callbacks_.size()); | 263 EXPECT_EQ(2u, mock_proxy_->pending_callbacks_.size()); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TEST_F(DomStorageCachedAreaTest, MutationsAreIgnoredUntilLoadCompletion) { | 266 TEST_F(DomStorageCachedAreaTest, MutationsAreIgnoredUntilLoadCompletion) { |
| 267 const int kConnectionId = 7; | 267 const int kConnectionId = 7; |
| 268 scoped_refptr<DomStorageCachedArea> cached_area = | 268 scoped_refptr<DomStorageCachedArea> cached_area = |
| 269 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_); | 269 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 270 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); | 270 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); |
| 271 EXPECT_TRUE(IsPrimed(cached_area)); | 271 EXPECT_TRUE(IsPrimed(cached_area.get())); |
| 272 EXPECT_TRUE(IsIgnoringAllMutations(cached_area)); | 272 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
| 273 | 273 |
| 274 // Before load completion, the mutation should be ignored. | 274 // Before load completion, the mutation should be ignored. |
| 275 cached_area->ApplyMutation(NullableString16(kKey, false), | 275 cached_area->ApplyMutation(NullableString16(kKey, false), |
| 276 NullableString16(kValue, false)); | 276 NullableString16(kValue, false)); |
| 277 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); | 277 EXPECT_TRUE(cached_area->GetItem(kConnectionId, kKey).is_null()); |
| 278 | 278 |
| 279 // Call the load completion callback. | 279 // Call the load completion callback. |
| 280 mock_proxy_->CompleteOnePendingCallback(true); | 280 mock_proxy_->CompleteOnePendingCallback(true); |
| 281 EXPECT_FALSE(IsIgnoringAllMutations(cached_area)); | 281 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
| 282 | 282 |
| 283 // Verify that mutations are now applied. | 283 // Verify that mutations are now applied. |
| 284 cached_area->ApplyMutation(NullableString16(kKey, false), | 284 cached_area->ApplyMutation(NullableString16(kKey, false), |
| 285 NullableString16(kValue, false)); | 285 NullableString16(kValue, false)); |
| 286 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 286 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
| 287 } | 287 } |
| 288 | 288 |
| 289 TEST_F(DomStorageCachedAreaTest, MutationsAreIgnoredUntilClearCompletion) { | 289 TEST_F(DomStorageCachedAreaTest, MutationsAreIgnoredUntilClearCompletion) { |
| 290 const int kConnectionId = 4; | 290 const int kConnectionId = 4; |
| 291 scoped_refptr<DomStorageCachedArea> cached_area = | 291 scoped_refptr<DomStorageCachedArea> cached_area = |
| 292 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_); | 292 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 293 cached_area->Clear(kConnectionId, kPageUrl); | 293 cached_area->Clear(kConnectionId, kPageUrl); |
| 294 EXPECT_TRUE(IsIgnoringAllMutations(cached_area)); | 294 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
| 295 mock_proxy_->CompleteOnePendingCallback(true); | 295 mock_proxy_->CompleteOnePendingCallback(true); |
| 296 EXPECT_FALSE(IsIgnoringAllMutations(cached_area)); | 296 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
| 297 | 297 |
| 298 // Verify that calling Clear twice works as expected, the first | 298 // Verify that calling Clear twice works as expected, the first |
| 299 // completion callback should have been cancelled. | 299 // completion callback should have been cancelled. |
| 300 ResetCacheOnly(cached_area); | 300 ResetCacheOnly(cached_area.get()); |
| 301 cached_area->Clear(kConnectionId, kPageUrl); | 301 cached_area->Clear(kConnectionId, kPageUrl); |
| 302 EXPECT_TRUE(IsIgnoringAllMutations(cached_area)); | 302 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
| 303 cached_area->Clear(kConnectionId, kPageUrl); | 303 cached_area->Clear(kConnectionId, kPageUrl); |
| 304 EXPECT_TRUE(IsIgnoringAllMutations(cached_area)); | 304 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
| 305 mock_proxy_->CompleteOnePendingCallback(true); | 305 mock_proxy_->CompleteOnePendingCallback(true); |
| 306 EXPECT_TRUE(IsIgnoringAllMutations(cached_area)); | 306 EXPECT_TRUE(IsIgnoringAllMutations(cached_area.get())); |
| 307 mock_proxy_->CompleteOnePendingCallback(true); | 307 mock_proxy_->CompleteOnePendingCallback(true); |
| 308 EXPECT_FALSE(IsIgnoringAllMutations(cached_area)); | 308 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
| 309 } | 309 } |
| 310 | 310 |
| 311 TEST_F(DomStorageCachedAreaTest, KeyMutationsAreIgnoredUntilCompletion) { | 311 TEST_F(DomStorageCachedAreaTest, KeyMutationsAreIgnoredUntilCompletion) { |
| 312 const int kConnectionId = 8; | 312 const int kConnectionId = 8; |
| 313 scoped_refptr<DomStorageCachedArea> cached_area = | 313 scoped_refptr<DomStorageCachedArea> cached_area = |
| 314 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_); | 314 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 315 | 315 |
| 316 // SetItem | 316 // SetItem |
| 317 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 317 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 318 mock_proxy_->CompleteOnePendingCallback(true); // load completion | 318 mock_proxy_->CompleteOnePendingCallback(true); // load completion |
| 319 EXPECT_FALSE(IsIgnoringAllMutations(cached_area)); | 319 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
| 320 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area, kKey)); | 320 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 321 cached_area->ApplyMutation(NullableString16(kKey, false), | 321 cached_area->ApplyMutation(NullableString16(kKey, false), |
| 322 NullableString16(true)); | 322 NullableString16(true)); |
| 323 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 323 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
| 324 mock_proxy_->CompleteOnePendingCallback(true); // set completion | 324 mock_proxy_->CompleteOnePendingCallback(true); // set completion |
| 325 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area, kKey)); | 325 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 326 | 326 |
| 327 // RemoveItem | 327 // RemoveItem |
| 328 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 328 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 329 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area, kKey)); | 329 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 330 mock_proxy_->CompleteOnePendingCallback(true); // remove completion | 330 mock_proxy_->CompleteOnePendingCallback(true); // remove completion |
| 331 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area, kKey)); | 331 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 332 | 332 |
| 333 // Multiple mutations to the same key. | 333 // Multiple mutations to the same key. |
| 334 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 334 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 335 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 335 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 336 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area, kKey)); | 336 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 337 mock_proxy_->CompleteOnePendingCallback(true); // set completion | 337 mock_proxy_->CompleteOnePendingCallback(true); // set completion |
| 338 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area, kKey)); | 338 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 339 mock_proxy_->CompleteOnePendingCallback(true); // remove completion | 339 mock_proxy_->CompleteOnePendingCallback(true); // remove completion |
| 340 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area, kKey)); | 340 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), 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.get(), kKey)); |
| 345 mock_proxy_->CompleteOnePendingCallback(false); | 345 mock_proxy_->CompleteOnePendingCallback(false); |
| 346 EXPECT_FALSE(IsPrimed(cached_area)); | 346 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 347 } | 347 } |
| 348 | 348 |
| 349 } // namespace dom_storage | 349 } // namespace dom_storage |
| OLD | NEW |