OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stdint.h> |
| 6 #include <utility> |
| 7 |
| 8 #include "base/callback_helpers.h" |
| 9 #include "base/macros.h" |
| 10 #include "base/run_loop.h" |
| 11 #include "content/browser/utility_process_host_impl.h" |
| 12 #include "content/common/mojo_test.mojom.h" |
| 13 #include "content/public/browser/browser_thread.h" |
| 14 #include "content/public/browser/utility_process_host_client.h" |
| 15 #include "content/public/common/service_registry.h" |
| 16 #include "content/public/test/content_browser_test.h" |
| 17 |
| 18 namespace content { |
| 19 namespace { |
| 20 |
| 21 class MojoIntegrationTest : public ContentBrowserTest { |
| 22 public: |
| 23 MojoIntegrationTest() {} |
| 24 |
| 25 void SetUpOnMainThread() override { |
| 26 base::RunLoop run_loop; |
| 27 BrowserThread::PostTaskAndReply( |
| 28 BrowserThread::IO, FROM_HERE, |
| 29 base::Bind(&MojoIntegrationTest::StartUtilityProcessOnIoThread, |
| 30 base::Unretained(this)), |
| 31 run_loop.QuitClosure()); |
| 32 run_loop.Run(); |
| 33 } |
| 34 |
| 35 void TearDownOnMainThread() override { |
| 36 base::RunLoop run_loop; |
| 37 BrowserThread::PostTaskAndReply( |
| 38 BrowserThread::IO, FROM_HERE, |
| 39 base::Bind(&MojoIntegrationTest::StopUtilityProcessOnIoThread, |
| 40 base::Unretained(this)), |
| 41 run_loop.QuitClosure()); |
| 42 run_loop.Run(); |
| 43 } |
| 44 |
| 45 protected: |
| 46 scoped_ptr<UtilityProcessHostImpl> host_; |
| 47 |
| 48 private: |
| 49 void StartUtilityProcessOnIoThread() { |
| 50 host_.reset(new UtilityProcessHostImpl(nullptr, nullptr)); |
| 51 ASSERT_TRUE(host_->StartMojoMode()); |
| 52 } |
| 53 |
| 54 void StopUtilityProcessOnIoThread() { |
| 55 host_.reset(); |
| 56 } |
| 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(MojoIntegrationTest); |
| 59 }; |
| 60 |
| 61 IN_PROC_BROWSER_TEST_F(MojoIntegrationTest, SubprocessSharedBuffer) { |
| 62 mojom::MojoTestPtr client; |
| 63 host_->GetServiceRegistry()->ConnectToRemoteService(mojo::GetProxy(&client)); |
| 64 |
| 65 base::RunLoop run_loop; |
| 66 client->MakeSharedBuffer( |
| 67 1234, [&run_loop] (mojo::ScopedSharedBufferHandle buffer) { |
| 68 base::ScopedClosureRunner runner(run_loop.QuitClosure()); |
| 69 ASSERT_TRUE(buffer.is_valid()); |
| 70 }); |
| 71 run_loop.Run(); |
| 72 } |
| 73 |
| 74 } // namespace |
| 75 } // namespace content |
OLD | NEW |