Skip to content

Fad cancel task when dialog closed #3228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 10, 2021

Conversation

rachaprince
Copy link

@rachaprince rachaprince commented Dec 9, 2021

Cancel the ongoing task when the dialog is dismissed or cancelled. Prevents hanging tasks

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 9, 2021

Coverage Report

Affected SDKs

  • firebase-app-distribution

    SDK overall coverage changed from 66.31% (28e1a16) to 67.43% (295c9a5d) by +1.11%.

    Filename Base (28e1a16) Head (295c9a5d) Diff
    FirebaseAppDistribution.java 80.86% 87.88% +7.01%
    InstallActivity.java 4.35% 4.29% -0.06%
    TesterSignInClient.java 84.62% 87.83% +3.21%

Test Logs

Notes

HTML coverage reports can be produced locally with ./gradlew <product>:checkCoverage.
Report files are located at <product-build-dir>/reports/jacoco/.

Head commit (295c9a5d) is created by Prow via merging commits: 28e1a16 2bbf265.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 9, 2021

Binary Size Report

Affected SDKs

  • firebase-app-distribution

    Type Base (28e1a16) Head (295c9a5d) Diff
    aar 118 kB 116 kB -1.82 kB (-1.5%)
    apk (aggressive) 739 kB 739 kB +80 B (+0.0%)
    apk (release) 1.55 MB 1.55 MB +276 B (+0.0%)

Test Logs

Notes

Head commit (295c9a5d) is created by Prow via merging commits: 28e1a16 2bbf265.

}
});
}
(dialogInterface, i) -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :)

Comment on lines 481 to 482
when(mockCheckForNewReleaseClient.checkForNewRelease()).thenReturn(Tasks.forResult(newRelease));
firebaseAppDistribution.setCachedNewRelease(newRelease);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to both mock checkForNewRelease() AND set the cached new release?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't. Good catch. (I think this is dead code from a previous implementation)

@@ -475,4 +475,20 @@ public void updateApp_withApkReleaseAvailable_returnsSameApkTask() {

assertEquals(updateTask, updateTaskToReturn);
}

private UpdateTask updateToNewRelease(AppDistributionReleaseInternal newRelease) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the consolidation of setup, but this is combining some of the setup with the actual actions being tested. Could we split out the mocking/caching from the updateIfNewReleaseAvailable() call?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Done. After removing the setCachedNewRelease call below, I felt like this wasn't doing enough to justify a separate method.

I moved the signin mocking to the setup method, since most tests aren't testing the signIn logic

@@ -374,14 +393,6 @@ public void updateToNewRelease_whenCheckForUpdateFails_updateAppNotCalled() {
assertEquals(FirebaseAppDistributionException.Status.NETWORK_FAILURE, e.getErrorCode());
}

@Test
public void updateToNewRelease_callsSignInTester() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just checking: did you remove this test because it's only verifying a method call?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I meant to leave a note here. I felt this test was testing implementation, not behavior, so I removed it

Copy link
Contributor

@lfkellogg lfkellogg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Love the test refactoring.

@rachaprince rachaprince merged commit dd1c336 into master Dec 10, 2021
@rachaprince rachaprince deleted the fad-cancel-task-when-dialog-closed branch December 10, 2021 14:56
@firebase firebase locked and limited conversation to collaborators Jan 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants