| 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 <memory> |
| 5 #include <string> | 6 #include <string> |
| 6 #include <utility> | 7 #include <utility> |
| 7 | 8 |
| 8 #include "base/macros.h" | 9 #include "base/macros.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 11 #include "device/serial/serial_device_enumerator.h" | 12 #include "device/serial/serial_device_enumerator.h" |
| 12 #include "device/serial/serial_service_impl.h" | 13 #include "device/serial/serial_service_impl.h" |
| 13 #include "device/serial/test_serial_io_handler.h" | 14 #include "device/serial/test_serial_io_handler.h" |
| 14 #include "extensions/browser/api/serial/serial_api.h" | 15 #include "extensions/browser/api/serial/serial_api.h" |
| 15 #include "extensions/browser/api/serial/serial_connection.h" | 16 #include "extensions/browser/api/serial/serial_connection.h" |
| 16 #include "extensions/browser/api/serial/serial_service_factory.h" | 17 #include "extensions/browser/api/serial/serial_service_factory.h" |
| 17 #include "extensions/browser/extension_function.h" | 18 #include "extensions/browser/extension_function.h" |
| 18 #include "extensions/common/api/serial.h" | 19 #include "extensions/common/api/serial.h" |
| 19 #include "extensions/common/switches.h" | 20 #include "extensions/common/switches.h" |
| 20 #include "extensions/test/result_catcher.h" | 21 #include "extensions/test/result_catcher.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
| 22 | 23 |
| 23 using testing::_; | 24 using testing::_; |
| 24 using testing::Return; | 25 using testing::Return; |
| 25 | 26 |
| 26 namespace extensions { | 27 namespace extensions { |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 class FakeSerialGetDevicesFunction : public AsyncExtensionFunction { | 30 class FakeSerialGetDevicesFunction : public AsyncExtensionFunction { |
| 30 public: | 31 public: |
| 31 bool RunAsync() override { | 32 bool RunAsync() override { |
| 32 base::ListValue* devices = new base::ListValue(); | 33 std::unique_ptr<base::ListValue> devices(new base::ListValue()); |
| 33 base::DictionaryValue* device0 = new base::DictionaryValue(); | 34 base::DictionaryValue* device0 = new base::DictionaryValue(); |
| 34 device0->SetString("path", "/dev/fakeserial"); | 35 device0->SetString("path", "/dev/fakeserial"); |
| 35 base::DictionaryValue* device1 = new base::DictionaryValue(); | 36 base::DictionaryValue* device1 = new base::DictionaryValue(); |
| 36 device1->SetString("path", "\\\\COM800\\"); | 37 device1->SetString("path", "\\\\COM800\\"); |
| 37 devices->Append(device0); | 38 devices->Append(device0); |
| 38 devices->Append(device1); | 39 devices->Append(device1); |
| 39 SetResult(devices); | 40 SetResult(std::move(devices)); |
| 40 SendResponse(true); | 41 SendResponse(true); |
| 41 return true; | 42 return true; |
| 42 } | 43 } |
| 43 | 44 |
| 44 protected: | 45 protected: |
| 45 ~FakeSerialGetDevicesFunction() override {} | 46 ~FakeSerialGetDevicesFunction() override {} |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 class FakeSerialDeviceEnumerator : public device::SerialDeviceEnumerator { | 49 class FakeSerialDeviceEnumerator : public device::SerialDeviceEnumerator { |
| 49 public: | 50 public: |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 IN_PROC_BROWSER_TEST_P(SerialApiTest, SerialRealHardware) { | 197 IN_PROC_BROWSER_TEST_P(SerialApiTest, SerialRealHardware) { |
| 197 ResultCatcher catcher; | 198 ResultCatcher catcher; |
| 198 catcher.RestrictToBrowserContext(browser()->profile()); | 199 catcher.RestrictToBrowserContext(browser()->profile()); |
| 199 | 200 |
| 200 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; | 201 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; |
| 201 } | 202 } |
| 202 | 203 |
| 203 INSTANTIATE_TEST_CASE_P(SerialApiTest, SerialApiTest, testing::Bool()); | 204 INSTANTIATE_TEST_CASE_P(SerialApiTest, SerialApiTest, testing::Bool()); |
| 204 | 205 |
| 205 } // namespace extensions | 206 } // namespace extensions |
| OLD | NEW |