Chromium Code Reviews| Index: extensions/renderer/api/serial/serial_api_unittest.cc |
| diff --git a/extensions/renderer/api/serial/serial_api_unittest.cc b/extensions/renderer/api/serial/serial_api_unittest.cc |
| index 36cbe456cc01be0dd174615d1596dbfb1f944b3d..642ef2c0ecdfe5d5000357ad87279f308a4603b4 100644 |
| --- a/extensions/renderer/api/serial/serial_api_unittest.cc |
| +++ b/extensions/renderer/api/serial/serial_api_unittest.cc |
| @@ -176,78 +176,83 @@ class GetControlSignalsTestIoHandler : public TestIoHandlerBase { |
| class ConfigurePortTestIoHandler : public TestIoHandlerBase { |
| public: |
| ConfigurePortTestIoHandler() {} |
| - bool ConfigurePort( |
| - const device::serial::ConnectionOptions& options) override { |
| + bool ConfigurePortImpl() override { |
| static const device::serial::ConnectionOptions expected_options[] = { |
| GenerateConnectionOptions(9600, |
| device::serial::DATA_BITS_EIGHT, |
| device::serial::PARITY_BIT_NO, |
| device::serial::STOP_BITS_ONE, |
| OPTIONAL_VALUE_FALSE), |
| - GenerateConnectionOptions(57600, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_NONE, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_SEVEN, |
| - device::serial::PARITY_BIT_NONE, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| + GenerateConnectionOptions(57600, // set |
|
Ken Rockot(use gerrit already)
2015/01/28 21:25:34
nit: two spaces before //
|
| device::serial::DATA_BITS_EIGHT, |
| - device::serial::PARITY_BIT_NONE, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| device::serial::PARITY_BIT_NO, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_ODD, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_EVEN, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_NONE, |
| device::serial::STOP_BITS_ONE, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_NONE, |
| - device::serial::STOP_BITS_TWO, |
| - OPTIONAL_VALUE_UNSET), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_NONE, |
| - device::serial::STOP_BITS_NONE, |
| OPTIONAL_VALUE_FALSE), |
| - GenerateConnectionOptions(0, |
| - device::serial::DATA_BITS_NONE, |
| - device::serial::PARITY_BIT_NONE, |
| - device::serial::STOP_BITS_NONE, |
| - OPTIONAL_VALUE_TRUE), |
| + GenerateConnectionOptions(57600, |
| + 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
|
| + device::serial::PARITY_BIT_NO, |
| + device::serial::STOP_BITS_ONE, |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, // set |
| + device::serial::PARITY_BIT_NO, |
| + device::serial::STOP_BITS_ONE, |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_NO, // set |
| + device::serial::STOP_BITS_ONE, |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_ODD, // set |
| + device::serial::STOP_BITS_ONE, |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_EVEN, // set |
| + device::serial::STOP_BITS_ONE, |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_EVEN, |
| + device::serial::STOP_BITS_ONE, // set |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_EVEN, |
| + device::serial::STOP_BITS_TWO, // set |
| + OPTIONAL_VALUE_FALSE), |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_EVEN, |
| + device::serial::STOP_BITS_TWO, |
| + OPTIONAL_VALUE_FALSE), // set |
| + GenerateConnectionOptions(57600, |
| + device::serial::DATA_BITS_EIGHT, |
| + device::serial::PARITY_BIT_EVEN, |
| + device::serial::STOP_BITS_TWO, |
| + OPTIONAL_VALUE_TRUE), // set |
| }; |
| - if (num_calls() >= arraysize(expected_options)) |
| + |
| + if (!TestIoHandlerBase::ConfigurePortImpl()) { |
| return false; |
| + } |
| - EXPECT_EQ(expected_options[num_calls()].bitrate, options.bitrate); |
| - EXPECT_EQ(expected_options[num_calls()].data_bits, options.data_bits); |
| - EXPECT_EQ(expected_options[num_calls()].parity_bit, options.parity_bit); |
| - EXPECT_EQ(expected_options[num_calls()].stop_bits, options.stop_bits); |
| + if (num_calls() >= arraysize(expected_options)) { |
| + return false; |
| + } |
| + |
| + EXPECT_EQ(expected_options[num_calls()].bitrate, options().bitrate); |
| + EXPECT_EQ(expected_options[num_calls()].data_bits, options().data_bits); |
| + EXPECT_EQ(expected_options[num_calls()].parity_bit, options().parity_bit); |
| + EXPECT_EQ(expected_options[num_calls()].stop_bits, options().stop_bits); |
| EXPECT_EQ(expected_options[num_calls()].has_cts_flow_control, |
| - options.has_cts_flow_control); |
| + options().has_cts_flow_control); |
| EXPECT_EQ(expected_options[num_calls()].cts_flow_control, |
| - options.cts_flow_control); |
| + options().cts_flow_control); |
| record_call(); |
| - return TestSerialIoHandler::ConfigurePort(options); |
| + return true; |
| } |
| private: |
| @@ -275,6 +280,7 @@ class FailToConnectTestIoHandler : public TestIoHandlerBase { |
| public: |
| FailToConnectTestIoHandler() {} |
| void Open(const std::string& port, |
| + const device::serial::ConnectionOptions& options, |
| const OpenCompleteCallback& callback) override { |
| callback.Run(false); |
| return; |