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

Unified Diff: mojo/android/javatests/core_test.cc

Issue 288993002: Add AsyncWaiter implementation to java API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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
Index: mojo/android/javatests/core_test.cc
diff --git a/mojo/android/javatests/core_test.cc b/mojo/android/javatests/core_test.cc
index 3d4032fc52c2b9a7e873d40cc6682f783420963b..3d9d274cdec6abc2860b03d57b19ec864b02a9f4 100644
--- a/mojo/android/javatests/core_test.cc
+++ b/mojo/android/javatests/core_test.cc
@@ -6,7 +6,21 @@
#include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h"
+#include "base/bind.h"
+#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
+#include "base/run_loop.h"
+#include "base/test/test_support_android.h"
#include "jni/CoreTest_jni.h"
+#include "mojo/public/cpp/environment/environment.h"
+
+namespace {
+
+struct TestEnvironment {
+ mojo::Environment environment;
+ base::MessageLoopForUI message_loop;
+};
+}
viettrungluu 2014/05/19 19:49:01 Nit: "// namespace" and blank line before this.
qsr 2014/05/20 07:47:18 Done.
namespace mojo {
namespace android {
@@ -16,6 +30,27 @@ static void InitApplicationContext(JNIEnv* env,
jobject context) {
base::android::ScopedJavaLocalRef<jobject> scoped_context(env, context);
base::android::InitApplicationContext(env, scoped_context);
+ base::InitAndroidTestMessageLoop();
+}
+
+static jlong SetupTestEnvironment(JNIEnv* env, jobject jcaller) {
+ return reinterpret_cast<intptr_t>(new TestEnvironment());
+}
+
+static void TearDownTestEnvironment(JNIEnv* env,
+ jobject jcaller,
+ jlong test_environment) {
+ delete reinterpret_cast<TestEnvironment*>(
viettrungluu 2014/05/19 19:49:01 Can't you just reinterpret_cast without the static
qsr 2014/05/20 07:47:18 done. Wasn't sure about reinterpret_cast on data o
+ static_cast<intptr_t>(test_environment));
+}
+
+static void RunLoop(JNIEnv* env, jobject jcaller, jlong timeout_ms) {
+ base::MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::MessageLoop::QuitClosure(),
+ base::TimeDelta::FromMilliseconds(timeout_ms));
+ base::RunLoop run_loop;
+ run_loop.Run();
}
bool RegisterCoreTest(JNIEnv* env) {

Powered by Google App Engine
This is Rietveld 408576698