| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "mojo/edk/system/test_utils.h" | 5 #include "mojo/edk/system/test_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | |
| 8 #include "base/callback.h" | |
| 9 #include "base/synchronization/waitable_event.h" | |
| 10 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
| 11 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 12 | 9 |
| 13 namespace mojo { | 10 namespace mojo { |
| 14 namespace system { | 11 namespace system { |
| 15 namespace test { | 12 namespace test { |
| 16 | 13 |
| 17 namespace { | |
| 18 | |
| 19 void PostTaskAndWaitHelper(base::WaitableEvent* event, | |
| 20 const base::Closure& task) { | |
| 21 task.Run(); | |
| 22 event->Signal(); | |
| 23 } | |
| 24 | |
| 25 } // namespace | |
| 26 | |
| 27 void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner, | |
| 28 const tracked_objects::Location& from_here, | |
| 29 const base::Closure& task) { | |
| 30 base::WaitableEvent event(false, false); | |
| 31 task_runner->PostTask(from_here, | |
| 32 base::Bind(&PostTaskAndWaitHelper, &event, task)); | |
| 33 event.Wait(); | |
| 34 } | |
| 35 | |
| 36 base::TimeDelta EpsilonTimeout() { | 14 base::TimeDelta EpsilonTimeout() { |
| 37 // Originally, our epsilon timeout was 10 ms, which was mostly fine but flaky on | 15 // Originally, our epsilon timeout was 10 ms, which was mostly fine but flaky on |
| 38 // some Windows bots. I don't recall ever seeing flakes on other bots. At 30 ms | 16 // some Windows bots. I don't recall ever seeing flakes on other bots. At 30 ms |
| 39 // tests seem reliable on Windows bots, but not at 25 ms. We'd like this timeout | 17 // tests seem reliable on Windows bots, but not at 25 ms. We'd like this timeout |
| 40 // to be as small as possible (see the description in the .h file). | 18 // to be as small as possible (see the description in the .h file). |
| 41 // | 19 // |
| 42 // Currently, |tiny_timeout()| is usually 100 ms (possibly scaled under ASAN, | 20 // Currently, |tiny_timeout()| is usually 100 ms (possibly scaled under ASAN, |
| 43 // etc.). Based on this, set it to (usually be) 30 ms on Windows and 20 ms | 21 // etc.). Based on this, set it to (usually be) 30 ms on Windows and 20 ms |
| 44 // elsewhere. | 22 // elsewhere. |
| 45 #if defined(OS_WIN) || defined(OS_ANDROID) | 23 #if defined(OS_WIN) || defined(OS_ANDROID) |
| 46 return (TestTimeouts::tiny_timeout() * 3) / 10; | 24 return (TestTimeouts::tiny_timeout() * 3) / 10; |
| 47 #else | 25 #else |
| 48 return (TestTimeouts::tiny_timeout() * 2) / 10; | 26 return (TestTimeouts::tiny_timeout() * 2) / 10; |
| 49 #endif | 27 #endif |
| 50 } | 28 } |
| 51 | 29 |
| 52 } // namespace test | 30 } // namespace test |
| 53 } // namespace system | 31 } // namespace system |
| 54 } // namespace mojo | 32 } // namespace mojo |
| OLD | NEW |