| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #undef LOG | 5 #undef LOG |
| 6 | 6 |
| 7 #include "webkit/tools/test_shell/test_shell.h" | 7 #include "webkit/tools/test_shell/test_shell.h" |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 #endif | 129 #endif |
| 130 test_params_(NULL), | 130 test_params_(NULL), |
| 131 is_modal_(false), | 131 is_modal_(false), |
| 132 is_loading_(false), | 132 is_loading_(false), |
| 133 allow_images_(true), | 133 allow_images_(true), |
| 134 allow_plugins_(true), | 134 allow_plugins_(true), |
| 135 allow_scripts_(true), | 135 allow_scripts_(true), |
| 136 dump_stats_table_on_exit_(false) { | 136 dump_stats_table_on_exit_(false) { |
| 137 delegate_.reset(new TestWebViewDelegate(this)); | 137 delegate_.reset(new TestWebViewDelegate(this)); |
| 138 popup_delegate_.reset(new TestWebViewDelegate(this)); | 138 popup_delegate_.reset(new TestWebViewDelegate(this)); |
| 139 layout_test_controller_.reset(new LayoutTestController(this)); | |
| 140 navigation_controller_.reset(new TestNavigationController(this)); | 139 navigation_controller_.reset(new TestNavigationController(this)); |
| 141 notification_presenter_.reset(new TestNotificationPresenter(this)); | 140 notification_presenter_.reset(new TestNotificationPresenter(this)); |
| 142 | 141 |
| 143 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); | 142 net::URLRequestFilter* filter = net::URLRequestFilter::GetInstance(); |
| 144 filter->AddHostnameHandler("test-shell-resource", "inspector", | 143 filter->AddHostnameHandler("test-shell-resource", "inspector", |
| 145 &URLRequestTestShellFileJob::InspectorFactory); | 144 &URLRequestTestShellFileJob::InspectorFactory); |
| 146 url_util::AddStandardScheme("test-shell-resource"); | 145 url_util::AddStandardScheme("test-shell-resource"); |
| 147 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( | 146 webkit_glue::SetUserAgent(webkit_glue::BuildUserAgentFromProduct( |
| 148 "TestShell/0.0.0.0"), false); | 147 "TestShell/0.0.0.0"), false); |
| 149 } | 148 } |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 395 |
| 397 void TestShell::TestTimedOut() { | 396 void TestShell::TestTimedOut() { |
| 398 puts("#TEST_TIMED_OUT\n"); | 397 puts("#TEST_TIMED_OUT\n"); |
| 399 TestFinished(); | 398 TestFinished(); |
| 400 } | 399 } |
| 401 | 400 |
| 402 void TestShell::Show(WebNavigationPolicy policy) { | 401 void TestShell::Show(WebNavigationPolicy policy) { |
| 403 delegate_->show(policy); | 402 delegate_->show(policy); |
| 404 } | 403 } |
| 405 | 404 |
| 406 void TestShell::BindJSObjectsToWindow(WebFrame* frame) { | |
| 407 // Only bind the test classes if we're running tests. | |
| 408 if (layout_test_mode_) { | |
| 409 layout_test_controller_->BindToJavascript(frame, "layoutTestController"); | |
| 410 layout_test_controller_->BindToJavascript(frame, "testRunner"); | |
| 411 } | |
| 412 } | |
| 413 | |
| 414 void TestShell::DumpBackForwardEntry(int index, string16* result) { | 405 void TestShell::DumpBackForwardEntry(int index, string16* result) { |
| 415 int current_index = navigation_controller_->GetLastCommittedEntryIndex(); | 406 int current_index = navigation_controller_->GetLastCommittedEntryIndex(); |
| 416 | 407 |
| 417 std::string content_state = | 408 std::string content_state = |
| 418 navigation_controller_->GetEntryAtIndex(index)->GetContentState(); | 409 navigation_controller_->GetEntryAtIndex(index)->GetContentState(); |
| 419 if (content_state.empty()) { | 410 if (content_state.empty()) { |
| 420 content_state = webkit_glue::CreateHistoryStateForURL( | 411 content_state = webkit_glue::CreateHistoryStateForURL( |
| 421 navigation_controller_->GetEntryAtIndex(index)->GetURL()); | 412 navigation_controller_->GetEntryAtIndex(index)->GetURL()); |
| 422 } | 413 } |
| 423 | 414 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 436 "===============================================\n")); | 427 "===============================================\n")); |
| 437 } | 428 } |
| 438 | 429 |
| 439 void TestShell::CallJSGC() { | 430 void TestShell::CallJSGC() { |
| 440 webView()->mainFrame()->collectGarbage(); | 431 webView()->mainFrame()->collectGarbage(); |
| 441 } | 432 } |
| 442 | 433 |
| 443 WebView* TestShell::CreateWebView() { | 434 WebView* TestShell::CreateWebView() { |
| 444 // If we're running layout tests, only open a new window if the test has | 435 // If we're running layout tests, only open a new window if the test has |
| 445 // called layoutTestController.setCanOpenWindows() | 436 // called layoutTestController.setCanOpenWindows() |
| 446 if (layout_test_mode_ && !layout_test_controller_->CanOpenWindows()) | 437 if (layout_test_mode_) |
| 447 return NULL; | 438 return NULL; |
| 448 | 439 |
| 449 TestShell* new_win; | 440 TestShell* new_win; |
| 450 if (!CreateNewWindow(GURL(), &new_win)) | 441 if (!CreateNewWindow(GURL(), &new_win)) |
| 451 return NULL; | 442 return NULL; |
| 452 | 443 |
| 453 return new_win->webView(); | 444 return new_win->webView(); |
| 454 } | 445 } |
| 455 | 446 |
| 456 void TestShell::ShowDevTools() { | 447 void TestShell::ShowDevTools() { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 485 | 476 |
| 486 void TestShell::SizeToSVG() { | 477 void TestShell::SizeToSVG() { |
| 487 SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); | 478 SizeTo(kSVGTestWindowWidth, kSVGTestWindowHeight); |
| 488 } | 479 } |
| 489 | 480 |
| 490 void TestShell::SizeToDefault() { | 481 void TestShell::SizeToDefault() { |
| 491 SizeTo(kTestWindowWidth, kTestWindowHeight); | 482 SizeTo(kTestWindowWidth, kTestWindowHeight); |
| 492 } | 483 } |
| 493 | 484 |
| 494 void TestShell::ResetTestController() { | 485 void TestShell::ResetTestController() { |
| 495 layout_test_controller_->Reset(); | |
| 496 notification_presenter_->Reset(); | 486 notification_presenter_->Reset(); |
| 497 delegate_->Reset(); | 487 delegate_->Reset(); |
| 498 if (geolocation_client_mock_.get()) | 488 if (geolocation_client_mock_.get()) |
| 499 geolocation_client_mock_->resetMock(); | 489 geolocation_client_mock_->resetMock(); |
| 500 } | 490 } |
| 501 | 491 |
| 502 void TestShell::LoadFile(const FilePath& file) { | 492 void TestShell::LoadFile(const FilePath& file) { |
| 503 LoadURLForFrame(net::FilePathToFileURL(file), string16()); | 493 LoadURLForFrame(net::FilePathToFileURL(file), string16()); |
| 504 } | 494 } |
| 505 | 495 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 return device_orientation_client_mock_.get(); | 606 return device_orientation_client_mock_.get(); |
| 617 } | 607 } |
| 618 | 608 |
| 619 WebKit::WebGeolocationClientMock* TestShell::geolocation_client_mock() { | 609 WebKit::WebGeolocationClientMock* TestShell::geolocation_client_mock() { |
| 620 if (!geolocation_client_mock_.get()) { | 610 if (!geolocation_client_mock_.get()) { |
| 621 geolocation_client_mock_.reset( | 611 geolocation_client_mock_.reset( |
| 622 WebKit::WebGeolocationClientMock::create()); | 612 WebKit::WebGeolocationClientMock::create()); |
| 623 } | 613 } |
| 624 return geolocation_client_mock_.get(); | 614 return geolocation_client_mock_.get(); |
| 625 } | 615 } |
| OLD | NEW |