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

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

Issue 9963107: Persist sessionStorage on disk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review (pkasting) Created 8 years, 4 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
« no previous file with comments | « webkit/dom_storage/dom_storage_area.cc ('k') | webkit/dom_storage/dom_storage_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/threading/sequenced_worker_pool.h" 10 #include "base/threading/sequenced_worker_pool.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 EXPECT_EQ(kValue, values[kKey].string()); 66 EXPECT_EQ(kValue, values[kKey].string());
67 } 67 }
68 }; 68 };
69 69
70 private: 70 private:
71 MessageLoop message_loop_; 71 MessageLoop message_loop_;
72 }; 72 };
73 73
74 TEST_F(DomStorageAreaTest, DomStorageAreaBasics) { 74 TEST_F(DomStorageAreaTest, DomStorageAreaBasics) {
75 scoped_refptr<DomStorageArea> area( 75 scoped_refptr<DomStorageArea> area(
76 new DomStorageArea(1, std::string(), kOrigin, NULL)); 76 new DomStorageArea(1, std::string(), kOrigin, NULL, NULL));
77 string16 old_value; 77 string16 old_value;
78 NullableString16 old_nullable_value; 78 NullableString16 old_nullable_value;
79 scoped_refptr<DomStorageArea> copy; 79 scoped_refptr<DomStorageArea> copy;
80 80
81 // We don't focus on the underlying DomStorageMap functionality 81 // We don't focus on the underlying DomStorageMap functionality
82 // since that's covered by seperate unit tests. 82 // since that's covered by seperate unit tests.
83 EXPECT_EQ(kOrigin, area->origin()); 83 EXPECT_EQ(kOrigin, area->origin());
84 EXPECT_EQ(1, area->namespace_id()); 84 EXPECT_EQ(1, area->namespace_id());
85 EXPECT_EQ(0u, area->Length()); 85 EXPECT_EQ(0u, area->Length());
86 EXPECT_TRUE(area->SetItem(kKey, kValue, &old_nullable_value)); 86 EXPECT_TRUE(area->SetItem(kKey, kValue, &old_nullable_value));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 131
132 // No directory, backing should be null. 132 // No directory, backing should be null.
133 { 133 {
134 scoped_refptr<DomStorageArea> area( 134 scoped_refptr<DomStorageArea> area(
135 new DomStorageArea(kOrigin, FilePath(), NULL)); 135 new DomStorageArea(kOrigin, FilePath(), NULL));
136 EXPECT_EQ(NULL, area->backing_.get()); 136 EXPECT_EQ(NULL, area->backing_.get());
137 EXPECT_TRUE(area->is_initial_import_done_); 137 EXPECT_TRUE(area->is_initial_import_done_);
138 EXPECT_FALSE(file_util::PathExists(kExpectedOriginFilePath)); 138 EXPECT_FALSE(file_util::PathExists(kExpectedOriginFilePath));
139 } 139 }
140 140
141 // Valid directory and origin but non-local namespace id. Backing should 141 // Valid directory and origin but no session storage backing. Backing should
142 // be null. 142 // be null.
143 { 143 {
144 scoped_refptr<DomStorageArea> area( 144 scoped_refptr<DomStorageArea> area(
145 new DomStorageArea(kSessionStorageNamespaceId, std::string(), kOrigin, 145 new DomStorageArea(kSessionStorageNamespaceId, std::string(), kOrigin,
146 NULL)); 146 NULL, NULL));
147 EXPECT_EQ(NULL, area->backing_.get()); 147 EXPECT_EQ(NULL, area->backing_.get());
148 EXPECT_TRUE(area->is_initial_import_done_); 148 EXPECT_TRUE(area->is_initial_import_done_);
149 149
150 NullableString16 old_value; 150 NullableString16 old_value;
151 EXPECT_TRUE(area->SetItem(kKey, kValue, &old_value)); 151 EXPECT_TRUE(area->SetItem(kKey, kValue, &old_value));
152 ASSERT_TRUE(old_value.is_null()); 152 ASSERT_TRUE(old_value.is_null());
153 153
154 // Check that saving a value has still left us without a backing database. 154 // Check that saving a value has still left us without a backing database.
155 EXPECT_EQ(NULL, area->backing_.get()); 155 EXPECT_EQ(NULL, area->backing_.get());
156 EXPECT_FALSE(file_util::PathExists(kExpectedOriginFilePath)); 156 EXPECT_FALSE(file_util::PathExists(kExpectedOriginFilePath));
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 EXPECT_EQ( 463 EXPECT_EQ(
464 FilePath().AppendASCII("-journal"), 464 FilePath().AppendASCII("-journal"),
465 DomStorageDatabase::GetJournalFilePath(FilePath())); 465 DomStorageDatabase::GetJournalFilePath(FilePath()));
466 EXPECT_EQ( 466 EXPECT_EQ(
467 FilePath().AppendASCII(".extensiononly-journal"), 467 FilePath().AppendASCII(".extensiononly-journal"),
468 DomStorageDatabase::GetJournalFilePath( 468 DomStorageDatabase::GetJournalFilePath(
469 FilePath().AppendASCII(".extensiononly"))); 469 FilePath().AppendASCII(".extensiononly")));
470 } 470 }
471 471
472 } // namespace dom_storage 472 } // namespace dom_storage
OLDNEW
« no previous file with comments | « webkit/dom_storage/dom_storage_area.cc ('k') | webkit/dom_storage/dom_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698