[Contact] TCT fixes vol. 2
authorRafal Galka <r.galka@samsung.com>
Tue, 30 Dec 2014 14:17:57 +0000 (15:17 +0100)
committerRafal Galka <r.galka@samsung.com>
Wed, 31 Dec 2014 09:39:51 +0000 (18:39 +0900)
[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

src/contact/js/tizen.contact.Contact.js
src/contact/js/tizen.contact.ContactDataStructures.js

index 8d0513bd8eb4567e0af7b0aa91bcdcd1e551deb8..cecc8433f8447cf6e8a8234a21bb49e6c16184db 100644 (file)
@@ -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 === '') {
index fe2e62cbf95ddf1e45ba8972f20a26a63c4ab9e0..eab625638779b45c47fc75c3d6e16ea8df484626 100644 (file)
@@ -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 /////////////////////////////////////////////////////////////////