mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1162531 - Add test for add-ons in distributions. r=rnewman
This commit is contained in:
parent
92089cac92
commit
15069d2583
Binary file not shown.
@ -53,6 +53,8 @@ import android.util.Log;
|
||||
* locales/
|
||||
* en-US/
|
||||
* suggestedsites.json
|
||||
* extensions/
|
||||
* distribution.test@mozilla.org.xpi
|
||||
*/
|
||||
public class testDistribution extends ContentProviderTest {
|
||||
private static final String CLASS_REFERRER_RECEIVER = "org.mozilla.gecko.distribution.ReferrerReceiver";
|
||||
@ -152,6 +154,7 @@ public class testDistribution extends ContentProviderTest {
|
||||
checkPreferences();
|
||||
checkLocalizedPreferences("en-US");
|
||||
checkSearchPlugin();
|
||||
checkAddon();
|
||||
|
||||
// Pre-clear distribution pref, and run es-MX localized preferences Test
|
||||
clearDistributionPref();
|
||||
@ -303,20 +306,7 @@ public class testDistribution extends ContentProviderTest {
|
||||
prefTestString,
|
||||
prefTestInt };
|
||||
|
||||
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
|
||||
mActions.sendPreferencesGetEvent(PREF_REQUEST_ID, prefNames);
|
||||
|
||||
JSONObject data = null;
|
||||
int requestId = -1;
|
||||
|
||||
// Wait until we get the correct "Preferences:Data" event
|
||||
while (requestId != PREF_REQUEST_ID) {
|
||||
data = new JSONObject(eventExpecter.blockForEventData());
|
||||
requestId = data.getInt("requestId");
|
||||
}
|
||||
eventExpecter.unregisterListener();
|
||||
|
||||
JSONArray preferences = data.getJSONArray("preferences");
|
||||
final JSONArray preferences = getPrefs(prefNames);
|
||||
for (int i = 0; i < preferences.length(); i++) {
|
||||
JSONObject pref = (JSONObject) preferences.get(i);
|
||||
String name = pref.getString("name");
|
||||
@ -364,6 +354,34 @@ public class testDistribution extends ContentProviderTest {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAddon() {
|
||||
try {
|
||||
final String[] prefNames = { "distribution.test.addonEnabled" };
|
||||
final JSONArray preferences = getPrefs(prefNames);
|
||||
final JSONObject pref = (JSONObject) preferences.get(0);
|
||||
mAsserter.is(pref.getBoolean("value"), true, "check distribution add-on is enabled");
|
||||
} catch (JSONException e) {
|
||||
mAsserter.ok(false, "exception getting preferences", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private JSONArray getPrefs(String[] prefNames) throws JSONException {
|
||||
Actions.RepeatedEventExpecter eventExpecter = mActions.expectGeckoEvent("Preferences:Data");
|
||||
mActions.sendPreferencesGetEvent(PREF_REQUEST_ID, prefNames);
|
||||
|
||||
JSONObject data = null;
|
||||
int requestId = -1;
|
||||
|
||||
// Wait until we get the correct "Preferences:Data" event
|
||||
while (requestId != PREF_REQUEST_ID) {
|
||||
data = new JSONObject(eventExpecter.blockForEventData());
|
||||
requestId = data.getInt("requestId");
|
||||
}
|
||||
eventExpecter.unregisterListener();
|
||||
|
||||
return data.getJSONArray("preferences");
|
||||
}
|
||||
|
||||
// Sets the distribution locale preference for the test.
|
||||
private void setTestLocale(String locale) {
|
||||
BrowserLocaleManager.getInstance().setSelectedLocale(mActivity, locale);
|
||||
|
Loading…
Reference in New Issue
Block a user