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

Side by Side Diff: device/serial/serial_service_unittest.cc

Issue 629523003: Rename Get to GetProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix device 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/bind.h" 5 #include "base/bind.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "device/serial/serial.mojom.h" 8 #include "device/serial/serial.mojom.h"
9 #include "device/serial/serial_service_impl.h" 9 #include "device/serial/serial_service_impl.h"
10 #include "device/serial/test_serial_io_handler.h" 10 #include "device/serial/test_serial_io_handler.h"
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 base::Bind(&SerialServiceTest::ReturnIoHandler, 79 base::Bind(&SerialServiceTest::ReturnIoHandler,
80 base::Unretained(this)), 80 base::Unretained(this)),
81 base::MessageLoopProxy::current()), 81 base::MessageLoopProxy::current()),
82 scoped_ptr<SerialDeviceEnumerator>(new FakeSerialDeviceEnumerator)), 82 scoped_ptr<SerialDeviceEnumerator>(new FakeSerialDeviceEnumerator)),
83 &service); 83 &service);
84 mojo::InterfacePtr<serial::Connection> connection; 84 mojo::InterfacePtr<serial::Connection> connection;
85 mojo::InterfacePtr<serial::DataSink> sink; 85 mojo::InterfacePtr<serial::DataSink> sink;
86 mojo::InterfacePtr<serial::DataSource> source; 86 mojo::InterfacePtr<serial::DataSource> source;
87 service->Connect(path, 87 service->Connect(path,
88 serial::ConnectionOptions::New(), 88 serial::ConnectionOptions::New(),
89 mojo::Get(&connection), 89 mojo::GetProxy(&connection),
90 mojo::Get(&sink), 90 mojo::GetProxy(&sink),
91 mojo::Get(&source)); 91 mojo::GetProxy(&source));
92 connection.set_error_handler(this); 92 connection.set_error_handler(this);
93 expecting_error_ = !expecting_success; 93 expecting_error_ = !expecting_success;
94 connection->GetInfo( 94 connection->GetInfo(
95 base::Bind(&SerialServiceTest::OnGotInfo, base::Unretained(this))); 95 base::Bind(&SerialServiceTest::OnGotInfo, base::Unretained(this)));
96 RunMessageLoop(); 96 RunMessageLoop();
97 EXPECT_EQ(!expecting_success, connection.encountered_error()); 97 EXPECT_EQ(!expecting_success, connection.encountered_error());
98 EXPECT_EQ(expecting_success, connected_); 98 EXPECT_EQ(expecting_success, connected_);
99 connection.reset(); 99 connection.reset();
100 } 100 }
101 101
102 base::MessageLoop message_loop_; 102 base::MessageLoop message_loop_;
103 scoped_ptr<base::RunLoop> run_loop_; 103 scoped_ptr<base::RunLoop> run_loop_;
104 mojo::Array<serial::DeviceInfoPtr> devices_; 104 mojo::Array<serial::DeviceInfoPtr> devices_;
105 scoped_refptr<TestSerialIoHandler> io_handler_; 105 scoped_refptr<TestSerialIoHandler> io_handler_;
106 bool connected_; 106 bool connected_;
107 bool expecting_error_; 107 bool expecting_error_;
108 serial::ConnectionInfoPtr info_; 108 serial::ConnectionInfoPtr info_;
109 109
110 private: 110 private:
111 DISALLOW_COPY_AND_ASSIGN(SerialServiceTest); 111 DISALLOW_COPY_AND_ASSIGN(SerialServiceTest);
112 }; 112 };
113 113
114 TEST_F(SerialServiceTest, GetDevices) { 114 TEST_F(SerialServiceTest, GetDevices) {
115 mojo::InterfacePtr<serial::SerialService> service; 115 mojo::InterfacePtr<serial::SerialService> service;
116 SerialServiceImpl::Create(NULL, mojo::Get(&service)); 116 SerialServiceImpl::Create(NULL, mojo::GetProxy(&service));
117 service.set_error_handler(this); 117 service.set_error_handler(this);
118 mojo::Array<serial::DeviceInfoPtr> result; 118 mojo::Array<serial::DeviceInfoPtr> result;
119 service->GetDevices( 119 service->GetDevices(
120 base::Bind(&SerialServiceTest::StoreDevices, base::Unretained(this))); 120 base::Bind(&SerialServiceTest::StoreDevices, base::Unretained(this)));
121 RunMessageLoop(); 121 RunMessageLoop();
122 122
123 // Because we're running on unknown hardware, only check that we received a 123 // Because we're running on unknown hardware, only check that we received a
124 // non-null result. 124 // non-null result.
125 EXPECT_TRUE(devices_); 125 EXPECT_TRUE(devices_);
126 } 126 }
127 127
128 TEST_F(SerialServiceTest, Connect) { 128 TEST_F(SerialServiceTest, Connect) {
129 RunConnectTest("device", true); 129 RunConnectTest("device", true);
130 } 130 }
131 131
132 TEST_F(SerialServiceTest, ConnectInvalidPath) { 132 TEST_F(SerialServiceTest, ConnectInvalidPath) {
133 RunConnectTest("invalid_path", false); 133 RunConnectTest("invalid_path", false);
134 } 134 }
135 135
136 TEST_F(SerialServiceTest, ConnectOpenFailed) { 136 TEST_F(SerialServiceTest, ConnectOpenFailed) {
137 io_handler_ = new FailToOpenIoHandler; 137 io_handler_ = new FailToOpenIoHandler;
138 RunConnectTest("device", false); 138 RunConnectTest("device", false);
139 } 139 }
140 140
141 } // namespace device 141 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_connection_unittest.cc ('k') | mojo/examples/compositor_app/compositor_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698