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

Side by Side Diff: device/hid/hid_connection_unittest.cc

Issue 419713002: Support permission_broker for chrome.hid devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix hid in app_shell after its move to //extensions Created 6 years, 4 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
« no previous file with comments | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2014 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 69
70 conn->Write(0, buffer, base::Bind(OnWriteNormal)); 70 conn->Write(0, buffer, base::Bind(OnWriteNormal));
71 } 71 }
72 72
73 } // namespace 73 } // namespace
74 74
75 class HidConnectionTest : public testing::Test { 75 class HidConnectionTest : public testing::Test {
76 protected: 76 protected:
77 virtual void SetUp() OVERRIDE { 77 virtual void SetUp() OVERRIDE {
78 message_loop_.reset(new base::MessageLoopForIO()); 78 message_loop_.reset(new base::MessageLoopForIO());
79 service_.reset(HidService::CreateInstance()); 79 service_.reset(HidService::Create(message_loop_->message_loop_proxy()));
80 ASSERT_TRUE(service_); 80 ASSERT_TRUE(service_);
81 81
82 std::vector<HidDeviceInfo> devices; 82 std::vector<HidDeviceInfo> devices;
83 service_->GetDevices(&devices); 83 service_->GetDevices(&devices);
84 device_id_ = kInvalidHidDeviceId; 84 device_id_ = kInvalidHidDeviceId;
85 for (std::vector<HidDeviceInfo>::iterator it = devices.begin(); 85 for (std::vector<HidDeviceInfo>::iterator it = devices.begin();
86 it != devices.end(); 86 it != devices.end();
87 ++it) { 87 ++it) {
88 if (it->vendor_id == kUSBLUFADemoVID && 88 if (it->vendor_id == kUSBLUFADemoVID &&
89 it->product_id == kUSBLUFADemoPID) { 89 it->product_id == kUSBLUFADemoPID) {
(...skipping 29 matching lines...) Expand all
119 TEST_F(HidConnectionTest, Write) { 119 TEST_F(HidConnectionTest, Write) {
120 scoped_refptr<HidConnection> connection = service_->Connect(device_id_); 120 scoped_refptr<HidConnection> connection = service_->Connect(device_id_);
121 121
122 if (connection) { 122 if (connection) {
123 message_loop_->PostTask(FROM_HERE, base::Bind(WriteNormal, connection)); 123 message_loop_->PostTask(FROM_HERE, base::Bind(WriteNormal, connection));
124 message_loop_->Run(); 124 message_loop_->Run();
125 } 125 }
126 } 126 }
127 127
128 } // namespace device 128 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698