From 87b5f80b6fdbbfdcce748d010d24ce529c6576ef Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Tue, 9 Jul 2013 16:06:45 +0200 Subject: [PATCH] Bug 875710: Added marionette tests for getCardLockRetryCount, r=vyang The marionette tests for getCardLockRetryCount test retrieving the retry count for 'pin', 'puk', and an invalid lock type. The former two must return success or 'NotSupportedError', the latter may only return 'IllegalAccessError'. * * * fix mar --HG-- extra : rebase_source : 509cd74e783eaf8d77be8b37c7143f3043d69b28 --- .../tests/marionette/test_icc_card_lock.js | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/dom/icc/tests/marionette/test_icc_card_lock.js b/dom/icc/tests/marionette/test_icc_card_lock.js index 561229d55c49..51d0ef3544ad 100644 --- a/dom/icc/tests/marionette/test_icc_card_lock.js +++ b/dom/icc/tests/marionette/test_icc_card_lock.js @@ -90,10 +90,80 @@ function testPinChangeSuccess() { }; } +/* Read PIN-lock retry count */ +function testPinCardLockRetryCount() { + let request = icc.getCardLockRetryCount('pin'); + + ok(request instanceof DOMRequest, + 'request instanceof ' + request.constructor); + + request.onsuccess = function onsuccess() { + is(request.result.lockType, 'pin', + 'lockType is ' + request.result.lockType); + ok(request.result.retryCount >= 0, + 'retryCount is ' + request.result.retryCount); + runNextTest(); + }; + request.onerror = function onerror() { + // The operation is optional any might not be supported for all + // all locks. In this case, we generate 'NotSupportedError' for + // the valid lock types. + is(request.error.name, 'RequestNotSupported', + 'error name is ' + request.error.name); + runNextTest(); + }; +} + +/* Read PUK-lock retry count */ +function testPukCardLockRetryCount() { + let request = icc.getCardLockRetryCount('puk'); + + ok(request instanceof DOMRequest, + 'request instanceof ' + request.constructor); + + request.onsuccess = function onsuccess() { + is(request.result.lockType, 'puk', + 'lockType is ' + request.result.lockType); + ok(request.result.retryCount >= 0, + 'retryCount is ' + request.result.retryCount); + runNextTest(); + }; + request.onerror = function onerror() { + // The operation is optional any might not be supported for all + // all locks. In this case, we generate 'NotSupportedError' for + // the valid lock types. + is(request.error.name, 'RequestNotSupported', + 'error name is ' + request.error.name); + runNextTest(); + }; +} + +/* Read lock retry count for an invalid entries */ +function testInvalidCardLockRetryCount() { + let request = icc.getCardLockRetryCount('invalid-lock-type'); + + ok(request instanceof DOMRequest, + 'request instanceof ' + request.constructor); + + request.onsuccess = function onsuccess() { + ok(false, + 'request should never return success for an invalid lock type'); + runNextTest(); + }; + request.onerror = function onerror() { + is(request.error.name, 'GenericFailure', + 'error name is ' + request.error.name); + runNextTest(); + }; +} + let tests = [ testPinChangeFailed, testPinChangeFailedNotification, testPinChangeSuccess, + testPinCardLockRetryCount, + testPukCardLockRetryCount, + testInvalidCardLockRetryCount ]; function runNextTest() {