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

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

Issue 601073002: Move string descriptor getters from UsbDeviceHandle to UsbDevice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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 "device/test/usb_test_gadget.h" 7 #include "device/test/usb_test_gadget.h"
8 #include "device/usb/usb_device.h" 8 #include "device/usb/usb_device.h"
9 #include "device/usb/usb_device_handle.h" 9 #include "device/usb/usb_device_handle.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 11 matching lines...) Expand all
22 private: 22 private:
23 scoped_ptr<base::MessageLoop> message_loop_; 23 scoped_ptr<base::MessageLoop> message_loop_;
24 }; 24 };
25 25
26 TEST_F(UsbServiceTest, ClaimGadget) { 26 TEST_F(UsbServiceTest, ClaimGadget) {
27 if (!UsbTestGadget::IsTestEnabled()) return; 27 if (!UsbTestGadget::IsTestEnabled()) return;
28 28
29 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim(); 29 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
30 ASSERT_TRUE(gadget.get()); 30 ASSERT_TRUE(gadget.get());
31 31
32 scoped_refptr<UsbDeviceHandle> handle = gadget->GetDevice()->Open(); 32 scoped_refptr<UsbDevice> device = gadget->GetDevice();
33
34 base::string16 utf16; 33 base::string16 utf16;
35 ASSERT_TRUE(handle->GetManufacturer(&utf16)); 34 ASSERT_TRUE(device->GetManufacturer(&utf16));
36 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16));
37 // Check again to make sure string descriptor caching works.
38 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16)); 35 ASSERT_EQ("Google Inc.", base::UTF16ToUTF8(utf16));
39 36
40 ASSERT_TRUE(handle->GetProduct(&utf16)); 37 ASSERT_TRUE(device->GetProduct(&utf16));
41 ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16));
42 // Check again to make sure string descriptor caching works.
43 ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16)); 38 ASSERT_EQ("Test Gadget (default state)", base::UTF16ToUTF8(utf16));
44 39
45 ASSERT_TRUE(handle->GetSerial(&utf16)); 40 ASSERT_TRUE(device->GetSerialNumber(&utf16));
46 ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(utf16)); 41 ASSERT_EQ(gadget->GetSerialNumber(), base::UTF16ToUTF8(utf16));
47 // Check again to make sure string descriptor caching works.
48 ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(utf16));
49 } 42 }
50 43
51 TEST_F(UsbServiceTest, DisconnectAndReconnect) { 44 TEST_F(UsbServiceTest, DisconnectAndReconnect) {
52 if (!UsbTestGadget::IsTestEnabled()) return; 45 if (!UsbTestGadget::IsTestEnabled()) return;
53 46
54 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim(); 47 scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
55 ASSERT_TRUE(gadget.get()); 48 ASSERT_TRUE(gadget.get());
56 ASSERT_TRUE(gadget->Disconnect()); 49 ASSERT_TRUE(gadget->Disconnect());
57 ASSERT_TRUE(gadget->Reconnect()); 50 ASSERT_TRUE(gadget->Reconnect());
58 } 51 }
59 52
60 } // namespace 53 } // namespace
61 54
62 } // namespace device 55 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698