OLD | NEW |
---|---|
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 }; | 49 }; |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 class HidConnectionTest : public testing::Test { | 53 class HidConnectionTest : public testing::Test { |
54 protected: | 54 protected: |
55 virtual void SetUp() OVERRIDE { | 55 virtual void SetUp() OVERRIDE { |
56 if (!UsbTestGadget::IsTestEnabled()) return; | 56 if (!UsbTestGadget::IsTestEnabled()) return; |
57 | 57 |
58 message_loop_.reset(new base::MessageLoopForIO()); | 58 message_loop_.reset(new base::MessageLoopForIO()); |
59 service_.reset(HidService::Create(message_loop_->message_loop_proxy())); | 59 service_.reset(HidService::GetInstance( |
60 message_loop_->message_loop_proxy())); | |
Reilly Grant (use Gerrit)
2014/08/12 17:12:17
This line points out exactly what I'm going to nee
| |
60 ASSERT_TRUE(service_); | 61 ASSERT_TRUE(service_); |
61 | 62 |
62 test_gadget_ = UsbTestGadget::Claim(); | 63 test_gadget_ = UsbTestGadget::Claim(); |
63 ASSERT_TRUE(test_gadget_); | 64 ASSERT_TRUE(test_gadget_); |
64 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); | 65 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); |
65 | 66 |
66 device_id_ = kInvalidHidDeviceId; | 67 device_id_ = kInvalidHidDeviceId; |
67 | 68 |
68 base::RunLoop run_loop; | 69 base::RunLoop run_loop; |
69 message_loop_->PostDelayedTask( | 70 message_loop_->PostDelayedTask( |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 scoped_refptr<IOBufferWithSize> read_buffer(new IOBufferWithSize(8)); | 125 scoped_refptr<IOBufferWithSize> read_buffer(new IOBufferWithSize(8)); |
125 TestCompletionCallback read_callback; | 126 TestCompletionCallback read_callback; |
126 conn->Read(read_buffer, read_callback.callback()); | 127 conn->Read(read_buffer, read_callback.callback()); |
127 ASSERT_TRUE(read_callback.WaitForResult()); | 128 ASSERT_TRUE(read_callback.WaitForResult()); |
128 ASSERT_EQ(8UL, read_callback.transferred()); | 129 ASSERT_EQ(8UL, read_callback.transferred()); |
129 ASSERT_EQ(i, *(int64_t*)read_buffer->data()); | 130 ASSERT_EQ(i, *(int64_t*)read_buffer->data()); |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 } // namespace device | 134 } // namespace device |
OLD | NEW |