gecko/mobile/android/base/tests/testPermissions.java.in

73 lines
2.5 KiB
Java

#filter substitution
package @ANDROID_PACKAGE_NAME@.tests;
import @ANDROID_PACKAGE_NAME@.*;
import android.widget.CheckBox;
import java.util.ArrayList;
public class testPermissions extends PixelTest {
@Override
protected int getTestType() {
return TEST_MOCHITEST;
}
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<CheckBox> 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();
}
}
}