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