Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | package org.mozilla.gecko.tests; |
michael@0 | 2 | |
michael@0 | 3 | import java.util.ArrayList; |
michael@0 | 4 | |
michael@0 | 5 | import org.mozilla.gecko.Actions; |
michael@0 | 6 | import org.mozilla.gecko.PaintedSurface; |
michael@0 | 7 | |
michael@0 | 8 | import android.widget.CheckBox; |
michael@0 | 9 | |
michael@0 | 10 | public class testPermissions extends PixelTest { |
michael@0 | 11 | public void testPermissions() { |
michael@0 | 12 | blockForGeckoReady(); |
michael@0 | 13 | |
michael@0 | 14 | geolocationTest(); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | private void geolocationTest() { |
michael@0 | 18 | Actions.RepeatedEventExpecter paintExpecter; |
michael@0 | 19 | |
michael@0 | 20 | // Test geolocation notification |
michael@0 | 21 | loadAndPaint(getAbsoluteUrl("/robocop/robocop_geolocation.html")); |
michael@0 | 22 | waitForText("wants your location"); |
michael@0 | 23 | |
michael@0 | 24 | // Uncheck the "Don't ask again for this site" checkbox |
michael@0 | 25 | ArrayList<CheckBox> checkBoxes = mSolo.getCurrentViews(CheckBox.class); |
michael@0 | 26 | mAsserter.ok(checkBoxes.size() == 1, "checkbox count", "only one checkbox visible"); |
michael@0 | 27 | mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked"); |
michael@0 | 28 | mSolo.clickOnCheckBox(0); |
michael@0 | 29 | mAsserter.ok(!mSolo.isCheckBoxChecked(0), "checkbox not checked", "checkbox is not checked"); |
michael@0 | 30 | |
michael@0 | 31 | // Test "Share" button functionality with unchecked checkbox |
michael@0 | 32 | paintExpecter = mActions.expectPaint(); |
michael@0 | 33 | mSolo.clickOnText("Share"); |
michael@0 | 34 | PaintedSurface painted = waitForPaint(paintExpecter); |
michael@0 | 35 | paintExpecter.unregisterListener(); |
michael@0 | 36 | try { |
michael@0 | 37 | mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green"); |
michael@0 | 38 | } finally { |
michael@0 | 39 | painted.close(); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | // Re-trigger geolocation notification |
michael@0 | 43 | reloadAndPaint(); |
michael@0 | 44 | waitForText("wants your location"); |
michael@0 | 45 | |
michael@0 | 46 | // Make sure the checkbox is checked this time |
michael@0 | 47 | mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked"); |
michael@0 | 48 | |
michael@0 | 49 | // Test "Share" button functionality with checked checkbox |
michael@0 | 50 | paintExpecter = mActions.expectPaint(); |
michael@0 | 51 | mSolo.clickOnText("Share"); |
michael@0 | 52 | painted = waitForPaint(paintExpecter); |
michael@0 | 53 | paintExpecter.unregisterListener(); |
michael@0 | 54 | try { |
michael@0 | 55 | mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green"); |
michael@0 | 56 | } finally { |
michael@0 | 57 | painted.close(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | // When we reload the page, location should be automatically shared |
michael@0 | 61 | painted = reloadAndGetPainted(); |
michael@0 | 62 | try { |
michael@0 | 63 | mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green"); |
michael@0 | 64 | } finally { |
michael@0 | 65 | painted.close(); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | } |