summaryrefslogtreecommitdiff
path: root/payload_consumer/postinstall_runner_action_unittest.cc
diff options
context:
space:
mode:
authorAlex Deymo <deymo@google.com>2016-06-09 16:23:28 -0700
committerTreehugger Robot <treehugger-gerrit@google.com>2016-06-10 01:45:03 +0000
commitd853730826e02647dee6ac818ceef73a4d0e57f0 (patch)
tree8859af10f6efe7715e60ee5cbfad972b5a1befa2 /payload_consumer/postinstall_runner_action_unittest.cc
parentcaa467282b7ab61c07e7695ca225c5d36c743755 (diff)
Add a few more unittest for parsing global_progress.
Postinstall program can occasionally return garbage instead of a fraction. Add two more test cases. Bug: None TEST=unittests still pass. Change-Id: Ia444acada78eaa124c618b68d3f0880b2348c8f6
Diffstat (limited to 'payload_consumer/postinstall_runner_action_unittest.cc')
-rw-r--r--payload_consumer/postinstall_runner_action_unittest.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/payload_consumer/postinstall_runner_action_unittest.cc b/payload_consumer/postinstall_runner_action_unittest.cc
index 5a8e9508..c3a51205 100644
--- a/payload_consumer/postinstall_runner_action_unittest.cc
+++ b/payload_consumer/postinstall_runner_action_unittest.cc
@@ -217,15 +217,23 @@ TEST_F(PostinstallRunnerActionTest, ProcessProgressLineTest) {
action.accumulated_weight_ = 1;
action.total_weight_ = 8;
- // 50% of the second actions is 2/8 = 0.25 of the total.
+ // 50% of the second action is 2/8 = 0.25 of the total.
EXPECT_CALL(mock_delegate_, ProgressUpdate(0.25));
action.ProcessProgressLine("global_progress 0.5");
testing::Mock::VerifyAndClearExpectations(&mock_delegate_);
+ // 1.5 should be read as 100%, to catch rounding error cases like 1.000001.
+ // 100% of the second is 3/8 of the total.
+ EXPECT_CALL(mock_delegate_, ProgressUpdate(0.375));
+ action.ProcessProgressLine("global_progress 1.5");
+ testing::Mock::VerifyAndClearExpectations(&mock_delegate_);
+
// None of these should trigger a progress update.
action.ProcessProgressLine("foo_bar");
action.ProcessProgressLine("global_progress");
action.ProcessProgressLine("global_progress ");
+ action.ProcessProgressLine("global_progress NaN");
+ action.ProcessProgressLine("global_progress Exception in ... :)");
}
// Test that postinstall succeeds in the simple case of running the default