Update Checkstyle library from 6.1 to 6.5
[chromium-blink-merge.git] / device / usb / usb_service_unittest.cc
blobedd07123ecd57e28c4d4b398ca55fe10994ed8df
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.
5 #include "base/message_loop/message_loop.h"
6 #include "base/strings/utf_string_conversions.h"
7 #include "device/test/usb_test_gadget.h"
8 #include "device/usb/usb_device.h"
9 #include "device/usb/usb_device_handle.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace device {
14 namespace {
16 class UsbServiceTest : public ::testing::Test {
17 public:
18 void SetUp() override { message_loop_.reset(new base::MessageLoopForIO); }
20 private:
21 scoped_ptr<base::MessageLoop> message_loop_;
24 TEST_F(UsbServiceTest, ClaimGadget) {
25 if (!UsbTestGadget::IsTestEnabled()) return;
27 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
28 ASSERT_TRUE(gadget.get());
30 scoped_refptr<UsbDevice> device = gadget->GetDevice();
31 base::string16 utf16;
32 ASSERT_TRUE(device->GetManufacturer(&utf16));
33 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16));
35 ASSERT_TRUE(device->GetProduct(&utf16));
36 ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16));
38 ASSERT_TRUE(device->GetSerialNumber(&utf16));
39 ASSERT_EQ(gadget->GetSerialNumber(), base::UTF16ToUTF8(utf16));
42 TEST_F(UsbServiceTest, DisconnectAndReconnect) {
43 if (!UsbTestGadget::IsTestEnabled()) return;
45 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
46 ASSERT_TRUE(gadget.get());
47 ASSERT_TRUE(gadget->Disconnect());
48 ASSERT_TRUE(gadget->Reconnect());
51 } // namespace
53 } // namespace device