2012-05-21 04:12:37 -07:00
|
|
|
/* 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/. */
|
2011-12-22 06:09:41 -08:00
|
|
|
|
2013-11-07 08:18:51 -08:00
|
|
|
package org.mozilla.gecko;
|
2011-12-22 06:09:41 -08:00
|
|
|
import java.util.List;
|
2012-03-08 10:25:44 -08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import android.database.Cursor;
|
2011-12-22 06:09:41 -08:00
|
|
|
|
|
|
|
public interface Actions {
|
2012-01-05 18:36:17 -08:00
|
|
|
|
2012-02-15 06:56:20 -08:00
|
|
|
/** Special keys supported by sendSpecialKey() */
|
|
|
|
public enum SpecialKey {
|
|
|
|
DOWN, UP, LEFT, RIGHT, ENTER, MENU, BACK
|
|
|
|
}
|
2012-01-05 18:36:17 -08:00
|
|
|
|
2012-02-15 06:56:20 -08:00
|
|
|
public interface EventExpecter {
|
|
|
|
/** Blocks until the event has been received. Subsequent calls will return immediately. */
|
|
|
|
public void blockForEvent();
|
2012-02-02 13:07:00 -08:00
|
|
|
|
2013-02-19 10:15:44 -08:00
|
|
|
/** Blocks until the event has been received and returns data associated with the event. */
|
|
|
|
public String blockForEventData();
|
|
|
|
|
2013-03-12 11:32:25 -07:00
|
|
|
/**
|
|
|
|
* Blocks until the event has been received, or until the timeout has been exceeded.
|
|
|
|
* Returns the data associated with the event, if applicable.
|
|
|
|
*/
|
|
|
|
public String blockForEventDataWithTimeout(long millis);
|
|
|
|
|
2012-02-15 06:56:20 -08:00
|
|
|
/** Polls to see if the event has been received. Once this returns true, subsequent calls will also return true. */
|
|
|
|
public boolean eventReceived();
|
2013-04-18 20:18:07 -07:00
|
|
|
|
|
|
|
/** Stop listening for events. */
|
|
|
|
public void unregisterListener();
|
2012-02-15 06:56:20 -08:00
|
|
|
}
|
2012-01-30 19:46:13 -08:00
|
|
|
|
2012-02-15 06:56:20 -08:00
|
|
|
public interface RepeatedEventExpecter extends EventExpecter {
|
|
|
|
/** Blocks until at least one event has been received, and no events have been received in the last <code>millis</code> milliseconds. */
|
|
|
|
public void blockUntilClear(long millis);
|
|
|
|
}
|
2012-01-30 19:46:13 -08:00
|
|
|
|
2012-05-25 10:04:12 -07:00
|
|
|
/**
|
|
|
|
* Sends an event to Gecko.
|
|
|
|
*
|
|
|
|
* @param geckoEvent The geckoEvent JSONObject's type
|
|
|
|
*/
|
|
|
|
void sendGeckoEvent(String geckoEvent, String data);
|
|
|
|
|
2013-09-04 06:58:32 -07:00
|
|
|
/**
|
|
|
|
* Sends a preferences get event to Gecko.
|
|
|
|
*
|
|
|
|
* @param requestId The id of this request.
|
|
|
|
* @param prefNames The preferences being requested.
|
|
|
|
*/
|
|
|
|
void sendPreferencesGetEvent(int requestId, String[] prefNames);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a preferences observe event to Gecko.
|
|
|
|
*
|
|
|
|
* @param requestId The id of this request.
|
|
|
|
* @param prefNames The preferences being requested.
|
|
|
|
*/
|
|
|
|
void sendPreferencesObserveEvent(int requestId, String[] prefNames);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends a preferences remove observers event to Gecko.
|
|
|
|
*
|
|
|
|
* @param requestId The id of this request.
|
|
|
|
*/
|
|
|
|
void sendPreferencesRemoveObserversEvent(int requestid);
|
|
|
|
|
2012-02-15 06:56:20 -08:00
|
|
|
/**
|
|
|
|
* Listens for a gecko event to be sent from the Gecko instance.
|
|
|
|
* The returned object can be used to test if the event has been
|
|
|
|
* received. Note that only one event is listened for.
|
|
|
|
*
|
|
|
|
* @param geckoEvent The geckoEvent JSONObject's type
|
|
|
|
*/
|
2012-08-10 14:59:12 -07:00
|
|
|
RepeatedEventExpecter expectGeckoEvent(String geckoEvent);
|
2011-12-22 06:09:41 -08:00
|
|
|
|
2012-02-15 06:56:20 -08:00
|
|
|
/**
|
|
|
|
* Listens for a paint event. Note that calling expectPaint() will
|
|
|
|
* invalidate the event expecters returned from any previous calls
|
|
|
|
* to expectPaint(); calling any methods on those invalidated objects
|
|
|
|
* will result in undefined behaviour.
|
|
|
|
*/
|
|
|
|
RepeatedEventExpecter expectPaint();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a string to the application
|
|
|
|
*
|
|
|
|
* @param keysToSend The string to send
|
|
|
|
*/
|
|
|
|
void sendKeys(String keysToSend);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send a special keycode to the element
|
|
|
|
*
|
|
|
|
* @param key The special key to send
|
|
|
|
*/
|
|
|
|
void sendSpecialKey(SpecialKey key);
|
2013-04-03 16:45:43 -07:00
|
|
|
void sendKeyCode(int keyCode);
|
2012-02-15 06:56:20 -08:00
|
|
|
|
|
|
|
void drag(int startingX, int endingX, int startingY, int endingY);
|
2012-03-08 10:25:44 -08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run a sql query on the specified database
|
|
|
|
*/
|
|
|
|
public Cursor querySql(String dbPath, String sql);
|
2011-12-22 06:09:41 -08:00
|
|
|
}
|