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

Unified Diff: content/browser/mojo_shell_browsertest.cc

Issue 1149833007: Embed a mojo ApplicationManager in content/browser (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: misc build fixes Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/mojo_shell_browsertest.cc
diff --git a/content/browser/mojo_shell_browsertest.cc b/content/browser/mojo_shell_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1e56707f181096c7f58e9e951086e222e7f41121
--- /dev/null
+++ b/content/browser/mojo_shell_browsertest.cc
@@ -0,0 +1,65 @@
+// 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/logging.h"
+#include "base/macros.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/run_loop.h"
+#include "content/browser/mojo_shell_context.h"
+#include "content/public/browser/mojo_app_connection.h"
+#include "content/public/common/application_registry.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"
+
+namespace content {
+
+const char kInProcessTestMojoApp[] = "system:content_in_process_test_app";
+
+class MojoShellTest : public ContentBrowserTest {
+ public:
+ MojoShellTest() {
+ MojoShellContext::SetApplicationRegistryInitializerForTesting(base::Bind(
+ &MojoShellTest::SetUpBrowserApplications, base::Unretained(this)));
+ }
+
+ protected:
+ virtual void SetUpBrowserApplications(ApplicationRegistry* registry) {
+ registry->RegisterStaticAppForURL(
+ GURL(kInProcessTestMojoApp), base::Bind(&CreateTestApp));
+ }
+
+ private:
+ static scoped_ptr<mojo::ApplicationDelegate> CreateTestApp() {
+ return scoped_ptr<mojo::ApplicationDelegate>(new TestMojoApp);
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MojoShellTest);
+};
+
+IN_PROC_BROWSER_TEST_F(MojoShellTest, TestBrowserConnection) {
+ auto test_app = MojoAppConnection::Create(GURL(kInProcessTestMojoApp));
+ 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

Powered by Google App Engine
This is Rietveld 408576698