diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /mobile/android/tests/javaaddons/src | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/tests/javaaddons/src')
3 files changed, 94 insertions, 0 deletions
diff --git a/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/ClassWithNoRecognizedConstructors.java b/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/ClassWithNoRecognizedConstructors.java new file mode 100644 index 000000000..93bf5e7cd --- /dev/null +++ b/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/ClassWithNoRecognizedConstructors.java @@ -0,0 +1,11 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.javaaddons.test; + +public class ClassWithNoRecognizedConstructors { + public ClassWithNoRecognizedConstructors(int a, String b, boolean c) { + } +} diff --git a/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/JavaAddonV0.java b/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/JavaAddonV0.java new file mode 100644 index 000000000..f0ea79535 --- /dev/null +++ b/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/JavaAddonV0.java @@ -0,0 +1,24 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.javaaddons.test; + +import android.os.Handler; +import android.os.Message; +import android.util.Log; + +import java.util.Map; + +public class JavaAddonV0 implements Handler.Callback { + public JavaAddonV0(Map<String, Handler.Callback> callbacks) { + callbacks.put("JavaAddon:V0", this); + } + + @Override + public boolean handleMessage(Message message) { + Log.i("JavaAddon", "handleMessage " + message.toString()); + return true; + } +} diff --git a/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/JavaAddonV1.java b/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/JavaAddonV1.java new file mode 100644 index 000000000..803a0d740 --- /dev/null +++ b/mobile/android/tests/javaaddons/src/org/mozilla/javaaddons/test/JavaAddonV1.java @@ -0,0 +1,59 @@ +/* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +package org.mozilla.javaaddons.test; + +import android.content.Context; +import android.util.Log; +import org.json.JSONException; +import org.json.JSONObject; +import org.mozilla.javaaddons.JavaAddonInterfaceV1.EventCallback; +import org.mozilla.javaaddons.JavaAddonInterfaceV1.EventDispatcher; +import org.mozilla.javaaddons.JavaAddonInterfaceV1.EventListener; +import org.mozilla.javaaddons.JavaAddonInterfaceV1.RequestCallback; + +public class JavaAddonV1 implements EventListener, RequestCallback { + protected final EventDispatcher mDispatcher; + + public JavaAddonV1(Context context, EventDispatcher dispatcher) { + mDispatcher = dispatcher; + mDispatcher.registerEventListener(this, "JavaAddon:V1"); + } + + @Override + public void handleMessage(Context context, String event, JSONObject message, EventCallback callback) { + Log.i("JavaAddon", "handleMessage: " + event + ", " + message.toString()); + final JSONObject output = new JSONObject(); + try { + output.put("outputStringKey", "inputStringKey=" + message.getString("inputStringKey")); + output.put("outputIntKey", 1 + message.getInt("inputIntKey")); + } catch (JSONException e) { + // Should never happen; ignore. + } + // Respond. + if (callback != null) { + callback.sendSuccess(output); + } + + // And send an independent Gecko event. + final JSONObject input = new JSONObject(); + try { + input.put("inputStringKey", "raw"); + input.put("inputIntKey", 3); + } catch (JSONException e) { + // Should never happen; ignore. + } + mDispatcher.sendRequestToGecko("JavaAddon:V1:Request", input, this); + } + + @Override + public void onResponse(Context context, JSONObject jsonObject) { + Log.i("JavaAddon", "onResponse: " + jsonObject.toString()); + // Unregister event listener, so that the JavaScript side can send a test message and + // check it is not handled. + mDispatcher.unregisterEventListener(this); + mDispatcher.sendRequestToGecko("JavaAddon:V1:VerificationRequest", jsonObject, null); + } +} |