From: Rafal Galka Date: Tue, 30 Dec 2014 14:17:57 +0000 (+0100) Subject: [Contact] TCT fixes vol. 2 X-Git-Tag: submit/tizen_tv/20150603.064601~1^2~692 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48602fa2a91cb4eadcb966d76f8c11e7e6968865;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Contact] TCT fixes vol. 2 [Verification] Following TCT should pass: - ContactName_nicknames_not_nullable - Contact_convertToString_with_null - ContactEmailAddress_label_attribute - ContactInstantMessenger_imAddress_attribute - ContactInstantMessenger_type_attribute Change-Id: I99d90c7d2809d5522cef1e9e4059fb79648255d0 --- diff --git a/src/contact/js/tizen.contact.Contact.js b/src/contact/js/tizen.contact.Contact.js index 8d0513bd..cecc8433 100644 --- a/src/contact/js/tizen.contact.Contact.js +++ b/src/contact/js/tizen.contact.Contact.js @@ -501,18 +501,14 @@ var _JSONToContactType = function(type, obj) { // Converts the Contact item to a string format. Contact.prototype.convertToString = function(format) { - if (arguments.length) { - if (!Type.isString(format)) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, - 'Invalid format type'); - } + format = format || TypeEnum[0]; - if (TypeEnum.indexOf(format) < 0) { - throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, - 'Invalid format'); - } - } else { - console.logd('No format selected. Default VCARD 3.0 has been set'); + if (!Type.isString(format)) { + throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format'); + } + + if (TypeEnum.indexOf(format) < 0) { + throw new tizen.WebAPIException(tizen.WebAPIException.TYPE_MISMATCH_ERR, 'Invalid format'); } if (this.id === '') { diff --git a/src/contact/js/tizen.contact.ContactDataStructures.js b/src/contact/js/tizen.contact.ContactDataStructures.js index fe2e62cb..eab62563 100644 --- a/src/contact/js/tizen.contact.ContactDataStructures.js +++ b/src/contact/js/tizen.contact.ContactDataStructures.js @@ -197,7 +197,7 @@ var ContactEmailAddress = function(address, types, isDefault) { AV.isConstructorCall(this, ContactEmailAddress); var _email = ''; - var _label = ''; + var _label = null; var _isDefault = false; var _types = ['WORK']; @@ -268,7 +268,7 @@ var ContactEmailAddress = function(address, types, isDefault) { return _label; }, set: function(v) { - _label = Converter.toString(v, false); + _label = Converter.toString(v, true); }, enumerable: true } @@ -571,6 +571,7 @@ var ContactName = function(data) { AV.isConstructorCall(this, ContactName); var _displayName = null; + var _nicknames = []; Object.defineProperties(this, { prefix: { @@ -599,8 +600,14 @@ var ContactName = function(data) { enumerable: true }, nicknames: { - value: [], - writable: true, + get: function() { + return _nicknames; + }, + set: function(nicknames) { + if (Type.isArray(nicknames)) { + _nicknames = nicknames; + } + }, enumerable: true }, phoneticFirstName: { @@ -683,15 +690,32 @@ var ContactRelationship = function(relativeName, type) { var ContactInstantMessenger = function(imAddress, type) { AV.isConstructorCall(this, ContactInstantMessenger); + var imAddress_ = ''; + var type_ = 'OTHER'; + Object.defineProperties(this, { imAddress: { - value: Type.isString(imAddress) ? imAddress : null, - writable: true, + get: function() { + return imAddress_; + }, + set: function(v) { + if (Type.isNullOrUndefined(v)) { + return; + } + imAddress_ = Converter.toString(v, false); + }, enumerable: true }, type: { - value: (Type.isNullOrUndefined(type) ? ContactInstantMessengerType.OTHER : type), - writable: true, + get: function() { + return type_; + }, + set: function(v) { + if (Type.isNullOrUndefined(v)) { + return; + } + type_ = Converter.toEnum(v, Object.keys(ContactInstantMessengerType), false); + }, enumerable: true }, label: { @@ -701,13 +725,8 @@ var ContactInstantMessenger = function(imAddress, type) { } }); - if (_editGuard.isEditEnabled()) { - for (var prop in arguments[0]) { - if (this.hasOwnProperty(prop)) { - this[prop] = arguments[0][prop]; - } - } - } + this.imAddress = imAddress; + this.type = type; }; // exports /////////////////////////////////////////////////////////////////