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

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

Issue 148063006: Put all scan results in the media galleries scan result dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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
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/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 23 matching lines...) Expand all
34 base::FilePath MakePath(std::string dir) { 34 base::FilePath MakePath(std::string dir) {
35 #if defined(OS_WIN) 35 #if defined(OS_WIN)
36 return base::FilePath(FILE_PATH_LITERAL("C:\\")).AppendASCII(dir); 36 return base::FilePath(FILE_PATH_LITERAL("C:\\")).AppendASCII(dir);
37 #elif defined(OS_POSIX) 37 #elif defined(OS_POSIX)
38 return base::FilePath(FILE_PATH_LITERAL("/")).Append(dir); 38 return base::FilePath(FILE_PATH_LITERAL("/")).Append(dir);
39 #else 39 #else
40 NOTIMPLEMENTED(); 40 NOTIMPLEMENTED();
41 #endif 41 #endif
42 } 42 }
43 43
44 MediaGalleryPrefId AddScanResult(MediaGalleriesPreferences* gallery_prefs,
45 const std::string& path, int audio_count,
46 int image_count, int video_count) {
47 MediaGalleryPrefInfo gallery_info;
48 gallery_prefs->LookUpGalleryByPath(MakePath(path), &gallery_info);
49 return gallery_prefs->AddGallery(
50 gallery_info.device_id,
51 gallery_info.path,
52 MediaGalleryPrefInfo::kScanResult,
53 gallery_info.volume_label,
54 gallery_info.vendor_name,
55 gallery_info.model_name,
56 gallery_info.total_size_in_bytes,
57 gallery_info.last_attach_time,
58 audio_count, image_count, video_count);
59 }
60
61 class MockMediaGalleriesScanResultDialog 44 class MockMediaGalleriesScanResultDialog
62 : public MediaGalleriesScanResultDialog { 45 : public MediaGalleriesScanResultDialog {
63 public: 46 public:
64 typedef base::Callback<void(int update_count)> DialogDestroyedCallback; 47 typedef base::Callback<void(int update_count)> DialogDestroyedCallback;
65 48
66 explicit MockMediaGalleriesScanResultDialog( 49 explicit MockMediaGalleriesScanResultDialog(
67 const DialogDestroyedCallback& callback) 50 const DialogDestroyedCallback& callback)
68 : update_count_(0), 51 : update_count_(0),
69 dialog_destroyed_callback_(callback) { 52 dialog_destroyed_callback_(callback) {
70 } 53 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 CommandLine::ForCurrentProcess(), base::FilePath(), false); 101 CommandLine::ForCurrentProcess(), base::FilePath(), false);
119 102
120 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get())); 103 gallery_prefs_.reset(new MediaGalleriesPreferences(profile_.get()));
121 base::RunLoop loop; 104 base::RunLoop loop;
122 gallery_prefs_->EnsureInitialized(loop.QuitClosure()); 105 gallery_prefs_->EnsureInitialized(loop.QuitClosure());
123 loop.Run(); 106 loop.Run();
124 107
125 std::vector<std::string> read_permissions; 108 std::vector<std::string> read_permissions;
126 read_permissions.push_back( 109 read_permissions.push_back(
127 extensions::MediaGalleriesPermission::kReadPermission); 110 extensions::MediaGalleriesPermission::kReadPermission);
128 extension_ = AddMediaGalleriesApp("read", read_permissions, profile_.get()); 111 extension_ = AddMediaGalleriesApp("allauto", read_permissions,
tommycli 2014/02/10 18:45:53 why did the name change to 'allauto'?
vandebo (ex-Chrome) 2014/02/11 19:19:31 incompletely reverted change. Fixed.
112 profile_.get());
129 } 113 }
130 114
131 virtual void TearDown() OVERRIDE { 115 virtual void TearDown() OVERRIDE {
132 TestStorageMonitor::RemoveSingleton(); 116 TestStorageMonitor::RemoveSingleton();
133 } 117 }
134 118
135 void StartDialog() { 119 void StartDialog() {
136 ASSERT_FALSE(controller_); 120 ASSERT_FALSE(controller_);
137 controller_ = new MediaGalleriesScanResultDialogController( 121 controller_ = new MediaGalleriesScanResultDialogController(
138 *extension_.get(), 122 *extension_.get(),
(...skipping 20 matching lines...) Expand all
159 } 143 }
160 144
161 extensions::Extension* extension() { 145 extensions::Extension* extension() {
162 return extension_.get(); 146 return extension_.get();
163 } 147 }
164 148
165 MediaGalleriesPreferences* gallery_prefs() { 149 MediaGalleriesPreferences* gallery_prefs() {
166 return gallery_prefs_.get(); 150 return gallery_prefs_.get();
167 } 151 }
168 152
153 MediaGalleryPrefId AddGallery(const std::string& path,
154 MediaGalleryPrefInfo::Type type,
155 int audio_count, int image_count,
Lei Zhang 2014/02/10 19:55:22 Switch to MediaGalleryScanResult?
vandebo (ex-Chrome) 2014/02/11 19:19:31 For the testing code, it's easier to take three in
156 int video_count) {
157 MediaGalleryPrefInfo gallery_info;
158 gallery_prefs_->LookUpGalleryByPath(MakePath(path), &gallery_info);
159 return gallery_prefs_->AddGallery(
160 gallery_info.device_id,
161 gallery_info.path,
162 type,
163 gallery_info.volume_label,
164 gallery_info.vendor_name,
165 gallery_info.model_name,
166 gallery_info.total_size_in_bytes,
167 gallery_info.last_attach_time,
168 audio_count, image_count, video_count);
169 }
170
171 MediaGalleryPrefId AddScanResult(const std::string& path, int audio_count,
172 int image_count, int video_count) {
173 return AddGallery(path, MediaGalleryPrefInfo::kScanResult, audio_count,
174 image_count, video_count);
175 }
176
169 private: 177 private:
170 MediaGalleriesScanResultDialog* CreateMockDialog( 178 MediaGalleriesScanResultDialog* CreateMockDialog(
171 MediaGalleriesScanResultDialogController* controller) { 179 MediaGalleriesScanResultDialogController* controller) {
172 EXPECT_FALSE(dialog_); 180 EXPECT_FALSE(dialog_);
173 dialog_update_count_at_destruction_ = 0; 181 dialog_update_count_at_destruction_ = 0;
174 dialog_ = new MockMediaGalleriesScanResultDialog(base::Bind( 182 dialog_ = new MockMediaGalleriesScanResultDialog(base::Bind(
175 &MediaGalleriesScanResultDialogControllerTest::OnDialogDestroyed, 183 &MediaGalleriesScanResultDialogControllerTest::OnDialogDestroyed,
176 weak_factory_.GetWeakPtr())); 184 weak_factory_.GetWeakPtr()));
177 return dialog_; 185 return dialog_;
178 } 186 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 EXPECT_TRUE(dialog()); 232 EXPECT_TRUE(dialog());
225 EXPECT_EQ(0U, controller()->GetGalleryList().size()); 233 EXPECT_EQ(0U, controller()->GetGalleryList().size());
226 234
227 controller()->DialogFinished(true); 235 controller()->DialogFinished(true);
228 EXPECT_FALSE(controller()); 236 EXPECT_FALSE(controller());
229 EXPECT_FALSE(dialog()); 237 EXPECT_FALSE(dialog());
230 EXPECT_EQ(0, dialog_update_count_at_destruction()); 238 EXPECT_EQ(0, dialog_update_count_at_destruction());
231 } 239 }
232 240
233 TEST_F(MediaGalleriesScanResultDialogControllerTest, AddScanResults) { 241 TEST_F(MediaGalleriesScanResultDialogControllerTest, AddScanResults) {
234 // Start with two scan results. 242 // Start with two scan results.
tommycli 2014/02/10 18:45:53 comment is out of date if you intend to test with
vandebo (ex-Chrome) 2014/02/11 19:19:31 Nope - we haven't done a scan, so all the existing
235 MediaGalleryPrefId scan1 = 243 MediaGalleryPrefId scan_id = AddScanResult("scan_id", 1, 0, 0);
236 gallery_prefs()->AddGalleryByPath(MakePath("scan1"), 244 MediaGalleryPrefId auto_id =
237 MediaGalleryPrefInfo::kScanResult); 245 AddGallery("auto_id", MediaGalleryPrefInfo::kAutoDetected, 2, 0, 0);
tommycli 2014/02/10 18:45:53 I think kAutoDetected Galleries need to have 0, 0,
vandebo (ex-Chrome) 2014/02/11 19:19:31 Why do you say that?
238 MediaGalleryPrefId scan2 =
239 gallery_prefs()->AddGalleryByPath(MakePath("scan2"),
240 MediaGalleryPrefInfo::kScanResult);
241 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 246 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
242 247
243 // Show the dialog, but cancel it. 248 // Show the dialog, but cancel it.
244 StartDialog(); 249 StartDialog();
245 EXPECT_EQ(2U, controller()->GetGalleryList().size()); 250 EXPECT_EQ(2U, controller()->GetGalleryList().size());
246 controller()->DialogFinished(false); 251 controller()->DialogFinished(false);
247 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 252 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
248 253
249 // Show the dialog, unselect both and accept it. 254 // Show the dialog, unselect both and accept it.
250 StartDialog(); 255 StartDialog();
251 EXPECT_EQ(2U, controller()->GetGalleryList().size()); 256 EXPECT_EQ(2U, controller()->GetGalleryList().size());
252 controller()->DidToggleGalleryId(scan1, false); 257 controller()->DidToggleGalleryId(scan_id, false);
253 controller()->DidToggleGalleryId(scan2, false); 258 controller()->DidToggleGalleryId(auto_id, false);
254 controller()->DialogFinished(true); 259 controller()->DialogFinished(true);
255 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 260 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
256 261
257 // Show the dialog, leave one selected and accept it. 262 // Show the dialog, leave one selected and accept it.
258 StartDialog(); 263 StartDialog();
259 EXPECT_EQ(2U, controller()->GetGalleryList().size()); 264 EXPECT_EQ(2U, controller()->GetGalleryList().size());
260 controller()->DidToggleGalleryId(scan1, false); 265 controller()->DidToggleGalleryId(scan_id, false);
261 controller()->DialogFinished(true); 266 controller()->DialogFinished(true);
262 MediaGalleryPrefIdSet permitted = 267 MediaGalleryPrefIdSet permitted =
263 gallery_prefs()->GalleriesForExtension(*extension()); 268 gallery_prefs()->GalleriesForExtension(*extension());
264 ASSERT_EQ(1U, permitted.size()); 269 ASSERT_EQ(1U, permitted.size());
265 EXPECT_EQ(scan2, *permitted.begin()); 270 EXPECT_EQ(auto_id, *permitted.begin());
266 271
267 // Show the dialog, toggle the remaining entry twice and then accept it. 272 // Show the dialog, toggle the remaining entry twice and then accept it.
268 StartDialog(); 273 StartDialog();
269 EXPECT_EQ(1U, controller()->GetGalleryList().size()); 274 EXPECT_EQ(1U, controller()->GetGalleryList().size());
270 controller()->DidToggleGalleryId(scan1, false); 275 controller()->DidToggleGalleryId(scan_id, false);
271 controller()->DidToggleGalleryId(scan1, true); 276 controller()->DidToggleGalleryId(scan_id, true);
272 controller()->DialogFinished(true); 277 controller()->DialogFinished(true);
273 EXPECT_EQ(2U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 278 EXPECT_EQ(2U, gallery_prefs()->GalleriesForExtension(*extension()).size());
274 } 279 }
275 280
276 TEST_F(MediaGalleriesScanResultDialogControllerTest, Blacklisted) { 281 TEST_F(MediaGalleriesScanResultDialogControllerTest, Blacklisted) {
277 // Start with two scan results. 282 // Start with two scan results.
tommycli 2014/02/10 18:45:53 out of date
278 MediaGalleryPrefId scan1 = 283 MediaGalleryPrefId scan_id = AddScanResult("scan_id", 1, 0, 0);
279 gallery_prefs()->AddGalleryByPath(MakePath("scan1"), 284 MediaGalleryPrefId auto_id =
280 MediaGalleryPrefInfo::kScanResult); 285 AddGallery("auto_id", MediaGalleryPrefInfo::kAutoDetected, 2, 0, 0);
tommycli 2014/02/10 18:45:53 0, 0, 0
281 MediaGalleryPrefId scan2 =
282 gallery_prefs()->AddGalleryByPath(MakePath("scan2"),
283 MediaGalleryPrefInfo::kScanResult);
284 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 286 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
285 287
286 // Show the dialog, but cancel it. 288 // Show the dialog, but cancel it.
287 StartDialog(); 289 StartDialog();
288 EXPECT_EQ(2U, controller()->GetGalleryList().size()); 290 EXPECT_EQ(2U, controller()->GetGalleryList().size());
289 controller()->DialogFinished(false); 291 controller()->DialogFinished(false);
290 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 292 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
291 293
292 // Blacklist one and try again. 294 // Blacklist one and try again.
293 gallery_prefs()->ForgetGalleryById(scan2); 295 gallery_prefs()->ForgetGalleryById(scan_id);
294 StartDialog(); 296 StartDialog();
295 EXPECT_EQ(1U, controller()->GetGalleryList().size()); 297 EXPECT_EQ(1U, controller()->GetGalleryList().size());
296 controller()->DialogFinished(false); 298 controller()->DialogFinished(false);
297 299
298 // Adding it as a user gallery should change its type. 300 // Adding it as a user gallery should change its type.
299 gallery_prefs()->AddGalleryByPath(MakePath("scan2"), 301 AddGallery("scan_id", MediaGalleryPrefInfo::kUserAdded, 1, 0, 0);
300 MediaGalleryPrefInfo::kUserAdded);
301 StartDialog(); 302 StartDialog();
302 EXPECT_EQ(1U, controller()->GetGalleryList().size()); 303 EXPECT_EQ(2U, controller()->GetGalleryList().size());
303 304
304 // Blacklisting the other while the dialog is open should remove it. 305 // Blacklisting the other while the dialog is open should remove it.
305 gallery_prefs()->ForgetGalleryById(scan1); 306 gallery_prefs()->ForgetGalleryById(auto_id);
306 EXPECT_EQ(0U, controller()->GetGalleryList().size()); 307 EXPECT_EQ(1U, controller()->GetGalleryList().size());
307 controller()->DialogFinished(false); 308 controller()->DialogFinished(false);
308 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 309 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
309 EXPECT_EQ(1, dialog_update_count_at_destruction()); 310 EXPECT_EQ(1, dialog_update_count_at_destruction());
310 } 311 }
311 312
312 TEST_F(MediaGalleriesScanResultDialogControllerTest, PrefUpdates) { 313 TEST_F(MediaGalleriesScanResultDialogControllerTest, PrefUpdates) {
313 MediaGalleryPrefId selected = 314 MediaGalleryPrefId selected = AddScanResult("selected", 1, 0, 0);
314 gallery_prefs()->AddGalleryByPath(MakePath("selected"), 315 MediaGalleryPrefId unselected = AddScanResult("unselected", 1, 0, 0);
315 MediaGalleryPrefInfo::kScanResult);
316 MediaGalleryPrefId unselected =
317 gallery_prefs()->AddGalleryByPath(MakePath("unselected"),
318 MediaGalleryPrefInfo::kScanResult);
319 MediaGalleryPrefId selected_add_permission = 316 MediaGalleryPrefId selected_add_permission =
320 gallery_prefs()->AddGalleryByPath(MakePath("selected_add_permission"), 317 AddScanResult("selected_add_permission", 1, 0, 0);
321 MediaGalleryPrefInfo::kScanResult);
322 MediaGalleryPrefId unselected_add_permission = 318 MediaGalleryPrefId unselected_add_permission =
323 gallery_prefs()->AddGalleryByPath(MakePath("unselected_add_permission"), 319 AddScanResult("unselected_add_permission", 1, 0, 0);
324 MediaGalleryPrefInfo::kScanResult);
325 MediaGalleryPrefId selected_removed = 320 MediaGalleryPrefId selected_removed =
326 gallery_prefs()->AddGalleryByPath(MakePath("selected_removed"), 321 AddScanResult("selected_removed", 1, 0, 0);
327 MediaGalleryPrefInfo::kScanResult);
328 MediaGalleryPrefId unselected_removed = 322 MediaGalleryPrefId unselected_removed =
329 gallery_prefs()->AddGalleryByPath(MakePath("unselected_removed"), 323 AddScanResult("unselected_removed", 1, 0, 0);
330 MediaGalleryPrefInfo::kScanResult);
331 MediaGalleryPrefId selected_update = 324 MediaGalleryPrefId selected_update =
332 gallery_prefs()->AddGalleryByPath(MakePath("selected_update"), 325 AddScanResult("selected_update", 1, 0, 0);
333 MediaGalleryPrefInfo::kScanResult);
334 MediaGalleryPrefId unselected_update = 326 MediaGalleryPrefId unselected_update =
335 gallery_prefs()->AddGalleryByPath(MakePath("unselected_update"), 327 AddScanResult("unselected_update", 1, 0, 0);
336 MediaGalleryPrefInfo::kScanResult);
337 328
338 gallery_prefs()->AddGalleryByPath(MakePath("user"), 329 gallery_prefs()->AddGalleryByPath(MakePath("user"),
339 MediaGalleryPrefInfo::kUserAdded); 330 MediaGalleryPrefInfo::kUserAdded);
340 gallery_prefs()->AddGalleryByPath(MakePath("auto_detected"), 331 gallery_prefs()->AddGalleryByPath(MakePath("auto_detected"),
341 MediaGalleryPrefInfo::kAutoDetected); 332 MediaGalleryPrefInfo::kAutoDetected);
342 MediaGalleryPrefId blacklisted = 333 MediaGalleryPrefId blacklisted =
343 gallery_prefs()->AddGalleryByPath(MakePath("blacklisted"), 334 gallery_prefs()->AddGalleryByPath(MakePath("blacklisted"),
344 MediaGalleryPrefInfo::kAutoDetected); 335 MediaGalleryPrefInfo::kAutoDetected);
345 gallery_prefs()->ForgetGalleryById(blacklisted); 336 gallery_prefs()->ForgetGalleryById(blacklisted);
346 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 337 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 EXPECT_EQ(5, dialog()->update_count()); 376 EXPECT_EQ(5, dialog()->update_count());
386 EXPECT_EQ(4U, controller()->GetGalleryList().size()); 377 EXPECT_EQ(4U, controller()->GetGalleryList().size());
387 const MediaGalleryPrefInfo& selected_update_info = 378 const MediaGalleryPrefInfo& selected_update_info =
388 gallery_prefs()->known_galleries().find(selected_update)->second; 379 gallery_prefs()->known_galleries().find(selected_update)->second;
389 gallery_prefs()->AddGallery( 380 gallery_prefs()->AddGallery(
390 selected_update_info.device_id, base::FilePath(), 381 selected_update_info.device_id, base::FilePath(),
391 MediaGalleryPrefInfo::kScanResult, 382 MediaGalleryPrefInfo::kScanResult,
392 base::ASCIIToUTF16("Updated & Selected"), 383 base::ASCIIToUTF16("Updated & Selected"),
393 base::string16(), base::string16(), 0, base::Time(), 0, 0, 0); 384 base::string16(), base::string16(), 0, base::Time(), 0, 0, 0);
394 EXPECT_EQ(6, dialog()->update_count()); 385 EXPECT_EQ(6, dialog()->update_count());
395 ASSERT_EQ(4U, controller()->GetGalleryList().size()); 386 EXPECT_EQ(4U, controller()->GetGalleryList().size());
Lei Zhang 2014/02/10 19:55:22 Why expect?
vandebo (ex-Chrome) 2014/02/11 19:19:31 Changed to assert
396 387
397 MediaGalleriesScanResultDialogController::OrderedScanResults results = 388 MediaGalleriesScanResultDialogController::OrderedScanResults results =
398 controller()->GetGalleryList(); 389 controller()->GetGalleryList();
399 EXPECT_EQ(selected, results[0].pref_info.pref_id); 390 EXPECT_EQ(selected, results[0].pref_info.pref_id);
400 EXPECT_TRUE(results[0].selected); 391 EXPECT_TRUE(results[0].selected);
401 EXPECT_EQ(selected_update, results[1].pref_info.pref_id); 392 EXPECT_EQ(selected_update, results[1].pref_info.pref_id);
402 EXPECT_TRUE(results[1].selected); 393 EXPECT_TRUE(results[1].selected);
403 EXPECT_EQ(base::ASCIIToUTF16("Updated & Selected"), 394 EXPECT_EQ(base::ASCIIToUTF16("Updated & Selected"),
404 results[1].pref_info.volume_label); 395 results[1].pref_info.volume_label);
405 EXPECT_EQ(unselected, results[2].pref_info.pref_id); 396 EXPECT_EQ(unselected, results[2].pref_info.pref_id);
406 EXPECT_FALSE(results[2].selected); 397 EXPECT_FALSE(results[2].selected);
407 EXPECT_EQ(unselected_update, results[3].pref_info.pref_id); 398 EXPECT_EQ(unselected_update, results[3].pref_info.pref_id);
408 EXPECT_FALSE(results[3].selected); 399 EXPECT_FALSE(results[3].selected);
409 EXPECT_EQ(base::ASCIIToUTF16("Updated & Unselected"), 400 EXPECT_EQ(base::ASCIIToUTF16("Updated & Unselected"),
410 results[3].pref_info.volume_label); 401 results[3].pref_info.volume_label);
411 402
412 controller()->DialogFinished(true); 403 controller()->DialogFinished(true);
413 EXPECT_EQ(4U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 404 EXPECT_EQ(4U, gallery_prefs()->GalleriesForExtension(*extension()).size());
414 StartDialog(); 405 StartDialog();
415 EXPECT_EQ(2U, controller()->GetGalleryList().size()); 406 EXPECT_EQ(2U, controller()->GetGalleryList().size());
416 controller()->DialogFinished(false); 407 controller()->DialogFinished(false);
417 } 408 }
418 409
419 TEST_F(MediaGalleriesScanResultDialogControllerTest, ForgetGallery) { 410 TEST_F(MediaGalleriesScanResultDialogControllerTest, ForgetGallery) {
420 // Start with two scan results. 411 // Start with two scan results.
421 MediaGalleryPrefId scan1 = 412 MediaGalleryPrefId scan1 = AddScanResult("scan1", 1, 0, 0);
422 gallery_prefs()->AddGalleryByPath(MakePath("scan1"), 413 MediaGalleryPrefId scan2 = AddScanResult("scan2", 2, 0, 0);
423 MediaGalleryPrefInfo::kScanResult);
424 MediaGalleryPrefId scan2 =
425 gallery_prefs()->AddGalleryByPath(MakePath("scan2"),
426 MediaGalleryPrefInfo::kScanResult);
427 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
428 414
429 // Remove one and then cancel. 415 // Remove one and then cancel.
430 StartDialog(); 416 StartDialog();
431 EXPECT_EQ(2U, controller()->GetGalleryList().size()); 417 EXPECT_EQ(2U, controller()->GetGalleryList().size());
432 controller()->DidForgetGallery(scan1); 418 controller()->DidForgetGallery(scan1);
433 controller()->DialogFinished(false); 419 controller()->DialogFinished(false);
434 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 420 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
435 421
436 // Remove one and then have it blacklisted from prefs. 422 // Remove one and then have it blacklisted from prefs.
437 StartDialog(); 423 StartDialog();
(...skipping 13 matching lines...) Expand all
451 controller()->DialogFinished(true); 437 controller()->DialogFinished(true);
452 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size()); 438 EXPECT_EQ(0U, gallery_prefs()->GalleriesForExtension(*extension()).size());
453 439
454 // Check that nothing shows up. 440 // Check that nothing shows up.
455 StartDialog(); 441 StartDialog();
456 EXPECT_EQ(0U, controller()->GetGalleryList().size()); 442 EXPECT_EQ(0U, controller()->GetGalleryList().size());
457 controller()->DialogFinished(false); 443 controller()->DialogFinished(false);
458 } 444 }
459 445
460 TEST_F(MediaGalleriesScanResultDialogControllerTest, SortOrder) { 446 TEST_F(MediaGalleriesScanResultDialogControllerTest, SortOrder) {
461 // Intentionally our of order numerically and alphabetically. 447 // Intentionally out of order numerically and alphabetically.
462 MediaGalleryPrefId third = AddScanResult(gallery_prefs(), "third", 2, 2, 2); 448 MediaGalleryPrefId third = AddScanResult("third", 2, 2, 2);
463 MediaGalleryPrefId second = AddScanResult(gallery_prefs(), "second", 9, 0, 0); 449 MediaGalleryPrefId second =
464 MediaGalleryPrefId first = AddScanResult(gallery_prefs(), "first", 8, 2, 3); 450 AddGallery("second", MediaGalleryPrefInfo::kAutoDetected, 9, 0, 0);
tommycli 2014/02/10 18:45:53 0, 0, 0
465 MediaGalleryPrefId fifth = AddScanResult(gallery_prefs(), "abb", 3, 0, 0); 451 MediaGalleryPrefId first = AddScanResult("first", 8, 2, 3);
466 MediaGalleryPrefId fourth = AddScanResult(gallery_prefs(), "aaa", 3, 0, 0); 452 MediaGalleryPrefId fifth = AddScanResult("abb", 3, 0, 0);
453 MediaGalleryPrefId fourth = AddScanResult("aaa", 3, 0, 0);
467 454
468 StartDialog(); 455 StartDialog();
469 MediaGalleriesScanResultDialogController::OrderedScanResults results = 456 MediaGalleriesScanResultDialogController::OrderedScanResults results =
470 controller()->GetGalleryList(); 457 controller()->GetGalleryList();
471 ASSERT_EQ(5U, results.size()); 458 ASSERT_EQ(5U, results.size());
472 EXPECT_EQ(first, results[0].pref_info.pref_id); 459 EXPECT_EQ(first, results[0].pref_info.pref_id);
473 EXPECT_EQ(second, results[1].pref_info.pref_id); 460 EXPECT_EQ(second, results[1].pref_info.pref_id);
474 EXPECT_EQ(third, results[2].pref_info.pref_id); 461 EXPECT_EQ(third, results[2].pref_info.pref_id);
475 EXPECT_EQ(fourth, results[3].pref_info.pref_id); 462 EXPECT_EQ(fourth, results[3].pref_info.pref_id);
476 EXPECT_EQ(fifth, results[4].pref_info.pref_id); 463 EXPECT_EQ(fifth, results[4].pref_info.pref_id);
477 controller()->DialogFinished(false); 464 controller()->DialogFinished(false);
478 } 465 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698