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

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc

Issue 10829384: SystemMonitor: Pull device type into the device id (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // MediaDeviceNotificationsLinux unit tests. 5 // MediaDeviceNotificationsLinux unit tests.
6 6
7 #include "chrome/browser/media_gallery/media_device_notifications_linux.h" 7 #include "chrome/browser/media_gallery/media_device_notifications_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/scoped_temp_dir.h" 18 #include "base/scoped_temp_dir.h"
19 #include "base/system_monitor/system_monitor.h" 19 #include "base/system_monitor/system_monitor.h"
20 #include "base/test/mock_devices_changed_observer.h" 20 #include "base/test/mock_devices_changed_observer.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "chrome/browser/media_gallery/media_storage_util.h"
22 #include "content/public/test/test_browser_thread.h" 23 #include "content/public/test/test_browser_thread.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace chrome { 26 namespace chrome {
26 27
27 namespace { 28 namespace {
28 29
29 using testing::_; 30 using testing::_;
30 31
31 const char kValidFS[] = "vfat"; 32 const char kValidFS[] = "vfat";
(...skipping 30 matching lines...) Expand all
62 *id = std::string(kDeviceId3); 63 *id = std::string(kDeviceId3);
63 device_name = kDeviceLabel3; 64 device_name = kDeviceLabel3;
64 } else { 65 } else {
65 return false; 66 return false;
66 } 67 }
67 68
68 *name = ASCIIToUTF16(device_name); 69 *name = ASCIIToUTF16(device_name);
69 return true; 70 return true;
70 } 71 }
71 72
73 std::string GetDCIMDeviceId(std::string unique_id) {
74 return chrome::MediaStorageUtil::MakeDeviceId(
75 chrome::MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, unique_id);
76 }
77
72 class MediaDeviceNotificationsLinuxTestWrapper 78 class MediaDeviceNotificationsLinuxTestWrapper
73 : public MediaDeviceNotificationsLinux { 79 : public MediaDeviceNotificationsLinux {
74 public: 80 public:
75 MediaDeviceNotificationsLinuxTestWrapper(const FilePath& path, 81 MediaDeviceNotificationsLinuxTestWrapper(const FilePath& path,
76 MessageLoop* message_loop) 82 MessageLoop* message_loop)
77 : MediaDeviceNotificationsLinux(path, &GetDeviceInfo), 83 : MediaDeviceNotificationsLinux(path, &GetDeviceInfo),
78 message_loop_(message_loop) { 84 message_loop_(message_loop) {
79 } 85 }
80 86
81 private: 87 private:
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 TEST_F(MediaDeviceNotificationsLinuxTest, BasicAttachDetach) { 266 TEST_F(MediaDeviceNotificationsLinuxTest, BasicAttachDetach) {
261 testing::Sequence mock_sequence; 267 testing::Sequence mock_sequence;
262 FilePath test_path = CreateMountPointWithDCIMDir(kMountPointA); 268 FilePath test_path = CreateMountPointWithDCIMDir(kMountPointA);
263 ASSERT_FALSE(test_path.empty()); 269 ASSERT_FALSE(test_path.empty());
264 MtabTestData test_data[] = { 270 MtabTestData test_data[] = {
265 MtabTestData(kDevice1, kInvalidPath, kValidFS), 271 MtabTestData(kDevice1, kInvalidPath, kValidFS),
266 MtabTestData(kDevice2, test_path.value(), kValidFS), 272 MtabTestData(kDevice2, test_path.value(), kValidFS),
267 }; 273 };
268 // Only |kDevice2| should be attached, since |kDevice1| has a bad path. 274 // Only |kDevice2| should be attached, since |kDevice1| has a bad path.
269 EXPECT_CALL(observer(), 275 EXPECT_CALL(observer(),
270 OnMediaDeviceAttached(kDeviceId2, 276 OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId2),
271 ASCIIToUTF16(kDeviceLabel2), 277 ASCIIToUTF16(kDeviceLabel2),
272 base::SystemMonitor::TYPE_PATH,
273 test_path.value())) 278 test_path.value()))
274 .InSequence(mock_sequence); 279 .InSequence(mock_sequence);
275 AppendToMtabAndRunLoop(test_data, arraysize(test_data)); 280 AppendToMtabAndRunLoop(test_data, arraysize(test_data));
276 281
277 // |kDevice2| should be detached here. 282 // |kDevice2| should be detached here.
278 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId2)) 283 EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId2)))
279 .InSequence(mock_sequence); 284 .InSequence(mock_sequence);
280 WriteEmptyMtabAndRunLoop(); 285 WriteEmptyMtabAndRunLoop();
281 } 286 }
282 287
283 // Only mount points with DCIM directories are recognized. 288 // Only mount points with DCIM directories are recognized.
284 TEST_F(MediaDeviceNotificationsLinuxTest, DCIM) { 289 TEST_F(MediaDeviceNotificationsLinuxTest, DCIM) {
285 testing::Sequence mock_sequence; 290 testing::Sequence mock_sequence;
286 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); 291 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA);
287 ASSERT_FALSE(test_path_a.empty()); 292 ASSERT_FALSE(test_path_a.empty());
288 MtabTestData test_data1[] = { 293 MtabTestData test_data1[] = {
289 MtabTestData(kDevice1, test_path_a.value(), kValidFS), 294 MtabTestData(kDevice1, test_path_a.value(), kValidFS),
290 }; 295 };
291 // |kDevice1| should be attached as expected. 296 // |kDevice1| should be attached as expected.
292 EXPECT_CALL(observer(), 297 EXPECT_CALL(observer(),
293 OnMediaDeviceAttached(kDeviceId1, 298 OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId1),
294 ASCIIToUTF16(kDeviceLabel1), 299 ASCIIToUTF16(kDeviceLabel1),
295 base::SystemMonitor::TYPE_PATH,
296 test_path_a.value())) 300 test_path_a.value()))
297 .InSequence(mock_sequence); 301 .InSequence(mock_sequence);
298 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); 302 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
299 303
300 // This should do nothing, since |kMountPointB| does not have a DCIM dir. 304 // This should do nothing, since |kMountPointB| does not have a DCIM dir.
301 FilePath test_path_b = CreateMountPointWithoutDCIMDir(kMountPointB); 305 FilePath test_path_b = CreateMountPointWithoutDCIMDir(kMountPointB);
302 ASSERT_FALSE(test_path_b.empty()); 306 ASSERT_FALSE(test_path_b.empty());
303 MtabTestData test_data2[] = { 307 MtabTestData test_data2[] = {
304 MtabTestData(kDevice2, test_path_b.value(), kValidFS), 308 MtabTestData(kDevice2, test_path_b.value(), kValidFS),
305 }; 309 };
306 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); 310 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
307 311
308 // |kDevice1| should be detached as expected. 312 // |kDevice1| should be detached as expected.
309 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId1)) 313 EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId1)))
310 .InSequence(mock_sequence); 314 .InSequence(mock_sequence);
311 WriteEmptyMtabAndRunLoop(); 315 WriteEmptyMtabAndRunLoop();
312 } 316 }
313 317
314 // More complicated test case with multiple devices on multiple mount points. 318 // More complicated test case with multiple devices on multiple mount points.
315 TEST_F(MediaDeviceNotificationsLinuxTest, SwapMountPoints) { 319 TEST_F(MediaDeviceNotificationsLinuxTest, SwapMountPoints) {
316 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); 320 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA);
317 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); 321 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB);
318 ASSERT_FALSE(test_path_a.empty()); 322 ASSERT_FALSE(test_path_a.empty());
319 ASSERT_FALSE(test_path_b.empty()); 323 ASSERT_FALSE(test_path_b.empty());
320 324
321 // Attach two devices. 325 // Attach two devices.
322 // kDevice1 -> kMountPointA 326 // kDevice1 -> kMountPointA
323 // kDevice2 -> kMountPointB 327 // kDevice2 -> kMountPointB
324 MtabTestData test_data1[] = { 328 MtabTestData test_data1[] = {
325 MtabTestData(kDevice1, test_path_a.value(), kValidFS), 329 MtabTestData(kDevice1, test_path_a.value(), kValidFS),
326 MtabTestData(kDevice2, test_path_b.value(), kValidFS), 330 MtabTestData(kDevice2, test_path_b.value(), kValidFS),
327 }; 331 };
328 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2); 332 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
329 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0); 333 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
330 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); 334 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
331 335
332 // Detach two devices from old mount points and attach the devices at new 336 // Detach two devices from old mount points and attach the devices at new
333 // mount points. 337 // mount points.
334 // kDevice1 -> kMountPointB 338 // kDevice1 -> kMountPointB
335 // kDevice2 -> kMountPointA 339 // kDevice2 -> kMountPointA
336 MtabTestData test_data2[] = { 340 MtabTestData test_data2[] = {
337 MtabTestData(kDevice1, test_path_b.value(), kValidFS), 341 MtabTestData(kDevice1, test_path_b.value(), kValidFS),
338 MtabTestData(kDevice2, test_path_a.value(), kValidFS), 342 MtabTestData(kDevice2, test_path_a.value(), kValidFS),
339 }; 343 };
340 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2); 344 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
341 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2); 345 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
342 OverwriteMtabAndRunLoop(test_data2, arraysize(test_data2)); 346 OverwriteMtabAndRunLoop(test_data2, arraysize(test_data2));
343 347
344 // Detach all devices. 348 // Detach all devices.
345 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 349 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
346 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2); 350 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
347 WriteEmptyMtabAndRunLoop(); 351 WriteEmptyMtabAndRunLoop();
348 } 352 }
349 353
350 // More complicated test case with multiple devices on multiple mount points. 354 // More complicated test case with multiple devices on multiple mount points.
351 TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesMultiMountPoints) { 355 TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesMultiMountPoints) {
352 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); 356 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA);
353 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); 357 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB);
354 ASSERT_FALSE(test_path_a.empty()); 358 ASSERT_FALSE(test_path_a.empty());
355 ASSERT_FALSE(test_path_b.empty()); 359 ASSERT_FALSE(test_path_b.empty());
356 360
357 // Attach two devices. 361 // Attach two devices.
358 // kDevice1 -> kMountPointA 362 // kDevice1 -> kMountPointA
359 // kDevice2 -> kMountPointB 363 // kDevice2 -> kMountPointB
360 MtabTestData test_data1[] = { 364 MtabTestData test_data1[] = {
361 MtabTestData(kDevice1, test_path_a.value(), kValidFS), 365 MtabTestData(kDevice1, test_path_a.value(), kValidFS),
362 MtabTestData(kDevice2, test_path_b.value(), kValidFS), 366 MtabTestData(kDevice2, test_path_b.value(), kValidFS),
363 }; 367 };
364 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2); 368 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
365 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0); 369 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
366 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); 370 AppendToMtabAndRunLoop(test_data1, arraysize(test_data1));
367 371
368 // Attach |kDevice1| to |kMountPointB|. 372 // Attach |kDevice1| to |kMountPointB|.
369 // |kDevice2| is inaccessible, so it is detached. |kDevice1| has been 373 // |kDevice2| is inaccessible, so it is detached. |kDevice1| has been
370 // re-attached at |kMountPointB|, so it is 'detached' from kMountPointA. 374 // re-attached at |kMountPointB|, so it is 'detached' from kMountPointA.
371 // kDevice1 -> kMountPointA 375 // kDevice1 -> kMountPointA
372 // kDevice2 -> kMountPointB 376 // kDevice2 -> kMountPointB
373 // kDevice1 -> kMountPointB 377 // kDevice1 -> kMountPointB
374 MtabTestData test_data2[] = { 378 MtabTestData test_data2[] = {
375 MtabTestData(kDevice1, test_path_b.value(), kValidFS), 379 MtabTestData(kDevice1, test_path_b.value(), kValidFS),
376 }; 380 };
377 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(1); 381 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(1);
378 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2); 382 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
379 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); 383 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
380 384
381 // Attach |kDevice2| to |kMountPointA|. 385 // Attach |kDevice2| to |kMountPointA|.
382 // kDevice1 -> kMountPointA 386 // kDevice1 -> kMountPointA
383 // kDevice2 -> kMountPointB 387 // kDevice2 -> kMountPointB
384 // kDevice1 -> kMountPointB 388 // kDevice1 -> kMountPointB
385 // kDevice2 -> kMountPointA 389 // kDevice2 -> kMountPointA
386 MtabTestData test_data3[] = { 390 MtabTestData test_data3[] = {
387 MtabTestData(kDevice2, test_path_a.value(), kValidFS), 391 MtabTestData(kDevice2, test_path_a.value(), kValidFS),
388 }; 392 };
389 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(1); 393 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(1);
390 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0); 394 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
391 AppendToMtabAndRunLoop(test_data3, arraysize(test_data3)); 395 AppendToMtabAndRunLoop(test_data3, arraysize(test_data3));
392 396
393 // Detach |kDevice2| from |kMountPointA|. 397 // Detach |kDevice2| from |kMountPointA|.
394 // kDevice1 -> kMountPointA 398 // kDevice1 -> kMountPointA
395 // kDevice2 -> kMountPointB 399 // kDevice2 -> kMountPointB
396 // kDevice1 -> kMountPointB 400 // kDevice1 -> kMountPointB
397 MtabTestData test_data4[] = { 401 MtabTestData test_data4[] = {
398 MtabTestData(kDevice1, test_path_a.value(), kValidFS), 402 MtabTestData(kDevice1, test_path_a.value(), kValidFS),
399 MtabTestData(kDevice2, test_path_b.value(), kValidFS), 403 MtabTestData(kDevice2, test_path_b.value(), kValidFS),
400 MtabTestData(kDevice1, test_path_b.value(), kValidFS), 404 MtabTestData(kDevice1, test_path_b.value(), kValidFS),
401 }; 405 };
402 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 406 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
403 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(1); 407 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(1);
404 OverwriteMtabAndRunLoop(test_data4, arraysize(test_data4)); 408 OverwriteMtabAndRunLoop(test_data4, arraysize(test_data4));
405 409
406 // Detach |kDevice1| from |kMountPointB|. 410 // Detach |kDevice1| from |kMountPointB|.
407 // kDevice1 -> kMountPointA 411 // kDevice1 -> kMountPointA
408 // kDevice2 -> kMountPointB 412 // kDevice2 -> kMountPointB
409 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(2); 413 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(2);
410 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(1); 414 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(1);
411 OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1)); 415 OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1));
412 416
413 // Detach all devices. 417 // Detach all devices.
414 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 418 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
415 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2); 419 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(2);
416 WriteEmptyMtabAndRunLoop(); 420 WriteEmptyMtabAndRunLoop();
417 } 421 }
418 422
419 // More complicated test case with multiple devices on one mount point. 423 // More complicated test case with multiple devices on one mount point.
420 TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesOneMountPoint) { 424 TEST_F(MediaDeviceNotificationsLinuxTest, MultiDevicesOneMountPoint) {
421 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); 425 FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA);
422 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB); 426 FilePath test_path_b = CreateMountPointWithDCIMDir(kMountPointB);
423 ASSERT_FALSE(test_path_a.empty()); 427 ASSERT_FALSE(test_path_a.empty());
424 ASSERT_FALSE(test_path_b.empty()); 428 ASSERT_FALSE(test_path_b.empty());
425 429
426 // |kDevice1| is most recently mounted at |kMountPointB|. 430 // |kDevice1| is most recently mounted at |kMountPointB|.
427 // kDevice1 -> kMountPointA 431 // kDevice1 -> kMountPointA
428 // kDevice2 -> kMountPointB 432 // kDevice2 -> kMountPointB
429 // kDevice1 -> kMountPointB 433 // kDevice1 -> kMountPointB
430 MtabTestData test_data1[] = { 434 MtabTestData test_data1[] = {
431 MtabTestData(kDevice1, test_path_a.value(), kValidFS), 435 MtabTestData(kDevice1, test_path_a.value(), kValidFS),
432 MtabTestData(kDevice2, test_path_b.value(), kValidFS), 436 MtabTestData(kDevice2, test_path_b.value(), kValidFS),
433 MtabTestData(kDevice1, test_path_b.value(), kValidFS), 437 MtabTestData(kDevice1, test_path_b.value(), kValidFS),
434 }; 438 };
435 EXPECT_CALL(observer(), 439 EXPECT_CALL(observer(),
436 OnMediaDeviceAttached(kDeviceId1, 440 OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId1),
437 ASCIIToUTF16(kDeviceLabel1), 441 ASCIIToUTF16(kDeviceLabel1),
438 base::SystemMonitor::TYPE_PATH,
439 test_path_b.value())) 442 test_path_b.value()))
440 .Times(1); 443 .Times(1);
441 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0); 444 EXPECT_CALL(observer(), OnMediaDeviceDetached(_)).Times(0);
442 OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1)); 445 OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1));
443 446
444 // Attach |kDevice3| to |kMountPointB|. 447 // Attach |kDevice3| to |kMountPointB|.
445 // |kDevice1| is inaccessible at its most recent mount point, so it is 448 // |kDevice1| is inaccessible at its most recent mount point, so it is
446 // detached and unavailable, even though it is still accessible via 449 // detached and unavailable, even though it is still accessible via
447 // |kMountPointA|. 450 // |kMountPointA|.
448 // kDevice1 -> kMountPointA 451 // kDevice1 -> kMountPointA
449 // kDevice2 -> kMountPointB 452 // kDevice2 -> kMountPointB
450 // kDevice1 -> kMountPointB 453 // kDevice1 -> kMountPointB
451 // kDevice3 -> kMountPointB 454 // kDevice3 -> kMountPointB
452 MtabTestData test_data2[] = { 455 MtabTestData test_data2[] = {
453 MtabTestData(kDevice3, test_path_b.value(), kValidFS), 456 MtabTestData(kDevice3, test_path_b.value(), kValidFS),
454 }; 457 };
455 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId1)).Times(1); 458 EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId1)))
459 .Times(1);
456 EXPECT_CALL(observer(), 460 EXPECT_CALL(observer(),
457 OnMediaDeviceAttached(kDeviceId3, 461 OnMediaDeviceAttached(GetDCIMDeviceId(kDeviceId3),
458 ASCIIToUTF16(kDeviceLabel3), 462 ASCIIToUTF16(kDeviceLabel3),
459 base::SystemMonitor::TYPE_PATH,
460 test_path_b.value())) 463 test_path_b.value()))
461 .Times(1); 464 .Times(1);
462 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); 465 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
463 466
464 // Detach all devices. 467 // Detach all devices.
465 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 468 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
466 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId3)).Times(1); 469 EXPECT_CALL(observer(), OnMediaDeviceDetached(GetDCIMDeviceId(kDeviceId3)))
470 .Times(1);
467 WriteEmptyMtabAndRunLoop(); 471 WriteEmptyMtabAndRunLoop();
468 } 472 }
469 473
470 } // namespace 474 } // namespace
471 475
472 } // namespace chrome 476 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698