Chromium Code Reviews| 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 "device/serial/serial_device_enumerator.h" | 5 #include "device/serial/serial_device_enumerator.h" |
| 6 #include "device/serial/serial_service_impl.h" | 6 #include "device/serial/serial_service_impl.h" |
| 7 #include "device/serial/test_serial_io_handler.h" | 7 #include "device/serial/test_serial_io_handler.h" |
| 8 #include "extensions/common/mojo/keep_alive.mojom.h" | 8 #include "extensions/common/mojo/keep_alive.mojom.h" |
| 9 #include "extensions/renderer/api_test_base.h" | 9 #include "extensions/renderer/api_test_base.h" |
| 10 #include "grit/extensions_renderer_resources.h" | 10 #include "grit/extensions_renderer_resources.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 ~GetControlSignalsTestIoHandler() override {} | 171 ~GetControlSignalsTestIoHandler() override {} |
| 172 | 172 |
| 173 DISALLOW_COPY_AND_ASSIGN(GetControlSignalsTestIoHandler); | 173 DISALLOW_COPY_AND_ASSIGN(GetControlSignalsTestIoHandler); |
| 174 }; | 174 }; |
| 175 | 175 |
| 176 class ConfigurePortTestIoHandler : public TestIoHandlerBase { | 176 class ConfigurePortTestIoHandler : public TestIoHandlerBase { |
| 177 public: | 177 public: |
| 178 ConfigurePortTestIoHandler() {} | 178 ConfigurePortTestIoHandler() {} |
| 179 bool ConfigurePort( | 179 bool ConfigurePortImpl() override { |
| 180 const device::serial::ConnectionOptions& options) override { | |
| 181 static const device::serial::ConnectionOptions expected_options[] = { | 180 static const device::serial::ConnectionOptions expected_options[] = { |
| 182 GenerateConnectionOptions(9600, | 181 GenerateConnectionOptions(9600, |
| 183 device::serial::DATA_BITS_EIGHT, | 182 device::serial::DATA_BITS_EIGHT, |
| 184 device::serial::PARITY_BIT_NO, | 183 device::serial::PARITY_BIT_NO, |
| 185 device::serial::STOP_BITS_ONE, | 184 device::serial::STOP_BITS_ONE, |
| 186 OPTIONAL_VALUE_FALSE), | 185 OPTIONAL_VALUE_FALSE), |
| 186 GenerateConnectionOptions(57600, // set | |
|
Ken Rockot(use gerrit already)
2015/01/28 21:25:34
nit: two spaces before //
| |
| 187 device::serial::DATA_BITS_EIGHT, | |
| 188 device::serial::PARITY_BIT_NO, | |
| 189 device::serial::STOP_BITS_ONE, | |
| 190 OPTIONAL_VALUE_FALSE), | |
| 187 GenerateConnectionOptions(57600, | 191 GenerateConnectionOptions(57600, |
| 188 device::serial::DATA_BITS_NONE, | 192 device::serial::DATA_BITS_SEVEN, // set |
|
Ken Rockot(use gerrit already)
2015/01/28 19:22:10
what is all this " // set" notation
Reilly Grant (use Gerrit)
2015/01/28 21:00:09
In the original test because the unmodified option
| |
| 189 device::serial::PARITY_BIT_NONE, | 193 device::serial::PARITY_BIT_NO, |
| 190 device::serial::STOP_BITS_NONE, | 194 device::serial::STOP_BITS_ONE, |
| 191 OPTIONAL_VALUE_UNSET), | 195 OPTIONAL_VALUE_FALSE), |
| 192 GenerateConnectionOptions(0, | 196 GenerateConnectionOptions(57600, |
| 193 device::serial::DATA_BITS_SEVEN, | 197 device::serial::DATA_BITS_EIGHT, // set |
| 194 device::serial::PARITY_BIT_NONE, | 198 device::serial::PARITY_BIT_NO, |
| 195 device::serial::STOP_BITS_NONE, | 199 device::serial::STOP_BITS_ONE, |
| 196 OPTIONAL_VALUE_UNSET), | 200 OPTIONAL_VALUE_FALSE), |
| 197 GenerateConnectionOptions(0, | 201 GenerateConnectionOptions(57600, |
| 198 device::serial::DATA_BITS_EIGHT, | 202 device::serial::DATA_BITS_EIGHT, |
| 199 device::serial::PARITY_BIT_NONE, | 203 device::serial::PARITY_BIT_NO, // set |
| 200 device::serial::STOP_BITS_NONE, | 204 device::serial::STOP_BITS_ONE, |
| 201 OPTIONAL_VALUE_UNSET), | 205 OPTIONAL_VALUE_FALSE), |
| 202 GenerateConnectionOptions(0, | 206 GenerateConnectionOptions(57600, |
| 203 device::serial::DATA_BITS_NONE, | 207 device::serial::DATA_BITS_EIGHT, |
| 204 device::serial::PARITY_BIT_NO, | 208 device::serial::PARITY_BIT_ODD, // set |
| 205 device::serial::STOP_BITS_NONE, | 209 device::serial::STOP_BITS_ONE, |
| 206 OPTIONAL_VALUE_UNSET), | 210 OPTIONAL_VALUE_FALSE), |
| 207 GenerateConnectionOptions(0, | 211 GenerateConnectionOptions(57600, |
| 208 device::serial::DATA_BITS_NONE, | 212 device::serial::DATA_BITS_EIGHT, |
| 209 device::serial::PARITY_BIT_ODD, | 213 device::serial::PARITY_BIT_EVEN, // set |
| 210 device::serial::STOP_BITS_NONE, | 214 device::serial::STOP_BITS_ONE, |
| 211 OPTIONAL_VALUE_UNSET), | 215 OPTIONAL_VALUE_FALSE), |
| 212 GenerateConnectionOptions(0, | 216 GenerateConnectionOptions(57600, |
| 213 device::serial::DATA_BITS_NONE, | 217 device::serial::DATA_BITS_EIGHT, |
| 214 device::serial::PARITY_BIT_EVEN, | 218 device::serial::PARITY_BIT_EVEN, |
| 215 device::serial::STOP_BITS_NONE, | 219 device::serial::STOP_BITS_ONE, // set |
| 216 OPTIONAL_VALUE_UNSET), | 220 OPTIONAL_VALUE_FALSE), |
| 217 GenerateConnectionOptions(0, | 221 GenerateConnectionOptions(57600, |
| 218 device::serial::DATA_BITS_NONE, | 222 device::serial::DATA_BITS_EIGHT, |
| 219 device::serial::PARITY_BIT_NONE, | 223 device::serial::PARITY_BIT_EVEN, |
| 220 device::serial::STOP_BITS_ONE, | 224 device::serial::STOP_BITS_TWO, // set |
| 221 OPTIONAL_VALUE_UNSET), | 225 OPTIONAL_VALUE_FALSE), |
| 222 GenerateConnectionOptions(0, | 226 GenerateConnectionOptions(57600, |
| 223 device::serial::DATA_BITS_NONE, | 227 device::serial::DATA_BITS_EIGHT, |
| 224 device::serial::PARITY_BIT_NONE, | 228 device::serial::PARITY_BIT_EVEN, |
| 225 device::serial::STOP_BITS_TWO, | 229 device::serial::STOP_BITS_TWO, |
| 226 OPTIONAL_VALUE_UNSET), | 230 OPTIONAL_VALUE_FALSE), // set |
| 227 GenerateConnectionOptions(0, | 231 GenerateConnectionOptions(57600, |
| 228 device::serial::DATA_BITS_NONE, | 232 device::serial::DATA_BITS_EIGHT, |
| 229 device::serial::PARITY_BIT_NONE, | 233 device::serial::PARITY_BIT_EVEN, |
| 230 device::serial::STOP_BITS_NONE, | 234 device::serial::STOP_BITS_TWO, |
| 231 OPTIONAL_VALUE_FALSE), | 235 OPTIONAL_VALUE_TRUE), // set |
| 232 GenerateConnectionOptions(0, | |
| 233 device::serial::DATA_BITS_NONE, | |
| 234 device::serial::PARITY_BIT_NONE, | |
| 235 device::serial::STOP_BITS_NONE, | |
| 236 OPTIONAL_VALUE_TRUE), | |
| 237 }; | 236 }; |
| 238 if (num_calls() >= arraysize(expected_options)) | 237 |
| 238 if (!TestIoHandlerBase::ConfigurePortImpl()) { | |
| 239 return false; | 239 return false; |
| 240 } | |
| 240 | 241 |
| 241 EXPECT_EQ(expected_options[num_calls()].bitrate, options.bitrate); | 242 if (num_calls() >= arraysize(expected_options)) { |
| 242 EXPECT_EQ(expected_options[num_calls()].data_bits, options.data_bits); | 243 return false; |
| 243 EXPECT_EQ(expected_options[num_calls()].parity_bit, options.parity_bit); | 244 } |
| 244 EXPECT_EQ(expected_options[num_calls()].stop_bits, options.stop_bits); | 245 |
| 246 EXPECT_EQ(expected_options[num_calls()].bitrate, options().bitrate); | |
| 247 EXPECT_EQ(expected_options[num_calls()].data_bits, options().data_bits); | |
| 248 EXPECT_EQ(expected_options[num_calls()].parity_bit, options().parity_bit); | |
| 249 EXPECT_EQ(expected_options[num_calls()].stop_bits, options().stop_bits); | |
| 245 EXPECT_EQ(expected_options[num_calls()].has_cts_flow_control, | 250 EXPECT_EQ(expected_options[num_calls()].has_cts_flow_control, |
| 246 options.has_cts_flow_control); | 251 options().has_cts_flow_control); |
| 247 EXPECT_EQ(expected_options[num_calls()].cts_flow_control, | 252 EXPECT_EQ(expected_options[num_calls()].cts_flow_control, |
| 248 options.cts_flow_control); | 253 options().cts_flow_control); |
| 249 record_call(); | 254 record_call(); |
| 250 return TestSerialIoHandler::ConfigurePort(options); | 255 return true; |
| 251 } | 256 } |
| 252 | 257 |
| 253 private: | 258 private: |
| 254 ~ConfigurePortTestIoHandler() override {} | 259 ~ConfigurePortTestIoHandler() override {} |
| 255 | 260 |
| 256 DISALLOW_COPY_AND_ASSIGN(ConfigurePortTestIoHandler); | 261 DISALLOW_COPY_AND_ASSIGN(ConfigurePortTestIoHandler); |
| 257 }; | 262 }; |
| 258 | 263 |
| 259 class FlushTestIoHandler : public TestIoHandlerBase { | 264 class FlushTestIoHandler : public TestIoHandlerBase { |
| 260 public: | 265 public: |
| 261 FlushTestIoHandler() {} | 266 FlushTestIoHandler() {} |
| 262 | 267 |
| 263 bool Flush() const override { | 268 bool Flush() const override { |
| 264 record_call(); | 269 record_call(); |
| 265 return true; | 270 return true; |
| 266 } | 271 } |
| 267 | 272 |
| 268 private: | 273 private: |
| 269 ~FlushTestIoHandler() override {} | 274 ~FlushTestIoHandler() override {} |
| 270 | 275 |
| 271 DISALLOW_COPY_AND_ASSIGN(FlushTestIoHandler); | 276 DISALLOW_COPY_AND_ASSIGN(FlushTestIoHandler); |
| 272 }; | 277 }; |
| 273 | 278 |
| 274 class FailToConnectTestIoHandler : public TestIoHandlerBase { | 279 class FailToConnectTestIoHandler : public TestIoHandlerBase { |
| 275 public: | 280 public: |
| 276 FailToConnectTestIoHandler() {} | 281 FailToConnectTestIoHandler() {} |
| 277 void Open(const std::string& port, | 282 void Open(const std::string& port, |
| 283 const device::serial::ConnectionOptions& options, | |
| 278 const OpenCompleteCallback& callback) override { | 284 const OpenCompleteCallback& callback) override { |
| 279 callback.Run(false); | 285 callback.Run(false); |
| 280 return; | 286 return; |
| 281 } | 287 } |
| 282 | 288 |
| 283 private: | 289 private: |
| 284 ~FailToConnectTestIoHandler() override {} | 290 ~FailToConnectTestIoHandler() override {} |
| 285 | 291 |
| 286 DISALLOW_COPY_AND_ASSIGN(FailToConnectTestIoHandler); | 292 DISALLOW_COPY_AND_ASSIGN(FailToConnectTestIoHandler); |
| 287 }; | 293 }; |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 | 631 |
| 626 TEST_F(SerialApiTest, SetPausedUnknownConnectionId) { | 632 TEST_F(SerialApiTest, SetPausedUnknownConnectionId) { |
| 627 RunTest("serial_unittest.js", "testSetPausedUnknownConnectionId"); | 633 RunTest("serial_unittest.js", "testSetPausedUnknownConnectionId"); |
| 628 } | 634 } |
| 629 | 635 |
| 630 TEST_F(SerialApiTest, SendUnknownConnectionId) { | 636 TEST_F(SerialApiTest, SendUnknownConnectionId) { |
| 631 RunTest("serial_unittest.js", "testSendUnknownConnectionId"); | 637 RunTest("serial_unittest.js", "testSendUnknownConnectionId"); |
| 632 } | 638 } |
| 633 | 639 |
| 634 } // namespace extensions | 640 } // namespace extensions |
| OLD | NEW |