Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2187)

Unified Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2837083003: DevTools: create test infrastructure so devtools drives the test (Closed)
Patch Set: fix Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/shell/browser/layout_test/blink_test_controller.cc
diff --git a/content/shell/browser/layout_test/blink_test_controller.cc b/content/shell/browser/layout_test/blink_test_controller.cc
index adea7036bdee1b106509502bed8c65c038735c1f..13196bcef78e39ec138eb9de666e3bc8e3851331 100644
--- a/content/shell/browser/layout_test/blink_test_controller.cc
+++ b/content/shell/browser/layout_test/blink_test_controller.cc
@@ -249,6 +249,7 @@ BlinkTestController* BlinkTestController::Get() {
BlinkTestController::BlinkTestController()
: main_window_(NULL),
+ secondary_window_(nullptr),
devtools_window_(nullptr),
test_phase_(BETWEEN_TESTS),
is_leak_detection_enabled_(
@@ -296,10 +297,14 @@ bool BlinkTestController::PrepareForLayoutTest(
current_working_directory_ = current_working_directory;
enable_pixel_dumping_ = enable_pixel_dumping;
expected_pixel_hash_ = expected_pixel_hash;
- if (test_url.spec().find("/inspector-unit/") == std::string::npos)
- test_url_ = test_url;
+ bool is_devtools_integration_test =
+ test_url.spec().find("/devtools-js/") != std::string::npos;
+ if (test_url.spec().find("/inspector-unit/") != std::string::npos)
+ test_url_ = LayoutTestDevToolsBindings::MapUnitTestURL(test_url);
dgozman 2017/06/15 21:16:48 Let's move this all to a single call LayoutTestDe
chenwilliam 2017/06/19 18:33:29 Done.
+ else if (is_devtools_integration_test)
+ test_url_ = LayoutTestDevToolsBindings::MapIntegrationTestURL(test_url);
else
- test_url_ = LayoutTestDevToolsBindings::MapJSTestURL(test_url);
+ test_url_ = test_url;
did_send_initial_test_configuration_ = false;
printer_->reset();
frame_to_layout_dump_map_.clear();
@@ -326,7 +331,10 @@ bool BlinkTestController::PrepareForLayoutTest(
current_pid_ = base::kNullProcessId;
default_prefs_ =
main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences();
- main_window_->LoadURL(test_url_);
+ if (is_devtools_integration_test)
+ LoadDevToolsJSTest();
+ else
+ main_window_->LoadURL(test_url_);
} else {
#if defined(OS_MACOSX)
// Shell::SizeTo is not implemented on all platforms.
@@ -352,12 +360,16 @@ bool BlinkTestController::PrepareForLayoutTest(
render_view_host->UpdateWebkitPreferences(default_prefs_);
HandleNewRenderFrameHost(render_view_host->GetMainFrame());
- NavigationController::LoadURLParams params(test_url_);
- params.transition_type = ui::PageTransitionFromInt(
- ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
- params.should_clear_history_list = true;
- main_window_->web_contents()->GetController().LoadURLWithParams(params);
- main_window_->web_contents()->Focus();
+ if (is_devtools_integration_test) {
+ LoadDevToolsJSTest();
+ } else {
+ NavigationController::LoadURLParams params(test_url_);
+ params.transition_type = ui::PageTransitionFromInt(
+ ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
+ params.should_clear_history_list = true;
+ main_window_->web_contents()->GetController().LoadURLWithParams(params);
+ main_window_->web_contents()->Focus();
+ }
}
main_window_->web_contents()->GetRenderViewHost()->GetWidget()->SetActive(
true);
@@ -365,6 +377,20 @@ bool BlinkTestController::PrepareForLayoutTest(
return true;
}
+void BlinkTestController::LoadDevToolsJSTest() {
+ devtools_window_ = main_window_;
+ if (!secondary_window_) {
dgozman 2017/06/15 21:16:48 Let's have SecondaryWindow() method which lazily c
chenwilliam 2017/06/19 18:33:29 Done.
+ ShellBrowserContext* browser_context =
+ ShellContentBrowserClient::Get()->browser_context();
+ secondary_window_ = content::Shell::CreateNewWindow(browser_context, GURL(),
+ nullptr, initial_size_);
+ }
+ devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools(
+ devtools_window_->web_contents(), secondary_window_->web_contents(), "",
+ test_url_.spec()));
+ secondary_window_->LoadURL(GURL(url::kAboutBlankURL));
+}
+
bool BlinkTestController::ResetAfterLayoutTest() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
printer_->PrintTextFooter();
@@ -379,6 +405,7 @@ bool BlinkTestController::ResetAfterLayoutTest() {
prefs_ = WebPreferences();
should_override_prefs_ = false;
LayoutTestContentBrowserClient::Get()->SetPopupBlockingEnabled(false);
+ devtools_bindings_.reset();
#if defined(OS_ANDROID)
// Re-using the shell's main window on Android causes issues with networking
@@ -841,13 +868,13 @@ void BlinkTestController::OnClearDevToolsLocalStorage() {
void BlinkTestController::OnShowDevTools(const std::string& settings,
const std::string& frontend_url) {
- if (!devtools_window_) {
+ if (!secondary_window_) {
ShellBrowserContext* browser_context =
ShellContentBrowserClient::Get()->browser_context();
- devtools_window_ = content::Shell::CreateNewWindow(browser_context, GURL(),
- nullptr, initial_size_);
+ secondary_window_ = content::Shell::CreateNewWindow(browser_context, GURL(),
+ nullptr, initial_size_);
}
-
+ devtools_window_ = secondary_window_;
devtools_bindings_.reset(LayoutTestDevToolsBindings::LoadDevTools(
devtools_window_->web_contents(), main_window_->web_contents(), settings,
frontend_url));
@@ -924,7 +951,7 @@ void BlinkTestController::OnCloseRemainingWindows() {
DevToolsAgentHost::DetachAllClients();
std::vector<Shell*> open_windows(Shell::windows());
for (size_t i = 0; i < open_windows.size(); ++i) {
- if (open_windows[i] != main_window_ && open_windows[i] != devtools_window_)
+ if (open_windows[i] != main_window_ && open_windows[i] != secondary_window_)
open_windows[i]->Close();
}
base::RunLoop().RunUntilIdle();

Powered by Google App Engine
This is Rietveld 408576698