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

Side by Side Diff: components/offline_pages/offline_page_metadata_store_impl_unittest.cc

Issue 1548203002: Convert Pass()→std::move() in //components/[n-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bad headers Created 4 years, 12 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
OLDNEW
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 <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 78 }
79 79
80 scoped_ptr<OfflinePageMetadataStoreImpl> 80 scoped_ptr<OfflinePageMetadataStoreImpl>
81 OfflinePageMetadataStoreImplTest::BuildStore() { 81 OfflinePageMetadataStoreImplTest::BuildStore() {
82 scoped_ptr<OfflinePageMetadataStoreImpl> store( 82 scoped_ptr<OfflinePageMetadataStoreImpl> store(
83 new OfflinePageMetadataStoreImpl(base::ThreadTaskRunnerHandle::Get(), 83 new OfflinePageMetadataStoreImpl(base::ThreadTaskRunnerHandle::Get(),
84 temp_directory_.path())); 84 temp_directory_.path()));
85 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, 85 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback,
86 base::Unretained(this))); 86 base::Unretained(this)));
87 PumpLoop(); 87 PumpLoop();
88 return store.Pass(); 88 return store;
89 } 89 }
90 90
91 void OfflinePageMetadataStoreImplTest::LoadCallback( 91 void OfflinePageMetadataStoreImplTest::LoadCallback(
92 OfflinePageMetadataStore::LoadStatus load_status, 92 OfflinePageMetadataStore::LoadStatus load_status,
93 const std::vector<OfflinePageItem>& offline_pages) { 93 const std::vector<OfflinePageItem>& offline_pages) {
94 last_called_callback_ = LOAD; 94 last_called_callback_ = LOAD;
95 last_status_ = load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ? 95 last_status_ = load_status == OfflinePageMetadataStore::LOAD_SUCCEEDED ?
96 STATUS_TRUE : STATUS_FALSE; 96 STATUS_TRUE : STATUS_FALSE;
97 offline_pages_.swap(const_cast<std::vector<OfflinePageItem>&>(offline_pages)); 97 offline_pages_.swap(const_cast<std::vector<OfflinePageItem>&>(offline_pages));
98 } 98 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, 131 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback,
132 base::Unretained(this), ADD)); 132 base::Unretained(this), ADD));
133 PumpLoop(); 133 PumpLoop();
134 EXPECT_EQ(ADD, last_called_callback_); 134 EXPECT_EQ(ADD, last_called_callback_);
135 EXPECT_EQ(STATUS_TRUE, last_status_); 135 EXPECT_EQ(STATUS_TRUE, last_status_);
136 136
137 ClearResults(); 137 ClearResults();
138 138
139 // Close the store first to ensure file lock is removed. 139 // Close the store first to ensure file lock is removed.
140 store.reset(); 140 store.reset();
141 store = BuildStore().Pass(); 141 store = BuildStore();
142 PumpLoop(); 142 PumpLoop();
143 143
144 EXPECT_EQ(LOAD, last_called_callback_); 144 EXPECT_EQ(LOAD, last_called_callback_);
145 EXPECT_EQ(STATUS_TRUE, last_status_); 145 EXPECT_EQ(STATUS_TRUE, last_status_);
146 EXPECT_EQ(1U, offline_pages_.size()); 146 EXPECT_EQ(1U, offline_pages_.size());
147 EXPECT_EQ(offline_page.url, offline_pages_[0].url); 147 EXPECT_EQ(offline_page.url, offline_pages_[0].url);
148 EXPECT_EQ(offline_page.bookmark_id, offline_pages_[0].bookmark_id); 148 EXPECT_EQ(offline_page.bookmark_id, offline_pages_[0].bookmark_id);
149 EXPECT_EQ(offline_page.version, offline_pages_[0].version); 149 EXPECT_EQ(offline_page.version, offline_pages_[0].version);
150 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); 150 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path);
151 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); 151 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, 196 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback,
197 base::Unretained(this))); 197 base::Unretained(this)));
198 PumpLoop(); 198 PumpLoop();
199 EXPECT_EQ(LOAD, last_called_callback_); 199 EXPECT_EQ(LOAD, last_called_callback_);
200 EXPECT_EQ(0U, offline_pages_.size()); 200 EXPECT_EQ(0U, offline_pages_.size());
201 201
202 ClearResults(); 202 ClearResults();
203 203
204 // Close and reload the store. 204 // Close and reload the store.
205 store.reset(); 205 store.reset();
206 store = BuildStore().Pass(); 206 store = BuildStore();
207 EXPECT_EQ(LOAD, last_called_callback_); 207 EXPECT_EQ(LOAD, last_called_callback_);
208 EXPECT_EQ(STATUS_TRUE, last_status_); 208 EXPECT_EQ(STATUS_TRUE, last_status_);
209 EXPECT_EQ(0U, offline_pages_.size()); 209 EXPECT_EQ(0U, offline_pages_.size());
210 } 210 }
211 211
212 // Adds metadata of multiple offline pages into a store and removes some. 212 // Adds metadata of multiple offline pages into a store and removes some.
213 TEST_F(OfflinePageMetadataStoreImplTest, AddRemoveMultipleOfflinePages) { 213 TEST_F(OfflinePageMetadataStoreImplTest, AddRemoveMultipleOfflinePages) {
214 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore()); 214 scoped_ptr<OfflinePageMetadataStoreImpl> store(BuildStore());
215 215
216 // Add an offline page. 216 // Add an offline page.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback, 258 base::Bind(&OfflinePageMetadataStoreImplTest::UpdateCallback,
259 base::Unretained(this), REMOVE)); 259 base::Unretained(this), REMOVE));
260 PumpLoop(); 260 PumpLoop();
261 EXPECT_EQ(REMOVE, last_called_callback_); 261 EXPECT_EQ(REMOVE, last_called_callback_);
262 EXPECT_EQ(STATUS_TRUE, last_status_); 262 EXPECT_EQ(STATUS_TRUE, last_status_);
263 263
264 ClearResults(); 264 ClearResults();
265 265
266 // Close and reload the store. 266 // Close and reload the store.
267 store.reset(); 267 store.reset();
268 store = BuildStore().Pass(); 268 store = BuildStore();
269 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback, 269 store->Load(base::Bind(&OfflinePageMetadataStoreImplTest::LoadCallback,
270 base::Unretained(this))); 270 base::Unretained(this)));
271 PumpLoop(); 271 PumpLoop();
272 272
273 EXPECT_EQ(LOAD, last_called_callback_); 273 EXPECT_EQ(LOAD, last_called_callback_);
274 EXPECT_EQ(STATUS_TRUE, last_status_); 274 EXPECT_EQ(STATUS_TRUE, last_status_);
275 EXPECT_EQ(1U, offline_pages_.size()); 275 EXPECT_EQ(1U, offline_pages_.size());
276 EXPECT_EQ(offline_page_2.url, offline_pages_[0].url); 276 EXPECT_EQ(offline_page_2.url, offline_pages_[0].url);
277 EXPECT_EQ(offline_page_2.bookmark_id, offline_pages_[0].bookmark_id); 277 EXPECT_EQ(offline_page_2.bookmark_id, offline_pages_[0].bookmark_id);
278 EXPECT_EQ(offline_page_2.version, offline_pages_[0].version); 278 EXPECT_EQ(offline_page_2.version, offline_pages_[0].version);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path); 341 EXPECT_EQ(offline_page.file_path, offline_pages_[0].file_path);
342 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size); 342 EXPECT_EQ(offline_page.file_size, offline_pages_[0].file_size);
343 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time); 343 EXPECT_EQ(offline_page.creation_time, offline_pages_[0].creation_time);
344 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time); 344 EXPECT_EQ(offline_page.last_access_time, offline_pages_[0].last_access_time);
345 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count); 345 EXPECT_EQ(offline_page.access_count, offline_pages_[0].access_count);
346 } 346 }
347 347
348 } // namespace 348 } // namespace
349 349
350 } // namespace offline_pages 350 } // namespace offline_pages
OLDNEW
« no previous file with comments | « components/offline_pages/offline_page_metadata_store_impl.cc ('k') | components/offline_pages/offline_page_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698