OLD | NEW |
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 "device/serial/serial_device_enumerator.h" | 5 #include "device/serial/serial_device_enumerator.h" |
6 #include "device/serial/serial_service_impl.h" | 6 #include "device/serial/serial_service_impl.h" |
7 #include "device/serial/test_serial_io_handler.h" | 7 #include "device/serial/test_serial_io_handler.h" |
8 #include "extensions/renderer/api_test_base.h" | 8 #include "extensions/renderer/api_test_base.h" |
9 #include "grit/extensions_renderer_resources.h" | 9 #include "grit/extensions_renderer_resources.h" |
10 | 10 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 virtual void SetUp() OVERRIDE { | 307 virtual void SetUp() OVERRIDE { |
308 ApiTestBase::SetUp(); | 308 ApiTestBase::SetUp(); |
309 env()->RegisterModule("serial", IDR_SERIAL_CUSTOM_BINDINGS_JS); | 309 env()->RegisterModule("serial", IDR_SERIAL_CUSTOM_BINDINGS_JS); |
310 env()->RegisterModule("serial_service", IDR_SERIAL_SERVICE_JS); | 310 env()->RegisterModule("serial_service", IDR_SERIAL_SERVICE_JS); |
311 env()->RegisterModule("device/serial/serial.mojom", IDR_SERIAL_MOJOM_JS); | 311 env()->RegisterModule("device/serial/serial.mojom", IDR_SERIAL_MOJOM_JS); |
312 service_provider()->AddService<device::serial::SerialService>(base::Bind( | 312 service_provider()->AddService<device::serial::SerialService>(base::Bind( |
313 &SerialApiTest::CreateSerialService, base::Unretained(this))); | 313 &SerialApiTest::CreateSerialService, base::Unretained(this))); |
314 } | 314 } |
315 | 315 |
316 virtual void TearDown() OVERRIDE { | 316 virtual void TearDown() OVERRIDE { |
317 if (io_handler_) | 317 if (io_handler_.get()) |
318 EXPECT_TRUE(io_handler_->HasOneRef()); | 318 EXPECT_TRUE(io_handler_->HasOneRef()); |
319 ApiTestBase::TearDown(); | 319 ApiTestBase::TearDown(); |
320 } | 320 } |
321 | 321 |
322 scoped_refptr<TestIoHandlerBase> io_handler_; | 322 scoped_refptr<TestIoHandlerBase> io_handler_; |
323 | 323 |
324 private: | 324 private: |
325 scoped_refptr<device::SerialIoHandler> GetIoHandler() { | 325 scoped_refptr<device::SerialIoHandler> GetIoHandler() { |
326 if (!io_handler_) | 326 if (!io_handler_.get()) |
327 io_handler_ = new TestIoHandlerBase; | 327 io_handler_ = new TestIoHandlerBase; |
328 return io_handler_; | 328 return io_handler_; |
329 } | 329 } |
330 | 330 |
331 void CreateSerialService( | 331 void CreateSerialService( |
332 mojo::InterfaceRequest<device::serial::SerialService> request) { | 332 mojo::InterfaceRequest<device::serial::SerialService> request) { |
333 mojo::BindToRequest(new device::SerialServiceImpl( | 333 mojo::BindToRequest(new device::SerialServiceImpl( |
334 new device::SerialConnectionFactory( | 334 new device::SerialConnectionFactory( |
335 base::Bind(&SerialApiTest::GetIoHandler, | 335 base::Bind(&SerialApiTest::GetIoHandler, |
336 base::Unretained(this)), | 336 base::Unretained(this)), |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 438 |
439 TEST_F(SerialApiTest, FlushUnknownConnectionId) { | 439 TEST_F(SerialApiTest, FlushUnknownConnectionId) { |
440 RunTest("serial_unittest.js", "testFlushUnknownConnectionId"); | 440 RunTest("serial_unittest.js", "testFlushUnknownConnectionId"); |
441 } | 441 } |
442 | 442 |
443 TEST_F(SerialApiTest, SetPausedUnknownConnectionId) { | 443 TEST_F(SerialApiTest, SetPausedUnknownConnectionId) { |
444 RunTest("serial_unittest.js", "testSetPausedUnknownConnectionId"); | 444 RunTest("serial_unittest.js", "testSetPausedUnknownConnectionId"); |
445 } | 445 } |
446 | 446 |
447 } // namespace extensions | 447 } // namespace extensions |
OLD | NEW |