Closed Bug 1002643 Opened 9 years ago Closed 9 years ago
Handover Manager unit tests .
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.131 Safari/537.36 Expected results: NfcHandoverManager lacks unit tests. Tests should assess that: - actions are queued properly while Bluetooth is disabled. - actions are executed after Bluetooth is turned on. - BT pairing and connection is performed when handleHandoverSelect() is called. - a couple more probably (ideas?) Draft for first two test cases is here: https://github.com/kamituel/gaia/commit/b23f8b20ac74f38e35c3f321b990328191afbe22
Summary: NfcHandoverManager queuing tests. → NfcHandoverManager unit tests.
9 years ago
To me the principle for writing tests for a module: function by function, figure out any combination of inputs and outputs for the function to be tested. * Have a clear function scope. * What's the possible input for this function? Test it. * What's the possible result after inputs? Test it.
@Alive, could you please assign me to this bug? (I can't do that myself, I don't have necessary Bugzilla permission yet)
I can assign. Assigning...
Assignee: nobody → kamituel
This bug blocks NFC 2.0 release.
In attachment, please find test cases for NfcHandoverManager. Test cases cover: - handover request/select - test whether, in positive scenario, NfcHandoverManager reacts correctly. This means it'll respond with handover select for incoming handover request, and it'll attempt to pair with peer device upon handover select. - when Bluetooth is on, whether actions are queued correctly and executed immediately after Bluetooth is turned on. - file transfer - test whether "nfc-manager-send-file" causes NfcHandoverManager to send handover request to peer device; similar for handover select. In addition to test cases existing already (by Arno), it should provide most important test cases for NfcHandoverManager (covering it's public API). While writing tests, I've also done some small refactoring, most notably I added CPS_* constants in nfc_utils.js / NDEF.
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. Please use https://github.com/mozilla-b2g/gaia/blob/master/shared/test/unit/mocks/mock_dom_request.js to implement all your dom request mocks before going further review.
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. I mark this for review, even though Travis build failed - I'm pretty confident failure wasn't caused by my commit. In fact, I've no idea what the error is, the only relevant message is: "Error: The name org.freedesktop.UPower was not provided by any .service files" Far, far from nfc ;)
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. Needs some finetune
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. Fixed your remarks, @Alive. Thanks for the review :) Oh, and Travis failed, here with message: "Waiting for server on port 8080 failed.". I think it's getting worse - is there some issue with Travis recently?
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. Please rebase and ask review again. Thanks and sorry being late.
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. Fixed your remarks and rebased.
Comment on attachment 8421854 [details] [review] Test cases for NfcHandoverManager. r+ with one question on github. Please leave comments here.
Attachment #8421854 - Flags: review?(alive) → review+
Alive, I've made MockBluetoothTransfer call NfcHandoverManager.transferComplete(true); to be able to test whether the whole process works, i.e. to see whether file transfer, when completed, will fire success on fileTransfer object.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → 2.0 S3 (6june)
You need to log in before you can comment on or make changes to this bug.