mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 06:35:42 +00:00
71 lines
2.4 KiB
Java
71 lines
2.4 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 {
|
|
private Actions.RepeatedEventExpecter mPaintExpecter;
|
|
|
|
@Override
|
|
protected int getTestType() {
|
|
return TEST_MOCHITEST;
|
|
}
|
|
|
|
public void testPermissions() {
|
|
blockForGeckoReady();
|
|
|
|
geolocationTest();
|
|
}
|
|
|
|
private void geolocationTest() {
|
|
// 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.getCurrentCheckBoxes();
|
|
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
|
|
mPaintExpecter = mActions.expectPaint();
|
|
mSolo.clickOnText("Share");
|
|
PaintedSurface painted = waitForPaint(mPaintExpecter);
|
|
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
|
|
mPaintExpecter = mActions.expectPaint();
|
|
mSolo.clickOnText("Share");
|
|
painted = waitForPaint(mPaintExpecter);
|
|
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();
|
|
}
|
|
}
|
|
}
|