Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6507619DE9 for ; Tue, 29 Mar 2016 21:42:10 +0000 (UTC) Received: (qmail 71956 invoked by uid 500); 29 Mar 2016 21:42:10 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 71928 invoked by uid 500); 29 Mar 2016 21:42:10 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 71919 invoked by uid 99); 29 Mar 2016 21:42:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Mar 2016 21:42:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 12004DFD43; Tue, 29 Mar 2016 21:42:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: omefire@apache.org To: commits@cordova.apache.org Message-Id: <8fdb97b109434465956054ea4731c06a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cordova-plugin-contacts git commit: CB-10881 Add extra logging to gather more information about tests behavior Date: Tue, 29 Mar 2016 21:42:10 +0000 (UTC) Repository: cordova-plugin-contacts Updated Branches: refs/heads/master 1c6668ef1 -> 8a08f75ca CB-10881 Add extra logging to gather more information about tests behavior 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/8a08f75c Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/tree/8a08f75c Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/diff/8a08f75c Branch: refs/heads/master Commit: 8a08f75cad9e6b127884e9e5e2fae3e44225c702 Parents: 1c6668e Author: Omar Mefire Authored: Tue Mar 29 12:51:46 2016 -0700 Committer: Omar Mefire Committed: Tue Mar 29 14:39:38 2016 -0700 ---------------------------------------------------------------------- tests/tests.js | 100 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts/blob/8a08f75c/tests/tests.js ---------------------------------------------------------------------- diff --git a/tests/tests.js b/tests/tests.js index 951a284..18def3a 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -49,7 +49,7 @@ exports.defineAutoTests = function() { }; var MEDIUM_TIMEOUT = 30000; - + var removeContact = function(done) { if (!gContactObj) { done(); @@ -116,6 +116,24 @@ exports.defineAutoTests = function() { removeNext(nextToRemove); }, done, obj); } + + // Convert seconds to HH:MM:SS format: http://stackoverflow.com/a/6313008/91607 + function toHHMMSS(secs) { + var sec_num = parseInt(secs, 10); // don't forget the second param + var hours = Math.floor(sec_num / 3600); + var minutes = Math.floor((sec_num - (hours * 3600)) / 60); + var seconds = sec_num - (hours * 3600) - (minutes * 60); + + if (hours < 10) {hours = "0" + hours;} + if (minutes < 10) {minutes = "0" + minutes;} + if (seconds < 10) {seconds = "0" + seconds;} + var time = hours + ':' + minutes + ':' + seconds; + return time; + } + + function getTimeInHHMMSS(date) { + return date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds(); + } describe("Contacts (navigator.contacts)", function() { it("contacts.spec.1 should exist", function() { @@ -198,7 +216,7 @@ exports.defineAutoTests = function() { }); describe("with newly-created contact", function() { - + afterEach(function (done) { removeContact(done); }); @@ -452,6 +470,10 @@ exports.defineAutoTests = function() { }); it("contacts.spec.22 update a contact", function(done) { + + var startTime = new Date(); + console.log("Spec22 - Start Time: " + getTimeInHHMMSS(startTime)); + // Save method is not supported on Windows platform if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) { pending(); @@ -477,7 +499,12 @@ exports.defineAutoTests = function() { "birthday": aDay }; - var saveFail = fail.bind(null, done); + var saveFail = function() { + var endTime = new Date(); + console.log("Spec22 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime.getTime() / 1000) - (endTime.getTime() / 1000) )); + fail.bind(null, done); + }; function updateSuccess(obj) { expect(obj).toBeDefined(); @@ -486,6 +513,11 @@ exports.defineAutoTests = function() { expect(obj.birthday.toDateString()).toBe(bDay.toDateString()); expect(obj.emails.length).toBe(1); expect(obj.emails[0].value).toBe('here@there.com'); + + var endTime = new Date(); + console.log("Spec22 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime.getTime() / 1000) - (endTime.getTime() / 1000) )); + done(); } @@ -511,13 +543,28 @@ exports.defineAutoTests = function() { }); it("contacts.spec.23 calling remove on a contact that has an id of null should return ContactError.UNKNOWN_ERROR", function(done) { + var startTime = new Date(); + console.log("Spec23 - Start Time: " + getTimeInHHMMSS(startTime)); + + var unexpectedSuccess = function() { + var endTime = new Date(); + console.log("Spec23 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + + fail.bind(null, done); + }; var expectedFail = function(result) { expect(result.code).toBe(ContactError.UNKNOWN_ERROR); + + var endTime = new Date(); + console.log("Spec23 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + done(); }; var rmContact = new Contact(); - rmContact.remove(fail.bind(null, done), expectedFail); + rmContact.remove(unexpectedSuccess, expectedFail); }); it("contacts.spec.24 calling remove on a contact that does not exist should return ContactError.UNKNOWN_ERROR", function(done) { @@ -574,6 +621,10 @@ exports.defineAutoTests = function() { }, MEDIUM_TIMEOUT); it("contacts.spec.26 Creating, saving, finding a contact should work, removing it should work", function(done) { + + var startTime = new Date(); + console.log("Spec26 - Start Time: " + getTimeInHHMMSS(startTime)); + // Save method is not supported on Windows platform if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) { pending(); @@ -586,14 +637,28 @@ exports.defineAutoTests = function() { saveAndFindBy(contact, ["displayName", "name"], contactName, function() { contact.remove(function() { contact = null; + + var endTime = new Date(); + console.log("Spec26 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + done(); }, function(e) { - throw ("Newly created contact's remove function invoked error callback. Test failed."); + + var endTime = new Date(); + console.log("Spec26 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + + throw ("Newly created contact's remove function invoked error callback. Test failed: " + JSON.stringify(e)); }); }); }, MEDIUM_TIMEOUT); it("contacts.spec.27 Should not be able to delete the same contact twice", function(done) { + + var startTime = new Date(); + console.log("Spec27 - Start Time: " + getTimeInHHMMSS(startTime)); + // Save method is not supported on Windows platform if (isWindows || isWindowsPhone8 || isIOSPermissionBlocked) { pending(); @@ -603,14 +668,33 @@ exports.defineAutoTests = function() { contact.name = new ContactName(); contact.name.familyName = contactName; contact.note = "DeleteMe2"; + + var failureHandler = function() { + console.log("Inside failureHandler"); + var endTime = new Date(); + console.log("Spec27 - EndTime: " + endTime); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + }; + saveAndFindBy(contact, ["displayName", "name"], contactName, function() { contact.remove(function() { var findWin = function(seas) { expect(seas.length).toBe(0); - contact.remove(function() { - throw ("Success callback called after non-existent Contact object called remove(). Test failed."); + contact.remove(function(e) { + + var endTime = new Date(); + console.log("Spec27 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + + throw ("Success callback called after non-existent Contact object called remove(). Test failed: " + JSON.stringify(e)); }, function(e) { contact = null; + + console.log("Inside contact.remove() failure callback"); + var endTime = new Date(); + console.log("Spec27 - EndTime: " + getTimeInHHMMSS(endTime)); + console.log("Time Elapsed: " + toHHMMSS( (startTime / 1000) - (endTime / 1000) )); + expect(e.code).toBe(ContactError.UNKNOWN_ERROR); done(); }); @@ -619,7 +703,7 @@ exports.defineAutoTests = function() { obj.filter = contactName; obj.multiple = true; navigator.contacts.find(["displayName", "name", "phoneNumbers", "emails"], findWin, fail, obj); - }, fail); + }, failureHandler); }); }, MEDIUM_TIMEOUT); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org