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

Unified Diff: content/browser/mojo_integration_browsertest.cc

Issue 1799923003: Add an end-to-end test that excercises Mojo with a sandbox. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « no previous file | content/common/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/mojo_integration_browsertest.cc
diff --git a/content/browser/mojo_integration_browsertest.cc b/content/browser/mojo_integration_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cda7900f3333dc108f275de940067c49651dd6ab
--- /dev/null
+++ b/content/browser/mojo_integration_browsertest.cc
@@ -0,0 +1,75 @@
+// Copyright 2016 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 <stdint.h>
+#include <utility>
+
+#include "base/callback_helpers.h"
+#include "base/macros.h"
+#include "base/run_loop.h"
+#include "content/browser/utility_process_host_impl.h"
+#include "content/common/mojo_test.mojom.h"
+#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/utility_process_host_client.h"
+#include "content/public/common/service_registry.h"
+#include "content/public/test/content_browser_test.h"
+
+namespace content {
+namespace {
+
+class MojoIntegrationTest : public ContentBrowserTest {
+ public:
+ MojoIntegrationTest() {}
+
+ void SetUpOnMainThread() override {
+ base::RunLoop run_loop;
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&MojoIntegrationTest::StartUtilityProcessOnIoThread,
+ base::Unretained(this)),
+ run_loop.QuitClosure());
+ run_loop.Run();
+ }
+
+ void TearDownOnMainThread() override {
+ base::RunLoop run_loop;
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::IO, FROM_HERE,
+ base::Bind(&MojoIntegrationTest::StopUtilityProcessOnIoThread,
+ base::Unretained(this)),
+ run_loop.QuitClosure());
+ run_loop.Run();
+ }
+
+ protected:
+ scoped_ptr<UtilityProcessHostImpl> host_;
+
+ private:
+ void StartUtilityProcessOnIoThread() {
+ host_.reset(new UtilityProcessHostImpl(nullptr, nullptr));
+ ASSERT_TRUE(host_->StartMojoMode());
+ }
+
+ void StopUtilityProcessOnIoThread() {
+ host_.reset();
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MojoIntegrationTest);
+};
+
+IN_PROC_BROWSER_TEST_F(MojoIntegrationTest, SubprocessSharedBuffer) {
+ mojom::MojoTestPtr client;
+ host_->GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&client));
+
+ base::RunLoop run_loop;
+ client->MakeSharedBuffer(
+ 1234, [&run_loop] (mojo::ScopedSharedBufferHandle buffer) {
+ base::ScopedClosureRunner runner(run_loop.QuitClosure());
+ ASSERT_TRUE(buffer.is_valid());
+ });
+ run_loop.Run();
+}
+
+} // namespace
+} // namespace content
« no previous file with comments | « no previous file | content/common/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698