You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/11/01 23:09:19 UTC
[16/58] [abbrv] updated unit tests to the latest version
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp8/blob/b2eba04a/tests/MobileSpecUnitTests/www/autotest/tests/globalization.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/globalization.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/globalization.tests.js
new file mode 100644
index 0000000..6903aee
--- /dev/null
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/globalization.tests.js
@@ -0,0 +1,808 @@
+describe('Globalization (navigator.globalization)', function () {
+ it("should exist", function() {
+ expect(navigator.globalization).toBeDefined();
+ });
+
+ describe("getLocaleName", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.getLocaleName).toBeDefined();
+ expect(typeof navigator.globalization.getLocaleName == 'function').toBe(true);
+ });
+ it("getLocaleName success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getLocaleName(win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("dateToString", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.dateToString).toBeDefined();
+ expect(typeof navigator.globalization.dateToString == 'function').toBe(true);
+ });
+ it("dateToString using default options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("dateToString using formatLength=short and selector=date options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win, fail, {formatLength: 'short', selector: 'date'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("dateToString using formatLength=full and selector=date options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win, fail, {formatLength: 'full', selector: 'date'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("dateToString using formatLength=medium and selector=date and time(default) options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win, fail, {formatLength: 'medium'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("dateToString using formatLength=long and selector=date and time(default) options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win, fail, {formatLength: 'long'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("dateToString using formatLength=full and selector=date and time(default) options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win, fail, {formatLength: 'full'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("stringToDate", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.stringToDate).toBeDefined();
+ expect(typeof navigator.globalization.stringToDate == 'function').toBe(true);
+ });
+ it("stringToDate using default options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.year).toBeDefined();
+ expect(typeof a.year).toBe('number');
+ expect(a.year >= 0 && a.year <=9999).toBe(true);
+ expect(a.month).toBeDefined();
+ expect(typeof a.month).toBe('number');
+ expect(a.month >= 0 && a.month <=11).toBe(true);
+ expect(a.day).toBeDefined();
+ expect(typeof a.day).toBe('number');
+ expect(a.day >= 1 && a.day <=31).toBe(true);
+ expect(a.hour).toBeDefined();
+ expect(typeof a.hour).toBe('number');
+ expect(a.hour >= 0 && a.hour <=23).toBe(true);
+ expect(a.minute).toBeDefined();
+ expect(typeof a.minute).toBe('number');
+ expect(a.minute >= 0 && a.minute <=59).toBe(true);
+ expect(a.second).toBeDefined();
+ expect(typeof a.second).toBe('number');
+ expect(a.second >= 0 && a.second <=59).toBe(true);
+ expect(a.millisecond).toBeDefined();
+ expect(typeof a.millisecond).toBe('number');
+ }),
+ fail = jasmine.createSpy();
+
+ var win2 = function(a) {
+ navigator.globalization.stringToDate(a.value, win, fail);
+ };
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win2, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("stringToDate using formatLength=short and selector=date options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.year).toBeDefined();
+ expect(typeof a.year).toBe('number');
+ expect(a.year >= 0 && a.year <=9999).toBe(true);
+ expect(a.month).toBeDefined();
+ expect(typeof a.month).toBe('number');
+ expect(a.month >= 0 && a.month <=11).toBe(true);
+ expect(a.day).toBeDefined();
+ expect(typeof a.day).toBe('number');
+ expect(a.day >= 1 && a.day <=31).toBe(true);
+ expect(a.hour).toBeDefined();
+ expect(typeof a.hour).toBe('number');
+ expect(a.hour >= 0 && a.hour <=23).toBe(true);
+ expect(a.minute).toBeDefined();
+ expect(typeof a.minute).toBe('number');
+ expect(a.minute >= 0 && a.minute <=59).toBe(true);
+ expect(a.second).toBeDefined();
+ expect(typeof a.second).toBe('number');
+ expect(a.second >= 0 && a.second <=59).toBe(true);
+ expect(a.millisecond).toBeDefined();
+ expect(typeof a.millisecond).toBe('number');
+ }),
+ fail = jasmine.createSpy();
+
+ var win2 = function(a) {
+ navigator.globalization.stringToDate(a.value, win, fail, {formatLength: 'short', selector: 'date'});
+ };
+
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win2, fail, {formatLength: 'short', selector: 'date'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("stringToDate using formatLength=full and selector=date options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.year).toBeDefined();
+ expect(typeof a.year).toBe('number');
+ expect(a.year >= 0 && a.year <=9999).toBe(true);
+ expect(a.month).toBeDefined();
+ expect(typeof a.month).toBe('number');
+ expect(a.month >= 0 && a.month <=11).toBe(true);
+ expect(a.day).toBeDefined();
+ expect(typeof a.day).toBe('number');
+ expect(a.day >= 1 && a.day <=31).toBe(true);
+ expect(a.hour).toBeDefined();
+ expect(typeof a.hour).toBe('number');
+ expect(a.hour >= 0 && a.hour <=23).toBe(true);
+ expect(a.minute).toBeDefined();
+ expect(typeof a.minute).toBe('number');
+ expect(a.minute >= 0 && a.minute <=59).toBe(true);
+ expect(a.second).toBeDefined();
+ expect(typeof a.second).toBe('number');
+ expect(a.second >= 0 && a.second <=59).toBe(true);
+ expect(a.millisecond).toBeDefined();
+ expect(typeof a.millisecond).toBe('number');
+ }),
+ fail = jasmine.createSpy();
+
+ var win2 = function(a) {
+ navigator.globalization.stringToDate(a.value, win, fail, {formatLength: 'full', selector: 'date'});
+ };
+ runs(function () {
+ navigator.globalization.dateToString(new Date(), win2, fail, {formatLength: 'full', selector: 'date'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("stringToDate using invalid date, error callback should be called with a GlobalizationError object", function() {
+ var win = jasmine.createSpy(),
+ fail = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.code).toBeDefined();
+ expect(typeof a.code).toBe('number');
+ expect(a.code === GlobalizationError.PARSING_ERROR).toBe(true);
+ expect(a.message).toBeDefined();
+ expect(typeof a.message).toBe('string');
+ expect(a.message !== "").toBe(true);
+ });
+
+ runs(function () {
+ navigator.globalization.stringToDate('notADate', win, fail, {selector:'foobar'});
+ });
+
+ waitsFor(function () { return fail.wasCalled; }, "fail never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(win).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("getDatePattern", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.getDatePattern).toBeDefined();
+ expect(typeof navigator.globalization.getDatePattern == 'function').toBe(true);
+ });
+ it("getDatePattern using default options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.pattern).toBeDefined();
+ expect(typeof a.pattern).toBe('string');
+ expect(a.pattern.length > 0).toBe(true);
+ expect(a.timezone).toBeDefined();
+ expect(typeof a.timezone).toBe('string');
+ expect(a.timezone.length > 0).toBe(true);
+ expect(a.utc_offset).toBeDefined();
+ expect(typeof a.utc_offset).toBe('number');
+ expect(a.dst_offset).toBeDefined();
+ expect(typeof a.dst_offset).toBe('number');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDatePattern(win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getDatePattern using formatLength=medium and selector=date options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.pattern).toBeDefined();
+ expect(typeof a.pattern).toBe('string');
+ expect(a.pattern.length > 0).toBe(true);
+ expect(a.timezone).toBeDefined();
+ expect(typeof a.timezone).toBe('string');
+ expect(a.timezone.length > 0).toBe(true);
+ expect(a.utc_offset).toBeDefined();
+ expect(typeof a.utc_offset).toBe('number');
+ expect(a.dst_offset).toBeDefined();
+ expect(typeof a.dst_offset).toBe('number');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDatePattern(win, fail, {formatLength: 'medium', selector: 'date'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("getDateNames", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.getDateNames).toBeDefined();
+ expect(typeof navigator.globalization.getDateNames == 'function').toBe(true);
+ });
+ it("getDateNames using default options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(a.value instanceof Array).toBe(true);
+ expect(a.value.length > 0).toBe(true);
+ expect(typeof a.value[0]).toBe('string');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDateNames(win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getDateNames using type=narrow and item=days options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(a.value instanceof Array).toBe(true);
+ expect(a.value.length > 0).toBe(true);
+ expect(typeof a.value[0]).toBe('string');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDateNames(win, fail, {type: 'narrow', item: 'days'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getDateNames using type=narrow and item=months options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(a.value instanceof Array).toBe(true);
+ expect(a.value.length > 0).toBe(true);
+ expect(typeof a.value[0]).toBe('string');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDateNames(win, fail, {type: 'narrow', item: 'months'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getDateNames using type=wide and item=days options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(a.value instanceof Array).toBe(true);
+ expect(a.value.length > 0).toBe(true);
+ expect(typeof a.value[0]).toBe('string');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDateNames(win, fail, {item: 'days'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getDateNames using type=wide and item=months options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(a.value instanceof Array).toBe(true);
+ expect(a.value.length > 0).toBe(true);
+ expect(typeof a.value[0]).toBe('string');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getDateNames(win, fail, {item: 'months'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("isDayLightSavingsTime", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.isDayLightSavingsTime).toBeDefined();
+ expect(typeof navigator.globalization.isDayLightSavingsTime == 'function').toBe(true);
+ });
+ it("isDayLightSavingsTime using default options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.dst).toBeDefined();
+ expect(typeof a.dst).toBe('boolean');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.isDayLightSavingsTime(new Date(), win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("getFirstDayOfWeek", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.getFirstDayOfWeek).toBeDefined();
+ expect(typeof navigator.globalization.getFirstDayOfWeek == 'function').toBe(true);
+ });
+ it("getFirstDayOfWeek success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('number');
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getFirstDayOfWeek(win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("numberToString", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.numberToString).toBeDefined();
+ expect(typeof navigator.globalization.numberToString == 'function').toBe(true);
+ });
+ it("numberToString using default options, should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.numberToString(3.25, win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("numberToString using type=percent options, should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.numberToString(.25, win, fail, {type: 'percent'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("numberToString using type=currency options, should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('string');
+ expect(a.value.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.numberToString(5.20, win, fail, {type: 'currency'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("stringToNumber", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.stringToNumber).toBeDefined();
+ expect(typeof navigator.globalization.stringToNumber == 'function').toBe(true);
+ });
+ it("stringToNumber using default options, should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('number');
+ expect(a.value > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ var win2 = function(a) {
+ navigator.globalization.stringToNumber(a.value, win, fail);
+ };
+
+ runs(function () {
+ navigator.globalization.numberToString(3.25, win2, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("stringToNumber using type=percent options, should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.value).toBeDefined();
+ expect(typeof a.value).toBe('number');
+ expect(a.value > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ var win2 = function(a) {
+ navigator.globalization.stringToNumber(a.value, win, fail, {type: 'percent'});
+ };
+
+ runs(function () {
+ navigator.globalization.numberToString(.25, win2, fail, {type: 'percent'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("getNumberPattern", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.getNumberPattern).toBeDefined();
+ expect(typeof navigator.globalization.getNumberPattern == 'function').toBe(true);
+ });
+ it("getNumberPattern using default options, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.pattern).toBeDefined();
+ expect(typeof a.pattern).toBe('string');
+ expect(a.pattern.length > 0).toBe(true);
+ expect(typeof a.symbol).toBe('string');
+ expect(typeof a.fraction).toBe('number');
+ expect(typeof a.rounding).toBe('number');
+ expect(a.positive).toBeDefined();
+ expect(typeof a.positive).toBe('string');
+ expect(a.positive.length >= 0).toBe(true);
+ expect(a.negative).toBeDefined();
+ expect(typeof a.negative).toBe('string');
+ expect(a.negative.length >= 0).toBe(true);
+ expect(a.decimal).toBeDefined();
+ expect(typeof a.decimal).toBe('string');
+ expect(a.decimal.length > 0).toBe(true);
+ expect(a.grouping).toBeDefined();
+ expect(typeof a.grouping).toBe('string');
+ expect(a.grouping.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getNumberPattern(win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getNumberPattern using type=percent, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.pattern).toBeDefined();
+ expect(typeof a.pattern).toBe('string');
+ expect(a.pattern.length > 0).toBe(true);
+ expect(typeof a.symbol).toBe('string');
+ expect(typeof a.fraction).toBe('number');
+ expect(typeof a.rounding).toBe('number');
+ expect(a.positive).toBeDefined();
+ expect(typeof a.positive).toBe('string');
+ expect(a.positive.length >= 0).toBe(true);
+ expect(a.negative).toBeDefined();
+ expect(typeof a.negative).toBe('string');
+ expect(a.negative.length >= 0).toBe(true);
+ expect(a.decimal).toBeDefined();
+ expect(typeof a.decimal).toBe('string');
+ expect(a.decimal.length > 0).toBe(true);
+ expect(a.grouping).toBeDefined();
+ expect(typeof a.grouping).toBe('string');
+ expect(a.grouping.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getNumberPattern(win, fail, {type: 'percent'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ it("getNumberPattern using type=currency, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.pattern).toBeDefined();
+ expect(typeof a.pattern).toBe('string');
+ expect(a.pattern.length > 0).toBe(true);
+ expect(typeof a.symbol).toBe('string');
+ expect(typeof a.fraction).toBe('number');
+ expect(typeof a.rounding).toBe('number');
+ expect(a.positive).toBeDefined();
+ expect(typeof a.positive).toBe('string');
+ expect(a.positive.length >= 0).toBe(true);
+ expect(a.negative).toBeDefined();
+ expect(typeof a.negative).toBe('string');
+ expect(a.negative.length >= 0).toBe(true);
+ expect(a.decimal).toBeDefined();
+ expect(typeof a.decimal).toBe('string');
+ expect(a.decimal.length > 0).toBe(true);
+ expect(a.grouping).toBeDefined();
+ expect(typeof a.grouping).toBe('string');
+ expect(a.grouping.length > 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getNumberPattern(win, fail, {type: 'currency'});
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+
+ describe("getCurrencyPattern", function() {
+ it("should exist", function() {
+ expect(typeof navigator.globalization.getCurrencyPattern).toBeDefined();
+ expect(typeof navigator.globalization.getCurrencyPattern == 'function').toBe(true);
+ });
+ it("getCurrencyPattern using EUR for currency, success callback should be called with a Properties object", function() {
+ var win = jasmine.createSpy().andCallFake(function(a) {
+ expect(a).toBeDefined();
+ expect(typeof a).toBe('object');
+ expect(a.pattern).toBeDefined();
+ expect(typeof a.pattern).toBe('string');
+ expect(a.pattern.length > 0).toBe(true);
+ expect(a.code).toBeDefined();
+ expect(typeof a.code).toBe('string');
+ expect(a.code.length > 0).toBe(true);
+ expect(typeof a.fraction).toBe('number');
+ expect(typeof a.rounding).toBe('number');
+ expect(a.decimal).toBeDefined();
+ expect(typeof a.decimal).toBe('string');
+ expect(a.decimal.length >= 0).toBe(true);
+ expect(a.grouping).toBeDefined();
+ expect(typeof a.grouping).toBe('string');
+ expect(a.grouping.length >= 0).toBe(true);
+ }),
+ fail = jasmine.createSpy();
+
+ runs(function () {
+ navigator.globalization.getCurrencyPattern("EUR", win, fail);
+ });
+
+ waitsFor(function () { return win.wasCalled; }, "win never called", Tests.TEST_TIMEOUT);
+
+ runs(function () {
+ expect(fail).not.toHaveBeenCalled();
+ });
+ });
+ });
+});
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp8/blob/b2eba04a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js b/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
index a921de3..2c90bbd 100644
--- a/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
+++ b/tests/MobileSpecUnitTests/www/autotest/tests/storage.tests.js
@@ -153,9 +153,22 @@ describe("Session Storage", function () {
expect(window.openDatabase);
});
- it("Should open a database", function() {
- var db = openDatabase("Database", "1.0", "HTML5 Database API example", 200000);
- expect(db).toBeDefined();
+ it("Should be able to create and drop tables", function() {
+ var win = jasmine.createSpy('win');
+ var fail1 = createDoNotCallSpy('fail1');
+ var fail2 = createDoNotCallSpy('fail2');
+ var db = openDatabase("Database", "1.0", "HTML5 Database API example", 5*1024*1024);
+ db.transaction(function(t) {
+ t.executeSql('CREATE TABLE IF NOT EXISTS foo(id int, name varchar(255));');
+ t.executeSql('CREATE TABLE IF NOT EXISTS foo2(id int, name varchar(255));');
+ }, fail1, step2);
+ function step2() {
+ db.transaction(function(t) {
+ t.executeSql('DROP TABLE foo;');
+ t.executeSql('DROP TABLE foo2');
+ }, fail2, win);
+ }
+ waitsForAny(win, fail1, fail2);
});
});
});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp8/blob/b2eba04a/tests/MobileSpecUnitTests/www/index.html
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/index.html b/tests/MobileSpecUnitTests/www/index.html
index 9c6f3cb..e7a77e0 100644
--- a/tests/MobileSpecUnitTests/www/index.html
+++ b/tests/MobileSpecUnitTests/www/index.html
@@ -10,7 +10,7 @@
</head>
<body onload="init();" id="stage" class="theme">
- <h1>PhoneGap Tests</h1>
+ <h1>Apache Cordova Tests</h1>
<div id="info">
<h4>Platform: <span id="platform"> </span></h4>
<h4>Version: <span id="version"> </span></h4>
@@ -33,5 +33,6 @@
<a href="notification/index.html" class="btn large">Notification</a>
<a href="sql/index.html" class="btn large">Web SQL</a>
<a href="storage/index.html" class="btn large">Local Storage</a>
+ <a href="execbenchmark/index.html" class="btn large">Benchmark exec()</a>
</body>
</html>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-wp8/blob/b2eba04a/tests/MobileSpecUnitTests/www/master.css
----------------------------------------------------------------------
diff --git a/tests/MobileSpecUnitTests/www/master.css b/tests/MobileSpecUnitTests/www/master.css
index f64b29c..2408052 100644
--- a/tests/MobileSpecUnitTests/www/master.css
+++ b/tests/MobileSpecUnitTests/www/master.css
@@ -95,6 +95,11 @@
padding:1.2em 0;
}
+ #stage.theme .wide{
+ width:100%;
+ padding:1.2em 0;
+ }
+
#stage.theme .backBtn{
border: 1px solid #555;
-webkit-border-radius: 5px;
@@ -128,4 +133,4 @@
#stage.theme .numeric{
width:100%;
- }
\ No newline at end of file
+ }