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

Side by Side Diff: chrome/browser/media_galleries/fileapi/picasa_data_provider_browsertest.cc

Issue 624173002: replace OVERRIDE and FINAL with override and final in chrome/browser/[j-q]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/files/file_enumerator.h" 7 #include "base/files/file_enumerator.h"
8 #include "base/files/file_util.h" 8 #include "base/files/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 ASSERT_TRUE( 130 ASSERT_TRUE(
131 base::Move(src_path, database_path_.Append(src_path.BaseName()))); 131 base::Move(src_path, database_path_.Append(src_path.BaseName())));
132 } 132 }
133 } 133 }
134 134
135 void SetInvalidateCallback(const base::Closure& callback) { 135 void SetInvalidateCallback(const base::Closure& callback) {
136 DCHECK(invalidate_callback_.is_null()); 136 DCHECK(invalidate_callback_.is_null());
137 invalidate_callback_ = callback; 137 invalidate_callback_ = callback;
138 } 138 }
139 139
140 virtual void InvalidateData() OVERRIDE { 140 virtual void InvalidateData() override {
141 PicasaDataProvider::InvalidateData(); 141 PicasaDataProvider::InvalidateData();
142 142
143 if (!invalidate_callback_.is_null()) { 143 if (!invalidate_callback_.is_null()) {
144 invalidate_callback_.Run(); 144 invalidate_callback_.Run();
145 invalidate_callback_.Reset(); 145 invalidate_callback_.Reset();
146 } 146 }
147 } 147 }
148 148
149 void SetAlbumMapsForTesting(const AlbumMap& album_map, 149 void SetAlbumMapsForTesting(const AlbumMap& album_map,
150 const AlbumMap& folder_map) { 150 const AlbumMap& folder_map) {
151 album_map_ = album_map; 151 album_map_ = album_map;
152 folder_map_ = folder_map; 152 folder_map_ = folder_map;
153 } 153 }
154 154
155 private: 155 private:
156 virtual void OnTempDirWatchStarted( 156 virtual void OnTempDirWatchStarted(
157 scoped_ptr<base::FilePathWatcher> temp_dir_watcher) OVERRIDE { 157 scoped_ptr<base::FilePathWatcher> temp_dir_watcher) override {
158 PicasaDataProvider::OnTempDirWatchStarted(temp_dir_watcher.Pass()); 158 PicasaDataProvider::OnTempDirWatchStarted(temp_dir_watcher.Pass());
159 159
160 file_watch_request_returned_ = true; 160 file_watch_request_returned_ = true;
161 for (std::vector<ReadyCallback>::const_iterator it = 161 for (std::vector<ReadyCallback>::const_iterator it =
162 file_watch_started_callbacks_.begin(); 162 file_watch_started_callbacks_.begin();
163 it != file_watch_started_callbacks_.end(); 163 it != file_watch_started_callbacks_.end();
164 ++it) { 164 ++it) {
165 it->Run(temp_dir_watcher_.get() != NULL); 165 it->Run(temp_dir_watcher_.get() != NULL);
166 } 166 }
167 file_watch_started_callbacks_.clear(); 167 file_watch_started_callbacks_.clear();
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 272
273 scoped_ptr<TestPicasaDataProvider> picasa_data_provider_; 273 scoped_ptr<TestPicasaDataProvider> picasa_data_provider_;
274 274
275 base::Closure quit_closure_; 275 base::Closure quit_closure_;
276 276
277 DISALLOW_COPY_AND_ASSIGN(PicasaDataProviderTest); 277 DISALLOW_COPY_AND_ASSIGN(PicasaDataProviderTest);
278 }; 278 };
279 279
280 class PicasaDataProviderNoDatabaseGetListTest : public PicasaDataProviderTest { 280 class PicasaDataProviderNoDatabaseGetListTest : public PicasaDataProviderTest {
281 protected: 281 protected:
282 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { 282 virtual PicasaDataProvider::DataType RequestedDataType() const override {
283 return PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA; 283 return PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA;
284 } 284 }
285 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { 285 virtual void VerifyRefreshResults(bool parse_success) override {
286 EXPECT_FALSE(parse_success); 286 EXPECT_FALSE(parse_success);
287 TestDone(); 287 TestDone();
288 } 288 }
289 }; 289 };
290 290
291 IN_PROC_BROWSER_TEST_F(PicasaDataProviderNoDatabaseGetListTest, 291 IN_PROC_BROWSER_TEST_F(PicasaDataProviderNoDatabaseGetListTest,
292 NoDatabaseGetList) { 292 NoDatabaseGetList) {
293 RunTest(); 293 RunTest();
294 } 294 }
295 295
296 class PicasaDataProviderNoDatabaseGetAlbumsImagesTest 296 class PicasaDataProviderNoDatabaseGetAlbumsImagesTest
297 : public PicasaDataProviderTest { 297 : public PicasaDataProviderTest {
298 protected: 298 protected:
299 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { 299 virtual PicasaDataProvider::DataType RequestedDataType() const override {
300 return PicasaDataProvider::ALBUMS_IMAGES_DATA; 300 return PicasaDataProvider::ALBUMS_IMAGES_DATA;
301 } 301 }
302 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { 302 virtual void VerifyRefreshResults(bool parse_success) override {
303 EXPECT_FALSE(parse_success); 303 EXPECT_FALSE(parse_success);
304 TestDone(); 304 TestDone();
305 } 305 }
306 }; 306 };
307 307
308 IN_PROC_BROWSER_TEST_F(PicasaDataProviderNoDatabaseGetAlbumsImagesTest, 308 IN_PROC_BROWSER_TEST_F(PicasaDataProviderNoDatabaseGetAlbumsImagesTest,
309 NoDatabaseGetAlbumsImages) { 309 NoDatabaseGetAlbumsImages) {
310 RunTest(); 310 RunTest();
311 } 311 }
312 312
313 class PicasaDataProviderGetListTest : public PicasaDataProviderTest { 313 class PicasaDataProviderGetListTest : public PicasaDataProviderTest {
314 protected: 314 protected:
315 virtual void InitializeTestData() OVERRIDE { 315 virtual void InitializeTestData() override {
316 WriteTestAlbumTable(GetColumnFileDestination(), test_folder_1_path(), 316 WriteTestAlbumTable(GetColumnFileDestination(), test_folder_1_path(),
317 test_folder_2_path()); 317 test_folder_2_path());
318 } 318 }
319 319
320 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { 320 virtual PicasaDataProvider::DataType RequestedDataType() const override {
321 return PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA; 321 return PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA;
322 } 322 }
323 323
324 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { 324 virtual void VerifyRefreshResults(bool parse_success) override {
325 ASSERT_TRUE(parse_success); 325 ASSERT_TRUE(parse_success);
326 VerifyTestAlbumTable( 326 VerifyTestAlbumTable(
327 data_provider(), test_folder_1_path(), test_folder_2_path()); 327 data_provider(), test_folder_1_path(), test_folder_2_path());
328 TestDone(); 328 TestDone();
329 } 329 }
330 }; 330 };
331 331
332 IN_PROC_BROWSER_TEST_F(PicasaDataProviderGetListTest, GetListTest) { 332 IN_PROC_BROWSER_TEST_F(PicasaDataProviderGetListTest, GetListTest) {
333 RunTest(); 333 RunTest();
334 } 334 }
335 335
336 class PicasaDataProviderGetAlbumsImagesTest : public PicasaDataProviderTest { 336 class PicasaDataProviderGetAlbumsImagesTest : public PicasaDataProviderTest {
337 protected: 337 protected:
338 virtual void InitializeTestData() OVERRIDE { 338 virtual void InitializeTestData() override {
339 WriteTestAlbumTable(GetColumnFileDestination(), test_folder_1_path(), 339 WriteTestAlbumTable(GetColumnFileDestination(), test_folder_1_path(),
340 test_folder_2_path()); 340 test_folder_2_path());
341 WriteTestAlbumsImagesIndex(test_folder_1_path(), test_folder_2_path()); 341 WriteTestAlbumsImagesIndex(test_folder_1_path(), test_folder_2_path());
342 } 342 }
343 343
344 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { 344 virtual PicasaDataProvider::DataType RequestedDataType() const override {
345 return PicasaDataProvider::ALBUMS_IMAGES_DATA; 345 return PicasaDataProvider::ALBUMS_IMAGES_DATA;
346 } 346 }
347 347
348 virtual void VerifyRefreshResults(bool parse_success) OVERRIDE { 348 virtual void VerifyRefreshResults(bool parse_success) override {
349 ASSERT_TRUE(parse_success); 349 ASSERT_TRUE(parse_success);
350 VerifyTestAlbumTable( 350 VerifyTestAlbumTable(
351 data_provider(), test_folder_1_path(), test_folder_2_path()); 351 data_provider(), test_folder_1_path(), test_folder_2_path());
352 VerifyTestAlbumsImagesIndex( 352 VerifyTestAlbumsImagesIndex(
353 data_provider(), test_folder_1_path(), test_folder_2_path()); 353 data_provider(), test_folder_1_path(), test_folder_2_path());
354 TestDone(); 354 TestDone();
355 } 355 }
356 }; 356 };
357 357
358 IN_PROC_BROWSER_TEST_F(PicasaDataProviderGetAlbumsImagesTest, 358 IN_PROC_BROWSER_TEST_F(PicasaDataProviderGetAlbumsImagesTest,
359 GetAlbumsImagesTest) { 359 GetAlbumsImagesTest) {
360 RunTest(); 360 RunTest();
361 } 361 }
362 362
363 class PicasaDataProviderMultipleMixedCallbacksTest 363 class PicasaDataProviderMultipleMixedCallbacksTest
364 : public PicasaDataProviderTest { 364 : public PicasaDataProviderTest {
365 public: 365 public:
366 PicasaDataProviderMultipleMixedCallbacksTest() 366 PicasaDataProviderMultipleMixedCallbacksTest()
367 : list_callbacks_called_(0), albums_images_callbacks_called_(0) {} 367 : list_callbacks_called_(0), albums_images_callbacks_called_(0) {}
368 368
369 virtual void InitializeTestData() OVERRIDE { 369 virtual void InitializeTestData() override {
370 WriteTestAlbumTable(GetColumnFileDestination(), test_folder_1_path(), 370 WriteTestAlbumTable(GetColumnFileDestination(), test_folder_1_path(),
371 test_folder_2_path()); 371 test_folder_2_path());
372 WriteTestAlbumsImagesIndex(test_folder_1_path(), test_folder_2_path()); 372 WriteTestAlbumsImagesIndex(test_folder_1_path(), test_folder_2_path());
373 } 373 }
374 374
375 virtual PicasaDataProvider::DataType RequestedDataType() const OVERRIDE { 375 virtual PicasaDataProvider::DataType RequestedDataType() const override {
376 return PicasaDataProvider::ALBUMS_IMAGES_DATA; 376 return PicasaDataProvider::ALBUMS_IMAGES_DATA;
377 } 377 }
378 378
379 protected: 379 protected:
380 virtual void ListCallback(int expected_list_callbacks_called, 380 virtual void ListCallback(int expected_list_callbacks_called,
381 bool parse_success) { 381 bool parse_success) {
382 ASSERT_TRUE(parse_success); 382 ASSERT_TRUE(parse_success);
383 ASSERT_EQ(expected_list_callbacks_called, ++list_callbacks_called_); 383 ASSERT_EQ(expected_list_callbacks_called, ++list_callbacks_called_);
384 VerifyTestAlbumTable( 384 VerifyTestAlbumTable(
385 data_provider(), test_folder_1_path(), test_folder_2_path()); 385 data_provider(), test_folder_1_path(), test_folder_2_path());
(...skipping 11 matching lines...) Expand all
397 } 397 }
398 398
399 private: 399 private:
400 void CheckTestDone() { 400 void CheckTestDone() {
401 ASSERT_LE(list_callbacks_called_, 2); 401 ASSERT_LE(list_callbacks_called_, 2);
402 ASSERT_LE(albums_images_callbacks_called_, 2); 402 ASSERT_LE(albums_images_callbacks_called_, 2);
403 if (list_callbacks_called_ == 2 && albums_images_callbacks_called_ == 2) 403 if (list_callbacks_called_ == 2 && albums_images_callbacks_called_ == 2)
404 TestDone(); 404 TestDone();
405 } 405 }
406 406
407 virtual void StartTestOnMediaTaskRunner() OVERRIDE { 407 virtual void StartTestOnMediaTaskRunner() override {
408 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); 408 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
409 409
410 data_provider()->RefreshData( 410 data_provider()->RefreshData(
411 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, 411 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA,
412 base::Bind(&PicasaDataProviderMultipleMixedCallbacksTest::ListCallback, 412 base::Bind(&PicasaDataProviderMultipleMixedCallbacksTest::ListCallback,
413 base::Unretained(this), 413 base::Unretained(this),
414 1)); 414 1));
415 data_provider()->RefreshData( 415 data_provider()->RefreshData(
416 PicasaDataProvider::ALBUMS_IMAGES_DATA, 416 PicasaDataProvider::ALBUMS_IMAGES_DATA,
417 base::Bind( 417 base::Bind(
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 &PicasaDataProvider::RefreshData, 459 &PicasaDataProvider::RefreshData,
460 base::Unretained(data_provider()), 460 base::Unretained(data_provider()),
461 RequestedDataType(), 461 RequestedDataType(),
462 base::Bind( 462 base::Bind(
463 &PicasaDataProviderFileWatcherInvalidateTest::VerifyRefreshResults, 463 &PicasaDataProviderFileWatcherInvalidateTest::VerifyRefreshResults,
464 base::Unretained(this)))); 464 base::Unretained(this))));
465 465
466 data_provider()->MoveTempFilesToDatabase(); 466 data_provider()->MoveTempFilesToDatabase();
467 } 467 }
468 468
469 virtual base::FilePath GetColumnFileDestination() const OVERRIDE { 469 virtual base::FilePath GetColumnFileDestination() const override {
470 return GetTempDirPath(); 470 return GetTempDirPath();
471 } 471 }
472 472
473 private: 473 private:
474 virtual void StartTestOnMediaTaskRunner() OVERRIDE { 474 virtual void StartTestOnMediaTaskRunner() override {
475 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); 475 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
476 476
477 // Refresh before moving album table to database dir, guaranteeing failure. 477 // Refresh before moving album table to database dir, guaranteeing failure.
478 data_provider()->RefreshData( 478 data_provider()->RefreshData(
479 RequestedDataType(), 479 RequestedDataType(),
480 base::Bind( 480 base::Bind(
481 &PicasaDataProviderFileWatcherInvalidateTest::ListCallback, 481 &PicasaDataProviderFileWatcherInvalidateTest::ListCallback,
482 base::Unretained(this))); 482 base::Unretained(this)));
483 } 483 }
484 }; 484 };
485 485
486 IN_PROC_BROWSER_TEST_F(PicasaDataProviderFileWatcherInvalidateTest, 486 IN_PROC_BROWSER_TEST_F(PicasaDataProviderFileWatcherInvalidateTest,
487 FileWatcherInvalidateTest) { 487 FileWatcherInvalidateTest) {
488 RunTest(); 488 RunTest();
489 } 489 }
490 490
491 class PicasaDataProviderInvalidateInflightTableReaderTest 491 class PicasaDataProviderInvalidateInflightTableReaderTest
492 : public PicasaDataProviderGetListTest { 492 : public PicasaDataProviderGetListTest {
493 protected: 493 protected:
494 // Don't write the database files until later. 494 // Don't write the database files until later.
495 virtual void InitializeTestData() OVERRIDE {} 495 virtual void InitializeTestData() override {}
496 496
497 private: 497 private:
498 virtual void StartTestOnMediaTaskRunner() OVERRIDE { 498 virtual void StartTestOnMediaTaskRunner() override {
499 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); 499 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
500 500
501 // Refresh before the database files have been written. 501 // Refresh before the database files have been written.
502 // This is guaranteed to fail to read the album table. 502 // This is guaranteed to fail to read the album table.
503 data_provider()->RefreshData( 503 data_provider()->RefreshData(
504 RequestedDataType(), 504 RequestedDataType(),
505 base::Bind(&PicasaDataProviderInvalidateInflightTableReaderTest:: 505 base::Bind(&PicasaDataProviderInvalidateInflightTableReaderTest::
506 VerifyRefreshResults, 506 VerifyRefreshResults,
507 base::Unretained(this))); 507 base::Unretained(this)));
508 508
(...skipping 25 matching lines...) Expand all
534 VerifyRefreshResults, 534 VerifyRefreshResults,
535 base::Unretained(this))); 535 base::Unretained(this)));
536 536
537 // Now invalidate all the data. The album maps will be re-read. 537 // Now invalidate all the data. The album maps will be re-read.
538 data_provider()->InvalidateData(); 538 data_provider()->InvalidateData();
539 539
540 // VerifyRefreshResults callback should receive correct results now. 540 // VerifyRefreshResults callback should receive correct results now.
541 } 541 }
542 542
543 private: 543 private:
544 virtual void StartTestOnMediaTaskRunner() OVERRIDE { 544 virtual void StartTestOnMediaTaskRunner() override {
545 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread()); 545 DCHECK(MediaFileSystemBackend::CurrentlyOnMediaTaskRunnerThread());
546 546
547 data_provider()->RefreshData( 547 data_provider()->RefreshData(
548 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA, 548 PicasaDataProvider::LIST_OF_ALBUMS_AND_FOLDERS_DATA,
549 base::Bind(&PicasaDataProviderInvalidateInflightAlbumsIndexerTest:: 549 base::Bind(&PicasaDataProviderInvalidateInflightAlbumsIndexerTest::
550 ListCallback, 550 ListCallback,
551 base::Unretained(this))); 551 base::Unretained(this)));
552 } 552 }
553 }; 553 };
554 554
555 IN_PROC_BROWSER_TEST_F(PicasaDataProviderInvalidateInflightAlbumsIndexerTest, 555 IN_PROC_BROWSER_TEST_F(PicasaDataProviderInvalidateInflightAlbumsIndexerTest,
556 InvalidateInflightAlbumsIndexerTest) { 556 InvalidateInflightAlbumsIndexerTest) {
557 RunTest(); 557 RunTest();
558 } 558 }
559 559
560 } // namespace picasa 560 } // namespace picasa
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698