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

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

Issue 9146025: Framing for a DOMStorage backend that does not depend on in-process-webkit. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/utf_string_conversions.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 #include "webkit/dom_storage/dom_storage_map.h"
8
9 namespace dom_storage {
10
11 TEST(DomStorageMapTest, DomStorageMapBasics) {
12 const string16 kKey(ASCIIToUTF16("key"));
13 const string16 kValue(ASCIIToUTF16("value"));
14 const string16 kKey2(ASCIIToUTF16("key2"));
15 const string16 kValue2(ASCIIToUTF16("value2"));
16
17 scoped_refptr<DomStorageMap> map(new DomStorageMap);
18 string16 old_value;
19 NullableString16 old_nullable_value;
20 ValuesMap swap;
21 scoped_refptr<DomStorageMap> copy;
22
23 // Check the behavior of an empty map.
24 EXPECT_EQ(0u, map->Length());
25 EXPECT_TRUE(map->Key(0).is_null());
26 EXPECT_TRUE(map->Key(100).is_null());
27 EXPECT_TRUE(map->GetItem(kKey).is_null());
28 EXPECT_FALSE(map->RemoveItem(kKey, &old_value));
29 copy = map->DeepCopy();
30 EXPECT_EQ(0u, copy->Length());
31 map->SwapValues(&swap);
32 EXPECT_TRUE(swap.empty());
33
34 // Check the behavior of a map containing some values.
35 EXPECT_TRUE(map->SetItem(kKey, kValue, &old_nullable_value));
36 EXPECT_TRUE(old_nullable_value.is_null());
37 EXPECT_EQ(1u, map->Length());
38 EXPECT_EQ(kKey, map->Key(0).string());
39 EXPECT_TRUE(map->Key(1).is_null());
40 EXPECT_EQ(kValue, map->GetItem(kKey).string());
41 EXPECT_TRUE(map->GetItem(kKey2).is_null());
42 EXPECT_TRUE(map->RemoveItem(kKey, &old_value));
43 EXPECT_EQ(kValue, old_value);
44 old_value.clear();
45
46 EXPECT_TRUE(map->SetItem(kKey, kValue, &old_nullable_value));
47 EXPECT_TRUE(map->SetItem(kKey2, kValue, &old_nullable_value));
48 EXPECT_TRUE(old_nullable_value.is_null());
49 EXPECT_TRUE(map->SetItem(kKey2, kValue2, &old_nullable_value));
50 EXPECT_EQ(kValue, old_nullable_value.string());
51 EXPECT_EQ(2u, map->Length());
52
53 copy = map->DeepCopy();
54 EXPECT_EQ(2u, copy->Length());
55 EXPECT_EQ(kValue, copy->GetItem(kKey).string());
56 EXPECT_EQ(kValue2, copy->GetItem(kKey2).string());
57
58 map->SwapValues(&swap);
59 EXPECT_EQ(2ul, swap.size());
60 EXPECT_EQ(0u, map->Length());
61 }
62
63 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698