Extensions: Store disable reasons in Sync
[chromium-blink-merge.git] / device / usb / usb_service_unittest.cc
blobf0e5ae272af14ba101736523e17431c056caac27
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 "base/test/test_io_thread.h"
8 #include "device/test/usb_test_gadget.h"
9 #include "device/usb/usb_device.h"
10 #include "device/usb/usb_device_handle.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace device {
15 namespace {
17 class UsbServiceTest : public ::testing::Test {
18 public:
19 void SetUp() override {
20 message_loop_.reset(new base::MessageLoopForUI);
21 io_thread_.reset(new base::TestIOThread(base::TestIOThread::kAutoStart));
24 protected:
25 scoped_ptr<base::MessageLoop> message_loop_;
26 scoped_ptr<base::TestIOThread> io_thread_;
29 TEST_F(UsbServiceTest, ClaimGadget) {
30 if (!UsbTestGadget::IsTestEnabled()) return;
32 scoped_ptr<UsbTestGadget> gadget =
33 UsbTestGadget::Claim(io_thread_->task_runner());
34 ASSERT_TRUE(gadget.get());
36 scoped_refptr<UsbDevice> device = gadget->GetDevice();
37 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(device->manufacturer_string()));
38 ASSERT_EQ("Test Gadget (default state)",
39 base::UTF16ToUTF8(device->product_string()));
42 TEST_F(UsbServiceTest, DisconnectAndReconnect) {
43 if (!UsbTestGadget::IsTestEnabled()) return;
45 scoped_ptr<UsbTestGadget> gadget =
46 UsbTestGadget::Claim(io_thread_->task_runner());
47 ASSERT_TRUE(gadget.get());
48 ASSERT_TRUE(gadget->Disconnect());
49 ASSERT_TRUE(gadget->Reconnect());
52 } // namespace
54 } // namespace device