chrome/browser/media_gallery/media_galleries_preferences_unittest.cc
// Whenever a gallery is added, its type is either set to "AutoDetected" or
// "UserAdded". When the gallery is removed, user added galleries are actually
// deleted and the auto detected galleries are moved to black listed state.
// When the gallery is added again, the black listed state is updated back to
// "AutoDetected" type.
Whenever a gallery is added, its type is either set to "AutoDetected" or
"UserAdded". When the gallery is removed, user added galleries are actually
deleted and the auto detected galleries are moved to black listed state.
When the gallery is added again, the black listed state is updated back to
"AutoDetected" type.
Whenever a gallery is added its type is either set to " AutoDetected " or " UserAdded " . When the gallery is removed user added galleries are actually deleted and the auto detected galleries are moved to black listed state . When the gallery is added again the black listed state is updated back to " AutoDetected " type .
TEST_F(MediaGalleriesPreferencesTest, UpdateGalleryType) {
  MediaGalleryPrefId auto_id, id;
  FilePath path;
  std::string device_id;
  string16 device_name;
  FilePath relative_path;
  Verify();
  path = MakePath("new_auto");
  MediaStorageUtil::GetDeviceInfoFromPath(path, &device_id, NULL,
                                          &relative_path);
  device_name = ASCIIToUTF16("NewAutoGallery");
  id = gallery_prefs()->AddGallery(device_id, device_name, relative_path,
                                   false );
  EXPECT_EQ(default_galleries_count() + 1UL, id);
  auto_id = id;
  AddGalleryExpectation(id, device_name, device_id, relative_path,
                        MediaGalleryPrefInfo::kAutoDetected);
  Verify();
  gallery_prefs()->ForgetGalleryById(auto_id);
  expected_galleries_[auto_id].type = MediaGalleryPrefInfo::kBlackListed;
  expected_galleries_for_all.erase(auto_id);
  Verify();
  id = gallery_prefs()->AddGalleryByPath(path);
  EXPECT_EQ(auto_id, id);
  AddGalleryExpectation(id, device_name, device_id, relative_path,
                        MediaGalleryPrefInfo::kAutoDetected);
  Verify();
}
TEST_F ( MediaGalleriesPreferencesTest , UpdateGalleryType ) { MediaGalleryPrefId auto_id , id ; FilePath path ; std :: string device_id ; string16 device_name ; FilePath relative_path ; Verify ( ) ; path = MakePath ( " " ) ; MediaStorageUtil :: GetDeviceInfoFromPath ( path , & device_id , NULL , & relative_path ) ; device_name = ASCIIToUTF16 ( " " ) ; id = gallery_prefs ( ) -> AddGallery ( device_id , device_name , relative_path , false ) ; EXPECT_EQ ( default_galleries_count ( ) + 1UL , id ) ; auto_id = id ; AddGalleryExpectation ( id , device_name , device_id , relative_path , MediaGalleryPrefInfo :: kAutoDetected ) ; Verify ( ) ; gallery_prefs ( ) -> ForgetGalleryById ( auto_id ) ; expected_galleries_ [ auto_id ] . type = MediaGalleryPrefInfo :: kBlackListed ; expected_galleries_for_all . erase ( auto_id ) ; Verify ( ) ; id = gallery_prefs ( ) -> AddGalleryByPath ( path ) ; EXPECT_EQ ( auto_id , id ) ; AddGalleryExpectation ( id , device_name , device_id , relative_path , MediaGalleryPrefInfo :: kAutoDetected ) ; Verify ( ) ; }
Whenever a gallery is added, its type is either set to "AutoDetected" or
"UserAdded".
Whenever a gallery is added its type is either set to " AutoDetected " or " UserAdded " .
// Add a new auto detect gallery to test with. /*auto*/ // Remove an auto added gallery (i.e. make it blacklisted). // Add the gallery again.