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 "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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |