From ba6836202b8d60478d96fd8509ad98cd89e1ee1c Mon Sep 17 00:00:00 2001 From: ricea Date: Sun, 1 Feb 2015 10:16:53 -0800 Subject: 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} --- net/socket/websocket_endpoint_lock_manager_unittest.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'net') diff --git a/net/socket/websocket_endpoint_lock_manager_unittest.cc b/net/socket/websocket_endpoint_lock_manager_unittest.cc index 1603a3b..dbe8494 100644 --- a/net/socket/websocket_endpoint_lock_manager_unittest.cc +++ b/net/socket/websocket_endpoint_lock_manager_unittest.cc @@ -292,6 +292,13 @@ TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsAsynchronous) { TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsDelayed) { 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); instance()->SetUnlockDelayForTesting(unlock_delay); FakeWaiter fake_waiter; @@ -302,8 +309,6 @@ TEST_F(WebSocketEndpointLockManagerTest, UnlockEndpointIsDelayed) { TimeTicks before_unlock = TimeTicks::Now(); instance()->UnlockEndpoint(DummyEndpoint()); - RunUntilIdle(); - EXPECT_FALSE(blocking_waiter.called()); blocking_waiter.WaitForLock(); TimeTicks after_unlock = TimeTicks::Now(); EXPECT_GE(after_unlock - before_unlock, unlock_delay); -- cgit v1.1