diff options
author | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 22:57:30 +0000 |
---|---|---|
committer | jbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-28 22:57:30 +0000 |
commit | 8e937c1e6a1cf0bdce081324965e105a6b17a3fc (patch) | |
tree | ffec2c670d3ceb188c0c1244b846b15adbe7838e /ui/views/focus | |
parent | ed50d3ee0ed2e26da0ff805dc52ee0c03f80df2e (diff) | |
download | chromium_src-8e937c1e6a1cf0bdce081324965e105a6b17a3fc.zip chromium_src-8e937c1e6a1cf0bdce081324965e105a6b17a3fc.tar.gz chromium_src-8e937c1e6a1cf0bdce081324965e105a6b17a3fc.tar.bz2 |
Add base::RunLoop and update ui_test_utils to use it to reduce flakiness
Timeout flakiness has been observed in multiple tests that use Quit. This changes various test utility APIs to use QuitNow via base::RunLoop instead. Some instances of Quit are left as-is where it appears they may have a use case.
The ui_test_utils QuitThisRunLoop function does a safer form of MessageLoop::QuitWhenIdle that allows a few generations of tasks to run before actually quitting the MessageLoop. This addresses the design assumptions of many existing tests while hopefully reducing flaky timeouts by moving away from QuitWhenIdle.
This fixes throughput_tests.cc which is currently timing out on Mac.
BUG=124906,130141,131220,128305,132932
Review URL: https://chromiumcodereview.appspot.com/10479018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/focus')
-rw-r--r-- | ui/views/focus/focus_manager_unittest_win.cc | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/ui/views/focus/focus_manager_unittest_win.cc b/ui/views/focus/focus_manager_unittest_win.cc index 2a18e54..0380293 100644 --- a/ui/views/focus/focus_manager_unittest_win.cc +++ b/ui/views/focus/focus_manager_unittest_win.cc @@ -4,6 +4,8 @@ #include "ui/views/focus/focus_manager.h" +#include "base/memory/scoped_ptr.h" +#include "base/run_loop.h" #include "base/utf_string_conversions.h" #include "ui/views/controls/button/text_button.h" #include "ui/views/focus/accelerator_handler.h" @@ -215,8 +217,8 @@ TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { PostKeyDown(ui::VKEY_9); PostKeyUp(ui::VKEY_9); AcceleratorHandler accelerator_handler; - MessageLoopForUI::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); - MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); + scoped_ptr<base::RunLoop> run_loop(new base::RunLoop(&accelerator_handler)); + run_loop->RunUntilIdle(); // Make sure we get a key-up and key-down. ASSERT_EQ(1U, mtv->keys_pressed().size()); EXPECT_EQ(ui::VKEY_9, mtv->keys_pressed()[0]); @@ -234,8 +236,8 @@ TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { PostKeyUp(ui::VKEY_9); PostKeyUp(ui::VKEY_7); PostKeyUp(ui::VKEY_8); - MessageLoopForUI::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); - MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); + run_loop.reset(new base::RunLoop(&accelerator_handler)); + run_loop->RunUntilIdle(); // Make sure we get a key-up and key-down. ASSERT_EQ(5U, mtv->keys_pressed().size()); EXPECT_EQ(ui::VKEY_9, mtv->keys_pressed()[0]); @@ -253,8 +255,8 @@ TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { // Now send an accelerator key sequence. PostKeyDown(ui::VKEY_0); PostKeyUp(ui::VKEY_0); - MessageLoopForUI::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); - MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); + run_loop.reset(new base::RunLoop(&accelerator_handler)); + run_loop->RunUntilIdle(); EXPECT_TRUE(mtv->keys_pressed().empty()); EXPECT_TRUE(mtv->keys_released().empty()); EXPECT_TRUE(mtv->accelerator_pressed()); @@ -268,8 +270,8 @@ TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { PostKeyDown(ui::VKEY_0); PostKeyUp(ui::VKEY_1); PostKeyUp(ui::VKEY_0); - MessageLoopForUI::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); - MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); + run_loop.reset(new base::RunLoop(&accelerator_handler)); + run_loop->RunUntilIdle(); EXPECT_TRUE(mtv->keys_pressed().empty()); EXPECT_TRUE(mtv->keys_released().empty()); EXPECT_TRUE(mtv->accelerator_pressed()); |