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

Side by Side Diff: webkit/dom_storage/dom_storage_area_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_area.h"
8
9 namespace dom_storage {
10
11 TEST(DomStorageAreaTest, DomStorageAreaBasics) {
12 const GURL kOrigin("http://dom_storage/");
13 const string16 kKey(ASCIIToUTF16("key"));
14 const string16 kValue(ASCIIToUTF16("value"));
15 const string16 kKey2(ASCIIToUTF16("key2"));
16 const string16 kValue2(ASCIIToUTF16("value2"));
17
18 scoped_refptr<DomStorageArea> area(
19 new DomStorageArea(1, kOrigin, FilePath(), NULL));
20 string16 old_value;
21 NullableString16 old_nullable_value;
22 scoped_refptr<DomStorageArea> copy;
23
24 // We don't focus on the underlying DomStorageMap functionality
25 // since that's covered by seperate unit tests.
26 EXPECT_EQ(kOrigin, area->origin());
27 EXPECT_EQ(1, area->namespace_id());
28 EXPECT_EQ(0u, area->Length());
29 area->SetItem(kKey, kValue, &old_nullable_value);
30 area->SetItem(kKey2, kValue2, &old_nullable_value);
31
32 // Verify that a copy shares the same map.
33 copy = area->ShallowCopy(2);
34 EXPECT_EQ(kOrigin, copy->origin());
35 EXPECT_EQ(2, copy->namespace_id());
36 EXPECT_EQ(area->Length(), copy->Length());
37 EXPECT_EQ(area->GetItem(kKey).string(), copy->GetItem(kKey).string());
38 EXPECT_EQ(area->Key(0).string(), copy->Key(0).string());
39 EXPECT_EQ(copy->map_.get(), area->map_.get());
40
41 // But will deep copy-on-write as needed.
42 EXPECT_TRUE(area->RemoveItem(kKey, &old_value));
43 EXPECT_NE(copy->map_.get(), area->map_.get());
44 copy = area->ShallowCopy(2);
45 EXPECT_EQ(copy->map_.get(), area->map_.get());
46 EXPECT_TRUE(area->SetItem(kKey, kValue, &old_nullable_value));
47 EXPECT_NE(copy->map_.get(), area->map_.get());
48 copy = area->ShallowCopy(2);
49 EXPECT_EQ(copy->map_.get(), area->map_.get());
50 EXPECT_NE(0u, area->Length());
51 EXPECT_TRUE(area->Clear());
52 EXPECT_EQ(0u, area->Length());
53 EXPECT_NE(copy->map_.get(), area->map_.get());
54 }
55
56 } // namespace dom_storage
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698