Skip to content
This repository was archived by the owner on Jan 26, 2024. It is now read-only.

Mock device support#17

Merged
bors-servo merged 6 commits intoservo:masterfrom
szeged:test-api
Oct 12, 2016
Merged

Mock device support#17
bors-servo merged 6 commits intoservo:masterfrom
szeged:test-api

Conversation

@dati91
Copy link
Copy Markdown
Contributor

@dati91 dati91 commented Oct 3, 2016

Adding mock device support for bluetooth.

Replaced the structs with enums, so we can implement the Bluetooth Test API with minimal code change.
For building the mock adapter, use --feature bluetooth-test.


This change is Reviewable

@dati91
Copy link
Copy Markdown
Contributor Author

dati91 commented Oct 3, 2016

r? @jdm

@larsbergstrom
Copy link
Copy Markdown
Contributor

Reviewed 3 of 3 files at r1, 2 of 2 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions.


src/bluetooth.rs, line 58 at r2 (raw file):

#[cfg(feature = "bluetooth-test")]
const NOT_SUPPORTED_ERROR: &'static str = "Error! Not supported function!";

How will this show up for developers? I see that the message is wrapped in an Err and returned in several places, but how will they know which function is not supported? If it won't be obvious from a call stack, it would be helpful to format the name of the function into the returned error message.


src/bluetooth.rs, line 70 at r2 (raw file):

    #[cfg(feature = "bluetooth-test")]
    Mock(Arc<FakeBluetoothAdapter>),
}

Given the complexity of the configuration space at this point, it might be worth a comment to describe what's going on here and what valid configuration sets are (e.g., which can co-exist like test and everything else). It's a nice set of macros, etc. to get the compiler to help you make sure you didn't miss one or have extra "can't happen" panic! paths in the code, but I do worry about the build-time experience a little.


Comments from Reviewable

@larsbergstrom
Copy link
Copy Markdown
Contributor

Just a couple of small nits and otherwise good to go!

@dati91
Copy link
Copy Markdown
Contributor Author

dati91 commented Oct 9, 2016

src/bluetooth.rs, line 58 at r2 (raw file):

Previously, larsbergstrom (Lars Bergstrom) wrote…

How will this show up for developers? I see that the message is wrapped in an Err and returned in several places, but how will they know which function is not supported? If it won't be obvious from a call stack, it would be helpful to format the name of the function into the returned error message.

This error will be returned if you want to use a mock function (e.g. set name) and your adapter/device/etc is not mock.

Comments from Reviewable

@zakorgy
Copy link
Copy Markdown
Contributor

zakorgy commented Oct 11, 2016

I wrote some description about the crate dependencies, features and usage in the README.md, with some example code in the first commit.
In the meantime I found, that the create_device, create_service, etc. methods should be public only when creating dummy structures, or else we can create "real" structures calling these functions, which is not the proper way doing that, the second commit fixes this.
Also removed lines longer than 120 character.
Are these changes sufficient ?

@larsbergstrom
Copy link
Copy Markdown
Contributor

@bors-servo r+

@bors-servo
Copy link
Copy Markdown

📌 Commit 434cb36 has been approved by larsbergstrom

@bors-servo
Copy link
Copy Markdown

⚡ Test exempted - status

@bors-servo bors-servo merged commit 434cb36 into servo:master Oct 12, 2016
bors-servo pushed a commit that referenced this pull request Oct 12, 2016
Mock device support

Adding mock device support for bluetooth.

Replaced the structs with enums, so we can implement the Bluetooth Test API with minimal code change.
For building the mock adapter, use `--feature bluetooth-test`.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/devices/17)
<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Nov 3, 2016
WebBluetooth Test API and tests

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612)

<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Nov 3, 2016
WebBluetooth Test API and tests

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612)

<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Nov 3, 2016
WebBluetooth Test API and tests

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612)

<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Nov 4, 2016
WebBluetooth Test API and tests

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612)

<!-- Reviewable:end -->
bors-servo pushed a commit to servo/servo that referenced this pull request Nov 4, 2016
WebBluetooth Test API and tests

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13612)

<!-- Reviewable:end -->
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 4, 2017
…st-api-impl); r=jdm

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: dae007fd1634bcf1545e67abaa7746fa95f10e94
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…st-api-impl); r=jdm

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: dae007fd1634bcf1545e67abaa7746fa95f10e94

UltraBlame original commit: 44661663a5b516d0df0b5743091b1ed1ff72bb25
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…st-api-impl); r=jdm

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: dae007fd1634bcf1545e67abaa7746fa95f10e94

UltraBlame original commit: 44661663a5b516d0df0b5743091b1ed1ff72bb25
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…st-api-impl); r=jdm

<!-- Please describe your changes on the following line: -->

This patch depends on the [devices mock device support PR](servo/devices#17).
After it lands, the Cargo files can be updated.
1. Adjust to the changes in [devices mock device support PR](servo/devices#17).
2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
3. Wpt tests for the already landed WebBluetooth functions.

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [x] There are tests for these changes

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: dae007fd1634bcf1545e67abaa7746fa95f10e94

UltraBlame original commit: 44661663a5b516d0df0b5743091b1ed1ff72bb25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants