Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 package org.mozilla.gecko.tests;
3 import java.util.ArrayList;
5 import org.mozilla.gecko.Actions;
6 import org.mozilla.gecko.PaintedSurface;
8 import android.widget.CheckBox;
10 public class testPermissions extends PixelTest {
11 public void testPermissions() {
12 blockForGeckoReady();
14 geolocationTest();
15 }
17 private void geolocationTest() {
18 Actions.RepeatedEventExpecter paintExpecter;
20 // Test geolocation notification
21 loadAndPaint(getAbsoluteUrl("/robocop/robocop_geolocation.html"));
22 waitForText("wants your location");
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");
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 }
42 // Re-trigger geolocation notification
43 reloadAndPaint();
44 waitForText("wants your location");
46 // Make sure the checkbox is checked this time
47 mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked");
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 }
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 }