Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2902)

Unified Diff: device/serial/serial_connection_unittest.cc

Issue 1527183003: Change mojo enums to be scoped enums in the generated C++ bindings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-binding-equals
Patch Set: rebase Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/serial/serial_connection_factory.cc ('k') | device/serial/serial_io_handler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/serial/serial_connection_unittest.cc
diff --git a/device/serial/serial_connection_unittest.cc b/device/serial/serial_connection_unittest.cc
index c3107555b047608d57ea3b0f54a1c44c0d205b39..3d5f51e9983e53e14e9ce884e904bcd20cfa6bac 100644
--- a/device/serial/serial_connection_unittest.cc
+++ b/device/serial/serial_connection_unittest.cc
@@ -61,8 +61,8 @@ class SerialConnectionTest : public testing::Test {
: connected_(false),
success_(false),
bytes_sent_(0),
- send_error_(serial::SEND_ERROR_NONE),
- receive_error_(serial::RECEIVE_ERROR_NONE),
+ send_error_(serial::SendError::NONE),
+ receive_error_(serial::ReceiveError::NONE),
expected_event_(EVENT_NONE) {}
void SetUp() override {
@@ -85,11 +85,12 @@ class SerialConnectionTest : public testing::Test {
service->Connect("device", serial::ConnectionOptions::New(),
mojo::GetProxy(&connection_), mojo::GetProxy(&sink),
mojo::GetProxy(&source), std::move(source_client));
- sender_.reset(new DataSender(std::move(sink), kBufferSize,
- serial::SEND_ERROR_DISCONNECTED));
- receiver_ =
- new DataReceiver(std::move(source), std::move(source_client_request),
- kBufferSize, serial::RECEIVE_ERROR_DISCONNECTED);
+ sender_.reset(
+ new DataSender(std::move(sink), kBufferSize,
+ static_cast<int32_t>(serial::SendError::DISCONNECTED)));
+ receiver_ = new DataReceiver(
+ std::move(source), std::move(source_client_request), kBufferSize,
+ static_cast<int32_t>(serial::ReceiveError::DISCONNECTED));
connection_.set_connection_error_handler(base::Bind(
&SerialConnectionTest::OnConnectionError, base::Unretained(this)));
connection_->GetInfo(
@@ -152,7 +153,7 @@ class SerialConnectionTest : public testing::Test {
void OnDataSent(uint32_t bytes_sent) {
bytes_sent_ += bytes_sent;
- send_error_ = serial::SEND_ERROR_NONE;
+ send_error_ = serial::SendError::NONE;
EventReceived(EVENT_DATA_SENT);
}
@@ -165,7 +166,7 @@ class SerialConnectionTest : public testing::Test {
void OnDataReceived(scoped_ptr<ReadOnlyBuffer> buffer) {
data_received_ += std::string(buffer->GetData(), buffer->GetSize());
buffer->Done(buffer->GetSize());
- receive_error_ = serial::RECEIVE_ERROR_NONE;
+ receive_error_ = serial::ReceiveError::NONE;
EventReceived(EVENT_DATA_RECEIVED);
}
@@ -207,16 +208,16 @@ TEST_F(SerialConnectionTest, GetInfo) {
// |info_| is filled in during SetUp().
ASSERT_TRUE(info_);
EXPECT_EQ(9600u, info_->bitrate);
- EXPECT_EQ(serial::DATA_BITS_EIGHT, info_->data_bits);
- EXPECT_EQ(serial::PARITY_BIT_NO, info_->parity_bit);
- EXPECT_EQ(serial::STOP_BITS_ONE, info_->stop_bits);
+ EXPECT_EQ(serial::DataBits::EIGHT, info_->data_bits);
+ EXPECT_EQ(serial::ParityBit::NO, info_->parity_bit);
+ EXPECT_EQ(serial::StopBits::ONE, info_->stop_bits);
EXPECT_FALSE(info_->cts_flow_control);
}
TEST_F(SerialConnectionTest, SetOptions) {
serial::ConnectionOptionsPtr options(serial::ConnectionOptions::New());
options->bitrate = 12345;
- options->data_bits = serial::DATA_BITS_SEVEN;
+ options->data_bits = serial::DataBits::SEVEN;
options->has_cts_flow_control = true;
options->cts_flow_control = true;
connection_->SetOptions(
@@ -227,9 +228,9 @@ TEST_F(SerialConnectionTest, SetOptions) {
ASSERT_TRUE(success_);
serial::ConnectionInfo* info = io_handler_->connection_info();
EXPECT_EQ(12345u, info->bitrate);
- EXPECT_EQ(serial::DATA_BITS_SEVEN, info->data_bits);
- EXPECT_EQ(serial::PARITY_BIT_NO, info->parity_bit);
- EXPECT_EQ(serial::STOP_BITS_ONE, info->stop_bits);
+ EXPECT_EQ(serial::DataBits::SEVEN, info->data_bits);
+ EXPECT_EQ(serial::ParityBit::NO, info->parity_bit);
+ EXPECT_EQ(serial::StopBits::ONE, info->stop_bits);
EXPECT_TRUE(info->cts_flow_control);
}
@@ -280,7 +281,7 @@ TEST_F(SerialConnectionTest, DisconnectWithSend) {
io_handler_->set_send_callback(base::Bind(base::DoNothing));
ASSERT_NO_FATAL_FAILURE(Send("data"));
WaitForEvent(EVENT_SEND_ERROR);
- EXPECT_EQ(serial::SEND_ERROR_DISCONNECTED, send_error_);
+ EXPECT_EQ(serial::SendError::DISCONNECTED, send_error_);
EXPECT_EQ(0, bytes_sent_);
EXPECT_TRUE(io_handler_->HasOneRef());
}
@@ -289,7 +290,7 @@ TEST_F(SerialConnectionTest, DisconnectWithReceive) {
connection_.reset();
ASSERT_NO_FATAL_FAILURE(Receive());
WaitForEvent(EVENT_RECEIVE_ERROR);
- EXPECT_EQ(serial::RECEIVE_ERROR_DISCONNECTED, receive_error_);
+ EXPECT_EQ(serial::ReceiveError::DISCONNECTED, receive_error_);
EXPECT_EQ("", data_received_);
EXPECT_TRUE(io_handler_->HasOneRef());
}
@@ -297,12 +298,12 @@ TEST_F(SerialConnectionTest, DisconnectWithReceive) {
TEST_F(SerialConnectionTest, Echo) {
ASSERT_NO_FATAL_FAILURE(Send("data"));
WaitForEvent(EVENT_DATA_SENT);
- EXPECT_EQ(serial::SEND_ERROR_NONE, send_error_);
+ EXPECT_EQ(serial::SendError::NONE, send_error_);
EXPECT_EQ(4, bytes_sent_);
ASSERT_NO_FATAL_FAILURE(Receive());
WaitForEvent(EVENT_DATA_RECEIVED);
EXPECT_EQ("data", data_received_);
- EXPECT_EQ(serial::RECEIVE_ERROR_NONE, receive_error_);
+ EXPECT_EQ(serial::ReceiveError::NONE, receive_error_);
}
TEST_F(SerialConnectionTest, Cancel) {
@@ -317,22 +318,22 @@ TEST_F(SerialConnectionTest, Cancel) {
WaitForEvent(EVENT_DATA_AT_IO_HANDLER);
EXPECT_EQ(0, bytes_sent_);
- ASSERT_TRUE(sender_->Cancel(serial::SEND_ERROR_TIMEOUT,
- base::Bind(&SerialConnectionTest::EventReceived,
- base::Unretained(this),
- EVENT_CANCEL_COMPLETE)));
+ ASSERT_TRUE(sender_->Cancel(
+ static_cast<int32_t>(serial::SendError::TIMEOUT),
+ base::Bind(&SerialConnectionTest::EventReceived, base::Unretained(this),
+ EVENT_CANCEL_COMPLETE)));
WaitForEvent(EVENT_CANCEL_COMPLETE);
- EXPECT_EQ(serial::SEND_ERROR_TIMEOUT, send_error_);
+ EXPECT_EQ(serial::SendError::TIMEOUT, send_error_);
ASSERT_NO_FATAL_FAILURE(Send("data"));
WaitForEvent(EVENT_DATA_SENT);
- EXPECT_EQ(serial::SEND_ERROR_NONE, send_error_);
+ EXPECT_EQ(serial::SendError::NONE, send_error_);
EXPECT_EQ(4, bytes_sent_);
ASSERT_NO_FATAL_FAILURE(Receive());
WaitForEvent(EVENT_DATA_RECEIVED);
EXPECT_EQ("data", data_received_);
- EXPECT_EQ(serial::RECEIVE_ERROR_NONE, receive_error_);
+ EXPECT_EQ(serial::ReceiveError::NONE, receive_error_);
}
} // namespace device
« no previous file with comments | « device/serial/serial_connection_factory.cc ('k') | device/serial/serial_io_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698