Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 916a84e3 authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

Merge "Always print the initial bugreport progress message." am: 5b17d713

am: 8b54eb76

Change-Id: I94389c1883ae72d2e209463d09b48cf60d0fce3f
parents 8ba87380 8b54eb76
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;
            }
+23 −0
Original line number Diff line number Diff line
@@ -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");