Chromium Code Reviews| Index: base/test/android/java/src/org/chromium/base/TestSystemMessageHandler.java |
| diff --git a/base/test/android/java/src/org/chromium/base/TestSystemMessageHandler.java b/base/test/android/java/src/org/chromium/base/TestSystemMessageHandler.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b2bd45435bc9831bfbacb68cfe3c4218fcab88f7 |
| --- /dev/null |
| +++ b/base/test/android/java/src/org/chromium/base/TestSystemMessageHandler.java |
| @@ -0,0 +1,47 @@ |
| +// 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. |
| + |
| +package org.chromium.base; |
| + |
| +import android.os.Message; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| + |
| +@JNINamespace("base::android") |
| +class TestSystemMessageHandler extends SystemMessageHandler { |
|
nyquist
2016/08/18 15:50:02
Nit: Could you explain how this class is different
gsennton
2016/08/18 18:56:54
Done.
|
| + private static final String TAG = "cr.TestSysMessageHandler"; |
|
nyquist
2016/08/18 15:50:02
Nit: Is this used?
gsennton
2016/08/18 18:56:54
Nope, removed.
|
| + private long mWaitableTestEvent; |
|
nyquist
2016/08/18 15:50:02
Nit: Could this also have Native in its name to cl
gsennton
2016/08/18 18:56:54
Done.
|
| + |
| + private TestSystemMessageHandler( |
| + long messagePumpDelegateNative, long messagePumpNative, long waitableTestEvent) { |
| + super(messagePumpDelegateNative, messagePumpNative); |
| + mWaitableTestEvent = waitableTestEvent; |
| + } |
| + |
| + @Override |
| + public void handleMessage(Message msg) { |
| + try { |
| + super.handleMessage(msg); |
| + } catch (TestException e) { |
| + nativeNotifyTestDone(mWaitableTestEvent); |
| + return; |
| + } |
| + } |
| + |
| + private static class TestException extends RuntimeException { |
| + TestException(String message) { |
| + super(message); |
| + } |
| + } |
| + |
| + @CalledByNative |
| + private static TestSystemMessageHandler create( |
| + long messagePumpDelegateNative, long messagePumpNative, long waitableTestEvent) { |
| + return new TestSystemMessageHandler( |
| + messagePumpDelegateNative, messagePumpNative, waitableTestEvent); |
| + } |
| + |
| + private static native void nativeNotifyTestDone(long messagePumpNative); |
| +} |