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

Side by Side Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2314853004: Remove calls to deprecated MessageLoop methods in chromeos. (Closed)
Patch Set: Created 4 years, 3 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 (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 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 11 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "chromeos/dbus/fake_cros_disks_client.h" 12 #include "chromeos/dbus/fake_cros_disks_client.h"
12 #include "chromeos/disks/disk_mount_manager.h" 13 #include "chromeos/disks/disk_mount_manager.h"
13 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 using chromeos::disks::DiskMountManager; 17 using chromeos::disks::DiskMountManager;
17 using chromeos::CrosDisksClient; 18 using chromeos::CrosDisksClient;
18 using chromeos::DBusThreadManager; 19 using chromeos::DBusThreadManager;
19 using chromeos::FakeCrosDisksClient; 20 using chromeos::FakeCrosDisksClient;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 chromeos::FORMAT_ERROR_UNKNOWN, 323 chromeos::FORMAT_ERROR_UNKNOWN,
323 "/device/source_path")) 324 "/device/source_path"))
324 .Times(1); 325 .Times(1);
325 } 326 }
326 327
327 fake_cros_disks_client_->MakeUnmountFail(); 328 fake_cros_disks_client_->MakeUnmountFail();
328 // Start test. 329 // Start test.
329 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 330 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
330 331
331 // Cros disks will respond asynchronoulsy, so let's drain the message loop. 332 // Cros disks will respond asynchronoulsy, so let's drain the message loop.
332 message_loop_.RunUntilIdle(); 333 base::RunLoop().RunUntilIdle();
333 334
334 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count()); 335 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count());
335 EXPECT_EQ("/device/mount_path", 336 EXPECT_EQ("/device/mount_path",
336 fake_cros_disks_client_->last_unmount_device_path()); 337 fake_cros_disks_client_->last_unmount_device_path());
337 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 338 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
338 fake_cros_disks_client_->last_unmount_options()); 339 fake_cros_disks_client_->last_unmount_options());
339 EXPECT_EQ(0, fake_cros_disks_client_->format_call_count()); 340 EXPECT_EQ(0, fake_cros_disks_client_->format_call_count());
340 341
341 // The device mount should still be here. 342 // The device mount should still be here.
342 EXPECT_TRUE(HasMountPoint("/device/mount_path")); 343 EXPECT_TRUE(HasMountPoint("/device/mount_path"));
(...skipping 23 matching lines...) Expand all
366 chromeos::FORMAT_ERROR_UNKNOWN, 367 chromeos::FORMAT_ERROR_UNKNOWN,
367 "/device/source_path")) 368 "/device/source_path"))
368 .Times(1); 369 .Times(1);
369 } 370 }
370 371
371 fake_cros_disks_client_->MakeFormatFail(); 372 fake_cros_disks_client_->MakeFormatFail();
372 // Start the test. 373 // Start the test.
373 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 374 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
374 375
375 // Cros disks will respond asynchronoulsy, so let's drain the message loop. 376 // Cros disks will respond asynchronoulsy, so let's drain the message loop.
376 message_loop_.RunUntilIdle(); 377 base::RunLoop().RunUntilIdle();
377 378
378 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count()); 379 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count());
379 EXPECT_EQ("/device/mount_path", 380 EXPECT_EQ("/device/mount_path",
380 fake_cros_disks_client_->last_unmount_device_path()); 381 fake_cros_disks_client_->last_unmount_device_path());
381 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 382 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
382 fake_cros_disks_client_->last_unmount_options()); 383 fake_cros_disks_client_->last_unmount_options());
383 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count()); 384 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count());
384 EXPECT_EQ("/device/source_path", 385 EXPECT_EQ("/device/source_path",
385 fake_cros_disks_client_->last_format_device_path()); 386 fake_cros_disks_client_->last_format_device_path());
386 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); 387 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem());
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 } 429 }
429 430
430 fake_cros_disks_client_->set_unmount_listener( 431 fake_cros_disks_client_->set_unmount_listener(
431 base::Bind(&FakeCrosDisksClient::MakeUnmountFail, 432 base::Bind(&FakeCrosDisksClient::MakeUnmountFail,
432 base::Unretained(fake_cros_disks_client_))); 433 base::Unretained(fake_cros_disks_client_)));
433 // Start the test. 434 // Start the test.
434 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 435 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
435 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 436 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
436 437
437 // Cros disks will respond asynchronoulsy, so let's drain the message loop. 438 // Cros disks will respond asynchronoulsy, so let's drain the message loop.
438 message_loop_.RunUntilIdle(); 439 base::RunLoop().RunUntilIdle();
439 440
440 EXPECT_EQ(2, fake_cros_disks_client_->unmount_call_count()); 441 EXPECT_EQ(2, fake_cros_disks_client_->unmount_call_count());
441 EXPECT_EQ("/device/mount_path", 442 EXPECT_EQ("/device/mount_path",
442 fake_cros_disks_client_->last_unmount_device_path()); 443 fake_cros_disks_client_->last_unmount_device_path());
443 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 444 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
444 fake_cros_disks_client_->last_unmount_options()); 445 fake_cros_disks_client_->last_unmount_options());
445 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count()); 446 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count());
446 EXPECT_EQ("/device/source_path", 447 EXPECT_EQ("/device/source_path",
447 fake_cros_disks_client_->last_format_device_path()); 448 fake_cros_disks_client_->last_format_device_path());
448 EXPECT_EQ("vfat", 449 EXPECT_EQ("vfat",
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 EXPECT_CALL(observer_, OnFormatEvent(DiskMountManager::FORMAT_COMPLETED, 481 EXPECT_CALL(observer_, OnFormatEvent(DiskMountManager::FORMAT_COMPLETED,
481 chromeos::FORMAT_ERROR_UNKNOWN, 482 chromeos::FORMAT_ERROR_UNKNOWN,
482 "/device/source_path")) 483 "/device/source_path"))
483 .Times(1); 484 .Times(1);
484 } 485 }
485 486
486 // Start the test. 487 // Start the test.
487 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 488 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
488 489
489 // Wait for Unmount and Format calls to end. 490 // Wait for Unmount and Format calls to end.
490 message_loop_.RunUntilIdle(); 491 base::RunLoop().RunUntilIdle();
491 492
492 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count()); 493 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count());
493 EXPECT_EQ("/device/mount_path", 494 EXPECT_EQ("/device/mount_path",
494 fake_cros_disks_client_->last_unmount_device_path()); 495 fake_cros_disks_client_->last_unmount_device_path());
495 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 496 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
496 fake_cros_disks_client_->last_unmount_options()); 497 fake_cros_disks_client_->last_unmount_options());
497 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count()); 498 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count());
498 EXPECT_EQ("/device/source_path", 499 EXPECT_EQ("/device/source_path",
499 fake_cros_disks_client_->last_format_device_path()); 500 fake_cros_disks_client_->last_format_device_path());
500 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); 501 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 EXPECT_CALL(observer_, OnFormatEvent(DiskMountManager::FORMAT_COMPLETED, 536 EXPECT_CALL(observer_, OnFormatEvent(DiskMountManager::FORMAT_COMPLETED,
536 chromeos::FORMAT_ERROR_NONE, 537 chromeos::FORMAT_ERROR_NONE,
537 "/device/source_path")) 538 "/device/source_path"))
538 .Times(1); 539 .Times(1);
539 } 540 }
540 541
541 // Start the test. 542 // Start the test.
542 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 543 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
543 544
544 // Wait for Unmount and Format calls to end. 545 // Wait for Unmount and Format calls to end.
545 message_loop_.RunUntilIdle(); 546 base::RunLoop().RunUntilIdle();
546 547
547 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count()); 548 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count());
548 EXPECT_EQ("/device/mount_path", 549 EXPECT_EQ("/device/mount_path",
549 fake_cros_disks_client_->last_unmount_device_path()); 550 fake_cros_disks_client_->last_unmount_device_path());
550 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 551 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
551 fake_cros_disks_client_->last_unmount_options()); 552 fake_cros_disks_client_->last_unmount_options());
552 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count()); 553 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count());
553 EXPECT_EQ("/device/source_path", 554 EXPECT_EQ("/device/source_path",
554 fake_cros_disks_client_->last_format_device_path()); 555 fake_cros_disks_client_->last_format_device_path());
555 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); 556 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 OnMountEvent(DiskMountManager::MOUNTING, 596 OnMountEvent(DiskMountManager::MOUNTING,
596 chromeos::MOUNT_ERROR_NONE, 597 chromeos::MOUNT_ERROR_NONE,
597 Field(&DiskMountManager::MountPointInfo::mount_path, 598 Field(&DiskMountManager::MountPointInfo::mount_path,
598 "/device/mount_path"))) 599 "/device/mount_path")))
599 .Times(1); 600 .Times(1);
600 601
601 // Start the test. 602 // Start the test.
602 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 603 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
603 604
604 // Wait for Unmount and Format calls to end. 605 // Wait for Unmount and Format calls to end.
605 message_loop_.RunUntilIdle(); 606 base::RunLoop().RunUntilIdle();
606 607
607 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count()); 608 EXPECT_EQ(1, fake_cros_disks_client_->unmount_call_count());
608 EXPECT_EQ("/device/mount_path", 609 EXPECT_EQ("/device/mount_path",
609 fake_cros_disks_client_->last_unmount_device_path()); 610 fake_cros_disks_client_->last_unmount_device_path());
610 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 611 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
611 fake_cros_disks_client_->last_unmount_options()); 612 fake_cros_disks_client_->last_unmount_options());
612 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count()); 613 EXPECT_EQ(1, fake_cros_disks_client_->format_call_count());
613 EXPECT_EQ("/device/source_path", 614 EXPECT_EQ("/device/source_path",
614 fake_cros_disks_client_->last_format_device_path()); 615 fake_cros_disks_client_->last_format_device_path());
615 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); 616 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem());
(...skipping 11 matching lines...) Expand all
627 "/device/source_path", 628 "/device/source_path",
628 chromeos::MOUNT_TYPE_DEVICE, 629 chromeos::MOUNT_TYPE_DEVICE,
629 "/device/mount_path"); 630 "/device/mount_path");
630 631
631 EXPECT_TRUE(HasMountPoint("/device/mount_path")); 632 EXPECT_TRUE(HasMountPoint("/device/mount_path"));
632 633
633 // Try formatting again. 634 // Try formatting again.
634 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path"); 635 DiskMountManager::GetInstance()->FormatMountedDevice("/device/mount_path");
635 636
636 // Wait for Unmount and Format calls to end. 637 // Wait for Unmount and Format calls to end.
637 message_loop_.RunUntilIdle(); 638 base::RunLoop().RunUntilIdle();
638 639
639 EXPECT_EQ(2, fake_cros_disks_client_->unmount_call_count()); 640 EXPECT_EQ(2, fake_cros_disks_client_->unmount_call_count());
640 EXPECT_EQ("/device/mount_path", 641 EXPECT_EQ("/device/mount_path",
641 fake_cros_disks_client_->last_unmount_device_path()); 642 fake_cros_disks_client_->last_unmount_device_path());
642 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE, 643 EXPECT_EQ(chromeos::UNMOUNT_OPTIONS_NONE,
643 fake_cros_disks_client_->last_unmount_options()); 644 fake_cros_disks_client_->last_unmount_options());
644 EXPECT_EQ(2, fake_cros_disks_client_->format_call_count()); 645 EXPECT_EQ(2, fake_cros_disks_client_->format_call_count());
645 EXPECT_EQ("/device/source_path", 646 EXPECT_EQ("/device/source_path",
646 fake_cros_disks_client_->last_format_device_path()); 647 fake_cros_disks_client_->last_format_device_path());
647 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); 648 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceSource, 725 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceSource,
725 chromeos::MOUNT_TYPE_DEVICE, kReadOnlyMountpath); 726 chromeos::MOUNT_TYPE_DEVICE, kReadOnlyMountpath);
726 727
727 const DiskMountManager::DiskMap& disks = manager->disks(); 728 const DiskMountManager::DiskMap& disks = manager->disks();
728 ASSERT_GT(disks.count(kReadOnlyDeviceSource), 0U); 729 ASSERT_GT(disks.count(kReadOnlyDeviceSource), 0U);
729 // The mounted disk should preserve the read-only flag of the block device. 730 // The mounted disk should preserve the read-only flag of the block device.
730 EXPECT_TRUE(disks.find(kReadOnlyDeviceSource)->second->is_read_only()); 731 EXPECT_TRUE(disks.find(kReadOnlyDeviceSource)->second->is_read_only());
731 } 732 }
732 733
733 } // namespace 734 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698