OLD | NEW |
(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 |
OLD | NEW |