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

Unified Diff: device/usb/usb_service_unittest.cc

Issue 420563008: [usb_gadget p12] Basic tests of usb_service using the USB test gadget. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/DEPS ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service_unittest.cc
diff --git a/device/usb/usb_service_unittest.cc b/device/usb/usb_service_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..79a5bb74925bb89f91df221758006a78a5aa7466
--- /dev/null
+++ b/device/usb/usb_service_unittest.cc
@@ -0,0 +1,51 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/message_loop/message_loop.h"
+#include "base/strings/utf_string_conversions.h"
+#include "components/usb_service/usb_device.h"
+#include "components/usb_service/usb_device_handle.h"
+#include "device/test/usb_test_gadget.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+using ::usb_service::UsbDeviceHandle;
+
+namespace device {
+
+namespace {
+
+class UsbServiceTest : public ::testing::Test {
+ public:
+ virtual void SetUp() {
+ message_loop_.reset(new base::MessageLoopForIO);
+ }
+
+ private:
+ scoped_ptr<base::MessageLoop> message_loop_;
+};
+
+TEST_F(UsbServiceTest, ClaimGadget) {
+ if (!UsbTestGadget::IsTestEnabled()) return;
+
+ scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
+ ASSERT_TRUE(gadget.get());
+
+ scoped_refptr<UsbDeviceHandle> handle = gadget->GetDevice()->Open();
+ base::string16 serial_utf16;
+ ASSERT_TRUE(handle->GetSerial(&serial_utf16));
+ ASSERT_EQ(gadget->GetSerial(), base::UTF16ToUTF8(serial_utf16));
+}
+
+TEST_F(UsbServiceTest, DisconnectAndReconnect) {
+ if (!UsbTestGadget::IsTestEnabled()) return;
+
+ scoped_ptr<UsbTestGadget> gadget = UsbTestGadget::Claim();
+ ASSERT_TRUE(gadget.get());
+ ASSERT_TRUE(gadget->Disconnect());
+ ASSERT_TRUE(gadget->Reconnect());
+}
+
+} // namespace
+
+} // namespace device
« no previous file with comments | « device/usb/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698