2013-11-07 08:18:51 -08:00
|
|
|
package org.mozilla.gecko.tests;
|
2012-05-16 12:00:45 -07:00
|
|
|
|
2013-11-07 08:18:51 -08:00
|
|
|
import org.mozilla.gecko.*;
|
2012-05-16 12:00:45 -07:00
|
|
|
|
|
|
|
import android.widget.CheckBox;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
public class testPermissions extends PixelTest {
|
2012-06-27 16:56:49 -07:00
|
|
|
@Override
|
|
|
|
protected int getTestType() {
|
|
|
|
return TEST_MOCHITEST;
|
|
|
|
}
|
|
|
|
|
2012-05-16 12:00:45 -07:00
|
|
|
public void testPermissions() {
|
2012-10-25 12:37:39 -07:00
|
|
|
blockForGeckoReady();
|
2012-05-16 12:00:45 -07:00
|
|
|
|
|
|
|
geolocationTest();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void geolocationTest() {
|
2013-04-18 20:18:09 -07:00
|
|
|
Actions.RepeatedEventExpecter paintExpecter;
|
|
|
|
|
2012-05-16 12:00:45 -07:00
|
|
|
// Test geolocation notification
|
2012-08-27 10:44:58 -07:00
|
|
|
loadAndPaint(getAbsoluteUrl("/robocop/robocop_geolocation.html"));
|
2013-02-27 07:21:24 -08:00
|
|
|
waitForText("wants your location");
|
2012-05-16 12:00:45 -07:00
|
|
|
|
|
|
|
// Uncheck the "Don't ask again for this site" checkbox
|
2013-04-10 23:53:15 -07:00
|
|
|
ArrayList<CheckBox> checkBoxes = mSolo.getCurrentViews(CheckBox.class);
|
2012-05-16 12:00:45 -07:00
|
|
|
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
|
2013-04-18 20:18:09 -07:00
|
|
|
paintExpecter = mActions.expectPaint();
|
2012-05-16 12:00:45 -07:00
|
|
|
mSolo.clickOnText("Share");
|
2013-04-18 20:18:09 -07:00
|
|
|
PaintedSurface painted = waitForPaint(paintExpecter);
|
|
|
|
paintExpecter.unregisterListener();
|
2012-08-27 10:44:58 -07:00
|
|
|
try {
|
|
|
|
mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
|
|
|
} finally {
|
|
|
|
painted.close();
|
|
|
|
}
|
2012-05-16 12:00:45 -07:00
|
|
|
|
|
|
|
// Re-trigger geolocation notification
|
|
|
|
reloadAndPaint();
|
2013-02-27 07:21:24 -08:00
|
|
|
waitForText("wants your location");
|
2012-05-16 12:00:45 -07:00
|
|
|
|
|
|
|
// 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
|
2013-04-18 20:18:09 -07:00
|
|
|
paintExpecter = mActions.expectPaint();
|
2012-05-16 12:00:45 -07:00
|
|
|
mSolo.clickOnText("Share");
|
2013-04-18 20:18:09 -07:00
|
|
|
painted = waitForPaint(paintExpecter);
|
|
|
|
paintExpecter.unregisterListener();
|
2012-08-27 10:44:58 -07:00
|
|
|
try {
|
|
|
|
mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
|
|
|
} finally {
|
|
|
|
painted.close();
|
|
|
|
}
|
2012-05-16 12:00:45 -07:00
|
|
|
|
|
|
|
// When we reload the page, location should be automatically shared
|
2012-08-27 10:44:58 -07:00
|
|
|
painted = reloadAndGetPainted();
|
|
|
|
try {
|
|
|
|
mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
|
|
|
} finally {
|
|
|
|
painted.close();
|
|
|
|
}
|
2012-05-16 12:00:45 -07:00
|
|
|
}
|
|
|
|
}
|