diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-05-24 03:47:08 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-05-24 03:47:09 +0000 |
commit | ea6826448b6a4dee754d0173711517075ca97119 (patch) | |
tree | c5eb566b2d5bdb5d3778f75126a70b54cfca2229 | |
parent | 3c8476cd9997283ea66601b63c72d4b08c7ca5c1 (diff) | |
parent | 899e6321aa35b1267a300441bf470731f5a9fd92 (diff) | |
download | core-ea6826448b6a4dee754d0173711517075ca97119.tar.gz |
Merge "Always print the initial bugreport progress message." into oc-dev
-rw-r--r-- | adb/bugreport.cpp | 2 | ||||
-rw-r--r-- | adb/bugreport_test.cpp | 23 |
2 files changed, 24 insertions, 1 deletions
diff --git a/adb/bugreport.cpp b/adb/bugreport.cpp index d159d6ae7..b3e391bb5 100644 --- a/adb/bugreport.cpp +++ b/adb/bugreport.cpp @@ -149,7 +149,7 @@ class BugreportStandardStreamsCallback : public StandardStreamsCallbackInterface int progress = std::stoi(line.substr(idx1, (idx2 - idx1))); int total = std::stoi(line.substr(idx2 + 1)); int progress_percentage = (progress * 100 / total); - if (progress_percentage <= last_progress_percentage_) { + if (progress_percentage != 0 && progress_percentage <= last_progress_percentage_) { // Ignore. return; } diff --git a/adb/bugreport_test.cpp b/adb/bugreport_test.cpp index 2b368d7be..d3787b40a 100644 --- a/adb/bugreport_test.cpp +++ b/adb/bugreport_test.cpp @@ -311,6 +311,29 @@ TEST_F(BugreportTest, OkProgressAlwaysForward) { ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args)); } +// Tests 'adb bugreport file.zip' when it succeeds and displays the initial progress of 0% +TEST_F(BugreportTest, OkProgressZeroPercentIsNotIgnored) { + ExpectBugreportzVersion("1.1"); + ExpectProgress(0); + ExpectProgress(1); + // clang-format off + EXPECT_CALL(br_, SendShellCommand(kTransportLocal, "HannibalLecter", "bugreportz -p", false, _)) + // NOTE: DoAll accepts at most 10 arguments, and we're almost reached that limit... + .WillOnce(DoAll( + WithArg<4>(WriteOnStdout("BEGIN:/device/bugreport.zip\n")), + WithArg<4>(WriteOnStdout("PROGRESS:1/100000\n")), + WithArg<4>(WriteOnStdout("PROGRESS:1/100\n")), // 1% + WithArg<4>(WriteOnStdout("OK:/device/bugreport.zip")), + WithArg<4>(ReturnCallbackDone()))); + // clang-format on + EXPECT_CALL(br_, DoSyncPull(ElementsAre(StrEq("/device/bugreport.zip")), StrEq("file.zip"), + true, StrEq("pulling file.zip"))) + .WillOnce(Return(true)); + + const char* args[] = {"bugreport", "file.zip"}; + ASSERT_EQ(0, br_.DoIt(kTransportLocal, "HannibalLecter", 2, args)); +} + // Tests 'adb bugreport dir' when it succeeds and destination is a directory. TEST_F(BugreportTest, OkDirectory) { ExpectBugreportzVersion("1.1"); |