зеркало из https://github.com/mozilla/gecko-dev.git
Bug 859563 - Explicitly unregisterListener once event expecters are no longer needed; r=cpeterson
This commit is contained in:
Родитель
f3d328634d
Коммит
8290531336
|
@ -63,6 +63,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||
if (!ret.booleanValue()) {
|
||||
geckoReadyExpector.blockForEvent();
|
||||
}
|
||||
geckoReadyExpector.unregisterListener();
|
||||
} catch (Exception e) {
|
||||
mAsserter.dumpLog("Exception in blockForGeckoReady", e);
|
||||
}
|
||||
|
@ -214,6 +215,7 @@ abstract class BaseTest extends ActivityInstrumentationTestCase2<Activity> {
|
|||
mActions.sendSpecialKey(Actions.SpecialKey.ENTER);
|
||||
// wait for screen to load
|
||||
contentEventExpecter.blockForEvent();
|
||||
contentEventExpecter.unregisterListener();
|
||||
}
|
||||
|
||||
protected final void loadUrl(String url) {
|
||||
|
|
|
@ -10,6 +10,7 @@ abstract class PixelTest extends BaseTest {
|
|||
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||
loadUrl(url);
|
||||
paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
||||
paintExpecter.unregisterListener();
|
||||
PaintedSurface p = mDriver.getPaintedSurface();
|
||||
if (p == null) {
|
||||
mAsserter.ok(p != null, "checking that painted surface loaded",
|
||||
|
@ -31,6 +32,7 @@ abstract class PixelTest extends BaseTest {
|
|||
mSolo.clickOnText("Reload");
|
||||
|
||||
paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
||||
paintExpecter.unregisterListener();
|
||||
PaintedSurface p = mDriver.getPaintedSurface();
|
||||
if (p == null) {
|
||||
mAsserter.ok(p != null, "checking that painted surface loaded",
|
||||
|
|
|
@ -56,6 +56,9 @@ public class testAboutPage extends PixelTest {
|
|||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
|
||||
tabEventExpecter.unregisterListener();
|
||||
contentEventExpecter.unregisterListener();
|
||||
|
||||
// Grab the title to make sure the about: page was loaded
|
||||
awesomebar = mDriver.findElement(getActivity(), "awesome_bar_title");
|
||||
mAsserter.isnot(awesomebar, null, "Got the awesomebar");
|
||||
|
|
|
@ -8,10 +8,6 @@ import org.json.JSONArray;
|
|||
import org.json.JSONObject;
|
||||
|
||||
public class testAddonManager extends PixelTest {
|
||||
Actions.EventExpecter tabEventExpecter;
|
||||
Actions.EventExpecter contentEventExpecter;
|
||||
String url = "about:addons";
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
return TEST_MOCHITEST;
|
||||
|
@ -24,6 +20,10 @@ public class testAddonManager extends PixelTest {
|
|||
With the Addons Manager open the test will verify that when it is opened again from the menu no new tab will be opened*/
|
||||
|
||||
public void testAddonManager() {
|
||||
Actions.EventExpecter tabEventExpecter;
|
||||
Actions.EventExpecter contentEventExpecter;
|
||||
String url = "about:addons";
|
||||
|
||||
blockForGeckoReady();
|
||||
|
||||
// Use the menu to open the Addon Manger
|
||||
|
@ -37,6 +37,9 @@ public class testAddonManager extends PixelTest {
|
|||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
|
||||
tabEventExpecter.unregisterListener();
|
||||
contentEventExpecter.unregisterListener();
|
||||
|
||||
// Verify the url
|
||||
verifyPageTitle("Add-ons");
|
||||
|
||||
|
@ -72,6 +75,7 @@ public class testAddonManager extends PixelTest {
|
|||
data = new JSONObject(eventExpecter.blockForEventData());
|
||||
requestId = data.getString("requestId");
|
||||
}
|
||||
eventExpecter.unregisterListener();
|
||||
|
||||
} catch (Exception ex) {
|
||||
mAsserter.ok(false, "exception in testAddonManager", ex.toString());
|
||||
|
@ -98,6 +102,9 @@ public class testAddonManager extends PixelTest {
|
|||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
|
||||
tabEventExpecter.unregisterListener();
|
||||
contentEventExpecter.unregisterListener();
|
||||
|
||||
// Verify tab count has increased
|
||||
verifyTabCount(2);
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ public class testAllPagesTab extends BaseTest {
|
|||
}
|
||||
mSolo.clickOnView(child);
|
||||
contentEventExpecter.blockForEvent();
|
||||
contentEventExpecter.unregisterListener();
|
||||
verifyUrl(url);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ public class testAxisLocking extends PixelTest {
|
|||
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||
meh.dragSync(20, 150, 10, 50);
|
||||
PaintedSurface painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 0, 100);
|
||||
// since checkScrollWithBoxes only checks 4 points, it may not pick up a
|
||||
|
@ -48,6 +49,7 @@ public class testAxisLocking extends PixelTest {
|
|||
}
|
||||
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 100, 200);
|
||||
} finally {
|
||||
|
|
|
@ -95,6 +95,7 @@ public class testBookmark extends PixelTest {
|
|||
mAsserter.ok(child != null, "list item can be retrieved", child != null ? child.toString() : "null!");
|
||||
mSolo.clickOnView(child);
|
||||
paintExpecter.blockUntilClear(PAINT_CLEAR_DELAY);
|
||||
paintExpecter.unregisterListener();
|
||||
|
||||
// Clean up the bookmark we created
|
||||
deleteBookmark();
|
||||
|
|
|
@ -70,6 +70,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
Actions.EventExpecter distributionSetExpecter = mActions.expectGeckoEvent("Distribution:Set:OK");
|
||||
init.invoke(null, mActivity, aPackagePath);
|
||||
distributionSetExpecter.blockForEvent();
|
||||
distributionSetExpecter.unregisterListener();
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "exception initializing distribution", e.toString());
|
||||
}
|
||||
|
@ -108,6 +109,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
data = new JSONObject(eventExpecter.blockForEventData());
|
||||
requestId = data.getString("requestId");
|
||||
}
|
||||
eventExpecter.unregisterListener();
|
||||
|
||||
JSONArray preferences = data.getJSONArray("preferences");
|
||||
for (int i = 0; i < preferences.length(); i++) {
|
||||
|
@ -140,6 +142,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
|
||||
try {
|
||||
JSONObject data = new JSONObject(eventExpecter.blockForEventData());
|
||||
eventExpecter.unregisterListener();
|
||||
JSONArray searchEngines = data.getJSONArray("searchEngines");
|
||||
boolean foundEngine = false;
|
||||
for (int i = 0; i < searchEngines.length(); i++) {
|
||||
|
@ -187,6 +190,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
data = new JSONObject(eventExpecter.blockForEventData());
|
||||
requestId = data.getString("requestId");
|
||||
}
|
||||
eventExpecter.unregisterListener();
|
||||
|
||||
} catch (Exception e) {
|
||||
mAsserter.ok(false, "exception setting test locale", e.toString());
|
||||
|
@ -220,6 +224,7 @@ public class testDistribution extends ContentProviderTest {
|
|||
data = new JSONObject(eventExpecter.blockForEventData());
|
||||
requestId = data.getString("requestId");
|
||||
}
|
||||
eventExpecter.unregisterListener();
|
||||
|
||||
JSONArray preferences = data.getJSONArray("preferences");
|
||||
for (int i = 0; i < preferences.length(); i++) {
|
||||
|
|
|
@ -26,12 +26,14 @@ public class testFindInPage extends PixelTest {
|
|||
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||
findText("Robocoop", 3); // This will be close enough to existing text to test that search finds just what it should
|
||||
PaintedSurface painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
mAsserter.ispixel(painted.getPixelAt(width,height), 255, 0, 0, "Pixel at " + String.valueOf(width) + "," + String.valueOf(height));
|
||||
|
||||
// Search that finds matches and therefor pans the page
|
||||
paintExpecter = mActions.expectPaint();
|
||||
findText("Robocop", 3);
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
mAsserter.isnotpixel(painted.getPixelAt(width,height), 255, 0, 0, "Pixel at " + String.valueOf(width) + "," + String.valueOf(height));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class testFlingCorrectness extends PixelTest {
|
|||
meh.dragSync(10, 150, 10, 50);
|
||||
meh.dragSync(10, 150, 10, 50);
|
||||
PaintedSurface painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 0, 200);
|
||||
} finally {
|
||||
|
@ -39,8 +40,10 @@ public class testFlingCorrectness extends PixelTest {
|
|||
|
||||
// now fling page downwards using a 100-pixel drag but a velocity of 15px/sec, so that
|
||||
// we scroll the full 200 pixels back to the top of the page
|
||||
paintExpecter = mActions.expectPaint();
|
||||
meh.flingSync(10, 50, 10, 150, 15);
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 0, 0);
|
||||
} finally {
|
||||
|
|
|
@ -66,6 +66,7 @@ public class testHistory extends PixelTest {
|
|||
mAsserter.isnot(mFirstChild, null, "Got history item");
|
||||
mSolo.clickOnView(mFirstChild);
|
||||
contentEventExpecter.blockForEvent();
|
||||
contentEventExpecter.unregisterListener();
|
||||
verifyUrl(url3);
|
||||
}
|
||||
|
||||
|
|
|
@ -227,6 +227,7 @@ public class testHistoryTab extends PixelTest {
|
|||
} else {
|
||||
mAsserter.ok(false, "waiting for history item", "history item available");
|
||||
}
|
||||
contentEventExpecter.unregisterListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,6 +32,7 @@ public class testOverscroll extends PixelTest {
|
|||
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||
meh.dragSync(10, 50, 10, 150);
|
||||
PaintedSurface painted = waitWithNoPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 0, 0);
|
||||
} finally {
|
||||
|
@ -42,6 +43,7 @@ public class testOverscroll extends PixelTest {
|
|||
paintExpecter = mActions.expectPaint();
|
||||
meh.dragSync(50, 10, 150, 10);
|
||||
painted = waitWithNoPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 0, 0);
|
||||
} finally {
|
||||
|
|
|
@ -29,6 +29,7 @@ public class testPanCorrectness extends PixelTest {
|
|||
Actions.RepeatedEventExpecter paintExpecter = mActions.expectPaint();
|
||||
meh.dragSync(10, 150, 10, 50);
|
||||
PaintedSurface painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 0, 100);
|
||||
} finally {
|
||||
|
@ -39,6 +40,7 @@ public class testPanCorrectness extends PixelTest {
|
|||
paintExpecter = mActions.expectPaint();
|
||||
meh.dragSync(150, 10, 50, 10);
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
checkScrollWithBoxes(painted, 100, 100);
|
||||
} finally {
|
||||
|
|
|
@ -7,8 +7,6 @@ import android.widget.CheckBox;
|
|||
import java.util.ArrayList;
|
||||
|
||||
public class testPermissions extends PixelTest {
|
||||
private Actions.RepeatedEventExpecter mPaintExpecter;
|
||||
|
||||
@Override
|
||||
protected int getTestType() {
|
||||
return TEST_MOCHITEST;
|
||||
|
@ -21,6 +19,8 @@ public class testPermissions extends PixelTest {
|
|||
}
|
||||
|
||||
private void geolocationTest() {
|
||||
Actions.RepeatedEventExpecter paintExpecter;
|
||||
|
||||
// Test geolocation notification
|
||||
loadAndPaint(getAbsoluteUrl("/robocop/robocop_geolocation.html"));
|
||||
waitForText("wants your location");
|
||||
|
@ -33,9 +33,10 @@ public class testPermissions extends PixelTest {
|
|||
mAsserter.ok(!mSolo.isCheckBoxChecked(0), "checkbox not checked", "checkbox is not checked");
|
||||
|
||||
// Test "Share" button functionality with unchecked checkbox
|
||||
mPaintExpecter = mActions.expectPaint();
|
||||
paintExpecter = mActions.expectPaint();
|
||||
mSolo.clickOnText("Share");
|
||||
PaintedSurface painted = waitForPaint(mPaintExpecter);
|
||||
PaintedSurface painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
||||
} finally {
|
||||
|
@ -50,9 +51,10 @@ public class testPermissions extends PixelTest {
|
|||
mAsserter.ok(mSolo.isCheckBoxChecked(0), "checkbox checked", "checkbox is checked");
|
||||
|
||||
// Test "Share" button functionality with checked checkbox
|
||||
mPaintExpecter = mActions.expectPaint();
|
||||
paintExpecter = mActions.expectPaint();
|
||||
mSolo.clickOnText("Share");
|
||||
painted = waitForPaint(mPaintExpecter);
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
mAsserter.ispixel(painted.getPixelAt(10, 10), 0, 0x80, 0, "checking page background is green");
|
||||
} finally {
|
||||
|
|
|
@ -116,6 +116,7 @@ public class testPrefsObserver extends BaseTest {
|
|||
// will do nothing.
|
||||
removePrefObserver();
|
||||
}
|
||||
mExpecter.unregisterListener();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@ public class testSearchSuggestions extends BaseTest {
|
|||
Actions.EventExpecter enginesEventExpecter = mActions.expectGeckoEvent("SearchEngines:Data");
|
||||
final Activity awesomeBarActivity = clickOnAwesomeBar();
|
||||
enginesEventExpecter.blockForEvent();
|
||||
enginesEventExpecter.unregisterListener();
|
||||
connectSuggestClient(awesomeBarActivity);
|
||||
|
||||
for (int i = 0; i < TEST_QUERY.length(); i++) {
|
||||
|
|
|
@ -73,6 +73,8 @@ public class testSystemPages extends PixelTest {
|
|||
// Wait for the new tab and page to load
|
||||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
tabEventExpecter.unregisterListener();
|
||||
contentEventExpecter.unregisterListener();
|
||||
|
||||
verifyTabCount(expectedTabCount);
|
||||
verifyUrl(expectedUrls[i]);
|
||||
|
@ -84,6 +86,7 @@ public class testSystemPages extends PixelTest {
|
|||
paintExpecter = mActions.expectPaint(); // Set up listener to catch the page load
|
||||
mSolo.clickOnText("About");
|
||||
waitForPaint(paintExpecter); // Waiting for the page to load
|
||||
paintExpecter.unregisterListener();
|
||||
|
||||
expectedTabCount--; // Decreasing since we don't expect this in a new tab
|
||||
verifyTabCount(expectedTabCount);
|
||||
|
|
|
@ -41,6 +41,7 @@ public class testVkbOverlap extends PixelTest {
|
|||
int greenPixelCount = 0;
|
||||
|
||||
PaintedSurface painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
try {
|
||||
greenPixelCount = countGreenPixels(painted);
|
||||
} finally {
|
||||
|
@ -66,6 +67,7 @@ public class testVkbOverlap extends PixelTest {
|
|||
// now that the focus is in the text field we will repaint every 500ms as the cursor blinks, so we need to use a smaller
|
||||
// "no paints" threshold to consider the page painted
|
||||
paintExpecter.blockUntilClear(LESS_THAN_CURSOR_BLINK_PERIOD);
|
||||
paintExpecter.unregisterListener();
|
||||
painted = mDriver.getPaintedSurface();
|
||||
try {
|
||||
// if the vkb scrolled into view as expected, then the number of green pixels now visible should be about the
|
||||
|
|
|
@ -64,6 +64,8 @@ public class testWebContentContextMenu extends PixelTest {
|
|||
// Wait for the new tab and page to load
|
||||
tabEventExpecter.blockForEvent();
|
||||
contentEventExpecter.blockForEvent();
|
||||
tabEventExpecter.unregisterListener();
|
||||
contentEventExpecter.unregisterListener();
|
||||
|
||||
// See tab count
|
||||
Element tabCount = mDriver.findElement(getActivity(), "tabs_count");
|
||||
|
|
|
@ -42,6 +42,7 @@ public class test_bug720538 extends PixelTest {
|
|||
MotionEventHelper meh = new MotionEventHelper(getInstrumentation(), mDriver.getGeckoLeft(), mDriver.getGeckoTop());
|
||||
meh.doubleTap(100, 100);
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
|
||||
try {
|
||||
// check a few points to ensure that we did a good zoom-to-block on the iframe. this checks that
|
||||
|
@ -59,6 +60,7 @@ public class test_bug720538 extends PixelTest {
|
|||
paintExpecter = mActions.expectPaint();
|
||||
meh.doubleTap(100, mDriver.getGeckoWidth() / 2);
|
||||
painted = waitForPaint(paintExpecter);
|
||||
paintExpecter.unregisterListener();
|
||||
|
||||
try {
|
||||
// and now we check a pixel at the bottom of the view to ensure that we have the page
|
||||
|
|
Загрузка…
Ссылка в новой задаче