forked from mozilla/gecko-dev
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add initial locale unit tests for the MozLoopService
- Loading branch information
Showing
4 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
browser/components/loop/test/xpcshell/test_loopservice_locales.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; | ||
|
||
Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | ||
Cu.import("resource://gre/modules/Services.jsm"); | ||
|
||
XPCOMUtils.defineLazyModuleGetter(this, "MozLoopService", | ||
"resource:///modules/loop/MozLoopService.jsm"); | ||
|
||
|
||
function test_locale() { | ||
// Set the pref to something controlled. | ||
Services.prefs.setCharPref("general.useragent.locale", "ab-CD"); | ||
|
||
do_check_eq(MozLoopService.locale, "ab-CD"); | ||
|
||
Services.prefs.clearUserPref("general.useragent.locale"); | ||
} | ||
|
||
function test_getStrings() { | ||
// Try an invalid string | ||
do_check_eq(MozLoopService.getStrings("invalid_not_found_string"), ""); | ||
|
||
// Get a string that has sub-items to test the function more fully. | ||
// XXX This depends on the L10n values, which I'd prefer not to do, but is the | ||
// simplest way for now. | ||
do_check_eq(MozLoopService.getStrings("caller"), '{"placeholder":"Identify this call"}'); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
function run_test() | ||
{ | ||
test_locale(); | ||
test_getStrings(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[DEFAULT] | ||
head = | ||
tail = | ||
firefox-appdir = browser | ||
|
||
[test_loopservice_locales.js] |
It's hard to keep track of every "new hotness" that comes along, but the current one for xpcshell tests is to use the Assert module (which is already injected into tests) - so instead of do_check_eq, use Assert.equal()