public void clearPrivateData() { selectSettingsItem(StringHelper.PRIVACY_SECTION_LABEL, StringHelper.CLEAR_PRIVATE_DATA_LABEL); Actions.EventExpecter clearData = mActions.expectGeckoEvent("Sanitize:Finished"); mSolo.clickOnText("Clear data"); clearData.blockForEvent(); clearData.unregisterListener(); }
protected final void hitEnterAndWait() { Actions.EventExpecter contentEventExpecter = mActions.expectGeckoEvent("DOMContentLoaded"); mActions.sendSpecialKey(Actions.SpecialKey.ENTER); // wait for screen to load contentEventExpecter.blockForEvent(); contentEventExpecter.unregisterListener(); }
protected void blockForGeckoReady() { try { Actions.EventExpecter geckoReadyExpector = mActions.expectGeckoEvent("Gecko:Ready"); if (!GeckoThread.checkLaunchState(LaunchState.GeckoRunning)) { geckoReadyExpector.blockForEvent(GECKO_READY_WAIT_MS, true); } geckoReadyExpector.unregisterListener(); } catch (Exception e) { mAsserter.dumpLog("Exception in blockForGeckoReady", e); } }
public void back() { Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow"); if (devType.equals("tablet")) { Element backBtn = mDriver.findElement(getActivity(), R.id.back); backBtn.click(); } else { mActions.sendSpecialKey(Actions.SpecialKey.BACK); } pageShowExpecter.blockForEvent(); pageShowExpecter.unregisterListener(); }
public void testSelectionHandler() { GeckoHelper.blockForReady(); Actions.EventExpecter robocopTestExpecter = getActions().expectGeckoEvent("Robocop:testSelectionHandler"); NavigationHelper.enterAndLoadUrl("chrome://roboextender/content/testSelectionHandler.html"); mToolbar.assertTitle(StringHelper.ROBOCOP_SELECTION_HANDLER_TITLE); while (!test(robocopTestExpecter)) { // do nothing } robocopTestExpecter.unregisterListener(); }
protected void doTestJavascript() throws Exception { // We want to be waiting for Robocop messages before the page is loaded // because the test harness runs each test in the suite (and possibly // completes testing) before the page load event is fired. final Actions.EventExpecter expecter = mActions.expectGeckoEvent(EVENT_TYPE); mAsserter.dumpLog("Registered listener for " + EVENT_TYPE); final String url = getAbsoluteUrl(StringHelper.getHarnessUrlForJavascript(javascriptUrl)); mAsserter.dumpLog("Loading JavaScript test from " + url); loadUrl(url); final JavascriptMessageParser testMessageParser = new JavascriptMessageParser(mAsserter, false); try { while (!testMessageParser.isTestFinished()) { if (logVerbose) { Log.v(LOGTAG, "Waiting for " + EVENT_TYPE); } String data = expecter.blockForEventData(); if (logVerbose) { Log.v(LOGTAG, "Got event with data '" + data + "'"); } JSONObject o = new JSONObject(data); String innerType = o.getString("innerType"); if (!"progress".equals(innerType)) { throw new Exception("Unexpected event innerType " + innerType); } String message = o.getString("message"); if (message == null) { throw new Exception("Progress message must not be null"); } testMessageParser.logMessage(message); } if (logDebug) { Log.d(LOGTAG, "Got test finished message"); } } finally { expecter.unregisterListener(); mAsserter.dumpLog("Unregistered listener for " + EVENT_TYPE); } }
public void forward() { Actions.EventExpecter pageShowExpecter = mActions.expectGeckoEvent("Content:PageShow"); if (devType.equals("tablet")) { Element fwdBtn = mDriver.findElement(getActivity(), R.id.forward); fwdBtn.click(); } else { mActions.sendSpecialKey(Actions.SpecialKey.MENU); waitForText("^New Tab$"); if (!osVersion.equals("2.x")) { Element fwdBtn = mDriver.findElement(getActivity(), R.id.forward); fwdBtn.click(); } else { mSolo.clickOnText("^Forward$"); } ensureMenuClosed(); } pageShowExpecter.blockForEvent(); pageShowExpecter.unregisterListener(); }
private boolean test(Actions.EventExpecter expecter) { final JSONObject eventData; try { eventData = new JSONObject(expecter.blockForEventData()); } catch (Exception ex) { // Log and ignore getAsserter().ok(false, "JS Test", "Error decoding data " + ex); return false; } if (eventData.has("result")) { getAsserter().ok(eventData.optBoolean("result"), "JS Test", eventData.optString("msg")); } EventDispatcher.sendResponse(eventData, new JSONObject()); return eventData.optBoolean("done", false); }