summaryrefslogtreecommitdiffstats
path: root/content/browser/mojo_shell_browsertest.cc
diff options
context:
space:
mode:
authorrockot <rockot@chromium.org>2015-06-04 17:30:52 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-05 00:32:18 +0000
commitb814a5850da5aa473ad526eef4b41a82b05037a0 (patch)
treed1730ed4fccfc7fda63bd51f30891a95e61ba915 /content/browser/mojo_shell_browsertest.cc
parent87c39e56c03c089751e4ae22dcea9ca7cf17c741 (diff)
downloadchromium_src-b814a5850da5aa473ad526eef4b41a82b05037a0.zip
chromium_src-b814a5850da5aa473ad526eef4b41a82b05037a0.tar.gz
chromium_src-b814a5850da5aa473ad526eef4b41a82b05037a0.tar.bz2
Embed a mojo ApplicationManager in content/browser
This embeds mojo/shell's ApplicationManager in content/browser and provides a way for arbitrary browser code to connect to Mojo apps as if the browser itself were a Mojo app. This is a basic implementation of Mojo app support which only loads static apps either in the browser process or a (per-app) utility process. Future CLs will address connection to apps from arbitrary render frames (i.e. connection requests which include the requestor's origin) as well as refactoring the utility process code further so that it serves strictly as a Mojo app runner. BUG=492422 Review URL: https://codereview.chromium.org/1149833007 Cr-Commit-Position: refs/heads/master@{#332974}
Diffstat (limited to 'content/browser/mojo_shell_browsertest.cc')
-rw-r--r--content/browser/mojo_shell_browsertest.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/content/browser/mojo_shell_browsertest.cc b/content/browser/mojo_shell_browsertest.cc
new file mode 100644
index 0000000..3dcde73
--- /dev/null
+++ b/content/browser/mojo_shell_browsertest.cc
@@ -0,0 +1,60 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/bind.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/run_loop.h"
+#include "content/browser/mojo/mojo_shell_context.h"
+#include "content/public/browser/mojo_app_connection.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/public/test/test_mojo_app.h"
+#include "content/public/test/test_mojo_service.mojom.h"
+#include "url/gurl.h"
+
+namespace content {
+
+const char kInProcessTestMojoAppUrl[] = "system:content_in_process_test_app";
+
+class MojoShellTest : public ContentBrowserTest {
+ public:
+ MojoShellTest() {
+ test_apps_[GURL(kInProcessTestMojoAppUrl)] = base::Bind(&CreateTestApp);
+ MojoShellContext::SetApplicationsForTest(&test_apps_);
+ }
+
+ private:
+ static scoped_ptr<mojo::ApplicationDelegate> CreateTestApp() {
+ return scoped_ptr<mojo::ApplicationDelegate>(new TestMojoApp);
+ }
+
+ MojoShellContext::StaticApplicationMap test_apps_;
+
+ DISALLOW_COPY_AND_ASSIGN(MojoShellTest);
+};
+
+IN_PROC_BROWSER_TEST_F(MojoShellTest, TestBrowserConnection) {
+ auto test_app = MojoAppConnection::Create(GURL(kInProcessTestMojoAppUrl));
+ TestMojoServicePtr test_service;
+ test_app->ConnectToService(&test_service);
+
+ base::RunLoop run_loop;
+ test_service->DoSomething(run_loop.QuitClosure());
+ run_loop.Run();
+}
+
+IN_PROC_BROWSER_TEST_F(MojoShellTest, TestUtilityConnection) {
+ // With no loader registered at this URL, the shell should spawn a utility
+ // process and connect us to it. content_shell's utility process always hosts
+ // a TestMojoApp at |kTestMojoAppUrl|.
+ auto test_app = MojoAppConnection::Create(GURL(kTestMojoAppUrl));
+ TestMojoServicePtr test_service;
+ test_app->ConnectToService(&test_service);
+
+ base::RunLoop run_loop;
+ test_service->DoSomething(run_loop.QuitClosure());
+ run_loop.Run();
+}
+
+} // namespace content