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

Side by Side Diff: device/usb/usb_device_handle_unittest.cc

Issue 1314273002: Manage UsbService lifetime in DeviceClient implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/usb/usb_context.cc ('k') | device/usb/usb_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "base/test/test_io_thread.h" 9 #include "base/test/test_io_thread.h"
10 #include "device/test/test_device_client.h"
10 #include "device/test/usb_test_gadget.h" 11 #include "device/test/usb_test_gadget.h"
11 #include "device/usb/usb_device.h" 12 #include "device/usb/usb_device.h"
12 #include "device/usb/usb_device_handle.h" 13 #include "device/usb/usb_device_handle.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace device { 16 namespace device {
16 17
17 namespace { 18 namespace {
18 19
19 class UsbDeviceHandleTest : public ::testing::Test { 20 class UsbDeviceHandleTest : public ::testing::Test {
20 public: 21 public:
21 void SetUp() override { 22 void SetUp() override {
22 message_loop_.reset(new base::MessageLoopForUI); 23 message_loop_.reset(new base::MessageLoopForUI);
23 io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart)); 24 io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart));
25 device_client_.reset(new TestDeviceClient(io_thread_->task_runner()));
24 } 26 }
25 27
26 protected: 28 protected:
27 scoped_ptr<base::TestIOThread> io_thread_; 29 scoped_ptr<base::TestIOThread> io_thread_;
28 30
29 private: 31 private:
30 scoped_ptr<base::MessageLoop> message_loop_; 32 scoped_ptr<base::MessageLoop> message_loop_;
33 scoped_ptr<TestDeviceClient> device_client_;
31 }; 34 };
32 35
33 class TestOpenCallback { 36 class TestOpenCallback {
34 public: 37 public:
35 TestOpenCallback() 38 TestOpenCallback()
36 : callback_( 39 : callback_(
37 base::Bind(&TestOpenCallback::SetResult, base::Unretained(this))) {} 40 base::Bind(&TestOpenCallback::SetResult, base::Unretained(this))) {}
38 41
39 scoped_refptr<UsbDeviceHandle> WaitForResult() { 42 scoped_refptr<UsbDeviceHandle> WaitForResult() {
40 run_loop_.Run(); 43 run_loop_.Run();
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TestResultCallback set_interface; 241 TestResultCallback set_interface;
239 handle->SetInterfaceAlternateSetting(2, 1, set_interface.callback()); 242 handle->SetInterfaceAlternateSetting(2, 1, set_interface.callback());
240 ASSERT_TRUE(set_interface.WaitForResult()); 243 ASSERT_TRUE(set_interface.WaitForResult());
241 244
242 handle->Close(); 245 handle->Close();
243 } 246 }
244 247
245 } // namespace 248 } // namespace
246 249
247 } // namespace device 250 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/usb_context.cc ('k') | device/usb/usb_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698