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

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

Issue 10780023: Change base::SystemMonitor's media device functions to take a type and string16 instead of a FilePa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix cros Created 8 years, 5 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>
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
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;
115 volume_broadcast.dbcv_size = sizeof(volume_broadcast); 118 volume_broadcast.dbcv_size = sizeof(volume_broadcast);
116 volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME; 119 volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME;
117 volume_broadcast.dbcv_unitmask = 0x0; 120 volume_broadcast.dbcv_unitmask = 0x0;
118 volume_broadcast.dbcv_flags = 0x0; 121 volume_broadcast.dbcv_flags = 0x0;
119 { 122 {
120 testing::InSequence sequence; 123 testing::InSequence sequence;
121 for (std::vector<int>::const_iterator it = device_indices.begin(); 124 for (std::vector<int>::const_iterator it = device_indices.begin();
122 it != device_indices.end(); 125 it != device_indices.end();
123 ++it) { 126 ++it) {
124 volume_broadcast.dbcv_unitmask |= 0x1 << *it; 127 volume_broadcast.dbcv_unitmask |= 0x1 << *it;
125 EXPECT_CALL(observer_, OnMediaDeviceDetached(*it)); 128 EXPECT_CALL(observer_, OnMediaDeviceDetached(base::IntToString(*it)));
126 } 129 }
127 } 130 }
128 window_->OnDeviceChange(DBT_DEVICEREMOVECOMPLETE, 131 window_->OnDeviceChange(DBT_DEVICEREMOVECOMPLETE,
129 reinterpret_cast<DWORD>(&volume_broadcast)); 132 reinterpret_cast<DWORD>(&volume_broadcast));
130 message_loop_.RunAllPending(); 133 message_loop_.RunAllPending();
131 } 134 }
132 135
133 TEST_F(MediaDeviceNotificationsWindowWinTest, RandomMessage) { 136 TEST_F(MediaDeviceNotificationsWindowWinTest, RandomMessage) {
134 window_->OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL); 137 window_->OnDeviceChange(DBT_DEVICEQUERYREMOVE, NULL);
135 message_loop_.RunAllPending(); 138 message_loop_.RunAllPending();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698