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

Side by Side Diff: content/shell/browser/layout_test/blink_test_controller.cc

Issue 2513423003: DevTools: Convert inspector-unit tests to use reusable test harness (Closed)
Patch Set: address CL feedback Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "content/shell/browser/layout_test/blink_test_controller.h" 5 #include "content/shell/browser/layout_test/blink_test_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <iostream> 9 #include <iostream>
10 #include <set> 10 #include <set>
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 bool BlinkTestController::PrepareForLayoutTest( 261 bool BlinkTestController::PrepareForLayoutTest(
262 const GURL& test_url, 262 const GURL& test_url,
263 const base::FilePath& current_working_directory, 263 const base::FilePath& current_working_directory,
264 bool enable_pixel_dumping, 264 bool enable_pixel_dumping,
265 const std::string& expected_pixel_hash) { 265 const std::string& expected_pixel_hash) {
266 DCHECK(CalledOnValidThread()); 266 DCHECK(CalledOnValidThread());
267 test_phase_ = DURING_TEST; 267 test_phase_ = DURING_TEST;
268 current_working_directory_ = current_working_directory; 268 current_working_directory_ = current_working_directory;
269 enable_pixel_dumping_ = enable_pixel_dumping; 269 enable_pixel_dumping_ = enable_pixel_dumping;
270 expected_pixel_hash_ = expected_pixel_hash; 270 expected_pixel_hash_ = expected_pixel_hash;
271 test_url_ = test_url; 271 test_url_ = LayoutTestDevToolsFrontend::MapJSTestURL(test_url);
pfeldman 2016/11/28 19:01:03 We should not defer to devtools-specific code here
chenwilliam 2016/11/29 22:33:33 Done.
272 did_send_initial_test_configuration_ = false; 272 did_send_initial_test_configuration_ = false;
273 printer_->reset(); 273 printer_->reset();
274 frame_to_layout_dump_map_.clear(); 274 frame_to_layout_dump_map_.clear();
275 render_process_host_observer_.RemoveAll(); 275 render_process_host_observer_.RemoveAll();
276 all_observed_render_process_hosts_.clear(); 276 all_observed_render_process_hosts_.clear();
277 main_window_render_process_hosts_.clear(); 277 main_window_render_process_hosts_.clear();
278 accumulated_layout_test_runtime_flags_changes_.Clear(); 278 accumulated_layout_test_runtime_flags_changes_.Clear();
279 ShellBrowserContext* browser_context = 279 ShellBrowserContext* browser_context =
280 ShellContentBrowserClient::Get()->browser_context(); 280 ShellContentBrowserClient::Get()->browser_context();
281 is_compositing_test_ = 281 is_compositing_test_ =
282 test_url.spec().find("compositing/") != std::string::npos; 282 test_url_.spec().find("compositing/") != std::string::npos;
283 initial_size_ = Shell::GetShellDefaultSize(); 283 initial_size_ = Shell::GetShellDefaultSize();
284 // The W3C SVG layout tests use a different size than the other layout tests. 284 // The W3C SVG layout tests use a different size than the other layout tests.
285 if (test_url.spec().find("W3C-SVG-1.1") != std::string::npos) 285 if (test_url_.spec().find("W3C-SVG-1.1") != std::string::npos)
286 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip); 286 initial_size_ = gfx::Size(kTestSVGWindowWidthDip, kTestSVGWindowHeightDip);
287 if (!main_window_) { 287 if (!main_window_) {
288 main_window_ = content::Shell::CreateNewWindow( 288 main_window_ = content::Shell::CreateNewWindow(
289 browser_context, 289 browser_context,
290 GURL(), 290 GURL(),
291 NULL, 291 NULL,
292 initial_size_); 292 initial_size_);
293 WebContentsObserver::Observe(main_window_->web_contents()); 293 WebContentsObserver::Observe(main_window_->web_contents());
294 current_pid_ = base::kNullProcessId; 294 current_pid_ = base::kNullProcessId;
295 default_prefs_ = 295 default_prefs_ =
296 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences(); 296 main_window_->web_contents()->GetRenderViewHost()->GetWebkitPreferences();
297 main_window_->LoadURL(test_url); 297 main_window_->LoadURL(test_url_);
298 } else { 298 } else {
299 #if defined(OS_MACOSX) 299 #if defined(OS_MACOSX)
300 // Shell::SizeTo is not implemented on all platforms. 300 // Shell::SizeTo is not implemented on all platforms.
301 main_window_->SizeTo(initial_size_); 301 main_window_->SizeTo(initial_size_);
302 #endif 302 #endif
303 main_window_->web_contents() 303 main_window_->web_contents()
304 ->GetRenderViewHost() 304 ->GetRenderViewHost()
305 ->GetWidget() 305 ->GetWidget()
306 ->GetView() 306 ->GetView()
307 ->SetSize(initial_size_); 307 ->SetSize(initial_size_);
308 main_window_->web_contents() 308 main_window_->web_contents()
309 ->GetRenderViewHost() 309 ->GetRenderViewHost()
310 ->GetWidget() 310 ->GetWidget()
311 ->WasResized(); 311 ->WasResized();
312 RenderViewHost* render_view_host = 312 RenderViewHost* render_view_host =
313 main_window_->web_contents()->GetRenderViewHost(); 313 main_window_->web_contents()->GetRenderViewHost();
314 314
315 // Compositing tests override the default preferences (see 315 // Compositing tests override the default preferences (see
316 // BlinkTestController::OverrideWebkitPrefs) so we force them to be 316 // BlinkTestController::OverrideWebkitPrefs) so we force them to be
317 // calculated again to ensure is_compositing_test_ changes are picked up. 317 // calculated again to ensure is_compositing_test_ changes are picked up.
318 OverrideWebkitPrefs(&default_prefs_); 318 OverrideWebkitPrefs(&default_prefs_);
319 319
320 render_view_host->UpdateWebkitPreferences(default_prefs_); 320 render_view_host->UpdateWebkitPreferences(default_prefs_);
321 HandleNewRenderFrameHost(render_view_host->GetMainFrame()); 321 HandleNewRenderFrameHost(render_view_host->GetMainFrame());
322 322
323 NavigationController::LoadURLParams params(test_url); 323 NavigationController::LoadURLParams params(test_url_);
324 params.transition_type = ui::PageTransitionFromInt( 324 params.transition_type = ui::PageTransitionFromInt(
325 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR); 325 ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
326 params.should_clear_history_list = true; 326 params.should_clear_history_list = true;
327 main_window_->web_contents()->GetController().LoadURLWithParams(params); 327 main_window_->web_contents()->GetController().LoadURLWithParams(params);
328 main_window_->web_contents()->Focus(); 328 main_window_->web_contents()->Focus();
329 } 329 }
330 main_window_->web_contents()->GetRenderViewHost()->GetWidget()->SetActive( 330 main_window_->web_contents()->GetRenderViewHost()->GetWidget()->SetActive(
331 true); 331 true);
332 main_window_->web_contents()->GetRenderViewHost()->GetWidget()->Focus(); 332 main_window_->web_contents()->GetRenderViewHost()->GetWidget()->Focus();
333 return true; 333 return true;
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } else { 944 } else {
945 printer_->AddErrorMessage(base::StringPrintf( 945 printer_->AddErrorMessage(base::StringPrintf(
946 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.", 946 "FAIL: Unexpected sendBluetoothManualChooserEvent() event name '%s'.",
947 event_name.c_str())); 947 event_name.c_str()));
948 return; 948 return;
949 } 949 }
950 bluetooth_chooser_factory_->SendEvent(event, argument); 950 bluetooth_chooser_factory_->SendEvent(event, argument);
951 } 951 }
952 952
953 } // namespace content 953 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698