OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/offline_pages/offline_page_metadata_store_impl.h" | 5 #include "components/offline_pages/offline_page_metadata_store_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 enum Status { STATUS_NONE, STATUS_TRUE, STATUS_FALSE }; | 34 enum Status { STATUS_NONE, STATUS_TRUE, STATUS_FALSE }; |
35 | 35 |
36 OfflinePageMetadataStoreImplTest(); | 36 OfflinePageMetadataStoreImplTest(); |
37 ~OfflinePageMetadataStoreImplTest() override; | 37 ~OfflinePageMetadataStoreImplTest() override; |
38 | 38 |
39 void TearDown() override { message_loop_.RunUntilIdle(); } | 39 void TearDown() override { message_loop_.RunUntilIdle(); } |
40 | 40 |
41 scoped_ptr<OfflinePageMetadataStoreImpl> BuildStore(); | 41 scoped_ptr<OfflinePageMetadataStoreImpl> BuildStore(); |
42 void PumpLoop(); | 42 void PumpLoop(); |
43 | 43 |
44 void LoadCallback(bool success, | 44 void LoadCallback(OfflinePageMetadataStore::LoadStatus load_status, |
45 const std::vector<OfflinePageItem>& offline_pages); | 45 const std::vector<OfflinePageItem>& offline_pages); |
46 void UpdateCallback(CalledCallback called_callback, bool success); | 46 void UpdateCallback(CalledCallback called_callback, bool success); |
47 | 47 |
48 void ClearResults(); | 48 void ClearResults(); |
49 | 49 |
50 protected: | 50 protected: |
51 CalledCallback last_called_callback_; | 51 CalledCallback last_called_callback_; |
52 Status last_status_; | 52 Status last_status_; |
53 std::vector<OfflinePageItem> offline_pages_; | 53 std::vector<OfflinePageItem> offline_pages_; |
54 | 54 |
55 base::ScopedTempDir temp_directory_; | 55 base::ScopedTempDir temp_directory_; |
56 base::MessageLoop message_loop_; | 56 base::MessageLoop message_loop_; |
57 scoped_ptr<base::RunLoop> run_loop_; | 57 scoped_ptr<base::RunLoop> run_loop_; |
58 }; | 58 }; |
59 | 59 |
60 OfflinePageMetadataStoreImplTest::OfflinePageMetadataStoreImplTest() | 60 OfflinePageMetadataStoreImplTest::OfflinePageMetadataStoreImplTest() |
61 : last_called_callback_(NONE), last_status_(STATUS_NONE) { | 61 : last_called_callback_(NONE), last_status_(STATUS_NONE) { |
62 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); | 62 EXPECT_TRUE(temp_directory_.CreateUniqueTempDir()); |
63 } | 63 } |
64 | 64 |
65 OfflinePageMetadataStoreImplTest::~OfflinePageMetadataStoreImplTest() { | 65 OfflinePageMetadataStoreImplTest::~OfflinePageMetadataStoreImplTest() { |
66 } | 66 } |
67 | 67 |
68 void OfflinePageMetadataStoreImplTest::PumpLoop() { | 68 void OfflinePageMetadataStoreImplTest::PumpLoop() { |
69 run_loop_.reset(new base::RunLoop()); | 69 base::RunLoop().RunUntilIdle(); |
70 run_loop_->Run(); | |
71 } | 70 } |
72 | 71 |
73 scoped_ptr<OfflinePageMetadataStoreImpl> | 72 scoped_ptr<OfflinePageMetadataStoreImpl> |
74 OfflinePageMetadataStoreImplTest::BuildStore() { | 73 OfflinePageMetadataStoreImplTest::BuildStore() { |
75 scoped_ptr<ProtoDatabaseImpl<offline_pages::OfflinePageEntry>> db( | 74 scoped_ptr<OfflinePageMetadataStoreImpl> store( |
76 new ProtoDatabaseImpl<offline_pages::OfflinePageEntry>( | 75 new OfflinePageMetadataStoreImpl(message_loop_.task_runner(), |
77 message_loop_.task_runner())); | 76 temp_directory_.path())); |
78 return scoped_ptr<OfflinePageMetadataStoreImpl>( | 77 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, |
79 new OfflinePageMetadataStoreImpl(db.Pass(), temp_directory_.path())); | 78 base::Unretained(this))); |
| 79 PumpLoop(); |
| 80 return store.Pass(); |
80 } | 81 } |
81 | 82 |
82 void OfflinePageMetadataStoreImplTest::LoadCallback( | 83 void OfflinePageMetadataStoreImplTest::LoadCallback( |
83 bool status, | 84 OfflinePageMetadataStore::LoadStatus load_status, |
84 const std::vector<OfflinePageItem>& offline_pages) { | 85 const std::vector<OfflinePageItem>& offline_pages) { |
85 last_called_callback_ = LOAD; | 86 last_called_callback_ = LOAD; |
86 last_status_ = status ? STATUS_TRUE : STATUS_FALSE; | 87 last_status_ = load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ? |
| 88 STATUS_TRUE : STATUS_FALSE; |
87 offline_pages_.swap(const_cast<std::vector<OfflinePageItem>&>(offline_pages)); | 89 offline_pages_.swap(const_cast<std::vector<OfflinePageItem>&>(offline_pages)); |
88 run_loop_->Quit(); | |
89 } | 90 } |
90 | 91 |
91 void OfflinePageMetadataStoreImplTest::UpdateCallback( | 92 void OfflinePageMetadataStoreImplTest::UpdateCallback( |
92 CalledCallback called_callback, | 93 CalledCallback called_callback, |
93 bool status) { | 94 bool status) { |
94 last_called_callback_ = called_callback; | 95 last_called_callback_ = called_callback; |
95 last_status_ = status ? STATUS_TRUE : STATUS_FALSE; | 96 last_status_ = status ? STATUS_TRUE : STATUS_FALSE; |
96 run_loop_->Quit(); | |
97 } | 97 } |
98 | 98 |
99 void OfflinePageMetadataStoreImplTest::ClearResults() { | 99 void OfflinePageMetadataStoreImplTest::ClearResults() { |
100 last_called_callback_ = NONE; | 100 last_called_callback_ = NONE; |
101 last_status_ = STATUS_NONE; | 101 last_status_ = STATUS_NONE; |
102 offline_pages_.clear(); | 102 offline_pages_.clear(); |
103 } | 103 } |
104 | 104 |
105 // Loads empty store and makes sure that there are no offline pages stored in | 105 // Loads empty store and makes sure that there are no offline pages stored in |
106 // it. | 106 // it. |
107 TEST_F(OfflinePageMetadataStoreImplTest, LoadEmptyStore) { | 107 TEST_F(OfflinePageMetadataStoreImplTest, LoadEmptyStore) { |
108 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 108 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); |
109 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | |
110 base::Unretained(this))); | |
111 PumpLoop(); | |
112 | |
113 EXPECT_EQ(LOAD, last_called_callback_); | 109 EXPECT_EQ(LOAD, last_called_callback_); |
114 EXPECT_EQ(STATUS_TRUE, last_status_); | 110 EXPECT_EQ(STATUS_TRUE, last_status_); |
115 EXPECT_EQ(0U, offline_pages_.size()); | 111 EXPECT_EQ(0U, offline_pages_.size()); |
116 } | 112 } |
117 | 113 |
118 // Adds metadata of an offline page into a store and then loads from the | 114 // Adds metadata of an offline page into a store and then opens the store |
119 // store to make sure the metadata is preserved. | 115 // again to make sure that stored metadata survives store restarts. |
120 TEST_F(OfflinePageMetadataStoreImplTest, AddOfflinePageThenLoad) { | 116 TEST_F(OfflinePageMetadataStoreImplTest, AddOfflinePage) { |
121 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 117 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); |
122 | 118 |
123 OfflinePageItem offline_page(GURL(kTestURL), kTestBookmarkId, | 119 OfflinePageItem offline_page(GURL(kTestURL), kTestBookmarkId, |
124 base::FilePath(kFilePath), kFileSize); | 120 base::FilePath(kFilePath), kFileSize); |
125 store->AddOrUpdateOfflinePage( | 121 store->AddOrUpdateOfflinePage( |
126 offline_page, | 122 offline_page, |
127 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 123 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, |
128 base::Unretained(this), ADD)); | 124 base::Unretained(this), ADD)); |
129 PumpLoop(); | 125 PumpLoop(); |
130 EXPECT_EQ(ADD, last_called_callback_); | 126 EXPECT_EQ(ADD, last_called_callback_); |
131 EXPECT_EQ(STATUS_TRUE, last_status_); | 127 EXPECT_EQ(STATUS_TRUE, last_status_); |
132 | 128 |
133 ClearResults(); | 129 ClearResults(); |
134 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 130 |
135 base::Unretained(this))); | 131 // Close the store first to ensure file lock is removed. |
| 132 store.reset(); |
| 133 store = BuildStore().Pass(); |
136 PumpLoop(); | 134 PumpLoop(); |
137 | 135 |
138 EXPECT_EQ(LOAD, last_called_callback_); | 136 EXPECT_EQ(LOAD, last_called_callback_); |
139 EXPECT_EQ(STATUS_TRUE, last_status_); | 137 EXPECT_EQ(STATUS_TRUE, last_status_); |
140 EXPECT_EQ(1U, offline_pages_.size()); | 138 EXPECT_EQ(1U, offline_pages_.size()); |
141 EXPECT_EQ(offline_page.url, offline_pages_[0].url); | 139 EXPECT_EQ(offline_page.url, offline_pages_[0].url); |
142 EXPECT_EQ(offline_page.bookmark_id, offline_pages_[0].bookmark_id); | 140 EXPECT_EQ(offline_page.bookmark_id, offline_pages_[0].bookmark_id); |
143 EXPECT_EQ(offline_page.version, offline_pages_[0].version); | 141 EXPECT_EQ(offline_page.version, offline_pages_[0].version); |
144 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | 142 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); |
145 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | 143 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); |
146 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | 144 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); |
147 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | 145 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); |
| 146 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); |
148 } | 147 } |
149 | 148 |
150 // Adds metadata of an offline page into a store and then opens the store | 149 // Tests removing offline page metadata from the store, for which it first adds |
151 // again to make sure that stored metadata survives store restarts. | 150 // metadata of an offline page. |
152 TEST_F(OfflinePageMetadataStoreImplTest, AddOfflinePageRestartLoad) { | 151 TEST_F(OfflinePageMetadataStoreImplTest, RemoveOfflinePage) { |
153 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 152 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); |
154 | 153 |
| 154 // Add an offline page. |
155 OfflinePageItem offline_page(GURL(kTestURL), kTestBookmarkId, | 155 OfflinePageItem offline_page(GURL(kTestURL), kTestBookmarkId, |
156 base::FilePath(kFilePath), kFileSize); | 156 base::FilePath(kFilePath), kFileSize); |
157 store->AddOrUpdateOfflinePage( | 157 store->AddOrUpdateOfflinePage( |
158 offline_page, | 158 offline_page, |
159 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 159 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, |
160 base::Unretained(this), ADD)); | 160 base::Unretained(this), ADD)); |
161 PumpLoop(); | 161 PumpLoop(); |
162 EXPECT_EQ(ADD, last_called_callback_); | 162 EXPECT_EQ(ADD, last_called_callback_); |
163 EXPECT_EQ(STATUS_TRUE, last_status_); | 163 EXPECT_EQ(STATUS_TRUE, last_status_); |
164 | 164 |
165 // Reset the store first to ensure file lock is removed. | |
166 store.reset(); | |
167 store = BuildStore().Pass(); | |
168 ClearResults(); | 165 ClearResults(); |
| 166 |
| 167 // Load the store. |
169 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 168 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, |
170 base::Unretained(this))); | 169 base::Unretained(this))); |
171 PumpLoop(); | 170 PumpLoop(); |
| 171 EXPECT_EQ(LOAD, last_called_callback_); |
| 172 EXPECT_EQ(1U, offline_pages_.size()); |
172 | 173 |
173 EXPECT_EQ(LOAD, last_called_callback_); | 174 // Remove the offline page. |
174 EXPECT_EQ(STATUS_TRUE, last_status_); | |
175 EXPECT_EQ(1U, offline_pages_.size()); | |
176 EXPECT_EQ(offline_page.url, offline_pages_[0].url); | |
177 EXPECT_EQ(offline_page.bookmark_id, offline_pages_[0].bookmark_id); | |
178 EXPECT_EQ(offline_page.version, offline_pages_[0].version); | |
179 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | |
180 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | |
181 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | |
182 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | |
183 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); | |
184 } | |
185 | |
186 // Tests removing offline page metadata from the store, for which it first adds | |
187 // metadata of an offline page. | |
188 TEST_F(OfflinePageMetadataStoreImplTest, RemoveOfflinePage) { | |
189 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | |
190 | |
191 OfflinePageItem offline_page(GURL(kTestURL), kTestBookmarkId, | |
192 base::FilePath(kFilePath), kFileSize); | |
193 store->AddOrUpdateOfflinePage( | |
194 offline_page, | |
195 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | |
196 base::Unretained(this), ADD)); | |
197 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | |
198 base::Unretained(this))); | |
199 std::vector<int64> ids_to_remove; | 175 std::vector<int64> ids_to_remove; |
200 ids_to_remove.push_back(offline_page.bookmark_id); | 176 ids_to_remove.push_back(offline_page.bookmark_id); |
201 store->RemoveOfflinePages( | 177 store->RemoveOfflinePages( |
202 ids_to_remove, | 178 ids_to_remove, |
203 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 179 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, |
204 base::Unretained(this), REMOVE)); | 180 base::Unretained(this), REMOVE)); |
205 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | |
206 base::Unretained(this))); | |
207 store.reset(); | |
208 store = BuildStore().Pass(); | |
209 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | |
210 base::Unretained(this))); | |
211 // Add offline page is exectued: | |
212 PumpLoop(); | |
213 EXPECT_EQ(ADD, last_called_callback_); | |
214 EXPECT_EQ(STATUS_TRUE, last_status_); | |
215 | |
216 // Load is exectued: | |
217 ClearResults(); | |
218 PumpLoop(); | |
219 | |
220 EXPECT_EQ(LOAD, last_called_callback_); | |
221 EXPECT_EQ(STATUS_TRUE, last_status_); | |
222 EXPECT_EQ(1U, offline_pages_.size()); | |
223 | |
224 // Remove offline page is exectued: | |
225 ClearResults(); | |
226 PumpLoop(); | 181 PumpLoop(); |
227 EXPECT_EQ(REMOVE, last_called_callback_); | 182 EXPECT_EQ(REMOVE, last_called_callback_); |
228 EXPECT_EQ(STATUS_TRUE, last_status_); | 183 EXPECT_EQ(STATUS_TRUE, last_status_); |
229 | 184 |
230 // Load is exectued: | |
231 ClearResults(); | 185 ClearResults(); |
| 186 |
| 187 // Load the store. |
| 188 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, |
| 189 base::Unretained(this))); |
232 PumpLoop(); | 190 PumpLoop(); |
| 191 EXPECT_EQ(LOAD, last_called_callback_); |
| 192 EXPECT_EQ(0U, offline_pages_.size()); |
233 | 193 |
| 194 ClearResults(); |
| 195 |
| 196 // Close and reload the store. |
| 197 store.reset(); |
| 198 store = BuildStore().Pass(); |
234 EXPECT_EQ(LOAD, last_called_callback_); | 199 EXPECT_EQ(LOAD, last_called_callback_); |
235 EXPECT_EQ(STATUS_TRUE, last_status_); | 200 EXPECT_EQ(STATUS_TRUE, last_status_); |
236 EXPECT_EQ(0U, offline_pages_.size()); | 201 EXPECT_EQ(0U, offline_pages_.size()); |
237 | |
238 // Checking the value after reseting the store. | |
239 ClearResults(); | |
240 PumpLoop(); | |
241 EXPECT_EQ(LOAD, last_called_callback_); | |
242 EXPECT_EQ(STATUS_TRUE, last_status_); | |
243 EXPECT_EQ(0U, offline_pages_.size()); | |
244 } | 202 } |
245 | 203 |
246 // Adds metadata of multiple offline pages into a store and removes some. | 204 // Adds metadata of multiple offline pages into a store and removes some. |
247 TEST_F(OfflinePageMetadataStoreImplTest, AddRemoveMultipleOfflinePages) { | 205 TEST_F(OfflinePageMetadataStoreImplTest, AddRemoveMultipleOfflinePages) { |
248 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); | 206 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); |
249 | 207 |
| 208 // Add an offline page. |
250 OfflinePageItem offline_page_1(GURL(kTestURL), kTestBookmarkId, | 209 OfflinePageItem offline_page_1(GURL(kTestURL), kTestBookmarkId, |
251 base::FilePath(kFilePath), kFileSize); | 210 base::FilePath(kFilePath), kFileSize); |
252 base::FilePath file_path_2 = | 211 base::FilePath file_path_2 = |
253 base::FilePath(FILE_PATH_LITERAL("//other.page.com.mhtml")); | 212 base::FilePath(FILE_PATH_LITERAL("//other.page.com.mhtml")); |
254 OfflinePageItem offline_page_2(GURL("https://other.page.com"), 5678LL, | 213 OfflinePageItem offline_page_2(GURL("https://other.page.com"), 5678LL, |
255 file_path_2, 12345, base::Time::Now()); | 214 file_path_2, 12345, base::Time::Now()); |
256 store->AddOrUpdateOfflinePage( | 215 store->AddOrUpdateOfflinePage( |
257 offline_page_1, | 216 offline_page_1, |
258 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 217 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, |
259 base::Unretained(this), ADD)); | 218 base::Unretained(this), ADD)); |
260 PumpLoop(); | 219 PumpLoop(); |
261 EXPECT_EQ(ADD, last_called_callback_); | 220 EXPECT_EQ(ADD, last_called_callback_); |
262 EXPECT_EQ(STATUS_TRUE, last_status_); | 221 EXPECT_EQ(STATUS_TRUE, last_status_); |
263 | 222 |
264 ClearResults(); | 223 ClearResults(); |
| 224 |
| 225 // Add anther offline page. |
265 store->AddOrUpdateOfflinePage( | 226 store->AddOrUpdateOfflinePage( |
266 offline_page_2, | 227 offline_page_2, |
267 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 228 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, |
268 base::Unretained(this), ADD)); | 229 base::Unretained(this), ADD)); |
269 PumpLoop(); | 230 PumpLoop(); |
270 EXPECT_EQ(ADD, last_called_callback_); | 231 EXPECT_EQ(ADD, last_called_callback_); |
271 EXPECT_EQ(STATUS_TRUE, last_status_); | 232 EXPECT_EQ(STATUS_TRUE, last_status_); |
272 | 233 |
273 ClearResults(); | 234 ClearResults(); |
| 235 |
| 236 // Load the store. |
274 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 237 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, |
275 base::Unretained(this))); | 238 base::Unretained(this))); |
276 PumpLoop(); | 239 PumpLoop(); |
277 | 240 |
278 EXPECT_EQ(LOAD, last_called_callback_); | 241 EXPECT_EQ(LOAD, last_called_callback_); |
279 EXPECT_EQ(STATUS_TRUE, last_status_); | 242 EXPECT_EQ(STATUS_TRUE, last_status_); |
280 EXPECT_EQ(2U, offline_pages_.size()); | 243 EXPECT_EQ(2U, offline_pages_.size()); |
281 | 244 |
| 245 // Remove the offline page. |
282 std::vector<int64> ids_to_remove; | 246 std::vector<int64> ids_to_remove; |
283 ids_to_remove.push_back(offline_page_1.bookmark_id); | 247 ids_to_remove.push_back(offline_page_1.bookmark_id); |
284 store->RemoveOfflinePages( | 248 store->RemoveOfflinePages( |
285 ids_to_remove, | 249 ids_to_remove, |
286 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, | 250 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, |
287 base::Unretained(this), REMOVE)); | 251 base::Unretained(this), REMOVE)); |
288 PumpLoop(); | 252 PumpLoop(); |
289 EXPECT_EQ(REMOVE, last_called_callback_); | 253 EXPECT_EQ(REMOVE, last_called_callback_); |
290 EXPECT_EQ(STATUS_TRUE, last_status_); | 254 EXPECT_EQ(STATUS_TRUE, last_status_); |
291 | 255 |
292 ClearResults(); | 256 ClearResults(); |
| 257 |
| 258 // Close and reload the store. |
293 store.reset(); | 259 store.reset(); |
294 store = BuildStore().Pass(); | 260 store = BuildStore().Pass(); |
295 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, | 261 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, |
296 base::Unretained(this))); | 262 base::Unretained(this))); |
297 PumpLoop(); | 263 PumpLoop(); |
298 | 264 |
299 EXPECT_EQ(LOAD, last_called_callback_); | 265 EXPECT_EQ(LOAD, last_called_callback_); |
300 EXPECT_EQ(STATUS_TRUE, last_status_); | 266 EXPECT_EQ(STATUS_TRUE, last_status_); |
301 EXPECT_EQ(1U, offline_pages_.size()); | 267 EXPECT_EQ(1U, offline_pages_.size()); |
302 EXPECT_EQ(offline_page_2.url, offline_pages_[0].url); | 268 EXPECT_EQ(offline_page_2.url, offline_pages_[0].url); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); | 333 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); |
368 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); | 334 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); |
369 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); | 335 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); |
370 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); | 336 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); |
371 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); | 337 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); |
372 } | 338 } |
373 | 339 |
374 } // namespace | 340 } // namespace |
375 | 341 |
376 } // namespace offline_pages | 342 } // namespace offline_pages |
OLD | NEW |