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

Side by Side Diff: content/browser/mojo_shell_browsertest.cc

Issue 1889253002: Remove uses of shell::Loader from content (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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <memory>
6
7 #include "base/bind.h"
8 #include "base/macros.h"
9 #include "base/run_loop.h"
10 #include "content/browser/mojo/mojo_shell_context.h"
11 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/mojo_app_connection.h"
13 #include "content/public/browser/web_contents.h"
14 #include "content/public/test/content_browser_test.h"
15 #include "content/public/test/test_mojo_app.h"
16 #include "content/public/test/test_mojo_service.mojom.h"
17 #include "content/shell/browser/shell.h"
18 #include "url/gurl.h"
19
20 namespace content {
21
22 const char kInProcessTestMojoAppName[] = "system:content_in_process_test_app";
23
24 class MojoShellTest : public ContentBrowserTest {
25 public:
26 MojoShellTest() {
27 test_apps_[kInProcessTestMojoAppName] = base::Bind(&CreateTestApp);
28 MojoShellContext::SetApplicationsForTest(&test_apps_);
29 }
30
31 protected:
32 std::string GetUserId() {
33 return BrowserContext::GetMojoUserIdFor(
34 shell()->web_contents()->GetBrowserContext());
35 }
36
37 private:
38 static std::unique_ptr<shell::ShellClient> CreateTestApp() {
39 return std::unique_ptr<shell::ShellClient>(new TestMojoApp);
40 }
41
42 MojoShellContext::StaticApplicationMap test_apps_;
43
44 DISALLOW_COPY_AND_ASSIGN(MojoShellTest);
45 };
46
47 IN_PROC_BROWSER_TEST_F(MojoShellTest, TestBrowserConnection) {
48 auto test_app = MojoAppConnection::Create(
49 GetUserId(), kInProcessTestMojoAppName, kBrowserMojoAppUrl);
50 mojom::TestMojoServicePtr test_service;
51 test_app->GetInterface(&test_service);
52
53 base::RunLoop run_loop;
54 test_service->DoSomething(run_loop.QuitClosure());
55 run_loop.Run();
56 }
57
58 IN_PROC_BROWSER_TEST_F(MojoShellTest, TestUtilityConnection) {
59 // With no loader registered at this URL, the shell should spawn a utility
60 // process and connect us to it. content_shell's utility process always hosts
61 // a TestMojoApp at |kTestMojoAppUrl|.
62 auto test_app = MojoAppConnection::Create(GetUserId(), kTestMojoAppUrl,
63 kBrowserMojoAppUrl);
64 mojom::TestMojoServicePtr test_service;
65 test_app->GetInterface(&test_service);
66
67 base::RunLoop run_loop;
68 test_service->DoSomething(run_loop.QuitClosure());
69 run_loop.Run();
70 }
71
72 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/mojo/mojo_shell_context.cc ('k') | content/browser/webui/web_ui_mojo_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698