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

Unified Diff: device/serial/serial_service_unittest.cc

Issue 363853003: Add a basic Mojo SerialService that implements GetDevices(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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/serial/serial_service_impl.cc ('k') | device/test/DEPS » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_service_unittest.cc
diff --git a/device/serial/serial_service_unittest.cc b/device/serial/serial_service_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7e77c14fabdeb785ebb29bf0f185e4c15180624d
--- /dev/null
+++ b/device/serial/serial_service_unittest.cc
@@ -0,0 +1,53 @@
+// 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/bind.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "device/serial/serial.mojom.h"
+#include "device/serial/serial_service_impl.h"
+#include "mojo/public/cpp/bindings/error_handler.h"
+#include "mojo/public/cpp/bindings/interface_ptr.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace device {
+
+class SerialServiceTest : public testing::Test, public mojo::ErrorHandler {
+ public:
+ SerialServiceTest() {}
+
+ void StoreDevices(mojo::Array<serial::DeviceInfoPtr> devices) {
+ devices_ = devices.Pass();
+ message_loop_.PostTask(FROM_HERE, run_loop_.QuitClosure());
+ }
+
+ virtual void OnConnectionError() OVERRIDE {
+ message_loop_.PostTask(FROM_HERE, run_loop_.QuitClosure());
+ FAIL() << "Connection error";
+ }
+
+ base::MessageLoop message_loop_;
+ base::RunLoop run_loop_;
+ mojo::Array<serial::DeviceInfoPtr> devices_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SerialServiceTest);
+};
+
+TEST_F(SerialServiceTest, GetDevices) {
+ mojo::InterfacePtr<serial::SerialService> service;
+ SerialServiceImpl::Create(mojo::Get(&service));
+ service.set_error_handler(this);
+ mojo::Array<serial::DeviceInfoPtr> result;
+ service->GetDevices(
+ base::Bind(&SerialServiceTest::StoreDevices, base::Unretained(this)));
+ run_loop_.Run();
+
+ // Because we're running on unknown hardware, only check that we received a
+ // non-null result.
+ EXPECT_TRUE(devices_);
+}
+
+} // namespace device
« no previous file with comments | « device/serial/serial_service_impl.cc ('k') | device/test/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698