Bug 1012403 - Reenable SettingsService tests; a=TEST-ONLY

This commit is contained in:
Kyle Machulis 2015-06-10 16:16:40 -07:00
parent 148d029425
commit 1a59ea3266
5 changed files with 97 additions and 91 deletions

View File

@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please # changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more. # don't change CLOBBER for WebIDL changes any more.
Bug 1165422 - Updated the Android SDK versions Bug 1012403 - Update SettingsService tests (requires clobber due to package manifest change)

View File

@ -535,6 +535,8 @@
@RESPATH@/components/messageWakeupService.manifest @RESPATH@/components/messageWakeupService.manifest
@RESPATH@/components/SettingsManager.js @RESPATH@/components/SettingsManager.js
@RESPATH@/components/SettingsManager.manifest @RESPATH@/components/SettingsManager.manifest
@BINPATH@/components/SettingsService.js
@BINPATH@/components/SettingsService.manifest
@RESPATH@/components/Webapps.js @RESPATH@/components/Webapps.js
@RESPATH@/components/Webapps.manifest @RESPATH@/components/Webapps.manifest
@RESPATH@/components/AppsService.js @RESPATH@/components/AppsService.js

View File

@ -9,7 +9,7 @@ EXTRA_COMPONENTS += [
'SettingsManager.manifest', 'SettingsManager.manifest',
] ]
if CONFIG['MOZ_B2G']: if CONFIG['MOZ_B2G'] or CONFIG['ENABLE_TESTS']:
EXTRA_COMPONENTS += [ EXTRA_COMPONENTS += [
'SettingsService.js', 'SettingsService.js',
'SettingsService.manifest', 'SettingsService.manifest',

View File

@ -1,5 +1,4 @@
[DEFAULT] [DEFAULT]
skip-if = (toolkit == 'gonk' && debug) #debug-only failure, bug 932878
support-files = support-files =
file_loadserver.js file_loadserver.js
file_bug1110872.js file_bug1110872.js

View File

@ -84,18 +84,22 @@ let tests = [
const TEST_OBSERVER_VALUE = true; const TEST_OBSERVER_VALUE = true;
const TEST_OBSERVER_MESSAGE = "test.observer.message"; const TEST_OBSERVER_MESSAGE = "test.observer.message";
function observer(subject, topic, data) { var obs = {
observe: function (subject, topic, data) {
if (topic !== MOZSETTINGS_CHANGED) { if (topic !== MOZSETTINGS_CHANGED) {
ok(false, "Event is not mozsettings-changed."); ok(false, "Event is not mozsettings-changed.");
return; return;
} }
// Data is now stored in subject
data = JSON.parse(data); if ("wrappedJSObject" in subject) {
ok(true, "JS object wrapped into subject");
subject = subject.wrappedJSObject;
}
function checkProp(name, type, value) { function checkProp(name, type, value) {
ok(name in data, "data." + name + " is present"); ok(name in subject, "subject." + name + " is present");
is(typeof data[name], type, "data." + name + " is " + type); is(typeof subject[name], type, "subject." + name + " is " + type);
is(data[name], value, "data." + name + " is " + value); is(subject[name], value, "subject." + name + " is " + value);
} }
checkProp("key", "string", TEST_OBSERVER_KEY); checkProp("key", "string", TEST_OBSERVER_KEY);
@ -105,8 +109,9 @@ let tests = [
Services.obs.removeObserver(this, MOZSETTINGS_CHANGED); Services.obs.removeObserver(this, MOZSETTINGS_CHANGED);
next(); next();
} }
};
Services.obs.addObserver(observer, MOZSETTINGS_CHANGED, false); Services.obs.addObserver(obs, MOZSETTINGS_CHANGED, false);
let lock = SettingsService.createLock(); let lock = SettingsService.createLock();
lock.set(TEST_OBSERVER_KEY, TEST_OBSERVER_VALUE, null); lock.set(TEST_OBSERVER_KEY, TEST_OBSERVER_VALUE, null);