//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTZDate, currentTimeDuration = [], exceptionName = "TypeMismatchError";
+ var currentTZDate, currentTimeDuration = [], exceptionName = TYPE_MISMATCH_ERR;
currentTimeDuration[0] = {length: 2, unit: "MINS"};
currentTZDate = tizen.time.getCurrentDateTime();
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTZDate = [], exceptionName = "TypeMismatchError";
+ var currentTZDate = [], exceptionName = TYPE_MISMATCH_ERR;
currentTZDate[0] = tizen.time.getCurrentDateTime();
currentTZDate[1] = {};
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTZDate = [], exceptionName = "TypeMismatchError";
+ var currentTZDate = [], exceptionName = TYPE_MISMATCH_ERR;
currentTZDate[0] = tizen.time.getCurrentDateTime();
currentTZDate[1] = {};
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTZDate = [], exceptionName = "TypeMismatchError";
+ var currentTZDate = [], exceptionName = TYPE_MISMATCH_ERR;
currentTZDate[0] = tizen.time.getCurrentDateTime();
currentTZDate[1] = {};
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTZDate = [], exceptionName = "TypeMismatchError";
+ var currentTZDate = [], exceptionName = TYPE_MISMATCH_ERR;
currentTZDate[0] = tizen.time.getCurrentDateTime();
currentTZDate[1] = {};
var currentTZDate = tizen.time.getCurrentDateTime(), returnedValue = null;
returnedValue = currentTZDate.toDateString();
assert_type(returnedValue, "string", "type check");
- assert_not_equals(returnedValue, null, "null check");
+ assert_not_equals(returnedValue, "", "returned");
}, "TZDate_toDateString");
</script>
var currentTZDate = tizen.time.getCurrentDateTime(), returnedValue = null;
returnedValue = currentTZDate.toLocaleDateString();
assert_type(returnedValue, "string", "type check");
- assert_not_equals(returnedValue, null, "null check");
+ assert_not_equals(returnedValue, "", "returned");
}, "TZDate_toLocaleDateString");
</script>
var currentTZDate = tizen.time.getCurrentDateTime(), returnedValue = null;
returnedValue = currentTZDate.toLocaleString();
assert_type(returnedValue, "string", "type check");
- assert_not_equals(returnedValue, null, "null check");
+ assert_not_equals(returnedValue, "", "returned");
}, "TZDate_toLocaleString");
</script>
var currentTZDate = tizen.time.getCurrentDateTime(), returnedValue = null;
returnedValue = currentTZDate.toLocaleTimeString();
assert_type(returnedValue, "string", "type check");
- assert_not_equals(returnedValue, null, "null check");
+ assert_not_equals(returnedValue, "", "returned");
}, "TZDate_toLocaleTimeString");
</script>
var currentTZDate = tizen.time.getCurrentDateTime(), returnedValue = null;
returnedValue = currentTZDate.toString();
assert_type(returnedValue, "string", "type check");
- assert_not_equals(returnedValue, null, "null check");
+ assert_not_equals(returnedValue, "", "returned");
}, "TZDate_toString");
</script>
var currentTZDate = tizen.time.getCurrentDateTime(), returnedValue = null;
returnedValue = currentTZDate.toTimeString();
assert_type(returnedValue, "string", "type check");
- assert_not_equals(returnedValue, null, "null check");
+ assert_not_equals(returnedValue, "", "returned");
}, "TZDate_toTimeString");
</script>
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTimeDuration = [], exceptionName = "TypeMismatchError";
+ var currentTimeDuration = [], exceptionName = TYPE_MISMATCH_ERR;
currentTimeDuration[0] = new tizen.TimeDuration(1, "DAYS");
currentTimeDuration[1] = {length: 2, unit: "MINS"};
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTimeDuration = [], exceptionName = "TypeMismatchError";
+ var currentTimeDuration = [], exceptionName = TYPE_MISMATCH_ERR;
currentTimeDuration[0] = new tizen.TimeDuration(1, "DAYS");
currentTimeDuration[1] = {length: 2, unit: "MINS"};
//==== TEST_CRITERIA MMA
test(function () {
var currentTimeDuration = new tizen.TimeDuration(1, "DAYS");
- assert_throws({name: "TypeMismatchError"},
+ assert_throws({name: TYPE_MISMATCH_ERR},
function () {
currentTimeDuration.greaterThan();
});
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTimeDuration = [], exceptionName = "TypeMismatchError";
+ var currentTimeDuration = [], exceptionName = TYPE_MISMATCH_ERR;
currentTimeDuration[0] = new tizen.TimeDuration(1, "DAYS");
currentTimeDuration[1] = {length: 2, unit: "MINS"};
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MTO
test(function () {
- var currentTimeDuration = [], exceptionName = "TypeMismatchError";
+ var currentTimeDuration = [], exceptionName = TYPE_MISMATCH_ERR;
currentTimeDuration[0] = new tizen.TimeDuration(1, "DAYS");
currentTimeDuration[1] = {length: 2, unit: "MINS"};
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MC
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().difference("abcd");
}, "Specific TypeMismatchError exception.");
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MC
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().earlierThan("abcd");
}, "Specific TypeMismatchError exception.");
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MC
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().earlierThan(123);
}, "Specific TypeMismatchError exception.");
//==== TEST_CRITERIA MC
test(function () {
var tzStr = tizen.time.getCurrentDateTime().toString();
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().earlierThan(tzStr);
}, "Specific TypeMismatchError exception.");
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MC
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().equalsTo("abcd");
}, "Specific TypeMismatchError exception.");
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MC
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().equalsTo(123);
}, "Specific TypeMismatchError exception.");
exp_ms = myDate.getMilliseconds();
ms = tizen.time.getCurrentDateTime().getMilliseconds();
- assert_gap_less_than(ms, exp_ms, 10);
+ assert_approx_equals(ms, exp_ms, 10, "getMilliseconds()");
}, "Time_TZDate_getMilliseconds");
</script>
exp_UTCMs = myDate.getUTCMilliseconds();
UTCMs = tizen.time.getCurrentDateTime().getUTCMilliseconds();
- assert_gap_less_than(UTCMs, exp_UTCMs, 10, "milliseconds check");
+ assert_approx_equals(UTCMs, exp_UTCMs, 10, "milliseconds check");
}, "Time_TZDate_getUTCMilliseconds");
</script>
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MC
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().laterThan("abcd");
}, "Specific TypeMismatchError exception.");
//==== SPEC_URL https://developer.tizen.org/help/topic/org.tizen.web.device.apireference/tizen/time.html
//==== TEST_CRITERIA MMINA MR
test(function () {
- assert_throws("TYPE_MISMATCH_ERR",
+ assert_throws({name: "TypeMismatchError"},
function () {
tizen.time.getCurrentDateTime().laterThan(123);
}, "Specific TypeMismatchError exception.");
dt.setMilliseconds(set_ms);
msAfterSet = dt.getMilliseconds();
- assert_gap_less_than(msAfterSet, set_ms, 10);
+ assert_approx_equals(msAfterSet, set_ms, 10, "getMilliseconds()");
}, "Time_TZDate_setMilliseconds_normal");
</script>
//==== TEST_CRITERIA
test(function () {
var tzid, timezone;
- try {
+ assert_throws({ name: INVALID_VALUES_ERR }, function () {
tzid = "ab";
timezone = tizen.time.getCurrentDateTime().toTimezone(tzid);
- assert_true(false, "Should throw an exception");
- } catch (e) {
- assert_equals(e.name,"InvalidValuesError","error message is " + e.message);
- }
+ });
}, "Time_TZDate_toTimezone_invalid");
</script>
//==== TEST_CRITERIA
test(function () {
var tzid, timezone;
- try {
+ assert_throws({ name: INVALID_VALUES_ERR }, function () {
tzid = null;
timezone = tizen.time.getCurrentDateTime().toTimezone(tzid);
- assert_true(false,"Should throw an exception");
- } catch (e) {
- assert_equals(e.name,"InvalidValuesError","error message is" +e.message);
- }
+ });
}, "Time_TZDate_toTimezone_null");
</script>
);
var testAdditionalParamArray = [ERROR_NUM, null, undefined];
-// var currentDate = new tizen.TZDate();
-
-function presenceTest() {
- assert_true(tizen, "Checking tizen object");
-}
-
-function checkTZDate(count, paramTZDate, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) {
- assert_true(paramTZDate instanceof tizen.TZDate, "checkTZDate() paramTZDate):");
- if (count == 0) {
- return;
- }
-
- switch (count) {
- case 1:
- assert_equals(arg1, paramTZDate.getTimezone(), "checkTZDate() timezone");
- break;
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- assert_equals(arg1, paramTZDate.getFullYear(), "checkTZDate() year");
- assert_equals(arg2, paramTZDate.getMonth(), "checkTZDate() month");
- assert_equals(arg3, paramTZDate.getDate(), "checkTZDate() date");
-
- if (count > 3) {
- assert_equals(arg4, paramTZDate.getHours(), "checkTZDate() hours");
- }
-
- if (count > 4) {
- assert_equals(arg5, paramTZDate.getMinutes(), "checkTZDate() minutes");
- }
-
- if (count > 5) {
- assert_equals(arg6, paramTZDate.getSeconds(), "checkTZDate() seconds");
- }
-
- if (count > 6) {
- assert_equals(arg7, paramTZDate.getMilliseconds(), "checkTZDate() milliseconds");
- }
-
- if (count > 7) {
- assert_equals(arg8, paramTZDate.getTimezone(), "checkTZDate() timezone");
- }
-
- break;
- }
-}
-
-function checkValidParamTZDate() {
- try {
- assert_true(!isUndefined(new tizen.TZDate(ERROR_NUM)), "checkValidParamTZDate new tizen.TZDate(ERROR_NUM) : ");
- console.error("checkValidParamTZDate expected error (expected : [" + TYPE_MISMATCH_ERR + "] but NoError)");
- } catch (e) {
- assert_equals("checkValidParamTZDate() new tizen.TZDate(ERROR_NUM) error", e.name, TYPE_MISMATCH_ERR);
- }
-
- try {
- assert_true(!isUndefined(new tizen.TZDate(new Date(), ERROR_NUM)), "checkValidParamTZDate new tizen.TZDate(new Date(), ERROR_NUM) : ");
- console.error("checkValidParamTZDate expected error (expected : [" + INVALID_VALUES_ERR + "] but NoError)");
- } catch (e) {
- assert_equals("checkValidParamTZDate() new tizen.TZDate(new Date(), ERROR_NUM) error", e.name, INVALID_VALUES_ERR);
- }
-
- try {
- TestEngine.test("checkValidParamTZDate new tizen.TZDate(expected_year, expected_month, expected_date, expected_hours, expected_minutes, expected_seconds, expected_milliseconds, ERROR_NUM) : ", !isUndefined(new tizen.TZDate(expected_year, expected_month, expected_date, expected_hours, expected_minutes, expected_seconds, expected_milliseconds, ERROR_NUM)));
- console.error("checkValidParamTZDate expected error (expected : [" + INVALID_VALUES_ERR + "] but NoError)");
- } catch (e) {
- assert_equals("checkValidParamTZDate() new tizen.TZDate(expected_year, expected_month, expected_date, expected_hours, expected_minutes, expected_seconds, expected_milliseconds, ERROR_NUM) error", e.name, INVALID_VALUES_ERR);
- }
-}
-
-function compareDate(date, tzdate, timezone) {
- assert_equals(date.getFullYear(), tzdate.getFullYear(), "compareDate() year");
- assert_equals(date.getMonth(), tzdate.getMonth(), "compareDate() month");
- assert_equals(date.getDate(), tzdate.getDate(), "compareDate() day");
- assert_equals(date.getHours(), tzdate.getHours(), "compareDate() hours");
- assert_equals(date.getMinutes(), tzdate.getMinutes(), "compareDate() mins");
- assert_equals(date.getSeconds(), tzdate.getSeconds(), "compareDate() sec");
- assert_equals(date.getMilliseconds(), tzdate.getMilliseconds(), "compareDate() millisec");
- if (!isUndefined(timezone)) {
- assert_equals(timezone, tzdate.getTimezone(), "compareDate() timezone");
- }
-}
-
-function checkTimeDuration(duration, expected_length, expected_unit) {
- assert_true(duration instanceof tizen.TimeDuration, "checkTimeDuration() duration instanceof tizen.TimeDuration :");
- if (isNull(expected_unit)) {
- expected_unit = "MSECS";
- }
-
- assert_type(duration.length, "number", "duration length");
- assert_type(duration.unit, "string", "duration unit");
- assert_equals(expected_length, duration.length, "checkTimeDuration() length");
- assert_equals(expected_unit, duration.unit, "checkTimeDuration() unit");
-}
-
-
-
-
-
-function assert_gap_less_than(actual, expect, distance){
- if( Math.abs(parseInt(actual-expect))<=distance ){
- assert_true(true);
- }else
- assert_true(false)
-}
-
-function FailTest()
-{
- t.step(function() { assert_true(false); } );
- t.done();
-}
-
-/*
-function assert_is_timezone(actual) {
- for (var i in _timezone_fields) {
- assert_own_property(actual, i);
- }
-}
-
-function assert_tzdate_same_as(actual, expected) {
- for (var field in _tzdate_fields) {
- _compare_field(actual[field], expected[field], field, _tzdate_fields[field]);
- }
-}
-
-function assert_timezone_same_as(actual, expected) {
- for (var field in _timezone_fields) {
- _compare_field(actual[field], expected[field], field, _timezone_fields[field]);
- }
-}
-
-
-function assert_contact_same_as(actual, expected) {
- for (var field in _contact_properties) {
- _compare_field(actual[field], expected[field], field, _contact_properties[field]);
- }
-}
-
-function _compare_field(actual, expected, fieldname, datatype) {
- if (expected == null) {
- assert_equals(actual, expected, "Comparing values of " + fieldname);
- } else if (datatype == "string" || datatype == "date" || datatype=="opaquestring") {
- if (expected == null || datatype != "opaquestring") {
- assert_equals(actual, expected, "Comparing values of " + fieldname);
- }
- } else if (datatype instanceof Array) {
- for (var i in expected) {
- _compare_field(actual[i], expected[i], fieldname, datatype[0]);
- }
- } else if (typeof(datatype)=='object') {
- for (var i in actual) {
- assert_own_property(expected, i, "Unexpected property " + i + " in " + fieldname);
- _compare_field(actual[i], expected[i], fieldname + "." + i, "string");
- }
- for (var j in expected) {
- assert_own_property(actual, j, "Missing property " + j + " in " + fieldname);
- }
- } else {
- assert_unreached( "Unknown datatype to compare:" + datatype);
- }
-}
-*/