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

Side by Side Diff: content/browser/battery_status/battery_monitor_integration_browsertest.cc

Issue 2157143002: Move interface registration to OnConnect in RPH (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 5 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
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | content/browser/browser_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <utility> 5 #include <utility>
6 6
7 #include "base/callback_list.h" 7 #include "base/callback_list.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "content/public/browser/content_browser_client.h" 12 #include "content/public/browser/content_browser_client.h"
13 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
14 #include "content/public/common/content_client.h" 14 #include "content/public/common/content_client.h"
15 #include "content/public/test/content_browser_test.h" 15 #include "content/public/test/content_browser_test.h"
16 #include "content/public/test/content_browser_test_utils.h" 16 #include "content/public/test/content_browser_test_utils.h"
17 #include "content/public/test/test_navigation_observer.h" 17 #include "content/public/test/test_navigation_observer.h"
18 #include "content/public/test/test_utils.h" 18 #include "content/public/test/test_utils.h"
19 #include "content/shell/browser/shell.h" 19 #include "content/shell/browser/shell.h"
20 #include "content/shell/browser/shell_content_browser_client.h" 20 #include "content/shell/browser/shell_content_browser_client.h"
21 #include "device/battery/battery_monitor.mojom.h" 21 #include "device/battery/battery_monitor.mojom.h"
22 #include "mojo/public/cpp/bindings/strong_binding.h" 22 #include "mojo/public/cpp/bindings/strong_binding.h"
23 #include "services/shell/public/cpp/connection.h"
23 #include "services/shell/public/cpp/interface_registry.h" 24 #include "services/shell/public/cpp/interface_registry.h"
24 25
25 // These tests run against a dummy implementation of the BatteryMonitor service. 26 // These tests run against a dummy implementation of the BatteryMonitor service.
26 // That is, they verify that the service implementation is correctly exposed to 27 // That is, they verify that the service implementation is correctly exposed to
27 // the renderer, whatever the implementation is. 28 // the renderer, whatever the implementation is.
28 29
29 namespace content { 30 namespace content {
30 31
31 namespace { 32 namespace {
32 33
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 std::unique_ptr<BatteryUpdateSubscription> subscription_; 84 std::unique_ptr<BatteryUpdateSubscription> subscription_;
84 mojo::StrongBinding<BatteryMonitor> binding_; 85 mojo::StrongBinding<BatteryMonitor> binding_;
85 QueryNextStatusCallback callback_; 86 QueryNextStatusCallback callback_;
86 }; 87 };
87 88
88 // Overrides the default service implementation with the test implementation 89 // Overrides the default service implementation with the test implementation
89 // declared above. 90 // declared above.
90 class TestContentBrowserClient : public ContentBrowserClient { 91 class TestContentBrowserClient : public ContentBrowserClient {
91 public: 92 public:
92 void ExposeInterfacesToRenderer( 93 void ExposeInterfacesToRenderer(
93 shell::InterfaceRegistry* registry, 94 shell::Connection* connection) override {
94 RenderProcessHost* render_process_host) override { 95 connection->GetInterfaceRegistry()->AddInterface(
95 registry->AddInterface(base::Bind(&FakeBatteryMonitor::Create)); 96 base::Bind(&FakeBatteryMonitor::Create),
97 content::BrowserThread::GetTaskRunnerForThread(
98 content::BrowserThread::UI));
96 } 99 }
97 100
98 void AppendExtraCommandLineSwitches(base::CommandLine* command_line, 101 void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
99 int child_process_id) override { 102 int child_process_id) override {
100 // Necessary for passing kIsolateSitesForTesting flag to the renderer. 103 // Necessary for passing kIsolateSitesForTesting flag to the renderer.
101 ShellContentBrowserClient::Get()->AppendExtraCommandLineSwitches( 104 ShellContentBrowserClient::Get()->AppendExtraCommandLineSwitches(
102 command_line, child_process_id); 105 command_line, child_process_id);
103 } 106 }
104 107
105 #if defined(OS_ANDROID) 108 #if defined(OS_ANDROID)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 TestNavigationObserver same_tab_observer2(shell()->web_contents(), 1); 182 TestNavigationObserver same_tab_observer2(shell()->web_contents(), 1);
180 status.level = 0.6; 183 status.level = 0.6;
181 UpdateBattery(status); 184 UpdateBattery(status);
182 same_tab_observer2.Wait(); 185 same_tab_observer2.Wait();
183 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref()); 186 EXPECT_EQ("pass", shell()->web_contents()->GetLastCommittedURL().ref());
184 } 187 }
185 188
186 } // namespace 189 } // namespace
187 190
188 } // namespace content 191 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/chrome_content_browser_client.cc ('k') | content/browser/browser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698