Commit 25ca7ee7 authored by charliea's avatar charliea Committed by Commit bot

tools/battor_agent: Adds missing RunUntilIdles in unit test

TBR=nednguyen@google.com,zhenw@chromium.org

Review URL: https://codereview.chromium.org/1642493004

Cr-Commit-Position: refs/heads/master@{#371884}
parent 99267833
...@@ -456,6 +456,7 @@ TEST_F(BattOrAgentTest, StopTracing) { ...@@ -456,6 +456,7 @@ TEST_F(BattOrAgentTest, StopTracing) {
}; };
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(cal_frame_header, cal_frame, 2)); CreateFrame(cal_frame_header, cal_frame, 2));
GetTaskRunner()->RunUntilIdle();
// Send the two real data frames. // Send the two real data frames.
BattOrFrameHeader frame_header1{0, 3 * sizeof(RawBattOrSample)}; BattOrFrameHeader frame_header1{0, 3 * sizeof(RawBattOrSample)};
...@@ -464,16 +465,19 @@ TEST_F(BattOrAgentTest, StopTracing) { ...@@ -464,16 +465,19 @@ TEST_F(BattOrAgentTest, StopTracing) {
}; };
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(frame_header1, frame1, 3)); CreateFrame(frame_header1, frame1, 3));
GetTaskRunner()->RunUntilIdle();
BattOrFrameHeader frame_header2{0, 1 * sizeof(RawBattOrSample)}; BattOrFrameHeader frame_header2{0, 1 * sizeof(RawBattOrSample)};
RawBattOrSample frame2[] = {RawBattOrSample{1, 1}}; RawBattOrSample frame2[] = {RawBattOrSample{1, 1}};
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(frame_header2, frame2, 1)); CreateFrame(frame_header2, frame2, 1));
GetTaskRunner()->RunUntilIdle();
// Send an empty last frame to indicate that we're done. // Send an empty last frame to indicate that we're done.
BattOrFrameHeader frame_header3{0, 0 * sizeof(RawBattOrSample)}; BattOrFrameHeader frame_header3{0, 0 * sizeof(RawBattOrSample)};
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(frame_header3, nullptr, 0)); CreateFrame(frame_header3, nullptr, 0));
GetTaskRunner()->RunUntilIdle();
EXPECT_TRUE(IsCommandComplete()); EXPECT_TRUE(IsCommandComplete());
EXPECT_EQ(BATTOR_ERROR_NONE, GetCommandError()); EXPECT_EQ(BATTOR_ERROR_NONE, GetCommandError());
...@@ -676,6 +680,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfCalibrationFrameHasWrongLength) { ...@@ -676,6 +680,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfCalibrationFrameHasWrongLength) {
}; };
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(cal_frame_header, cal_frame, 2)); CreateFrame(cal_frame_header, cal_frame, 2));
GetTaskRunner()->RunUntilIdle();
EXPECT_TRUE(IsCommandComplete()); EXPECT_TRUE(IsCommandComplete());
EXPECT_EQ(BATTOR_ERROR_UNEXPECTED_MESSAGE, GetCommandError()); EXPECT_EQ(BATTOR_ERROR_UNEXPECTED_MESSAGE, GetCommandError());
...@@ -690,6 +695,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfDataFrameHasWrongLength) { ...@@ -690,6 +695,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfDataFrameHasWrongLength) {
}; };
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(cal_frame_header, cal_frame, 1)); CreateFrame(cal_frame_header, cal_frame, 1));
GetTaskRunner()->RunUntilIdle();
// Send a data frame with a mismatch between the frame length in the // Send a data frame with a mismatch between the frame length in the
// header and the actual frame length. // header and the actual frame length.
...@@ -718,6 +724,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfCalibrationFrameMissingByte) { ...@@ -718,6 +724,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfCalibrationFrameMissingByte) {
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
std::move(cal_frame_bytes)); std::move(cal_frame_bytes));
GetTaskRunner()->RunUntilIdle();
EXPECT_TRUE(IsCommandComplete()); EXPECT_TRUE(IsCommandComplete());
EXPECT_EQ(BATTOR_ERROR_UNEXPECTED_MESSAGE, GetCommandError()); EXPECT_EQ(BATTOR_ERROR_UNEXPECTED_MESSAGE, GetCommandError());
...@@ -732,6 +739,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfDataFrameMissingByte) { ...@@ -732,6 +739,7 @@ TEST_F(BattOrAgentTest, StopTracingFailsIfDataFrameMissingByte) {
}; };
GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES, GetAgent()->OnMessageRead(true, BATTOR_MESSAGE_TYPE_SAMPLES,
CreateFrame(cal_frame_header, cal_frame, 1)); CreateFrame(cal_frame_header, cal_frame, 1));
GetTaskRunner()->RunUntilIdle();
BattOrFrameHeader frame_header{0, 1}; BattOrFrameHeader frame_header{0, 1};
RawBattOrSample frame[] = {RawBattOrSample{1, 1}}; RawBattOrSample frame[] = {RawBattOrSample{1, 1}};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment