diff -r 000000000000 -r 6474c204b198 mobile/android/base/tests/testPermissions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mobile/android/base/tests/testPermissions.java Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,68 @@ +package org.mozilla.gecko.tests; + +import java.util.ArrayList; + +import org.mozilla.gecko.Actions; +import org.mozilla.gecko.PaintedSurface; + +import android.widget.CheckBox; + +public class testPermissions extends PixelTest { + public void testPermissions() { + blockForGeckoReady(); + + geolocationTest(); + } + + private void geolocationTest() { + Actions.RepeatedEventExpecter paintExpecter; + + // Test geolocation notification + loadAndPaint(getAbsoluteUrl("/robocop/robocop_geolocation.html")); + waitForText("wants your location"); + + // Uncheck the "Don't ask again for this site" checkbox + ArrayList checkBoxes = mSolo.getCurrentViews(CheckBox.class); + mAsserter.ok(checkBoxes.size() == 1, "checkbox count", "only one checkbox visible"); + mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked"); + mSolo.clickOnCheckBox(0); + mAsserter.ok(!mSolo.isCheckBoxChecked(0), "checkbox not checked", "checkbox is not checked"); + + // Test "Share" button functionality with unchecked checkbox + paintExpecter = mActions.expectPaint(); + mSolo.clickOnText("Share"); + PaintedSurface painted = waitForPaint(paintExpecter); + paintExpecter.unregisterListener(); + try { + mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green"); + } finally { + painted.close(); + } + + // Re-trigger geolocation notification + reloadAndPaint(); + waitForText("wants your location"); + + // Make sure the checkbox is checked this time + mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked"); + + // Test "Share" button functionality with checked checkbox + paintExpecter = mActions.expectPaint(); + mSolo.clickOnText("Share"); + painted = waitForPaint(paintExpecter); + paintExpecter.unregisterListener(); + try { + mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green"); + } finally { + painted.close(); + } + + // When we reload the page, location should be automatically shared + painted = reloadAndGetPainted(); + try { + mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green"); + } finally { + painted.close(); + } + } +}