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

Side by Side Diff: chrome/browser/media_galleries/media_scan_manager_unittest.cc

Issue 167863002: Update media galleries scan results, even when zero. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix up test Created 6 years, 10 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 | « chrome/browser/media_galleries/media_scan_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/command_line.h" 6 #include "base/command_line.h"
7 #include "base/file_util.h" 7 #include "base/file_util.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 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 size_t galleries_before = gallery_prefs()->known_galleries().size(); 377 size_t galleries_before = gallery_prefs()->known_galleries().size();
378 378
379 MediaGalleryPrefId ungranted_scan = 379 MediaGalleryPrefId ungranted_scan =
380 AddGallery("uscan", MediaGalleryPrefInfo::kScanResult, 1, 0, 0); 380 AddGallery("uscan", MediaGalleryPrefInfo::kScanResult, 1, 0, 0);
381 MediaGalleryPrefId granted_scan = 381 MediaGalleryPrefId granted_scan =
382 AddGallery("gscan", MediaGalleryPrefInfo::kScanResult, 0, 2, 0); 382 AddGallery("gscan", MediaGalleryPrefInfo::kScanResult, 0, 2, 0);
383 gallery_prefs()->SetGalleryPermissionForExtension(*extension(), granted_scan, 383 gallery_prefs()->SetGalleryPermissionForExtension(*extension(), granted_scan,
384 true); 384 true);
385 EXPECT_EQ(galleries_before + 2, gallery_prefs()->known_galleries().size()); 385 EXPECT_EQ(galleries_before + 2, gallery_prefs()->known_galleries().size());
386 386
387 // Run once with no scan results. "uscan" should go away, but "gscan" should 387 // Run once with no scan results. "uscan" should go away and "gscan" should
388 // be unaffected. 388 // have its scan counts updated.
389 MediaFolderFinder::MediaFolderFinderResults found_folders; 389 MediaFolderFinder::MediaFolderFinderResults found_folders;
390 SetFindFoldersResults(true, found_folders); 390 SetFindFoldersResults(true, found_folders);
391 391
392 MediaGalleryScanResult file_counts; 392 MediaGalleryScanResult file_counts;
393 SetExpectedScanResults(0 /*gallery_count*/, file_counts); 393 SetExpectedScanResults(0 /*gallery_count*/, file_counts);
394 StartScan(); 394 StartScan();
395 395
396 base::RunLoop().RunUntilIdle(); 396 base::RunLoop().RunUntilIdle();
397 EXPECT_EQ(1, FindFolderDestroyCount()); 397 EXPECT_EQ(1, FindFolderDestroyCount());
398 EXPECT_EQ(galleries_before + 1, gallery_prefs()->known_galleries().size()); 398 EXPECT_EQ(galleries_before + 1, gallery_prefs()->known_galleries().size());
399 CheckFileCounts(granted_scan, 0, 2, 0); 399 CheckFileCounts(granted_scan, 0, 0, 0);
400 400
401 MediaGalleryPrefId id = 401 MediaGalleryPrefId id =
402 AddGallery("uscan", MediaGalleryPrefInfo::kScanResult, 1, 1, 1); 402 AddGallery("uscan", MediaGalleryPrefInfo::kScanResult, 1, 1, 1);
403 EXPECT_NE(id, ungranted_scan); 403 EXPECT_NE(id, ungranted_scan);
404 ungranted_scan = id; 404 ungranted_scan = id;
405 405
406 // Add scan results near the existing scan results. 406 // Add scan results near the existing scan results.
407 file_counts.audio_count = 0; 407 file_counts.audio_count = 0;
408 file_counts.image_count = 0; 408 file_counts.image_count = 0;
409 file_counts.video_count = 7; 409 file_counts.video_count = 7;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 CheckFileCounts(auto_id, 1, 0, 0); 442 CheckFileCounts(auto_id, 1, 0, 0);
443 CheckFileCounts(user_id, 0, 2, 0); 443 CheckFileCounts(user_id, 0, 2, 0);
444 CheckFileCounts(scan_id, 0, 0, 3); 444 CheckFileCounts(scan_id, 0, 0, 3);
445 445
446 MediaFolderFinder::MediaFolderFinderResults found_folders; 446 MediaFolderFinder::MediaFolderFinderResults found_folders;
447 MediaGalleryScanResult file_counts; 447 MediaGalleryScanResult file_counts;
448 file_counts.audio_count = 4; 448 file_counts.audio_count = 4;
449 base::FilePath path = MakeTestFolder("auto/dir1"); 449 base::FilePath path = MakeTestFolder("auto/dir1");
450 found_folders[path] = file_counts; 450 found_folders[path] = file_counts;
451 451
452 file_counts.audio_count = 6;
453 path = MakeTestFolder("scan");
454 found_folders[path] = file_counts;
455
452 file_counts.audio_count = 5; 456 file_counts.audio_count = 5;
453 path = MakeTestFolder("user/dir2"); 457 path = MakeTestFolder("user/dir2");
454 found_folders[path] = file_counts; 458 found_folders[path] = file_counts;
455 459
456 file_counts.audio_count = 6;
457 path = MakeTestFolder("scan");
458 found_folders[path] = file_counts;
459
460 SetFindFoldersResults(true, found_folders); 460 SetFindFoldersResults(true, found_folders);
461 461
462 file_counts.audio_count = 0; 462 file_counts.audio_count = 0;
463 SetExpectedScanResults(0 /*gallery_count*/, file_counts); 463 SetExpectedScanResults(0 /*gallery_count*/, file_counts);
464 StartScan(); 464 StartScan();
465 465
466 base::RunLoop().RunUntilIdle(); 466 base::RunLoop().RunUntilIdle();
467 EXPECT_EQ(1, FindFolderDestroyCount()); 467 EXPECT_EQ(1, FindFolderDestroyCount());
468 EXPECT_EQ(galleries_before + 3, gallery_prefs()->known_galleries().size()); 468 EXPECT_EQ(galleries_before + 3, gallery_prefs()->known_galleries().size());
469 CheckFileCounts(auto_id, 4, 0, 0); 469 CheckFileCounts(auto_id, 4, 0, 0);
470 CheckFileCounts(user_id, 5, 0, 0); 470 CheckFileCounts(user_id, 5, 0, 0);
471 CheckFileCounts(scan_id, 6, 0, 0); 471 CheckFileCounts(scan_id, 6, 0, 0);
472
473 EXPECT_EQ(1U, found_folders.erase(path));
474 SetFindFoldersResults(true, found_folders);
475 SetExpectedScanResults(0 /*gallery_count*/, file_counts);
476 StartScan();
477
478 base::RunLoop().RunUntilIdle();
479 EXPECT_EQ(2, FindFolderDestroyCount());
480 EXPECT_EQ(galleries_before + 3, gallery_prefs()->known_galleries().size());
481 CheckFileCounts(auto_id, 4, 0, 0);
482 CheckFileCounts(user_id, 0, 0, 0);
483 CheckFileCounts(scan_id, 6, 0, 0);
472 } 484 }
OLDNEW
« no previous file with comments | « chrome/browser/media_galleries/media_scan_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698