Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_window_win_unittest.cc

Issue 10876093: Improve the device type constants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 { 96 {
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::REMOVABLE_MASS_STORAGE_WITH_DCIM,
107 base::IntToString(*it));
107 EXPECT_CALL(observer_, OnRemovableStorageAttached(device_id, name, drive)) 108 EXPECT_CALL(observer_, OnRemovableStorageAttached(device_id, name, drive))
108 .Times(0); 109 .Times(0);
109 } 110 }
110 } 111 }
111 window_->OnDeviceChange(DBT_DEVICEARRIVAL, 112 window_->OnDeviceChange(DBT_DEVICEARRIVAL,
112 reinterpret_cast<DWORD>(&volume_broadcast)); 113 reinterpret_cast<DWORD>(&volume_broadcast));
113 message_loop_.RunAllPending(); 114 message_loop_.RunAllPending();
114 } 115 }
115 116
116 void MediaDeviceNotificationsWindowWinTest::DoDevicesDetachedTest( 117 void MediaDeviceNotificationsWindowWinTest::DoDevicesDetachedTest(
117 const std::vector<int>& device_indices) { 118 const std::vector<int>& device_indices) {
118 DEV_BROADCAST_VOLUME volume_broadcast; 119 DEV_BROADCAST_VOLUME volume_broadcast;
119 volume_broadcast.dbcv_size = sizeof(volume_broadcast); 120 volume_broadcast.dbcv_size = sizeof(volume_broadcast);
120 volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME; 121 volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME;
121 volume_broadcast.dbcv_unitmask = 0x0; 122 volume_broadcast.dbcv_unitmask = 0x0;
122 volume_broadcast.dbcv_flags = 0x0; 123 volume_broadcast.dbcv_flags = 0x0;
123 { 124 {
124 testing::InSequence sequence; 125 testing::InSequence sequence;
125 for (std::vector<int>::const_iterator it = device_indices.begin(); 126 for (std::vector<int>::const_iterator it = device_indices.begin();
126 it != device_indices.end(); 127 it != device_indices.end();
127 ++it) { 128 ++it) {
128 volume_broadcast.dbcv_unitmask |= 0x1 << *it; 129 volume_broadcast.dbcv_unitmask |= 0x1 << *it;
129 std::string device_id = MediaStorageUtil::MakeDeviceId( 130 std::string device_id = MediaStorageUtil::MakeDeviceId(
130 MediaStorageUtil::USB_MASS_STORAGE_WITH_DCIM, base::IntToString(*it)); 131 MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM,
132 base::IntToString(*it));
131 EXPECT_CALL(observer_, OnRemovableStorageDetached(device_id)).Times(0); 133 EXPECT_CALL(observer_, OnRemovableStorageDetached(device_id)).Times(0);
132 } 134 }
133 } 135 }
134 window_->OnDeviceChange(DBT_DEVICEREMOVECOMPLETE, 136 window_->OnDeviceChange(DBT_DEVICEREMOVECOMPLETE,
135 reinterpret_cast<DWORD>(&volume_broadcast)); 137 reinterpret_cast<DWORD>(&volume_broadcast));
136 message_loop_.RunAllPending(); 138 message_loop_.RunAllPending();
137 } 139 }
138 140
139 TEST_F(MediaDeviceNotificationsWindowWinTest, RandomMessage) { 141 TEST_F(MediaDeviceNotificationsWindowWinTest, RandomMessage) {
140 window_->OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL); 142 window_->OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 std::vector<int> device_indices; 203 std::vector<int> device_indices;
202 device_indices.push_back(0); 204 device_indices.push_back(0);
203 device_indices.push_back(1); 205 device_indices.push_back(1);
204 device_indices.push_back(2); 206 device_indices.push_back(2);
205 device_indices.push_back(3); 207 device_indices.push_back(3);
206 208
207 DoDevicesDetachedTest(device_indices); 209 DoDevicesDetachedTest(device_indices);
208 } 210 }
209 211
210 } // namespace chrome 212 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698