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

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

Issue 420563008: [usb_gadget p12] Basic tests of usb_service using the USB test gadget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « device/usb/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/message_loop/message_loop.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "components/usb_service/usb_device.h"
8 #include "components/usb_service/usb_device_handle.h"
9 #include "device/test/usb_test_gadget.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 using ::usb_service::UsbDeviceHandle;
13
14 namespace device {
15
16 namespace {
17
18 class UsbServiceTest : public ::testing::Test {
19 public:
20 virtual void SetUp() {
21 message_loop_.reset(new base::MessageLoopForIO);
22 }
23
24 private:
25 scoped_ptr<base::MessageLoop> message_loop_;
26 };
27
28 TEST_F(UsbServiceTest, ClaimGadget) {
29 if (!UsbTestGadget::IsTestEnabled()) return;
30
31 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
32 ASSERT_TRUE(gadget.get());
33
34 scoped_refptr<UsbDeviceHandle> handle = gadget->GetDevice()->Open();
35 base::string16 serial_utf16;
36 ASSERT_TRUE(handle->GetSerial(&serial_utf16));
37 ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(serial_utf16));
38 }
39
40 TEST_F(UsbServiceTest, DisconnectAndReconnect) {
41 if (!UsbTestGadget::IsTestEnabled()) return;
42
43 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
44 ASSERT_TRUE(gadget.get());
45 ASSERT_TRUE(gadget->Disconnect());
46 ASSERT_TRUE(gadget->Reconnect());
47 }
48
49 } // namespace
50
51 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698