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 <string> | 5 #include <string> |
6 | 6 |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "device/serial/test_serial_io_handler.h" | 8 #include "device/serial/test_serial_io_handler.h" |
9 #include "extensions/browser/api/serial/serial_api.h" | 9 #include "extensions/browser/api/serial/serial_api.h" |
10 #include "extensions/browser/api/serial/serial_connection.h" | 10 #include "extensions/browser/api/serial/serial_connection.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 public: | 22 public: |
23 SerialApiTest() {} | 23 SerialApiTest() {} |
24 }; | 24 }; |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 namespace extensions { | 28 namespace extensions { |
29 | 29 |
30 class FakeSerialGetDevicesFunction : public AsyncExtensionFunction { | 30 class FakeSerialGetDevicesFunction : public AsyncExtensionFunction { |
31 public: | 31 public: |
32 virtual bool RunAsync() OVERRIDE { | 32 virtual bool RunAsync() override { |
33 base::ListValue* devices = new base::ListValue(); | 33 base::ListValue* devices = new base::ListValue(); |
34 base::DictionaryValue* device0 = new base::DictionaryValue(); | 34 base::DictionaryValue* device0 = new base::DictionaryValue(); |
35 device0->SetString("path", "/dev/fakeserial"); | 35 device0->SetString("path", "/dev/fakeserial"); |
36 base::DictionaryValue* device1 = new base::DictionaryValue(); | 36 base::DictionaryValue* device1 = new base::DictionaryValue(); |
37 device1->SetString("path", "\\\\COM800\\"); | 37 device1->SetString("path", "\\\\COM800\\"); |
38 devices->Append(device0); | 38 devices->Append(device0); |
39 devices->Append(device1); | 39 devices->Append(device1); |
40 SetResult(devices); | 40 SetResult(devices); |
41 SendResponse(true); | 41 SendResponse(true); |
42 return true; | 42 return true; |
(...skipping 19 matching lines...) Expand all Loading... |
62 virtual ~FakeEchoSerialIoHandler() {} | 62 virtual ~FakeEchoSerialIoHandler() {} |
63 | 63 |
64 private: | 64 private: |
65 DISALLOW_COPY_AND_ASSIGN(FakeEchoSerialIoHandler); | 65 DISALLOW_COPY_AND_ASSIGN(FakeEchoSerialIoHandler); |
66 }; | 66 }; |
67 | 67 |
68 class FakeSerialConnectFunction : public core_api::SerialConnectFunction { | 68 class FakeSerialConnectFunction : public core_api::SerialConnectFunction { |
69 protected: | 69 protected: |
70 virtual SerialConnection* CreateSerialConnection( | 70 virtual SerialConnection* CreateSerialConnection( |
71 const std::string& port, | 71 const std::string& port, |
72 const std::string& owner_extension_id) const OVERRIDE { | 72 const std::string& owner_extension_id) const override { |
73 scoped_refptr<FakeEchoSerialIoHandler> io_handler = | 73 scoped_refptr<FakeEchoSerialIoHandler> io_handler = |
74 new FakeEchoSerialIoHandler; | 74 new FakeEchoSerialIoHandler; |
75 EXPECT_CALL(*io_handler.get(), SetControlSignals(_)).Times(1).WillOnce( | 75 EXPECT_CALL(*io_handler.get(), SetControlSignals(_)).Times(1).WillOnce( |
76 Return(true)); | 76 Return(true)); |
77 SerialConnection* serial_connection = | 77 SerialConnection* serial_connection = |
78 new SerialConnection(port, owner_extension_id); | 78 new SerialConnection(port, owner_extension_id); |
79 serial_connection->SetIoHandlerForTest(io_handler); | 79 serial_connection->SetIoHandlerForTest(io_handler); |
80 return serial_connection; | 80 return serial_connection; |
81 } | 81 } |
82 | 82 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 | 127 |
128 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; | 128 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; |
129 } | 129 } |
130 | 130 |
131 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { | 131 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { |
132 extensions::ResultCatcher catcher; | 132 extensions::ResultCatcher catcher; |
133 catcher.RestrictToBrowserContext(browser()->profile()); | 133 catcher.RestrictToBrowserContext(browser()->profile()); |
134 | 134 |
135 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; | 135 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; |
136 } | 136 } |
OLD | NEW |