| 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
|
|
|