Commit c0fcece6 authored by Becky Zhou's avatar Becky Zhou Committed by Commit Bot

Fix DownloadActivityTest#testSpaceDisplay

Changed Assert to Criteria checks for SpaceDisplay text updates.
Removed @RetryOnFailure flag.

Bug: 751492
Change-Id: I04b2cfdbb058ed50daa0187ae95117801f4a5073
Reviewed-on: https://chromium-review.googlesource.com/792392Reviewed-by: default avatarTheresa <twellington@chromium.org>
Commit-Queue: Becky Zhou <huayinz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519773}
parent 467e6e5a
......@@ -139,7 +139,6 @@ public class DownloadActivityTest {
@Test
@MediumTest
@RetryOnFailure(message = "crbug.com/751492")
public void testSpaceDisplay() throws Exception {
// This first check is a Criteria because initialization of the Adapter is asynchronous.
CriteriaHelper.pollUiThread(new Criteria() {
......@@ -156,7 +155,14 @@ public class DownloadActivityTest {
ThreadUtils.runOnUiThread(() -> mAdapter.onDownloadItemCreated(updateItem));
mAdapterObserver.onChangedCallback.waitForCallback(callCount, 2);
mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(spaceDisplayCallCount);
Assert.assertEquals("6.50 GB downloaded", mSpaceUsedDisplay.getText());
// Use Criteria here because the text for SpaceDisplay is updated through an AsyncTask.
// Same for the checks below.
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
return TextUtils.equals("6.50 GB downloaded", mSpaceUsedDisplay.getText());
}
});
// Mark one download as deleted on disk, which should prevent it from being counted.
callCount = mAdapterObserver.onChangedCallback.getCallCount();
......@@ -166,7 +172,12 @@ public class DownloadActivityTest {
ThreadUtils.runOnUiThread(() -> mAdapter.onDownloadItemUpdated(deletedItem));
mAdapterObserver.onChangedCallback.waitForCallback(callCount, 2);
mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(spaceDisplayCallCount);
Assert.assertEquals("5.50 GB downloaded", mSpaceUsedDisplay.getText());
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
return TextUtils.equals("5.50 GB downloaded", mSpaceUsedDisplay.getText());
}
});
// Say that the offline page has been deleted.
callCount = mAdapterObserver.onChangedCallback.getCallCount();
......@@ -178,7 +189,12 @@ public class DownloadActivityTest {
deletedPage.id));
mAdapterObserver.onChangedCallback.waitForCallback(callCount, 2);
mAdapterObserver.onSpaceDisplayUpdatedCallback.waitForCallback(spaceDisplayCallCount);
Assert.assertEquals("512.00 MB downloaded", mSpaceUsedDisplay.getText());
CriteriaHelper.pollUiThread(new Criteria() {
@Override
public boolean isSatisfied() {
return TextUtils.equals("512.00 MB downloaded", mSpaceUsedDisplay.getText());
}
});
}
/** Clicking on filters affects various things in the UI. */
......
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