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

Unified Diff: device/usb/device_impl_unittest.cc

Issue 1155163008: Build a basic Mojo service framework for device/usb (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DISALLOW Created 5 years, 7 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/device_impl.cc ('k') | device/usb/device_manager_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/device_impl_unittest.cc
diff --git a/device/usb/device_impl_unittest.cc b/device/usb/device_impl_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..293ffdd7fb23b0154aa3d676de941a7880833ba1
--- /dev/null
+++ b/device/usb/device_impl_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright 2015 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/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "device/usb/device_impl.h"
+#include "device/usb/mock_usb_device.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/mojo/src/mojo/public/cpp/bindings/interface_request.h"
+
+namespace device {
+namespace usb {
+
+namespace {
+
+using DeviceImplTest = testing::Test;
+
+void ExpectDeviceInfoAndThen(uint16_t vendor_id,
+ uint16_t product_id,
+ const std::string& manufacturer,
+ const std::string& product,
+ const std::string& serial_number,
+ const base::Closure& continuation,
+ DeviceInfoPtr device_info) {
+ EXPECT_EQ(vendor_id, device_info->vendor_id);
+ EXPECT_EQ(product_id, device_info->product_id);
+ EXPECT_EQ(manufacturer, device_info->manufacturer);
+ EXPECT_EQ(product, device_info->product);
+ EXPECT_EQ(serial_number, device_info->serial_number);
+ continuation.Run();
+}
+
+} // namespace
+
+// Test that the information returned via the Device::GetDeviceInfo matches that
+// of the underlying device.
+TEST_F(DeviceImplTest, GetDeviceInfo) {
+ base::MessageLoop message_loop;
+ scoped_refptr<MockUsbDevice> fake_device =
+ new MockUsbDevice(0x1234, 0x5678, "ACME", "Frobinator", "ABCDEF");
+ DevicePtr device;
+ EXPECT_CALL(*fake_device.get(), GetConfiguration());
+ new DeviceImpl(fake_device, mojo::GetProxy(&device));
+
+ base::RunLoop run_loop;
+ device->GetDeviceInfo(base::Bind(&ExpectDeviceInfoAndThen, 0x1234, 0x5678,
+ "ACME", "Frobinator", "ABCDEF",
+ run_loop.QuitClosure()));
+ run_loop.Run();
+}
+
+} // namespace usb
+} // namespace device
« no previous file with comments | « device/usb/device_impl.cc ('k') | device/usb/device_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698