| 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/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "webkit/renderer/dom_storage/dom_storage_cached_area.h" | 10 #include "webkit/renderer/dom_storage/dom_storage_cached_area.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 const int kConnectionId = 8; | 313 const int kConnectionId = 8; |
| 314 scoped_refptr<DomStorageCachedArea> cached_area = | 314 scoped_refptr<DomStorageCachedArea> cached_area = |
| 315 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); | 315 new DomStorageCachedArea(kNamespaceId, kOrigin, mock_proxy_.get()); |
| 316 | 316 |
| 317 // SetItem | 317 // SetItem |
| 318 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 318 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 319 mock_proxy_->CompleteOnePendingCallback(true); // load completion | 319 mock_proxy_->CompleteOnePendingCallback(true); // load completion |
| 320 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); | 320 EXPECT_FALSE(IsIgnoringAllMutations(cached_area.get())); |
| 321 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 321 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 322 cached_area->ApplyMutation(base::NullableString16(kKey, false), | 322 cached_area->ApplyMutation(base::NullableString16(kKey, false), |
| 323 base::NullableString16(true)); | 323 base::NullableString16()); |
| 324 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); | 324 EXPECT_EQ(kValue, cached_area->GetItem(kConnectionId, kKey).string()); |
| 325 mock_proxy_->CompleteOnePendingCallback(true); // set completion | 325 mock_proxy_->CompleteOnePendingCallback(true); // set completion |
| 326 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 326 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 327 | 327 |
| 328 // RemoveItem | 328 // RemoveItem |
| 329 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 329 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 330 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 330 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 331 mock_proxy_->CompleteOnePendingCallback(true); // remove completion | 331 mock_proxy_->CompleteOnePendingCallback(true); // remove completion |
| 332 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 332 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 333 | 333 |
| 334 // Multiple mutations to the same key. | 334 // Multiple mutations to the same key. |
| 335 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 335 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 336 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); | 336 cached_area->RemoveItem(kConnectionId, kKey, kPageUrl); |
| 337 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 337 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 338 mock_proxy_->CompleteOnePendingCallback(true); // set completion | 338 mock_proxy_->CompleteOnePendingCallback(true); // set completion |
| 339 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 339 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 340 mock_proxy_->CompleteOnePendingCallback(true); // remove completion | 340 mock_proxy_->CompleteOnePendingCallback(true); // remove completion |
| 341 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 341 EXPECT_FALSE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 342 | 342 |
| 343 // A failed set item operation should Reset the cache. | 343 // A failed set item operation should Reset the cache. |
| 344 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); | 344 EXPECT_TRUE(cached_area->SetItem(kConnectionId, kKey, kValue, kPageUrl)); |
| 345 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); | 345 EXPECT_TRUE(IsIgnoringKeyMutations(cached_area.get(), kKey)); |
| 346 mock_proxy_->CompleteOnePendingCallback(false); | 346 mock_proxy_->CompleteOnePendingCallback(false); |
| 347 EXPECT_FALSE(IsPrimed(cached_area.get())); | 347 EXPECT_FALSE(IsPrimed(cached_area.get())); |
| 348 } | 348 } |
| 349 | 349 |
| 350 } // namespace dom_storage | 350 } // namespace dom_storage |
| OLD | NEW |