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 "chrome/browser/media_gallery/media_device_notifications_window_win.h" | 5 #include "chrome/browser/media_gallery/media_device_notifications_window_win.h" |
6 | 6 |
7 #include <dbt.h> | 7 #include <dbt.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/scoped_temp_dir.h" | 15 #include "base/scoped_temp_dir.h" |
16 #include "base/sys_string_conversions.h" | 16 #include "base/string_number_conversions.h" |
17 #include "base/system_monitor/system_monitor.h" | 17 #include "base/system_monitor/system_monitor.h" |
18 #include "base/test/mock_devices_changed_observer.h" | 18 #include "base/test/mock_devices_changed_observer.h" |
19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 | 26 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 volume_broadcast.dbcv_unitmask = 0x0; | 91 volume_broadcast.dbcv_unitmask = 0x0; |
92 volume_broadcast.dbcv_flags = 0x0; | 92 volume_broadcast.dbcv_flags = 0x0; |
93 { | 93 { |
94 testing::InSequence sequence; | 94 testing::InSequence sequence; |
95 for (std::vector<int>::const_iterator it = device_indices.begin(); | 95 for (std::vector<int>::const_iterator it = device_indices.begin(); |
96 it != device_indices.end(); | 96 it != device_indices.end(); |
97 ++it) { | 97 ++it) { |
98 volume_broadcast.dbcv_unitmask |= 0x1 << *it; | 98 volume_broadcast.dbcv_unitmask |= 0x1 << *it; |
99 std::wstring drive(L"_:\\"); | 99 std::wstring drive(L"_:\\"); |
100 drive[0] = 'A' + *it; | 100 drive[0] = 'A' + *it; |
101 std::string name("V"); | 101 FilePath::StringType name = L"V" + drive; |
102 name.append(base::SysWideToUTF8(drive)); | 102 EXPECT_CALL(observer_, |
103 EXPECT_CALL(observer_, OnMediaDeviceAttached(*it, name, FilePath(drive))). | 103 OnMediaDeviceAttached(base::IntToString(*it), |
104 Times(0); | 104 name, |
| 105 base::SystemMonitor::TYPE_PATH, |
| 106 drive)) |
| 107 .Times(0); |
105 } | 108 } |
106 } | 109 } |
107 window_->OnDeviceChange(DBT_DEVICEARRIVAL, | 110 window_->OnDeviceChange(DBT_DEVICEARRIVAL, |
108 reinterpret_cast<DWORD>(&volume_broadcast)); | 111 reinterpret_cast<DWORD>(&volume_broadcast)); |
109 message_loop_.RunAllPending(); | 112 message_loop_.RunAllPending(); |
110 } | 113 } |
111 | 114 |
112 void MediaDeviceNotificationsWindowWinTest::DoDevicesDetachedTest( | 115 void MediaDeviceNotificationsWindowWinTest::DoDevicesDetachedTest( |
113 const std::vector<int>& device_indices) { | 116 const std::vector<int>& device_indices) { |
114 DEV_BROADCAST_VOLUME volume_broadcast; | 117 DEV_BROADCAST_VOLUME volume_broadcast; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 196 |
194 TEST_F(MediaDeviceNotificationsWindowWinTest, DevicesDetachedAdjacentBits) { | 197 TEST_F(MediaDeviceNotificationsWindowWinTest, DevicesDetachedAdjacentBits) { |
195 std::vector<int> device_indices; | 198 std::vector<int> device_indices; |
196 device_indices.push_back(0); | 199 device_indices.push_back(0); |
197 device_indices.push_back(1); | 200 device_indices.push_back(1); |
198 device_indices.push_back(2); | 201 device_indices.push_back(2); |
199 device_indices.push_back(3); | 202 device_indices.push_back(3); |
200 | 203 |
201 DoDevicesDetachedTest(device_indices); | 204 DoDevicesDetachedTest(device_indices); |
202 } | 205 } |
OLD | NEW |