Closed Bug 1002643 Opened 9 years ago Closed 9 years ago

NfcHandoverManager unit tests.

Categories

(Firefox OS Graveyard :: NFC, defect)

defect
Not set
normal

Tracking

(tracking-b2g:backlog)

RESOLVED FIXED
2.0 S3 (6june)
tracking-b2g backlog

People

(Reporter: kamituel, Assigned: kamituel)

References

Details

Attachments

(1 file)

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.
Flags: needinfo?(alive)
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.
Flags: needinfo?(alive)
@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.
Blocks: b2g-NFC-2.0
Depends on: 1005886
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Depends on: 1007237
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.
Attachment #8421854 - Flags: review?(alive)
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.
Attachment #8421854 - Flags: review?(alive)
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 ;)
Attachment #8421854 - Flags: review?(alive)
blocking-b2g: --- → backlog
Comment on attachment 8421854 [details] [review]
Test cases for NfcHandoverManager.

Needs some finetune
Attachment #8421854 - Flags: review?(alive)
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?
Attachment #8421854 - Flags: review?(alive)
Comment on attachment 8421854 [details] [review]
Test cases for NfcHandoverManager.

Please rebase and ask review again. Thanks and sorry being late.
Attachment #8421854 - Flags: review?(alive)
Comment on attachment 8421854 [details] [review]
Test cases for NfcHandoverManager.

Fixed your remarks and rebased.
Attachment #8421854 - Flags: review?(alive)
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+
Whiteboard: checkin-needed
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.
master: https://github.com/mozilla-b2g/gaia/commit/832154d8dccb59ed575e4825bb3283fd1fed13f1
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Whiteboard: checkin-needed
Target Milestone: --- → 2.0 S3 (6june)
blocking-b2g: backlog → ---
You need to log in before you can comment on or make changes to this bug.