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

Unified Diff: mojo/edk/embedder/embedder_test_util.cc

Issue 728783003: Add infrastructure to run tests on android. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Use file_hash Created 6 years, 1 month 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: 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

Powered by Google App Engine
This is Rietveld 408576698