| Index: mojo/edk/embedder/embedder_test_util.cc
|
| diff --git a/mojo/edk/embedder/embedder_test_util.cc b/mojo/edk/embedder/embedder_test_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ba7a8e06102f30d891b87fecbaab5c3c94c01dda
|
| --- /dev/null
|
| +++ b/mojo/edk/embedder/embedder_test_util.cc
|
| @@ -0,0 +1,52 @@
|
| +// Copyright 2014 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 "mojo/edk/embedder/embedder_test_util.h"
|
| +
|
| +#include "base/bind.h"
|
| +#include "mojo/edk/embedder/embedder.h"
|
| +
|
| +namespace mojo {
|
| +namespace embedder {
|
| +
|
| +ScopedTestChannel::ScopedTestChannel(
|
| + scoped_refptr<base::TaskRunner> io_thread_task_runner,
|
| + ScopedPlatformHandle platform_handle)
|
| + : io_thread_task_runner_(io_thread_task_runner),
|
| + bootstrap_message_pipe_(MOJO_HANDLE_INVALID),
|
| + did_create_channel_event_(true, false),
|
| + channel_info_(nullptr) {
|
| + bootstrap_message_pipe_ =
|
| + CreateChannel(platform_handle.Pass(), io_thread_task_runner_,
|
| + base::Bind(&ScopedTestChannel::DidCreateChannel,
|
| + base::Unretained(this)),
|
| + nullptr)
|
| + .release()
|
| + .value();
|
| + CHECK_NE(bootstrap_message_pipe_, MOJO_HANDLE_INVALID);
|
| +}
|
| +
|
| +ScopedTestChannel::~ScopedTestChannel() {
|
| + DestroyChannel(channel_info_);
|
| +}
|
| +
|
| +void ScopedTestChannel::WaitForChannelCreationCompletion() {
|
| + did_create_channel_event_.Wait();
|
| +}
|
| +
|
| +void ScopedTestChannel::DidCreateChannel(ChannelInfo* channel_info) {
|
| + CHECK(channel_info);
|
| + CHECK(!channel_info_);
|
| + channel_info_ = channel_info;
|
| + did_create_channel_event_.Signal();
|
| +}
|
| +
|
| +EmbedderTest::EmbedderTest() : test_io_thread_(base::TestIOThread::kAutoStart) {
|
| +}
|
| +
|
| +EmbedderTest::~EmbedderTest() {
|
| +}
|
| +
|
| +} // namespace embedder
|
| +} // namespace mojo
|
|
|