OLD | NEW |
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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h" | 7 #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h" |
8 #include "chrome/browser/storage_monitor/storage_monitor.h" | 8 #include "chrome/browser/storage_monitor/storage_monitor.h" |
9 #include "chrome/browser/storage_monitor/test_storage_monitor.h" | 9 #include "chrome/browser/storage_monitor/test_storage_monitor.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 | 59 |
60 TEST(StorageMonitorTest, GetAttachedStorageEmpty) { | 60 TEST(StorageMonitorTest, GetAttachedStorageEmpty) { |
61 MessageLoop message_loop; | 61 MessageLoop message_loop; |
62 test::TestStorageMonitor monitor; | 62 test::TestStorageMonitor monitor; |
63 std::vector<StorageMonitor::StorageInfo> devices = | 63 std::vector<StorageMonitor::StorageInfo> devices = |
64 monitor.GetAttachedStorage(); | 64 monitor.GetAttachedStorage(); |
65 EXPECT_EQ(0U, devices.size()); | 65 EXPECT_EQ(0U, devices.size()); |
66 } | 66 } |
67 | 67 |
68 TEST(StorageMonitorTest, | 68 TEST(StorageMonitorTest, GetRemovableStorageAttachDetach) { |
69 GetRemovableStorageAttachDetach) { | |
70 MessageLoop message_loop; | 69 MessageLoop message_loop; |
71 test::TestStorageMonitor monitor; | 70 test::TestStorageMonitor monitor; |
72 const std::string kDeviceId1 = "42"; | 71 const std::string kDeviceId1 = "42"; |
73 const string16 kDeviceName1 = ASCIIToUTF16("test"); | 72 const string16 kDeviceName1 = ASCIIToUTF16("test"); |
74 const base::FilePath kDevicePath1(FILE_PATH_LITERAL("/testfoo")); | 73 const base::FilePath kDevicePath1(FILE_PATH_LITERAL("/testfoo")); |
75 monitor.receiver()->ProcessAttach(StorageMonitor::StorageInfo( | 74 monitor.receiver()->ProcessAttach(StorageMonitor::StorageInfo( |
76 kDeviceId1, kDeviceName1, kDevicePath1.value())); | 75 kDeviceId1, kDeviceName1, kDevicePath1.value())); |
77 message_loop.RunUntilIdle(); | 76 message_loop.RunUntilIdle(); |
78 std::vector<StorageMonitor::StorageInfo> devices = | 77 std::vector<StorageMonitor::StorageInfo> devices = |
79 monitor.GetAttachedStorage(); | 78 monitor.GetAttachedStorage(); |
(...skipping 25 matching lines...) Expand all Loading... |
105 EXPECT_EQ(kDeviceName2, devices[0].name); | 104 EXPECT_EQ(kDeviceName2, devices[0].name); |
106 EXPECT_EQ(kDevicePath2.value(), devices[0].location); | 105 EXPECT_EQ(kDevicePath2.value(), devices[0].location); |
107 | 106 |
108 monitor.receiver()->ProcessDetach(kDeviceId2); | 107 monitor.receiver()->ProcessDetach(kDeviceId2); |
109 message_loop.RunUntilIdle(); | 108 message_loop.RunUntilIdle(); |
110 devices = monitor.GetAttachedStorage(); | 109 devices = monitor.GetAttachedStorage(); |
111 EXPECT_EQ(0U, devices.size()); | 110 EXPECT_EQ(0U, devices.size()); |
112 } | 111 } |
113 | 112 |
114 } // namespace chrome | 113 } // namespace chrome |
OLD | NEW |