michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: package org.mozilla.gecko; michael@0: import android.database.Cursor; michael@0: michael@0: public interface Actions { michael@0: michael@0: /** Special keys supported by sendSpecialKey() */ michael@0: public enum SpecialKey { michael@0: DOWN, UP, LEFT, RIGHT, ENTER, MENU, BACK michael@0: } michael@0: michael@0: public interface EventExpecter { michael@0: /** Blocks until the event has been received. Subsequent calls will return immediately. */ michael@0: public void blockForEvent(); michael@0: public void blockForEvent(long millis, boolean failOnTimeout); michael@0: michael@0: /** Blocks until the event has been received and returns data associated with the event. */ michael@0: public String blockForEventData(); michael@0: michael@0: /** michael@0: * Blocks until the event has been received, or until the timeout has been exceeded. michael@0: * Returns the data associated with the event, if applicable. michael@0: */ michael@0: public String blockForEventDataWithTimeout(long millis); michael@0: michael@0: /** Polls to see if the event has been received. Once this returns true, subsequent calls will also return true. */ michael@0: public boolean eventReceived(); michael@0: michael@0: /** Stop listening for events. */ michael@0: public void unregisterListener(); michael@0: } michael@0: michael@0: public interface RepeatedEventExpecter extends EventExpecter { michael@0: /** Blocks until at least one event has been received, and no events have been received in the last millis milliseconds. */ michael@0: public void blockUntilClear(long millis); michael@0: } michael@0: michael@0: /** michael@0: * Sends an event to Gecko. michael@0: * michael@0: * @param geckoEvent The geckoEvent JSONObject's type michael@0: */ michael@0: void sendGeckoEvent(String geckoEvent, String data); michael@0: michael@0: /** michael@0: * Sends a preferences get event to Gecko. michael@0: * michael@0: * @param requestId The id of this request. michael@0: * @param prefNames The preferences being requested. michael@0: */ michael@0: void sendPreferencesGetEvent(int requestId, String[] prefNames); michael@0: michael@0: /** michael@0: * Sends a preferences observe event to Gecko. michael@0: * michael@0: * @param requestId The id of this request. michael@0: * @param prefNames The preferences being requested. michael@0: */ michael@0: void sendPreferencesObserveEvent(int requestId, String[] prefNames); michael@0: michael@0: /** michael@0: * Sends a preferences remove observers event to Gecko. michael@0: * michael@0: * @param requestId The id of this request. michael@0: */ michael@0: void sendPreferencesRemoveObserversEvent(int requestid); michael@0: michael@0: /** michael@0: * Listens for a gecko event to be sent from the Gecko instance. michael@0: * The returned object can be used to test if the event has been michael@0: * received. Note that only one event is listened for. michael@0: * michael@0: * @param geckoEvent The geckoEvent JSONObject's type michael@0: */ michael@0: RepeatedEventExpecter expectGeckoEvent(String geckoEvent); michael@0: michael@0: /** michael@0: * Listens for a paint event. Note that calling expectPaint() will michael@0: * invalidate the event expecters returned from any previous calls michael@0: * to expectPaint(); calling any methods on those invalidated objects michael@0: * will result in undefined behaviour. michael@0: */ michael@0: RepeatedEventExpecter expectPaint(); michael@0: michael@0: /** michael@0: * Send a string to the application michael@0: * michael@0: * @param keysToSend The string to send michael@0: */ michael@0: void sendKeys(String keysToSend); michael@0: michael@0: /** michael@0: * Send a special keycode to the element michael@0: * michael@0: * @param key The special key to send michael@0: */ michael@0: void sendSpecialKey(SpecialKey key); michael@0: void sendKeyCode(int keyCode); michael@0: michael@0: void drag(int startingX, int endingX, int startingY, int endingY); michael@0: michael@0: /** michael@0: * Run a sql query on the specified database michael@0: */ michael@0: public Cursor querySql(String dbPath, String sql); michael@0: }