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 "device/serial/serial_device_enumerator.h" | 6 #include "device/serial/serial_device_enumerator.h" |
6 #include "device/serial/serial_service_impl.h" | 7 #include "device/serial/serial_service_impl.h" |
7 #include "device/serial/test_serial_io_handler.h" | 8 #include "device/serial/test_serial_io_handler.h" |
8 #include "extensions/browser/mojo/stash_backend.h" | 9 #include "extensions/browser/mojo/stash_backend.h" |
9 #include "extensions/common/mojo/keep_alive.mojom.h" | 10 #include "extensions/common/mojo/keep_alive.mojom.h" |
10 #include "extensions/renderer/api_test_base.h" | 11 #include "extensions/renderer/api_test_base.h" |
11 #include "grit/extensions_renderer_resources.h" | 12 #include "grit/extensions_renderer_resources.h" |
12 | 13 |
13 // A test launcher for tests for the serial API defined in | 14 // A test launcher for tests for the serial API defined in |
14 // extensions/test/data/serial_unittest.js. Each C++ test function sets up a | 15 // extensions/test/data/serial_unittest.js. Each C++ test function sets up a |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 io_handler_ = new TestIoHandlerBase; | 433 io_handler_ = new TestIoHandlerBase; |
433 return io_handler_; | 434 return io_handler_; |
434 } | 435 } |
435 | 436 |
436 void CreateSerialService( | 437 void CreateSerialService( |
437 mojo::InterfaceRequest<device::serial::SerialService> request) { | 438 mojo::InterfaceRequest<device::serial::SerialService> request) { |
438 mojo::BindToRequest(new device::SerialServiceImpl( | 439 mojo::BindToRequest(new device::SerialServiceImpl( |
439 new device::SerialConnectionFactory( | 440 new device::SerialConnectionFactory( |
440 base::Bind(&SerialApiTest::GetIoHandler, | 441 base::Bind(&SerialApiTest::GetIoHandler, |
441 base::Unretained(this)), | 442 base::Unretained(this)), |
442 base::MessageLoopProxy::current()), | 443 base::ThreadTaskRunnerHandle::Get()), |
443 scoped_ptr<device::SerialDeviceEnumerator>( | 444 scoped_ptr<device::SerialDeviceEnumerator>( |
444 new FakeSerialDeviceEnumerator)), | 445 new FakeSerialDeviceEnumerator)), |
445 &request); | 446 &request); |
446 } | 447 } |
447 | 448 |
448 DISALLOW_COPY_AND_ASSIGN(SerialApiTest); | 449 DISALLOW_COPY_AND_ASSIGN(SerialApiTest); |
449 }; | 450 }; |
450 | 451 |
451 TEST_F(SerialApiTest, GetDevices) { | 452 TEST_F(SerialApiTest, GetDevices) { |
452 RunTest("serial_unittest.js", "testGetDevices"); | 453 RunTest("serial_unittest.js", "testGetDevices"); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 RunTest("serial_unittest.js", "testStashNoConnections")); | 679 RunTest("serial_unittest.js", "testStashNoConnections")); |
679 env()->context()->DispatchOnUnloadEvent(); | 680 env()->context()->DispatchOnUnloadEvent(); |
680 io_handler_ = nullptr; | 681 io_handler_ = nullptr; |
681 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); | 682 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); |
682 ApiTestEnvironment new_api_test_env(new_env.get()); | 683 ApiTestEnvironment new_api_test_env(new_env.get()); |
683 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); | 684 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); |
684 new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections"); | 685 new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections"); |
685 } | 686 } |
686 | 687 |
687 } // namespace extensions | 688 } // namespace extensions |
OLD | NEW |