Commit e3a05a1d authored by Christian Dullweber's avatar Christian Dullweber Committed by Commit Bot

Fix flaky BrowsingDataTest

Sometimes BrowsingDataTest.testCookiesDeleted fails because it gets a
result that doesn't contain number.
This can happen if the BrowsingDataCounter result isn't calculated
within 140ms and the counter responds with "Calculating...".
To fix test flakiness, we have to ignore these messages.

Bug: 909690
Change-Id: I087280bd98b8e5604a352692e3f0740e30eb4f02
Reviewed-on: https://chromium-review.googlesource.com/c/1353923
Commit-Queue: Christian Dullweber <dullweber@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611706}
parent 22797233
...@@ -67,6 +67,7 @@ public class BrowsingDataTest { ...@@ -67,6 +67,7 @@ public class BrowsingDataTest {
BrowsingDataCounterBridge[] counter = {null}; BrowsingDataCounterBridge[] counter = {null};
CallbackHelper helper = new CallbackHelper(); CallbackHelper helper = new CallbackHelper();
BrowsingDataCounterBridge.BrowsingDataCounterCallback callback = (result) -> { BrowsingDataCounterBridge.BrowsingDataCounterCallback callback = (result) -> {
if (result.equals("Calculating...")) return;
out[0] = result; out[0] = result;
helper.notifyCalled(); helper.notifyCalled();
}; };
...@@ -77,7 +78,9 @@ public class BrowsingDataTest { ...@@ -77,7 +78,9 @@ public class BrowsingDataTest {
helper.waitForCallback(0); helper.waitForCallback(0);
// The counter returns a result like "3 sites" or "None". // The counter returns a result like "3 sites" or "None".
if (out[0].equals("None")) return 0; if (out[0].equals("None")) return 0;
return Integer.parseInt(out[0].replaceAll("[^0-9]", "")); String cookieCount = out[0].replaceAll("[^0-9]", "");
Assert.assertFalse("Result should contain a number: " + out[0], cookieCount.isEmpty());
return Integer.parseInt(cookieCount);
} }
private String runJavascriptAsync(String type) throws Exception { private String runJavascriptAsync(String type) throws Exception {
......
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