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 "base/thread_task_runner_handle.h" | 5 #include "base/thread_task_runner_handle.h" |
6 #include "device/serial/serial_device_enumerator.h" | 6 #include "device/serial/serial_device_enumerator.h" |
7 #include "device/serial/serial_service_impl.h" | 7 #include "device/serial/serial_service_impl.h" |
8 #include "device/serial/test_serial_io_handler.h" | 8 #include "device/serial/test_serial_io_handler.h" |
9 #include "extensions/browser/mojo/stash_backend.h" | 9 #include "extensions/browser/mojo/stash_backend.h" |
10 #include "extensions/common/mojo/keep_alive.mojom.h" | 10 #include "extensions/common/mojo/keep_alive.mojom.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 | 429 |
430 private: | 430 private: |
431 scoped_refptr<device::SerialIoHandler> GetIoHandler() { | 431 scoped_refptr<device::SerialIoHandler> GetIoHandler() { |
432 if (!io_handler_.get()) | 432 if (!io_handler_.get()) |
433 io_handler_ = new TestIoHandlerBase; | 433 io_handler_ = new TestIoHandlerBase; |
434 return io_handler_; | 434 return io_handler_; |
435 } | 435 } |
436 | 436 |
437 void CreateSerialService( | 437 void CreateSerialService( |
438 mojo::InterfaceRequest<device::serial::SerialService> request) { | 438 mojo::InterfaceRequest<device::serial::SerialService> request) { |
439 mojo::BindToRequest(new device::SerialServiceImpl( | 439 new device::SerialServiceImpl( |
440 new device::SerialConnectionFactory( | 440 new device::SerialConnectionFactory( |
441 base::Bind(&SerialApiTest::GetIoHandler, | 441 base::Bind(&SerialApiTest::GetIoHandler, base::Unretained(this)), |
442 base::Unretained(this)), | 442 base::ThreadTaskRunnerHandle::Get()), |
443 base::ThreadTaskRunnerHandle::Get()), | 443 scoped_ptr<device::SerialDeviceEnumerator>( |
444 scoped_ptr<device::SerialDeviceEnumerator>( | 444 new FakeSerialDeviceEnumerator), |
445 new FakeSerialDeviceEnumerator)), | 445 request.Pass()); |
446 &request); | |
447 } | 446 } |
448 | 447 |
449 DISALLOW_COPY_AND_ASSIGN(SerialApiTest); | 448 DISALLOW_COPY_AND_ASSIGN(SerialApiTest); |
450 }; | 449 }; |
451 | 450 |
452 TEST_F(SerialApiTest, GetDevices) { | 451 TEST_F(SerialApiTest, GetDevices) { |
453 RunTest("serial_unittest.js", "testGetDevices"); | 452 RunTest("serial_unittest.js", "testGetDevices"); |
454 } | 453 } |
455 | 454 |
456 TEST_F(SerialApiTest, ConnectFail) { | 455 TEST_F(SerialApiTest, ConnectFail) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 RunTest("serial_unittest.js", "testStashNoConnections")); | 678 RunTest("serial_unittest.js", "testStashNoConnections")); |
680 env()->context()->DispatchOnUnloadEvent(); | 679 env()->context()->DispatchOnUnloadEvent(); |
681 io_handler_ = nullptr; | 680 io_handler_ = nullptr; |
682 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); | 681 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); |
683 ApiTestEnvironment new_api_test_env(new_env.get()); | 682 ApiTestEnvironment new_api_test_env(new_env.get()); |
684 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); | 683 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); |
685 new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections"); | 684 new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections"); |
686 } | 685 } |
687 | 686 |
688 } // namespace extensions | 687 } // namespace extensions |
OLD | NEW |