Commit d8866e79 authored by jochen@chromium.org's avatar jochen@chromium.org

[content shell] don't open new windows after printing the test results

Otherwise, if there's e.g. still a download in flight, we might open a new
window after closing all windows but before starting the next test

BUG=111316
R=marja@chromium.org

Review URL: https://chromiumcodereview.appspot.com/16074003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202552 0039d316-1c4b-4281-b951-d872f2087c98
parent e3d35df0
...@@ -171,7 +171,7 @@ WebKitTestController* WebKitTestController::Get() { ...@@ -171,7 +171,7 @@ WebKitTestController* WebKitTestController::Get() {
WebKitTestController::WebKitTestController() WebKitTestController::WebKitTestController()
: main_window_(NULL), : main_window_(NULL),
is_running_test_(false) { test_phase_(BETWEEN_TESTS) {
CHECK(!instance_); CHECK(!instance_);
instance_ = this; instance_ = this;
printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr)); printer_.reset(new WebKitTestResultPrinter(&std::cout, &std::cerr));
...@@ -185,7 +185,7 @@ WebKitTestController::WebKitTestController() ...@@ -185,7 +185,7 @@ WebKitTestController::WebKitTestController()
WebKitTestController::~WebKitTestController() { WebKitTestController::~WebKitTestController() {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
CHECK(instance_ == this); CHECK(instance_ == this);
CHECK(!is_running_test_); CHECK(test_phase_ == BETWEEN_TESTS);
GpuDataManager::GetInstance()->RemoveObserver(this); GpuDataManager::GetInstance()->RemoveObserver(this);
DiscardMainWindow(); DiscardMainWindow();
instance_ = NULL; instance_ = NULL;
...@@ -197,7 +197,7 @@ bool WebKitTestController::PrepareForLayoutTest( ...@@ -197,7 +197,7 @@ bool WebKitTestController::PrepareForLayoutTest(
bool enable_pixel_dumping, bool enable_pixel_dumping,
const std::string& expected_pixel_hash) { const std::string& expected_pixel_hash) {
DCHECK(CalledOnValidThread()); DCHECK(CalledOnValidThread());
is_running_test_ = true; test_phase_ = DURING_TEST;
current_working_directory_ = current_working_directory; current_working_directory_ = current_working_directory;
enable_pixel_dumping_ = enable_pixel_dumping; enable_pixel_dumping_ = enable_pixel_dumping;
expected_pixel_hash_ = expected_pixel_hash; expected_pixel_hash_ = expected_pixel_hash;
...@@ -263,7 +263,7 @@ bool WebKitTestController::ResetAfterLayoutTest() { ...@@ -263,7 +263,7 @@ bool WebKitTestController::ResetAfterLayoutTest() {
printer_->PrintTextFooter(); printer_->PrintTextFooter();
printer_->PrintImageFooter(); printer_->PrintImageFooter();
send_configuration_to_next_host_ = false; send_configuration_to_next_host_ = false;
is_running_test_ = false; test_phase_ = BETWEEN_TESTS;
is_compositing_test_ = false; is_compositing_test_ = false;
enable_pixel_dumping_ = false; enable_pixel_dumping_ = false;
expected_pixel_hash_.clear(); expected_pixel_hash_.clear();
...@@ -299,6 +299,9 @@ void WebKitTestController::OverrideWebkitPrefs(WebPreferences* prefs) { ...@@ -299,6 +299,9 @@ void WebKitTestController::OverrideWebkitPrefs(WebPreferences* prefs) {
} }
void WebKitTestController::OpenURL(const GURL& url) { void WebKitTestController::OpenURL(const GURL& url) {
if (test_phase_ != DURING_TEST)
return;
Shell::CreateNewWindow(main_window_->web_contents()->GetBrowserContext(), Shell::CreateNewWindow(main_window_->web_contents()->GetBrowserContext(),
url, url,
main_window_->web_contents()->GetSiteInstance(), main_window_->web_contents()->GetSiteInstance(),
...@@ -424,10 +427,11 @@ void WebKitTestController::DiscardMainWindow() { ...@@ -424,10 +427,11 @@ void WebKitTestController::DiscardMainWindow() {
// loop. Otherwise, we're already outside of the message loop, and we just // loop. Otherwise, we're already outside of the message loop, and we just
// discard the main window. // discard the main window.
WebContentsObserver::Observe(NULL); WebContentsObserver::Observe(NULL);
if (is_running_test_) { if (test_phase_ != BETWEEN_TESTS) {
Shell::CloseAllWindows(); Shell::CloseAllWindows();
base::MessageLoop::current()->PostTask(FROM_HERE, base::MessageLoop::current()->PostTask(FROM_HERE,
base::MessageLoop::QuitClosure()); base::MessageLoop::QuitClosure());
test_phase_ = CLEAN_UP;
} else if (main_window_) { } else if (main_window_) {
main_window_->Close(); main_window_->Close();
} }
...@@ -463,6 +467,7 @@ void WebKitTestController::OnTestFinished(bool did_timeout) { ...@@ -463,6 +467,7 @@ void WebKitTestController::OnTestFinished(bool did_timeout) {
DiscardMainWindow(); DiscardMainWindow();
return; return;
} }
test_phase_ = CLEAN_UP;
if (!printer_->output_finished()) if (!printer_->output_finished())
printer_->PrintImageFooter(); printer_->PrintImageFooter();
RenderViewHost* render_view_host = RenderViewHost* render_view_host =
......
...@@ -120,6 +120,12 @@ class WebKitTestController : public base::NonThreadSafe, ...@@ -120,6 +120,12 @@ class WebKitTestController : public base::NonThreadSafe,
virtual void OnGpuProcessCrashed(base::TerminationStatus exit_code) OVERRIDE; virtual void OnGpuProcessCrashed(base::TerminationStatus exit_code) OVERRIDE;
private: private:
enum TestPhase {
BETWEEN_TESTS,
DURING_TEST,
CLEAN_UP
};
static WebKitTestController* instance_; static WebKitTestController* instance_;
void TimeoutHandler(); void TimeoutHandler();
...@@ -156,9 +162,8 @@ class WebKitTestController : public base::NonThreadSafe, ...@@ -156,9 +162,8 @@ class WebKitTestController : public base::NonThreadSafe,
// created. // created.
bool send_configuration_to_next_host_; bool send_configuration_to_next_host_;
// True if we are currently running a layout test, and false during the setup // What phase of running an individual test we are currently in.
// phase between two layout tests. TestPhase test_phase_;
bool is_running_test_;
// True if the currently running test is a compositing test. // True if the currently running test is a compositing test.
bool is_compositing_test_; bool is_compositing_test_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment