| 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 // StorageMonitorLinux unit tests. | 5 // StorageMonitorLinux unit tests. |
| 6 | 6 |
| 7 #include "components/storage_monitor/storage_monitor_linux.h" | 7 #include "components/storage_monitor/storage_monitor_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/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 15 #include "base/files/scoped_temp_dir.h" | 15 #include "base/files/scoped_temp_dir.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/thread_task_runner_handle.h" |
| 20 #include "components/storage_monitor/mock_removable_storage_observer.h" | 21 #include "components/storage_monitor/mock_removable_storage_observer.h" |
| 21 #include "components/storage_monitor/removable_device_constants.h" | 22 #include "components/storage_monitor/removable_device_constants.h" |
| 22 #include "components/storage_monitor/storage_info.h" | 23 #include "components/storage_monitor/storage_info.h" |
| 23 #include "components/storage_monitor/storage_monitor.h" | 24 #include "components/storage_monitor/storage_monitor.h" |
| 24 #include "components/storage_monitor/test_media_transfer_protocol_manager_linux.
h" | 25 #include "components/storage_monitor/test_media_transfer_protocol_manager_linux.
h" |
| 25 #include "components/storage_monitor/test_storage_monitor.h" | 26 #include "components/storage_monitor/test_storage_monitor.h" |
| 26 #include "content/public/test/test_browser_thread_bundle.h" | 27 #include "content/public/test/test_browser_thread_bundle.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 29 |
| 29 namespace storage_monitor { | 30 namespace storage_monitor { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 SetMediaTransferProtocolManagerForTest( | 126 SetMediaTransferProtocolManagerForTest( |
| 126 new TestMediaTransferProtocolManagerLinux()); | 127 new TestMediaTransferProtocolManagerLinux()); |
| 127 SetGetDeviceInfoCallbackForTest(base::Bind(&GetDeviceInfo)); | 128 SetGetDeviceInfoCallbackForTest(base::Bind(&GetDeviceInfo)); |
| 128 } | 129 } |
| 129 ~TestStorageMonitorLinux() override {} | 130 ~TestStorageMonitorLinux() override {} |
| 130 | 131 |
| 131 private: | 132 private: |
| 132 void UpdateMtab( | 133 void UpdateMtab( |
| 133 const MtabWatcherLinux::MountPointDeviceMap& new_mtab) override { | 134 const MtabWatcherLinux::MountPointDeviceMap& new_mtab) override { |
| 134 StorageMonitorLinux::UpdateMtab(new_mtab); | 135 StorageMonitorLinux::UpdateMtab(new_mtab); |
| 135 base::MessageLoopProxy::current()->PostTask( | 136 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 136 FROM_HERE, base::MessageLoop::QuitClosure()); | 137 FROM_HERE, base::MessageLoop::QuitClosure()); |
| 137 } | 138 } |
| 138 | 139 |
| 139 DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorLinux); | 140 DISALLOW_COPY_AND_ASSIGN(TestStorageMonitorLinux); |
| 140 }; | 141 }; |
| 141 | 142 |
| 142 class StorageMonitorLinuxTest : public testing::Test { | 143 class StorageMonitorLinuxTest : public testing::Test { |
| 143 public: | 144 public: |
| 144 struct MtabTestData { | 145 struct MtabTestData { |
| 145 MtabTestData(const std::string& mount_device, | 146 MtabTestData(const std::string& mount_device, |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 GetStorageSize(test_path_a)); | 669 GetStorageSize(test_path_a)); |
| 669 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), | 670 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), |
| 670 GetStorageSize(test_path_b)); | 671 GetStorageSize(test_path_b)); |
| 671 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), | 672 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), |
| 672 GetStorageSize(base::FilePath(kInvalidPath))); | 673 GetStorageSize(base::FilePath(kInvalidPath))); |
| 673 } | 674 } |
| 674 | 675 |
| 675 } // namespace | 676 } // namespace |
| 676 | 677 |
| 677 } // namespace storage_monitor | 678 } // namespace storage_monitor |
| OLD | NEW |