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

Side by Side Diff: content/shell/renderer/layout_test/blink_test_runner.cc

Issue 1836203002: Change the battery-status layout tests to use JS mocks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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 #include "content/shell/renderer/layout_test/blink_test_runner.h" 5 #include "content/shell/renderer/layout_test/blink_test_runner.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <clocale> 9 #include <clocale>
10 #include <cmath> 10 #include <cmath>
(...skipping 16 matching lines...) Expand all
27 #include "base/thread_task_runner_handle.h" 27 #include "base/thread_task_runner_handle.h"
28 #include "base/time/time.h" 28 #include "base/time/time.h"
29 #include "base/values.h" 29 #include "base/values.h"
30 #include "build/build_config.h" 30 #include "build/build_config.h"
31 #include "components/plugins/renderer/plugin_placeholder.h" 31 #include "components/plugins/renderer/plugin_placeholder.h"
32 #include "components/test_runner/gamepad_controller.h" 32 #include "components/test_runner/gamepad_controller.h"
33 #include "components/test_runner/web_test_interfaces.h" 33 #include "components/test_runner/web_test_interfaces.h"
34 #include "components/test_runner/web_test_proxy.h" 34 #include "components/test_runner/web_test_proxy.h"
35 #include "components/test_runner/web_test_runner.h" 35 #include "components/test_runner/web_test_runner.h"
36 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
37 #include "content/public/common/service_registry.h"
37 #include "content/public/common/url_constants.h" 38 #include "content/public/common/url_constants.h"
38 #include "content/public/common/web_preferences.h" 39 #include "content/public/common/web_preferences.h"
39 #include "content/public/renderer/media_stream_utils.h" 40 #include "content/public/renderer/media_stream_utils.h"
40 #include "content/public/renderer/render_frame.h" 41 #include "content/public/renderer/render_frame.h"
42 #include "content/public/renderer/render_thread.h"
41 #include "content/public/renderer/render_view.h" 43 #include "content/public/renderer/render_view.h"
42 #include "content/public/renderer/render_view_visitor.h" 44 #include "content/public/renderer/render_view_visitor.h"
43 #include "content/public/renderer/renderer_gamepad_provider.h" 45 #include "content/public/renderer/renderer_gamepad_provider.h"
44 #include "content/public/test/layouttest_support.h" 46 #include "content/public/test/layouttest_support.h"
45 #include "content/shell/common/layout_test/layout_test_messages.h" 47 #include "content/shell/common/layout_test/layout_test_messages.h"
46 #include "content/shell/common/shell_messages.h" 48 #include "content/shell/common/shell_messages.h"
47 #include "content/shell/common/shell_switches.h" 49 #include "content/shell/common/shell_switches.h"
48 #include "content/shell/renderer/layout_test/blink_test_helpers.h" 50 #include "content/shell/renderer/layout_test/blink_test_helpers.h"
49 #include "content/shell/renderer/layout_test/layout_test_render_process_observer .h" 51 #include "content/shell/renderer/layout_test/layout_test_render_process_observer .h"
50 #include "content/shell/renderer/layout_test/leak_detector.h" 52 #include "content/shell/renderer/layout_test/leak_detector.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 local_frame = RenderFrame::FromWebFrame(frame); 590 local_frame = RenderFrame::FromWebFrame(frame);
589 break; 591 break;
590 } 592 }
591 } 593 }
592 DCHECK(local_frame); 594 DCHECK(local_frame);
593 Send(new ShellViewHostMsg_LayoutTestRuntimeFlagsChanged( 595 Send(new ShellViewHostMsg_LayoutTestRuntimeFlagsChanged(
594 local_frame->GetRoutingID(), changed_values)); 596 local_frame->GetRoutingID(), changed_values));
595 } 597 }
596 598
597 void BlinkTestRunner::TestFinished() { 599 void BlinkTestRunner::TestFinished() {
600 // In layout tests, mock Mojo service factories implemented in JS may be
601 // installed on the per-frame and the per-process service registries. With
602 // the test finished, clear any overrides so they don't interfere with any
603 // later tests and so they aren't detected as leaks.
604 RenderThread::Get()->GetServiceRegistry()->ClearServiceOverridesForTesting();
605 render_view()
606 ->GetMainRenderFrame()
607 ->GetServiceRegistry()
608 ->ClearServiceOverridesForTesting();
609
598 if (!is_main_window_ || !render_view()->GetMainRenderFrame()) { 610 if (!is_main_window_ || !render_view()->GetMainRenderFrame()) {
599 Send(new ShellViewHostMsg_TestFinishedInSecondaryRenderer(routing_id())); 611 Send(new ShellViewHostMsg_TestFinishedInSecondaryRenderer(routing_id()));
600 return; 612 return;
601 } 613 }
602 test_runner::WebTestInterfaces* interfaces = 614 test_runner::WebTestInterfaces* interfaces =
603 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces(); 615 LayoutTestRenderProcessObserver::GetInstance()->test_interfaces();
604 interfaces->SetTestIsRunning(false); 616 interfaces->SetTestIsRunning(false);
605 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) { 617 if (interfaces->TestRunner()->ShouldDumpBackForwardList()) {
606 SyncNavigationStateVisitor visitor; 618 SyncNavigationStateVisitor visitor;
607 RenderView::ForEach(&visitor); 619 RenderView::ForEach(&visitor);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 get_bluetooth_events_callbacks_.pop_front(); 1021 get_bluetooth_events_callbacks_.pop_front();
1010 callback.Run(events); 1022 callback.Run(events);
1011 } 1023 }
1012 1024
1013 void BlinkTestRunner::ReportLeakDetectionResult( 1025 void BlinkTestRunner::ReportLeakDetectionResult(
1014 const LeakDetectionResult& report) { 1026 const LeakDetectionResult& report) {
1015 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report)); 1027 Send(new ShellViewHostMsg_LeakDetectionDone(routing_id(), report));
1016 } 1028 }
1017 1029
1018 } // namespace content 1030 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698