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

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

Issue 2840593002: Remove usage of ScopedTaskScheduler. (Closed)
Patch Set: revert_client_cert_resolver_and_auto_connect_handler Created 3 years, 7 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/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h" 10 #include "base/run_loop.h"
12 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
13 #include "base/test/scoped_task_scheduler.h" 12 #include "base/test/scoped_task_environment.h"
14 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
15 #include "chromeos/dbus/fake_cros_disks_client.h" 14 #include "chromeos/dbus/fake_cros_disks_client.h"
16 #include "chromeos/disks/disk_mount_manager.h" 15 #include "chromeos/disks/disk_mount_manager.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 17
19 using base::MakeUnique; 18 using base::MakeUnique;
20 using base::StringPrintf; 19 using base::StringPrintf;
21 using chromeos::disks::DiskMountManager; 20 using chromeos::disks::DiskMountManager;
22 using chromeos::CrosDisksClient; 21 using chromeos::CrosDisksClient;
23 using chromeos::DBusThreadManager; 22 using chromeos::DBusThreadManager;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 398
400 // Shift operators of ostream. 399 // Shift operators of ostream.
401 // Needed to print values in case of EXPECT_* failure in gtest. 400 // Needed to print values in case of EXPECT_* failure in gtest.
402 std::ostream& operator<<(std::ostream& stream, 401 std::ostream& operator<<(std::ostream& stream,
403 const FormatEvent& format_event) { 402 const FormatEvent& format_event) {
404 return stream << format_event.DebugString(); 403 return stream << format_event.DebugString();
405 } 404 }
406 405
407 class DiskMountManagerTest : public testing::Test { 406 class DiskMountManagerTest : public testing::Test {
408 public: 407 public:
409 DiskMountManagerTest() : scoped_task_scheduler_(&message_loop_) {} 408 DiskMountManagerTest()
409 : scoped_task_environment_(
410 base::test::ScopedTaskEnvironment::MainThreadType::UI) {}
410 ~DiskMountManagerTest() override {} 411 ~DiskMountManagerTest() override {}
411 412
412 // Sets up test dbus tread manager and disks mount manager. 413 // Sets up test dbus tread manager and disks mount manager.
413 // Initializes disk mount manager disks and mount points. 414 // Initializes disk mount manager disks and mount points.
414 // Adds a test observer to the disk mount manager. 415 // Adds a test observer to the disk mount manager.
415 void SetUp() override { 416 void SetUp() override {
416 fake_cros_disks_client_ = new FakeCrosDisksClient; 417 fake_cros_disks_client_ = new FakeCrosDisksClient;
417 DBusThreadManager::GetSetterForTesting()->SetCrosDisksClient( 418 DBusThreadManager::GetSetterForTesting()->SetCrosDisksClient(
418 std::unique_ptr<CrosDisksClient>(fake_cros_disks_client_)); 419 std::unique_ptr<CrosDisksClient>(fake_cros_disks_client_));
419 420
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 477
477 for (size_t i = 0; i < arraysize(kTestMountPoints); i++) 478 for (size_t i = 0; i < arraysize(kTestMountPoints); i++)
478 AddTestMountPoint(kTestMountPoints[i]); 479 AddTestMountPoint(kTestMountPoints[i]);
479 } 480 }
480 481
481 protected: 482 protected:
482 chromeos::FakeCrosDisksClient* fake_cros_disks_client_; 483 chromeos::FakeCrosDisksClient* fake_cros_disks_client_;
483 std::unique_ptr<MockDiskMountManagerObserver> observer_; 484 std::unique_ptr<MockDiskMountManagerObserver> observer_;
484 485
485 private: 486 private:
486 base::MessageLoopForUI message_loop_; 487 base::test::ScopedTaskEnvironment scoped_task_environment_;
487 base::test::ScopedTaskScheduler scoped_task_scheduler_;
488 }; 488 };
489 489
490 // Tests that the observer gets notified on attempt to format non existent mount 490 // Tests that the observer gets notified on attempt to format non existent mount
491 // point. 491 // point.
492 TEST_F(DiskMountManagerTest, Format_NotMounted) { 492 TEST_F(DiskMountManagerTest, Format_NotMounted) {
493 DiskMountManager::GetInstance()->FormatMountedDevice("/mount/non_existent"); 493 DiskMountManager::GetInstance()->FormatMountedDevice("/mount/non_existent");
494 ASSERT_EQ(1U, observer_->GetEventCount()); 494 ASSERT_EQ(1U, observer_->GetEventCount());
495 EXPECT_EQ(FormatEvent(DiskMountManager::FORMAT_COMPLETED, 495 EXPECT_EQ(FormatEvent(DiskMountManager::FORMAT_COMPLETED,
496 chromeos::FORMAT_ERROR_UNKNOWN, "/mount/non_existent"), 496 chromeos::FORMAT_ERROR_UNKNOWN, "/mount/non_existent"),
497 observer_->GetFormatEvent(0)); 497 observer_->GetFormatEvent(0));
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 VerifyMountEvent(observer_->GetMountEvent(1), DiskMountManager::MOUNTING, 933 VerifyMountEvent(observer_->GetMountEvent(1), DiskMountManager::MOUNTING,
934 chromeos::MOUNT_ERROR_NONE, kDevice1MountPath); 934 chromeos::MOUNT_ERROR_NONE, kDevice1MountPath);
935 // The read-write device should be remounted in read-write mode. 935 // The read-write device should be remounted in read-write mode.
936 EXPECT_FALSE( 936 EXPECT_FALSE(
937 manager->FindDiskBySourcePath(kDevice1SourcePath)->is_read_only()); 937 manager->FindDiskBySourcePath(kDevice1SourcePath)->is_read_only());
938 // Remounted disk should also appear as writable to observers. 938 // Remounted disk should also appear as writable to observers.
939 EXPECT_FALSE(observer_->GetMountEvent(1).disk->is_read_only()); 939 EXPECT_FALSE(observer_->GetMountEvent(1).disk->is_read_only());
940 } 940 }
941 941
942 } // namespace 942 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698