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

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

Issue 1312993008: Manage HidService lifetime in DeviceClient implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_usb_service_get_instance
Patch Set: Created 5 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
« no previous file with comments | « device/device_tests.gyp ('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/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 146
147 class HidConnectionTest : public testing::Test { 147 class HidConnectionTest : public testing::Test {
148 protected: 148 protected:
149 void SetUp() override { 149 void SetUp() override {
150 if (!UsbTestGadget::IsTestEnabled()) return; 150 if (!UsbTestGadget::IsTestEnabled()) return;
151 151
152 message_loop_.reset(new base::MessageLoopForUI()); 152 message_loop_.reset(new base::MessageLoopForUI());
153 io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart)); 153 io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart));
154 device_client_.reset(new TestDeviceClient(io_thread_->task_runner())); 154 device_client_.reset(new TestDeviceClient(io_thread_->task_runner()));
155 155
156 service_ = HidService::GetInstance(io_thread_->task_runner()); 156 service_ = DeviceClient::Get()->GetHidService();
157 ASSERT_TRUE(service_); 157 ASSERT_TRUE(service_);
158 158
159 test_gadget_ = UsbTestGadget::Claim(io_thread_->task_runner()); 159 test_gadget_ = UsbTestGadget::Claim(io_thread_->task_runner());
160 ASSERT_TRUE(test_gadget_); 160 ASSERT_TRUE(test_gadget_);
161 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); 161 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO));
162 162
163 DeviceCatcher device_catcher(service_, 163 DeviceCatcher device_catcher(service_,
164 test_gadget_->GetDevice()->serial_number()); 164 test_gadget_->GetDevice()->serial_number());
165 device_id_ = device_catcher.WaitForDevice(); 165 device_id_ = device_catcher.WaitForDevice();
166 ASSERT_NE(device_id_, kInvalidHidDeviceId); 166 ASSERT_NE(device_id_, kInvalidHidDeviceId);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT_EQ(0, read_callback.buffer()->data()[0]); 201 ASSERT_EQ(0, read_callback.buffer()->data()[0]);
202 for (unsigned char j = 1; j < kBufferSize; ++j) { 202 for (unsigned char j = 1; j < kBufferSize; ++j) {
203 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); 203 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]);
204 } 204 }
205 } 205 }
206 206
207 conn->Close(); 207 conn->Close();
208 } 208 }
209 209
210 } // namespace device 210 } // namespace device
OLDNEW
« no previous file with comments | « device/device_tests.gyp ('k') | device/hid/hid_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698