Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
| index 669124f913a858b43f727352ed8d741dbe746322..71ad8b8cace784570afa9dc515d75a9d852c3658 100644 |
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/widget/ToolbarProgressBarTest.java |
| @@ -7,6 +7,7 @@ package org.chromium.chrome.browser.widget; |
| import static org.chromium.base.test.util.Restriction.RESTRICTION_TYPE_PHONE; |
| import android.test.suitebuilder.annotation.MediumTest; |
| +import android.view.View; |
| import org.chromium.base.ThreadUtils; |
| import org.chromium.base.test.util.Feature; |
| @@ -35,7 +36,7 @@ public class ToolbarProgressBarTest extends ChromeActivityTestCaseBase<ChromeAct |
| /** |
| * Test that calling progressBar.setProgress(# > 0) followed by progressBar.setProgress(0) |
| - * results in a hidden progress bar (the secondary progress needs to be 0). |
| + * results in a hidden progress bar. |
| * @throws InterruptedException |
| */ |
| @Feature({"Android-Toolbar"}) |
| @@ -59,33 +60,52 @@ public class ToolbarProgressBarTest extends ChromeActivityTestCaseBase<ChromeAct |
| } |
| }); |
| + // Confirm that the progress bar is hidden. |
| + CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
|
Ted C
2015/07/17 23:42:44
assertTrue?
Kibeom Kim (inactive)
2015/07/19 08:48:55
Done.
|
| + @Override |
| + public boolean isSatisfied() { |
| + return progressBar.get().getVisibility() != View.VISIBLE; |
| + } |
| + }, |
| + CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL + ToolbarProgressBar.HIDING_DURATION_MS, |
|
Ted C
2015/07/17 23:42:44
I would have the ability to overwrite these delays
Kibeom Kim (inactive)
2015/07/19 08:48:55
Sorry I don't understand the overwriting delays su
Ted C
2015/07/20 18:23:45
Sorry for being unclear. But I meant have a metho
Kibeom Kim (inactive)
2015/07/20 19:09:12
Done.
|
| + CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| + |
| + // Progress |
| ThreadUtils.runOnUiThread(new Runnable() { |
| @Override |
| public void run() { |
| - assertEquals("Progress bar should be hidden to start.", 0, |
| - progressBar.get().getProgress()); |
| - progressBar.get().setProgress(10); |
| - assertTrue("Progress bar did not start animating", |
| - progressBar.get().isAnimatingForShowOrHide()); |
| - progressBar.get().setProgress(0); |
| + progressBar.get().start(); |
| + progressBar.get().setProgress(0.5f); |
| } |
| }); |
| - // Wait for the progress bar to finish any and all animations. |
| + // Confirm that the progress bar is fully visible. |
| CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
|
Ted C
2015/07/17 23:42:44
assertTrue and all others.
Kibeom Kim (inactive)
2015/07/19 08:48:55
Done.
|
| @Override |
| public boolean isSatisfied() { |
| - return !progressBar.get().isAnimatingForShowOrHide(); |
| + return progressBar.get().getVisibility() == View.VISIBLE |
| + && progressBar.get().getAlpha() == 1.0f; |
| } |
| - }); |
| + }, |
| + CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL + ToolbarProgressBar.SHOWING_DURATION_MS, |
| + CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| + // Clear progress |
| ThreadUtils.runOnUiThread(new Runnable() { |
| @Override |
| public void run() { |
| - // The secondary progress should be gone. |
| - assertEquals("Progress bar background still visible.", 0, |
| - progressBar.get().getSecondaryProgress()); |
| + progressBar.get().finish(true); |
| } |
| }); |
| + |
| + // Confirm that the progress bar is hidden. |
| + CriteriaHelper.pollForUIThreadCriteria(new Criteria() { |
| + @Override |
| + public boolean isSatisfied() { |
| + return progressBar.get().getVisibility() != View.VISIBLE; |
| + } |
| + }, |
| + CriteriaHelper.DEFAULT_MAX_TIME_TO_POLL + ToolbarProgressBar.HIDING_DURATION_MS, |
| + CriteriaHelper.DEFAULT_POLLING_INTERVAL); |
| } |
| } |