| OLD | NEW |
| 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 "components/storage_monitor/storage_monitor_chromeos.h" | 5 #include "components/storage_monitor/storage_monitor_chromeos.h" |
| 6 | 6 |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return StorageInfo::MakeDeviceId( | 52 return StorageInfo::MakeDeviceId( |
| 53 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, | 53 StorageInfo::REMOVABLE_MASS_STORAGE_WITH_DCIM, |
| 54 kFSUniqueIdPrefix + unique_id); | 54 kFSUniqueIdPrefix + unique_id); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // A test version of StorageMonitorCros that exposes protected methods to tests. | 57 // A test version of StorageMonitorCros that exposes protected methods to tests. |
| 58 class TestStorageMonitorCros : public StorageMonitorCros { | 58 class TestStorageMonitorCros : public StorageMonitorCros { |
| 59 public: | 59 public: |
| 60 TestStorageMonitorCros() {} | 60 TestStorageMonitorCros() {} |
| 61 | 61 |
| 62 virtual ~TestStorageMonitorCros() {} | 62 ~TestStorageMonitorCros() override {} |
| 63 | 63 |
| 64 virtual void Init() override { | 64 void Init() override { |
| 65 SetMediaTransferProtocolManagerForTest( | 65 SetMediaTransferProtocolManagerForTest( |
| 66 new TestMediaTransferProtocolManagerLinux()); | 66 new TestMediaTransferProtocolManagerLinux()); |
| 67 StorageMonitorCros::Init(); | 67 StorageMonitorCros::Init(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 virtual void OnMountEvent(DiskMountManager::MountEvent event, | 70 void OnMountEvent( |
| 71 DiskMountManager::MountEvent event, |
| 71 chromeos::MountError error_code, | 72 chromeos::MountError error_code, |
| 72 const DiskMountManager::MountPointInfo& mount_info) override { | 73 const DiskMountManager::MountPointInfo& mount_info) override { |
| 73 StorageMonitorCros::OnMountEvent(event, error_code, mount_info); | 74 StorageMonitorCros::OnMountEvent(event, error_code, mount_info); |
| 74 } | 75 } |
| 75 | 76 |
| 76 virtual bool GetStorageInfoForPath(const base::FilePath& path, | 77 bool GetStorageInfoForPath(const base::FilePath& path, |
| 77 StorageInfo* device_info) const override { | 78 StorageInfo* device_info) const override { |
| 78 return StorageMonitorCros::GetStorageInfoForPath(path, device_info); | 79 return StorageMonitorCros::GetStorageInfoForPath(path, device_info); |
| 79 } | 80 } |
| 80 virtual void EjectDevice( | 81 void EjectDevice(const std::string& device_id, |
| 81 const std::string& device_id, | 82 base::Callback<void(EjectStatus)> callback) override { |
| 82 base::Callback<void(EjectStatus)> callback) override { | |
| 83 StorageMonitorCros::EjectDevice(device_id, callback); | 83 StorageMonitorCros::EjectDevice(device_id, callback); |
| 84 } | 84 } |
| 85 | 85 |
| 86 private: | 86 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorCros); | 87 DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorCros); |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // Wrapper class to test StorageMonitorCros. | 90 // Wrapper class to test StorageMonitorCros. |
| 91 class StorageMonitorCrosTest : public testing::Test { | 91 class StorageMonitorCrosTest : public testing::Test { |
| 92 public: | 92 public: |
| 93 StorageMonitorCrosTest(); | 93 StorageMonitorCrosTest(); |
| 94 virtual ~StorageMonitorCrosTest(); | 94 ~StorageMonitorCrosTest() override; |
| 95 | 95 |
| 96 void EjectNotify(StorageMonitor::EjectStatus status); | 96 void EjectNotify(StorageMonitor::EjectStatus status); |
| 97 | 97 |
| 98 protected: | 98 protected: |
| 99 // testing::Test: | 99 // testing::Test: |
| 100 virtual void SetUp() override; | 100 void SetUp() override; |
| 101 virtual void TearDown() override; | 101 void TearDown() override; |
| 102 | 102 |
| 103 void MountDevice(chromeos::MountError error_code, | 103 void MountDevice(chromeos::MountError error_code, |
| 104 const DiskMountManager::MountPointInfo& mount_info, | 104 const DiskMountManager::MountPointInfo& mount_info, |
| 105 const std::string& unique_id, | 105 const std::string& unique_id, |
| 106 const std::string& device_label, | 106 const std::string& device_label, |
| 107 const std::string& vendor_name, | 107 const std::string& vendor_name, |
| 108 const std::string& product_name, | 108 const std::string& product_name, |
| 109 chromeos::DeviceType device_type, | 109 chromeos::DeviceType device_type, |
| 110 uint64 device_size_in_bytes); | 110 uint64 device_size_in_bytes); |
| 111 | 111 |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 base::Bind(&StorageMonitorCrosTest::EjectNotify, | 545 base::Bind(&StorageMonitorCrosTest::EjectNotify, |
| 546 base::Unretained(this))); | 546 base::Unretained(this))); |
| 547 base::RunLoop().RunUntilIdle(); | 547 base::RunLoop().RunUntilIdle(); |
| 548 | 548 |
| 549 EXPECT_EQ(StorageMonitor::EJECT_OK, status_); | 549 EXPECT_EQ(StorageMonitor::EJECT_OK, status_); |
| 550 } | 550 } |
| 551 | 551 |
| 552 } // namespace | 552 } // namespace |
| 553 | 553 |
| 554 } // namespace storage_monitor | 554 } // namespace storage_monitor |
| OLD | NEW |