OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 <memory> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/macros.h" | 8 #include "base/macros.h" |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
9 #include "content/browser/mojo/mojo_shell_context.h" | 10 #include "content/browser/mojo/mojo_shell_context.h" |
10 #include "content/public/browser/browser_context.h" | 11 #include "content/public/browser/browser_context.h" |
11 #include "content/public/browser/mojo_app_connection.h" | 12 #include "content/public/browser/mojo_app_connection.h" |
12 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
13 #include "content/public/test/content_browser_test.h" | 14 #include "content/public/test/content_browser_test.h" |
14 #include "content/public/test/test_mojo_app.h" | 15 #include "content/public/test/test_mojo_app.h" |
15 #include "content/public/test/test_mojo_service.mojom.h" | 16 #include "content/public/test/test_mojo_service.mojom.h" |
16 #include "content/shell/browser/shell.h" | 17 #include "content/shell/browser/shell.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace content { | 20 namespace content { |
20 | 21 |
21 const char kInProcessTestMojoAppName[] = "system:content_in_process_test_app"; | 22 const char kInProcessTestMojoAppName[] = "system:content_in_process_test_app"; |
22 | 23 |
23 class MojoShellTest : public ContentBrowserTest { | 24 class MojoShellTest : public ContentBrowserTest { |
24 public: | 25 public: |
25 MojoShellTest() { | 26 MojoShellTest() { |
26 test_apps_[kInProcessTestMojoAppName] = base::Bind(&CreateTestApp); | 27 test_apps_[kInProcessTestMojoAppName] = base::Bind(&CreateTestApp); |
27 MojoShellContext::SetApplicationsForTest(&test_apps_); | 28 MojoShellContext::SetApplicationsForTest(&test_apps_); |
28 } | 29 } |
29 | 30 |
30 protected: | 31 protected: |
31 std::string GetUserId() { | 32 std::string GetUserId() { |
32 return BrowserContext::GetMojoUserIdFor( | 33 return BrowserContext::GetMojoUserIdFor( |
33 shell()->web_contents()->GetBrowserContext()); | 34 shell()->web_contents()->GetBrowserContext()); |
34 } | 35 } |
35 | 36 |
36 private: | 37 private: |
37 static scoped_ptr<mojo::ShellClient> CreateTestApp() { | 38 static std::unique_ptr<mojo::ShellClient> CreateTestApp() { |
38 return scoped_ptr<mojo::ShellClient>(new TestMojoApp); | 39 return std::unique_ptr<mojo::ShellClient>(new TestMojoApp); |
39 } | 40 } |
40 | 41 |
41 MojoShellContext::StaticApplicationMap test_apps_; | 42 MojoShellContext::StaticApplicationMap test_apps_; |
42 | 43 |
43 DISALLOW_COPY_AND_ASSIGN(MojoShellTest); | 44 DISALLOW_COPY_AND_ASSIGN(MojoShellTest); |
44 }; | 45 }; |
45 | 46 |
46 IN_PROC_BROWSER_TEST_F(MojoShellTest, TestBrowserConnection) { | 47 IN_PROC_BROWSER_TEST_F(MojoShellTest, TestBrowserConnection) { |
47 auto test_app = MojoAppConnection::Create( | 48 auto test_app = MojoAppConnection::Create( |
48 GetUserId(), kInProcessTestMojoAppName, kBrowserMojoAppUrl); | 49 GetUserId(), kInProcessTestMojoAppName, kBrowserMojoAppUrl); |
(...skipping 13 matching lines...) Expand all Loading... |
62 kBrowserMojoAppUrl); | 63 kBrowserMojoAppUrl); |
63 mojom::TestMojoServicePtr test_service; | 64 mojom::TestMojoServicePtr test_service; |
64 test_app->GetInterface(&test_service); | 65 test_app->GetInterface(&test_service); |
65 | 66 |
66 base::RunLoop run_loop; | 67 base::RunLoop run_loop; |
67 test_service->DoSomething(run_loop.QuitClosure()); | 68 test_service->DoSomething(run_loop.QuitClosure()); |
68 run_loop.Run(); | 69 run_loop.Run(); |
69 } | 70 } |
70 | 71 |
71 } // namespace content | 72 } // namespace content |
OLD | NEW |