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> |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 testing::InSequence sequence; | 97 testing::InSequence sequence; |
98 for (std::vector<int>::const_iterator it = device_indices.begin(); | 98 for (std::vector<int>::const_iterator it = device_indices.begin(); |
99 it != device_indices.end(); | 99 it != device_indices.end(); |
100 ++it) { | 100 ++it) { |
101 volume_broadcast.dbcv_unitmask |= 0x1 << *it; | 101 volume_broadcast.dbcv_unitmask |= 0x1 << *it; |
102 std::wstring drive(L"_:\\"); | 102 std::wstring drive(L"_:\\"); |
103 drive[0] = 'A' + *it; | 103 drive[0] = 'A' + *it; |
104 FilePath::StringType name = L"V" + drive; | 104 FilePath::StringType name = L"V" + drive; |
105 std::string device_id = MediaStorageUtil::MakeDeviceId( | 105 std::string device_id = MediaStorageUtil::MakeDeviceId( |
106 MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, base::IntToString(*it)); | 106 MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, base::IntToString(*it)); |
107 EXPECT_CALL(observer_, OnMediaDeviceAttached(device_id, name, drive)) | 107 EXPECT_CALL(observer_, OnRemovableStorageAttached(device_id, name, drive)) |
108 .Times(0); | 108 .Times(0); |
109 } | 109 } |
110 } | 110 } |
111 window_->OnDeviceChange(DBT_DEVICEARRIVAL, | 111 window_->OnDeviceChange(DBT_DEVICEARRIVAL, |
112 reinterpret_cast<DWORD>(&volume_broadcast)); | 112 reinterpret_cast<DWORD>(&volume_broadcast)); |
113 message_loop_.RunAllPending(); | 113 message_loop_.RunAllPending(); |
114 } | 114 } |
115 | 115 |
116 void MediaDeviceNotificationsWindowWinTest::DoDevicesDetachedTest( | 116 void MediaDeviceNotificationsWindowWinTest::DoDevicesDetachedTest( |
117 const std::vector<int>& device_indices) { | 117 const std::vector<int>& device_indices) { |
118 DEV_BROADCAST_VOLUME volume_broadcast; | 118 DEV_BROADCAST_VOLUME volume_broadcast; |
119 volume_broadcast.dbcv_size = sizeof(volume_broadcast); | 119 volume_broadcast.dbcv_size = sizeof(volume_broadcast); |
120 volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME; | 120 volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME; |
121 volume_broadcast.dbcv_unitmask = 0x0; | 121 volume_broadcast.dbcv_unitmask = 0x0; |
122 volume_broadcast.dbcv_flags = 0x0; | 122 volume_broadcast.dbcv_flags = 0x0; |
123 { | 123 { |
124 testing::InSequence sequence; | 124 testing::InSequence sequence; |
125 for (std::vector<int>::const_iterator it = device_indices.begin(); | 125 for (std::vector<int>::const_iterator it = device_indices.begin(); |
126 it != device_indices.end(); | 126 it != device_indices.end(); |
127 ++it) { | 127 ++it) { |
128 volume_broadcast.dbcv_unitmask |= 0x1 << *it; | 128 volume_broadcast.dbcv_unitmask |= 0x1 << *it; |
129 std::string device_id = MediaStorageUtil::MakeDeviceId( | 129 std::string device_id = MediaStorageUtil::MakeDeviceId( |
130 MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, base::IntToString(*it)); | 130 MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, base::IntToString(*it)); |
131 EXPECT_CALL(observer_, OnMediaDeviceDetached(device_id)).Times(0); | 131 EXPECT_CALL(observer_, OnRemovableStorageDetached(device_id)).Times(0); |
132 } | 132 } |
133 } | 133 } |
134 window_->OnDeviceChange(DBT_DEVICEREMOVECOMPLETE, | 134 window_->OnDeviceChange(DBT_DEVICEREMOVECOMPLETE, |
135 reinterpret_cast<DWORD>(&volume_broadcast)); | 135 reinterpret_cast<DWORD>(&volume_broadcast)); |
136 message_loop_.RunAllPending(); | 136 message_loop_.RunAllPending(); |
137 } | 137 } |
138 | 138 |
139 TEST_F(MediaDeviceNotificationsWindowWinTest, RandomMessage) { | 139 TEST_F(MediaDeviceNotificationsWindowWinTest, RandomMessage) { |
140 window_->OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL); | 140 window_->OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL); |
141 message_loop_.RunAllPending(); | 141 message_loop_.RunAllPending(); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 std::vector<int> device_indices; | 201 std::vector<int> device_indices; |
202 device_indices.push_back(0); | 202 device_indices.push_back(0); |
203 device_indices.push_back(1); | 203 device_indices.push_back(1); |
204 device_indices.push_back(2); | 204 device_indices.push_back(2); |
205 device_indices.push_back(3); | 205 device_indices.push_back(3); |
206 | 206 |
207 DoDevicesDetachedTest(device_indices); | 207 DoDevicesDetachedTest(device_indices); |
208 } | 208 } |
209 | 209 |
210 } // namespace chrome | 210 } // namespace chrome |
OLD | NEW |