cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dase...@apache.org
Subject cordova-plugin-contacts git commit: CB-10985 Android sets type to -1 for ims Added a corresponding test
Date Mon, 11 Apr 2016 08:49:45 GMT
Repository: cordova-plugin-contacts
Updated Branches:
  refs/heads/master f551c9284 -> 0f8945b91


CB-10985 Android sets type to -1 for ims
Added a corresponding test


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/commit/0f8945b9
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/0f8945b9
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/0f8945b9

Branch: refs/heads/master
Commit: 0f8945b911e3cf2617919bd7d3831019bb3b43f4
Parents: f551c92
Author: daserge <v-seshak@microsoft.com>
Authored: Tue Apr 5 22:55:15 2016 +0300
Committer: daserge <v-seshak@microsoft.com>
Committed: Mon Apr 11 10:39:28 2016 +0300

----------------------------------------------------------------------
 src/android/ContactAccessorSdk5.java |  4 ++--
 tests/tests.js                       | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/0f8945b9/src/android/ContactAccessorSdk5.java
----------------------------------------------------------------------
diff --git a/src/android/ContactAccessorSdk5.java b/src/android/ContactAccessorSdk5.java
index bd43bf1..f62bf1b 100644
--- a/src/android/ContactAccessorSdk5.java
+++ b/src/android/ContactAccessorSdk5.java
@@ -904,7 +904,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
             im.put("id", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im._ID)));
             im.put("pref", false); // Android does not store pref attribute
             im.put("value", cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.DATA)));
-            im.put("type", getImType(cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.PROTOCOL))));
+            im.put("type", getImType(Integer.parseInt(cursor.getString(cursor.getColumnIndex(CommonDataKinds.Im.PROTOCOL)))));
         } catch (JSONException e) {
             Log.e(LOG_TAG, e.getMessage(), e);
         }
@@ -1513,7 +1513,7 @@ public class ContactAccessorSdk5 extends ContactAccessor {
                 .withValueBackReference(ContactsContract.Data.RAW_CONTACT_ID, 0)
                 .withValue(ContactsContract.Data.MIMETYPE, CommonDataKinds.Im.CONTENT_ITEM_TYPE)
                 .withValue(CommonDataKinds.Im.DATA, getJsonString(im, "value"))
-                .withValue(CommonDataKinds.Im.TYPE, getImType(getJsonString(im, "type")))
+                .withValue(CommonDataKinds.Im.PROTOCOL, getImType(getJsonString(im, "type")))
                 .build());
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/0f8945b9/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index fc5fde5..24da0eb 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -677,6 +677,32 @@ exports.defineAutoTests = function() {
                     done();
                 }, done, this);
             }, MEDIUM_TIMEOUT);
+
+            it("contacts.spec.32 Find should return a contact with correct IM field", function(done)
{
+                // Save method is not supported on Windows platform
+                if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) {
+                    pending();
+                }
+                var contactName = "DeleteMe";
+                var ims = [{
+                    type: "Skype",
+                    value: "imValue"
+                }];
+                var contact = new Contact();
+                contact.name = new ContactName();
+                contact.name.familyName = contactName;
+                contact.note = "DeleteMe";
+                contact.ims = ims;
+                saveAndFindBy(contact, ["displayName", "name"], contactName, function(found)
{
+                    expect(found.ims).toEqual(jasmine.any(Array));
+                    expect(found.ims[0]).toBeDefined();
+                    if (found.ims[0]) {
+                        expect(found.ims[0].type).toEqual(ims[0].type);
+                        expect(found.ims[0].value).toEqual(ims[0].value);
+                    }
+                    done();
+                }, done, this);
+            }, MEDIUM_TIMEOUT);
         });
 
         describe('ContactError interface', function() {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message