summaryrefslogtreecommitdiffstats
path: root/ash/drag_drop
diff options
context:
space:
mode:
authorjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 22:57:30 +0000
committerjbates@chromium.org <jbates@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-28 22:57:30 +0000
commit8e937c1e6a1cf0bdce081324965e105a6b17a3fc (patch)
treeffec2c670d3ceb188c0c1244b846b15adbe7838e /ash/drag_drop
parented50d3ee0ed2e26da0ff805dc52ee0c03f80df2e (diff)
downloadchromium_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 'ash/drag_drop')
-rw-r--r--ash/drag_drop/drag_drop_controller.cc9
-rw-r--r--ash/drag_drop/drag_drop_controller.h4
2 files changed, 10 insertions, 3 deletions
diff --git a/ash/drag_drop/drag_drop_controller.cc b/ash/drag_drop/drag_drop_controller.cc
index 51ca88d..dcc1029 100644
--- a/ash/drag_drop/drag_drop_controller.cc
+++ b/ash/drag_drop/drag_drop_controller.cc
@@ -7,6 +7,7 @@
#include "ash/drag_drop/drag_image_view.h"
#include "ash/shell.h"
#include "base/message_loop.h"
+#include "base/run_loop.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/cursor_manager.h"
@@ -82,9 +83,11 @@ int DragDropController::StartDragAndDrop(const ui::OSExchangeData& data,
#if !defined(OS_MACOSX)
if (should_block_during_drag_drop_) {
+ base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher());
+ quit_closure_ = run_loop.QuitClosure();
MessageLoopForUI* loop = MessageLoopForUI::current();
MessageLoop::ScopedNestableTaskAllower allow_nested(loop);
- loop->RunWithDispatcher(aura::Env::GetInstance()->GetDispatcher());
+ run_loop.Run();
}
#endif // !defined(OS_MACOSX)
@@ -163,7 +166,7 @@ void DragDropController::Drop(aura::Window* target,
Cleanup();
if (should_block_during_drag_drop_)
- MessageLoop::current()->QuitNow();
+ quit_closure_.Run();
}
void DragDropController::DragCancel() {
@@ -181,7 +184,7 @@ void DragDropController::DragCancel() {
drag_operation_ = 0;
StartCanceledAnimation();
if (should_block_during_drag_drop_)
- MessageLoop::current()->QuitNow();
+ quit_closure_.Run();
}
bool DragDropController::IsDragDropInProgress() {
diff --git a/ash/drag_drop/drag_drop_controller.h b/ash/drag_drop/drag_drop_controller.h
index d44ba20..df13d15 100644
--- a/ash/drag_drop/drag_drop_controller.h
+++ b/ash/drag_drop/drag_drop_controller.h
@@ -7,6 +7,7 @@
#pragma once
#include "ash/ash_export.h"
+#include "base/callback.h"
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/event.h"
#include "ui/aura/event_filter.h"
@@ -99,6 +100,9 @@ class ASH_EXPORT DragDropController
// Only be used for tests.
bool should_block_during_drag_drop_;
+ // Closure for quitting nested message loop.
+ base::Closure quit_closure_;
+
DISALLOW_COPY_AND_ASSIGN(DragDropController);
};