OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "components/usb_service/usb_device.h" | 7 #include "components/usb_service/usb_device.h" |
8 #include "components/usb_service/usb_device_handle.h" | 8 #include "components/usb_service/usb_device_handle.h" |
9 #include "device/test/usb_test_gadget.h" | 9 #include "device/test/usb_test_gadget.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 scoped_ptr<base::MessageLoop> message_loop_; | 25 scoped_ptr<base::MessageLoop> message_loop_; |
26 }; | 26 }; |
27 | 27 |
28 TEST_F(UsbServiceTest, ClaimGadget) { | 28 TEST_F(UsbServiceTest, ClaimGadget) { |
29 if (!UsbTestGadget::IsTestEnabled()) return; | 29 if (!UsbTestGadget::IsTestEnabled()) return; |
30 | 30 |
31 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim(); | 31 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim(); |
32 ASSERT_TRUE(gadget.get()); | 32 ASSERT_TRUE(gadget.get()); |
33 | 33 |
34 scoped_refptr<UsbDeviceHandle> handle = gadget->GetDevice()->Open(); | 34 scoped_refptr<UsbDeviceHandle> handle = gadget->GetDevice()->Open(); |
35 base::string16 serial_utf16; | 35 |
36 ASSERT_TRUE(handle->GetSerial(&serial_utf16)); | 36 base::string16 utf16; |
37 ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(serial_utf16)); | 37 ASSERT_TRUE(handle->GetManufacturer(&utf16)); |
| 38 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16)); |
| 39 // Check again to make sure string descriptor caching works. |
| 40 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16)); |
| 41 |
| 42 ASSERT_TRUE(handle->GetProduct(&utf16)); |
| 43 ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16)); |
| 44 // Check again to make sure string descriptor caching works. |
| 45 ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16)); |
| 46 |
| 47 ASSERT_TRUE(handle->GetSerial(&utf16)); |
| 48 ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(utf16)); |
| 49 // Check again to make sure string descriptor caching works. |
| 50 ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(utf16)); |
38 } | 51 } |
39 | 52 |
40 TEST_F(UsbServiceTest, DisconnectAndReconnect) { | 53 TEST_F(UsbServiceTest, DisconnectAndReconnect) { |
41 if (!UsbTestGadget::IsTestEnabled()) return; | 54 if (!UsbTestGadget::IsTestEnabled()) return; |
42 | 55 |
43 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim(); | 56 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim(); |
44 ASSERT_TRUE(gadget.get()); | 57 ASSERT_TRUE(gadget.get()); |
45 ASSERT_TRUE(gadget->Disconnect()); | 58 ASSERT_TRUE(gadget->Disconnect()); |
46 ASSERT_TRUE(gadget->Reconnect()); | 59 ASSERT_TRUE(gadget->Reconnect()); |
47 } | 60 } |
48 | 61 |
49 } // namespace | 62 } // namespace |
50 | 63 |
51 } // namespace device | 64 } // namespace device |
OLD | NEW |