Bug 1045209 - Updating tests for new OpenH264 plugin path handling. r=unfocused,ted,jmaher

This commit is contained in:
Qeole 2014-08-25 17:23:34 +02:00
parent 506e1ad07a
commit 9d1f222db8
7 changed files with 41 additions and 52 deletions

View File

@ -4,7 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
INSTALL_TARGETS += FAKE_GMP_PLUGIN
FAKE_GMP_PLUGIN_DEST = $(DEPTH)/dist/bin/gmp-fake
FAKE_GMP_PLUGIN_DEST = $(DEPTH)/dist/bin/gmp-fake/1.0
FAKE_GMP_PLUGIN_FILES = \
$(SHARED_LIBRARY) \
$(srcdir)/fake.info

View File

@ -176,7 +176,7 @@ $(_DEST_DIR):
$(NSINSTALL) -D $@
stage-package:
$(NSINSTALL) -D $(PKG_STAGE)/mochitest && $(NSINSTALL) -D $(PKG_STAGE)/bin/plugins && $(NSINSTALL) -D $(DIST)/plugins && $(NSINSTALL) -D $(PKG_STAGE)/bin/plugins/gmp-fake
$(NSINSTALL) -D $(PKG_STAGE)/mochitest && $(NSINSTALL) -D $(PKG_STAGE)/bin/plugins && $(NSINSTALL) -D $(DIST)/plugins && $(NSINSTALL) -D $(PKG_STAGE)/bin/plugins/gmp-fake/1.0
cp $(DEPTH)/mozinfo.json $(PKG_STAGE)/mochitest
(cd $(DEPTH)/_tests/testing && tar $(TAR_CREATE_FLAGS) - mochitest) | (cd $(PKG_STAGE) && tar -xf -)
@cp $(DEPTH)/mozinfo.json $(PKG_STAGE)/mochitest
@ -184,4 +184,4 @@ stage-package:
@(cd $(DIST_BIN)/components && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_COMPONENTS)) | (cd $(PKG_STAGE)/bin/components && tar -xf -)
(cd $(topsrcdir)/build/pgo && tar $(TAR_CREATE_FLAGS) - certs) | (cd $(PKG_STAGE) && tar -xf -)
@(cd $(DIST)/plugins && tar $(TAR_CREATE_FLAGS) - $(TEST_HARNESS_PLUGINS)) | (cd $(PKG_STAGE)/bin/plugins && tar -xf -)
$(foreach x,$(GMP_TEST_FILES),cp $(x) $(PKG_STAGE)/bin/plugins/gmp-fake;)
$(foreach x,$(GMP_TEST_FILES),cp $(x) $(PKG_STAGE)/bin/plugins/gmp-fake/1.0;)

View File

@ -363,7 +363,7 @@ class MochitestRunner(MozbuildObject):
if options.gmp_path is None:
# Need to fix the location of gmp_fake which might not be shipped in the binary
bin_path = self.get_binary_path()
options.gmp_path = os.path.join(os.path.dirname(bin_path), 'gmp-fake')
options.gmp_path = os.path.join(os.path.dirname(bin_path), 'gmp-fake', '1.0')
logger_options = {key: value for key, value in vars(options).iteritems() if key.startswith('log')}

View File

@ -1166,12 +1166,12 @@ class Mochitest(MochitestUtilsMixin):
return options.gmp_path
# For local builds, gmp-fake will be under dist/bin.
gmp_path = os.path.join(options.xrePath, 'gmp-fake')
gmp_path = os.path.join(options.xrePath, 'gmp-fake', '1.0')
if os.path.isdir(gmp_path):
return gmp_path
# For packaged builds, gmp-fake will get copied under $profile/plugins.
gmp_path = os.path.join(self.profile.profile, 'plugins', 'gmp-fake')
gmp_path = os.path.join(self.profile.profile, 'plugins', 'gmp-fake', '1.0')
if os.path.isdir(gmp_path):
return gmp_path
# This is fatal for desktop environments.

View File

@ -29,11 +29,9 @@ add_test(function test_prefs() {
GMPPrefs.set(GMPPrefs.KEY_URL, "http://not-really-used");
GMPPrefs.set(GMPPrefs.KEY_URL_OVERRIDE, "http://not-really-used-2");
GMPPrefs.set(GMPPrefs.KEY_ADDON_LAST_UPDATE, "1", addon1);
GMPPrefs.set(GMPPrefs.KEY_ADDON_PATH, "2", addon1);
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, "3", addon1);
GMPPrefs.set(GMPPrefs.KEY_ADDON_LAST_UPDATE, "4", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_PATH, "5", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, "6", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, "2", addon1);
GMPPrefs.set(GMPPrefs.KEY_ADDON_LAST_UPDATE, "3", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_VERSION, "4", addon2);
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, false, addon2);
GMPPrefs.set(GMPPrefs.KEY_CERT_CHECKATTRS, true);
@ -41,11 +39,9 @@ add_test(function test_prefs() {
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL), "http://not-really-used");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_URL_OVERRIDE), "http://not-really-used-2");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, addon1), "1");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_PATH, addon1), "2");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, addon1), "3");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, addon2), "4");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_PATH, addon2), "5");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, addon2), "6");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, addon1), "2");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE, addon2), "3");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, addon2), "4");
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_AUTOUPDATE, addon2), false);
do_check_true(GMPPrefs.get(GMPPrefs.KEY_CERT_CHECKATTRS));
GMPPrefs.set(GMPPrefs.KEY_ADDON_AUTOUPDATE, true, addon2);
@ -435,7 +431,7 @@ function test_checkForAddons_installAddon(id, includeSize,wantInstallReject) {
let readData = readStringFromFile(extractedFile);
do_check_eq(readData, data);
// Check that the downloaded zip mathces the offered zip exactly
// Check that the downloaded zip matches the offered zip exactly
let downloadedGMPFile = FileUtils.getFile("TmpD",
[gmpAddon.id + ".zip"]);
do_check_true(downloadedGMPFile.exists());
@ -446,8 +442,6 @@ function test_checkForAddons_installAddon(id, includeSize,wantInstallReject) {
// Make sure the prefs are set correctly
do_check_true(!!GMPPrefs.get(GMPPrefs.KEY_ADDON_LAST_UPDATE,
gmpAddon.id, ""));
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_PATH, gmpAddon.id, ""),
extractedFile.parent.path);
do_check_eq(GMPPrefs.get(GMPPrefs.KEY_ADDON_VERSION, gmpAddon.id, ""),
"1.1");
// Make sure it reports as being installed

View File

@ -11,7 +11,6 @@ let OpenH264Scope = Cu.import("resource://gre/modules/addons/OpenH264Provider.js
const OPENH264_PLUGIN_ID = "gmp-gmpopenh264";
const OPENH264_PREF_BRANCH = "media." + OPENH264_PLUGIN_ID + ".";
const OPENH264_PREF_ENABLED = OPENH264_PREF_BRANCH + "enabled";
const OPENH264_PREF_PATH = OPENH264_PREF_BRANCH + "path";
const OPENH264_PREF_VERSION = OPENH264_PREF_BRANCH + "version";
const OPENH264_PREF_LASTUPDATE = OPENH264_PREF_BRANCH + "lastUpdate";
const OPENH264_PREF_AUTOUPDATE = OPENH264_PREF_BRANCH + "autoupdate";
@ -99,7 +98,6 @@ add_task(function* initializeState() {
Services.obs.removeObserver(gOptionsObserver, AddonManager.OPTIONS_NOTIFICATION_DISPLAYED);
Services.prefs.clearUserPref(OPENH264_PREF_ENABLED);
Services.prefs.clearUserPref(OPENH264_PREF_PATH);
Services.prefs.clearUserPref(OPENH264_PREF_VERSION);
Services.prefs.clearUserPref(OPENH264_PREF_LASTUPDATE);
Services.prefs.clearUserPref(OPENH264_PREF_AUTOUPDATE);
@ -116,10 +114,9 @@ add_task(function* initializeState() {
// Start out with OpenH264 not being installed, disabled and automatic updates disabled.
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "");
Services.prefs.setCharPref(OPENH264_PREF_LASTUPDATE, "");
Services.prefs.setIntPref (OPENH264_PREF_LASTUPDATE, 0);
Services.prefs.setBoolPref(OPENH264_PREF_AUTOUPDATE, false);
Services.prefs.setCharPref(OPENH264_PREF_PATH, "");
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "");
});
add_task(function* testNotInstalled() {
@ -162,10 +159,9 @@ add_task(function* testNotInstalledDetails() {
add_task(function* testInstalled() {
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, true);
Services.prefs.setBoolPref(OPENH264_PREF_VERSION, "1.2.3.4");
Services.prefs.setBoolPref(OPENH264_PREF_LASTUPDATE, "" + TEST_DATE.getTime());
Services.prefs.setIntPref (OPENH264_PREF_LASTUPDATE, TEST_DATE.getTime());
Services.prefs.setBoolPref(OPENH264_PREF_AUTOUPDATE, false);
Services.prefs.setCharPref(OPENH264_PREF_PATH, "foo/bar");
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "1.2.3.4");
yield gCategoryUtilities.openType("plugin");
@ -204,20 +200,17 @@ add_task(function* testInstalledDetails() {
});
add_task(function* testPreferencesButton() {
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
file.append("openh264");
file.append("testDir");
let prefValues = [
{ enabled: false, path: "" },
{ enabled: false, path: file.path },
{ enabled: true, path: "" },
{ enabled: true, path: file.path },
{ enabled: false, version: "" },
{ enabled: false, version: "1.2.3.4" },
{ enabled: true, version: "" },
{ enabled: true, version: "1.2.3.4" },
];
for (let prefs of prefValues) {
dump("Testing preferences button with pref settings: " + JSON.stringify(prefs) + "\n");
Services.prefs.setCharPref(OPENH264_PREF_PATH, prefs.path);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, prefs.version);
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, prefs.enabled);
yield gCategoryUtilities.openType("plugin");

View File

@ -8,7 +8,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
const OPENH264_PLUGIN_ID = "gmp-gmpopenh264";
const OPENH264_PREF_BRANCH = "media." + OPENH264_PLUGIN_ID + ".";
const OPENH264_PREF_ENABLED = OPENH264_PREF_BRANCH + "enabled";
const OPENH264_PREF_PATH = OPENH264_PREF_BRANCH + "path";
const OPENH264_PREF_VERSION = OPENH264_PREF_BRANCH + "version";
const OPENH264_PREF_LASTUPDATE = OPENH264_PREF_BRANCH + "lastUpdate";
const OPENH264_PREF_AUTOUPDATE = OPENH264_PREF_BRANCH + "autoupdate";
@ -55,7 +54,7 @@ function run_test() {
}
add_task(function* test_notInstalled() {
Services.prefs.setCharPref(OPENH264_PREF_PATH, "");
Services.prefs.setCharPref(OPENH264_PREF_VERSION, "");
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
@ -106,13 +105,12 @@ add_task(function* test_installed() {
const TEST_TIME_SEC = Math.round(TEST_DATE.getTime() / 1000);
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
file.append("openh264");
file.append("testDir");
file.append(OPENH264_PLUGIN_ID);
file.append(TEST_VERSION);
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
Services.prefs.setCharPref(OPENH264_PREF_LASTUPDATE, "" + TEST_TIME_SEC);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
Services.prefs.setCharPref(OPENH264_PREF_PATH, file.path);
let addons = yield promiseAddonsByIDs([OPENH264_PLUGIN_ID]);
Assert.equal(addons.length, 1);
@ -139,7 +137,7 @@ add_task(function* test_installed() {
let libraries = addon.pluginLibraries;
Assert.ok(libraries);
Assert.equal(libraries.length, 1);
Assert.equal(libraries[0], "testDir");
Assert.equal(libraries[0], TEST_VERSION);
let fullpath = addon.pluginFullpath;
Assert.equal(fullpath.length, 1);
Assert.equal(fullpath[0], file.path);
@ -179,9 +177,11 @@ add_task(function* test_autoUpdatePrefPersistance() {
});
add_task(function* test_pluginRegistration() {
const TEST_VERSION = "1.2.3.4";
let file = Services.dirsvc.get("ProfD", Ci.nsIFile);
file.append("openh264");
file.append("testDir");
file.append(OPENH264_PLUGIN_ID);
file.append(TEST_VERSION);
let addedPath = null
let removedPath = null;
@ -197,35 +197,37 @@ add_task(function* test_pluginRegistration() {
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, true);
// Check that the OpenH264 plugin gets registered after startup.
Services.prefs.setCharPref(OPENH264_PREF_PATH, file.path);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
clearPaths();
yield promiseRestartManager();
Assert.equal(addedPath, file.path);
Assert.equal(removedPath, null);
// Check that clearing the path doesn't trigger registration.
// Check that clearing the version doesn't trigger registration.
clearPaths();
Services.prefs.clearUserPref(OPENH264_PREF_PATH);
Services.prefs.clearUserPref(OPENH264_PREF_VERSION);
Assert.equal(addedPath, null);
Assert.equal(removedPath, file.path);
// Restarting with no path set should not trigger registration.
// Restarting with no version set should not trigger registration.
clearPaths();
yield promiseRestartManager();
Assert.equal(addedPath, null);
Assert.equal(removedPath, null);
// Changing the pref mid-session should cause unregistration and registration.
Services.prefs.setCharPref(OPENH264_PREF_PATH, file.path);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
clearPaths();
let file2 = file.clone();
file2.append("foo");
Services.prefs.setCharPref(OPENH264_PREF_PATH, file2.path);
const TEST_VERSION_2 = "5.6.7.8";
let file2 = Services.dirsvc.get("ProfD", Ci.nsIFile);
file2.append(OPENH264_PLUGIN_ID);
file2.append(TEST_VERSION_2);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION_2);
Assert.equal(addedPath, file2.path);
Assert.equal(removedPath, file.path);
// Disabling OpenH264 should cause unregistration.
Services.prefs.setCharPref(OPENH264_PREF_PATH, file.path);
Services.prefs.setCharPref(OPENH264_PREF_VERSION, TEST_VERSION);
clearPaths();
Services.prefs.setBoolPref(OPENH264_PREF_ENABLED, false);
Assert.equal(addedPath, null);