Commit ba683620 authored by ricea's avatar ricea Committed by Commit bot

Fix UnlockEndpointIsDelayed again.

On DrMemory and Valgrind builds, it takes more than 1ms just to post the task
inside UnlockEndpoint() and then enter the message loop, so the delayed task was
being executed inside RunUntilIdle().

Remove the call to RunUntilIdle() and the check that the callback wasn't called
inside it. The check at 314 is sufficient to verify that at least 1ms has
passed, which in normal compiles means that a delay was applied.

On DrMemory and Valgrind builds, the test may just verify that everything is
running very slowly, but at least it will be deterministic.

BUG=451999
TEST=net_unittests

Review URL: https://codereview.chromium.org/878373002

Cr-Commit-Position: refs/heads/master@{#314093}
parent e7b882fa
...@@ -292,6 +292,13 @@ TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsAsynchronous) { ...@@ -292,6 +292,13 @@ TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsAsynchronous) {
TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsDelayed) { TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsDelayed) {
using base::TimeTicks; using base::TimeTicks;
// This 1ms delay is too short for very slow environments (usually those
// running memory checkers). In those environments, the code takes >1ms to run
// and no delay is needed. Rather than increase the delay and slow down the
// test everywhere, the test doesn't explicitly verify that a delay has been
// applied. Instead it just verifies that the whole thing took >=1ms. 1ms is
// easily enough for normal compiles even on Android, so the fact that there
// is a delay is still checked on every platform.
const base::TimeDelta unlock_delay = base::TimeDelta::FromMilliseconds(1); const base::TimeDelta unlock_delay = base::TimeDelta::FromMilliseconds(1);
instance()->SetUnlockDelayForTesting(unlock_delay); instance()->SetUnlockDelayForTesting(unlock_delay);
FakeWaiter fake_waiter; FakeWaiter fake_waiter;
...@@ -302,8 +309,6 @@ TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsDelayed) { ...@@ -302,8 +309,6 @@ TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsDelayed) {
TimeTicks before_unlock = TimeTicks::Now(); TimeTicks before_unlock = TimeTicks::Now();
instance()->UnlockEndpoint(DummyEndpoint()); instance()->UnlockEndpoint(DummyEndpoint());
RunUntilIdle();
EXPECT_FALSE(blocking_waiter.called());
blocking_waiter.WaitForLock(); blocking_waiter.WaitForLock();
TimeTicks after_unlock = TimeTicks::Now(); TimeTicks after_unlock = TimeTicks::Now();
EXPECT_GE(after_unlock - before_unlock, unlock_delay); EXPECT_GE(after_unlock - before_unlock, unlock_delay);
......
# Flaky. crbug.com/451999
WebSocketEndpointLockManagerTest.UnlockEndpointIsDelayed
...@@ -15,6 +15,3 @@ SimpleIndexFileTest.WriteThenLoadIndex ...@@ -15,6 +15,3 @@ SimpleIndexFileTest.WriteThenLoadIndex
# Flaky. http://crbug.com/237450 # Flaky. http://crbug.com/237450
DiskCacheBackendTest.SimpleCacheAppCacheOnlyDoomAll DiskCacheBackendTest.SimpleCacheAppCacheOnlyDoomAll
DiskCacheBackendTest.SimpleCacheDoomAll DiskCacheBackendTest.SimpleCacheDoomAll
# Flaky. crbug.com/451999
WebSocketEndpointLockManagerTest.UnlockEndpointIsDelayed
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