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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/serial/serial_service_impl.cc ('k') | device/test/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h"
8 #include "device/serial/serial.mojom.h"
9 #include "device/serial/serial_service_impl.h"
10 #include "mojo/public/cpp/bindings/error_handler.h"
11 #include "mojo/public/cpp/bindings/interface_ptr.h"
12 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 namespace device {
16
17 class SerialServiceTest : public testing::Test, public mojo::ErrorHandler {
18 public:
19 SerialServiceTest() {}
20
21 void StoreDevices(mojo::Array<serial::DeviceInfoPtr> devices) {
22 devices_ = devices.Pass();
23 message_loop_.PostTask(FROM_HERE, run_loop_.QuitClosure());
24 }
25
26 virtual void OnConnectionError() OVERRIDE {
27 message_loop_.PostTask(FROM_HERE, run_loop_.QuitClosure());
28 FAIL() << "Connection error";
29 }
30
31 base::MessageLoop message_loop_;
32 base::RunLoop run_loop_;
33 mojo::Array<serial::DeviceInfoPtr> devices_;
34
35 private:
36 DISALLOW_COPY_AND_ASSIGN(SerialServiceTest);
37 };
38
39 TEST_F(SerialServiceTest, GetDevices) {
40 mojo::InterfacePtr<serial::SerialService> service;
41 SerialServiceImpl::Create(mojo::Get(&service));
42 service.set_error_handler(this);
43 mojo::Array<serial::DeviceInfoPtr> result;
44 service->GetDevices(
45 base::Bind(&SerialServiceTest::StoreDevices, base::Unretained(this)));
46 run_loop_.Run();
47
48 // Because we're running on unknown hardware, only check that we received a
49 // non-null result.
50 EXPECT_TRUE(devices_);
51 }
52
53 } // namespace device
OLDNEW
« 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