diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-13 18:12:33 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-13 18:12:33 +0000 |
commit | 1d829b94ae45ee49b9f53f8bbd01eb6259eaf6b2 (patch) | |
tree | 5bc187746f6599a2b03cbb4faf67dbf9b8edacb4 /webkit/tools | |
parent | 8b7f7a26848a9bcd252ae4e0877dc858b941a68e (diff) | |
download | chromium_src-1d829b94ae45ee49b9f53f8bbd01eb6259eaf6b2.zip chromium_src-1d829b94ae45ee49b9f53f8bbd01eb6259eaf6b2.tar.gz chromium_src-1d829b94ae45ee49b9f53f8bbd01eb6259eaf6b2.tar.bz2 |
Delay the ProcessWork call just like WebKit's DumpRenderTree implementation.
To precisely match their behavior, I had to not delay the TestFinished call
when there is no work to process.
This CL avoids bugs related to DidStartLoading being called without a preceding
DidStopLoading. https://bugs.webkit.org/show_bug.cgi?id=21068 describes the
duplicate load problem in more detail, and I think that is a real bug that
should be fixed.
R=brettw
Review URL: http://codereview.chromium.org/10676
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5351 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 14 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.h | 14 |
2 files changed, 18 insertions, 10 deletions
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index 0f309d7..b187fb2 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -128,6 +128,18 @@ LayoutTestController::WorkQueue::~WorkQueue() { Reset(); } +void LayoutTestController::WorkQueue::ProcessWorkSoon() { + if (shell_->delegate()->top_loading_frame()) + return; + + if (!queue_.empty()) { + // We delay processing queued work to avoid recursion problems. + timer_.Start(base::TimeDelta(), this, &WorkQueue::ProcessWork); + } else if (!wait_until_done_) { + shell_->TestFinished(); + } +} + void LayoutTestController::WorkQueue::ProcessWork() { // Quit doing work once a load is in progress. while (!queue_.empty() && !shell_->delegate()->top_loading_frame()) { @@ -379,7 +391,7 @@ void LayoutTestController::LocationChangeDone() { work_queue_.set_frozen(true); if (!wait_until_done_) - work_queue_.ProcessWork(); + work_queue_.ProcessWorkSoon(); } void LayoutTestController::setCanOpenWindows( diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h index 53f3995..8d2507c 100644 --- a/webkit/tools/test_shell/layout_test_controller.h +++ b/webkit/tools/test_shell/layout_test_controller.h @@ -16,6 +16,7 @@ #include <queue> +#include "base/timer.h" #include "webkit/glue/cpp_bound_class.h" class TestShell; @@ -167,14 +168,6 @@ class LayoutTestController : public CppBoundClass { bool CanOpenWindows() { return can_open_windows_; } bool ShouldAddFileToPasteboard() { return should_add_file_to_pasteboard_; } - // If we have queued events, fire them and then dump the test output. - // Otherwise, just dump the test output. - // Used by the layout tests for tests that span more than a single load. - // This is called by the test webview delegate when a page finishes - // loading (successful or not). Once all the work has been processed, we - // dump the test output. - void ProcessWork() { work_queue_.ProcessWork(); } - // Called by the webview delegate when the toplevel frame load is done. void LocationChangeDone(); @@ -201,7 +194,7 @@ class LayoutTestController : public CppBoundClass { class WorkQueue { public: virtual ~WorkQueue(); - void ProcessWork(); + void ProcessWorkSoon(); // Reset the state of the class between tests. void Reset(); @@ -212,6 +205,9 @@ class LayoutTestController : public CppBoundClass { bool empty() { return queue_.empty(); } private: + void ProcessWork(); + + base::OneShotTimer<WorkQueue> timer_; std::queue<WorkItem*> queue_; bool frozen_; }; |