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" |
11 #include "extensions/browser/extension_function.h" | 11 #include "extensions/browser/extension_function.h" |
12 #include "extensions/common/api/serial.h" | 12 #include "extensions/common/api/serial.h" |
| 13 #include "extensions/test/result_catcher.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
14 | 15 |
15 using testing::_; | 16 using testing::_; |
16 using testing::Return; | 17 using testing::Return; |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 class SerialApiTest : public ExtensionApiTest { | 21 class SerialApiTest : public ExtensionApiTest { |
21 public: | 22 public: |
22 SerialApiTest() {} | 23 SerialApiTest() {} |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // mean that your user is in the "tty" or "uucp" group on Ubuntu flavors of | 108 // mean that your user is in the "tty" or "uucp" group on Ubuntu flavors of |
108 // Linux, or else that the port's path (e.g., /dev/ttyACM0) has global | 109 // Linux, or else that the port's path (e.g., /dev/ttyACM0) has global |
109 // read/write permissions. | 110 // read/write permissions. |
110 // | 111 // |
111 // 3. You have uploaded a program to the board that does a byte-for-byte echo | 112 // 3. You have uploaded a program to the board that does a byte-for-byte echo |
112 // on the virtual serial port at 57600 bps. An example is at | 113 // on the virtual serial port at 57600 bps. An example is at |
113 // chrome/test/data/extensions/api_test/serial/api/serial_arduino_test.ino. | 114 // chrome/test/data/extensions/api_test/serial/api/serial_arduino_test.ino. |
114 // | 115 // |
115 #define SIMULATE_SERIAL_PORTS (1) | 116 #define SIMULATE_SERIAL_PORTS (1) |
116 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialFakeHardware) { | 117 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialFakeHardware) { |
117 ResultCatcher catcher; | 118 extensions::ResultCatcher catcher; |
118 catcher.RestrictToProfile(browser()->profile()); | 119 catcher.RestrictToBrowserContext(browser()->profile()); |
119 | 120 |
120 #if SIMULATE_SERIAL_PORTS | 121 #if SIMULATE_SERIAL_PORTS |
121 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( | 122 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( |
122 "serial.getDevices", FakeSerialGetDevicesFunctionFactory)); | 123 "serial.getDevices", FakeSerialGetDevicesFunctionFactory)); |
123 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( | 124 ASSERT_TRUE(extensions::ExtensionFunctionDispatcher::OverrideFunction( |
124 "serial.connect", FakeSerialConnectFunctionFactory)); | 125 "serial.connect", FakeSerialConnectFunctionFactory)); |
125 #endif | 126 #endif |
126 | 127 |
127 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; | 128 ASSERT_TRUE(RunExtensionTest("serial/api")) << message_; |
128 } | 129 } |
129 | 130 |
130 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { | 131 IN_PROC_BROWSER_TEST_F(SerialApiTest, SerialRealHardware) { |
131 ResultCatcher catcher; | 132 extensions::ResultCatcher catcher; |
132 catcher.RestrictToProfile(browser()->profile()); | 133 catcher.RestrictToBrowserContext(browser()->profile()); |
133 | 134 |
134 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; | 135 ASSERT_TRUE(RunExtensionTest("serial/real_hardware")) << message_; |
135 } | 136 } |
OLD | NEW |