Skip to content

WebBluetooth Test API and tests#13612

Merged
bors-servo merged 3 commits intoservo:masterfrom
szeged:test-api-impl
Nov 4, 2016
Merged

WebBluetooth Test API and tests#13612
bors-servo merged 3 commits intoservo:masterfrom
szeged:test-api-impl

Conversation

@zakorgy
Copy link
Copy Markdown
Contributor

@zakorgy zakorgy commented Oct 6, 2016

This patch depends on the devices mock device support PR.
After it lands, the Cargo files can be updated.

  1. Adjust to the changes in devices mock device support PR.
  2. WebBluetooth Test API implementation. Based on : https://webbluetoothcg.github.io/web-bluetooth/tests.html
  3. Wpt tests for the already landed WebBluetooth functions.
  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • There are tests for these changes

This change is Reviewable

@highfive
Copy link
Copy Markdown

highfive commented Oct 6, 2016

Heads up! This PR modifies the following files:

  • @KiChjang: components/net/lib.rs, components/script/dom/mod.rs, components/script/dom/webidls/Window.webidl, components/net/bluetooth_thread.rs, components/script/dom/window.rs, components/net/bluetooth_test.rs, components/net/Cargo.toml, components/net_traits/bluetooth_thread.rs, components/net_traits/bluetooth_thread.rs, components/script/dom/webidls/TestRunner.webidl, components/script/dom/testrunner.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Oct 6, 2016
@highfive
Copy link
Copy Markdown

highfive commented Oct 6, 2016

warning Warning warning

  • These commits include an empty title element (<title></title>). Consider adding appropriate metadata.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests/unit/net instead?

@Manishearth
Copy link
Copy Markdown
Member

Not sure if I'm the one to review this, I don't know anything about bluetooth

@dati91
Copy link
Copy Markdown
Contributor

dati91 commented Oct 6, 2016

r? @jdm

@highfive highfive assigned jdm and unassigned Manishearth Oct 6, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #13596) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Oct 7, 2016
@zakorgy zakorgy force-pushed the test-api-impl branch 2 times, most recently from d866053 to bbbe8a8 Compare October 14, 2016 14:22
@jdm jdm removed the S-needs-rebase There are merge conflict errors. label Oct 14, 2016
@jdm
Copy link
Copy Markdown
Member

jdm commented Oct 14, 2016

I'm sorry that I haven't reviewed this yet. I've been swamped with reviews in multiple projects recently; this is in my queue.

Copy link
Copy Markdown
Member

@jdm jdm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So many tests for previous untestable code! This is really great! However, there is a lot of duplication in the test files, which makes them harder to read and maintain in the future. I propose we create helper functions for each class of test (out of range, disconnect after, disconnect during, etc.) that takes a callback, and move as much of the common code into the helpers as possible. I'm even tempted to suggest that the tests be organized in files that test those cases for all of the different methods, rather than having separate files that duplicate tests in each subdirectory. Does that make sense?

Some(a) => a,
None => return drop(sender.send(Err(BluetoothError::Type(ADAPTER_ERROR.to_string())))),
};
let device = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we make a device_from_service_id helper that returns Option<BluetoothDevice> and use it here and below?


// callback BluetoothManualChooserEventsCallback = void(sequence<DOMString> events);

[Pref="dom.bluetooth.enabled", Exposed=(Window,Worker)]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is WebBluetooth supposed to be exposed in workers? Let's use the dom.bluetooth.testing.enabled preference here instead, too.


// https://webbluetoothcg.github.io/web-bluetooth/tests#test-interfaces
partial interface Window {
readonly attribute TestRunner testRunner;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://webbluetoothcg.github.io/web-bluetooth/tests#security-and-privacy suggests that this should have a Pref annotation for a separate preference like dom.bluetooth.testing.enabled.

let (sender, receiver) = ipc::channel().unwrap();
self.get_bluetooth_thread().send(BluetoothMethodMsg::Test(String::from(dataSetName), sender)).unwrap();

let result = receiver.recv().unwrap();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can replace this line and the match with receiver.recv().unwrap().into().

}

fn get_bluetooth_thread(&self) -> IpcSender<BluetoothMethodMsg> {
self.global().as_window().bluetooth_thread()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks like we don't expect bluetooth to work in Workers (as mentioned in a later comment).

}

pub fn test(manager: &mut BluetoothManager, data_set_name: String, sender: &IpcSender<BluetoothResult<()>>) {
match manager.get_or_create_adapter().as_ref() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let adapter = match manager.get_or_create_adapter().as_ref() {
    Some(adapter) => adapter,
    None => return drop(sender.send(...)),
};

GLUCOSE_HEART_RATE_ADAPTER => {
set_adapter(adapter, GLUCOSE_HEART_RATE_ADAPTER.to_owned(), sender);

// Glucose Device
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the comments with the device names in this code add much - we already call the local variables names like glucose_device, and we're passing arguments like GLUCOSE_DEVICE_NAME :)

})
.then(device => device.gatt.connect())
.then(gattServer => assert_true(gattServer.connected))
.catch(error => assert_unreached('Promise should have resolved. ' + error));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe promise_test automatically fails tests for unexpected rejections, so this can be removed from all the tests.

});
})
.catch(error => assert_unreached('Promise should have resolved. ' + error));
}, 'disconnect() called before getCharacteristic. Reject with NetworkError.');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/before/during/

.then(service => service.getCharacteristics(body_sensor_location.name))
.then(characteristics => {
for (let i = 1; i < characteristics.length; i++) {
characteristics[i].readValue()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to store each promise in a vector, and return Promise.all(promises) from this function.

@jdm
Copy link
Copy Markdown
Member

jdm commented Oct 14, 2016

Note - I stopped reviewing the third commit about halfway through the tests once I realized how much duplication I was seeing. I believe it will be easier to review the tests after they are reorganized according to my suggestion.

@jdm jdm added S-needs-code-changes Changes have not yet been made that were requested by a reviewer. and removed S-awaiting-review There is new code that needs to be reviewed. labels Oct 14, 2016
@zakorgy zakorgy changed the title [WIP] WebBluetooth Test API and tests WebBluetooth Test API and tests Oct 18, 2016
@zakorgy zakorgy mentioned this pull request Oct 18, 2016
2 tasks
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Oct 18, 2016
@zakorgy
Copy link
Copy Markdown
Contributor Author

zakorgy commented Oct 18, 2016

@jdm we have fixed the first and second commit as you mentioned, this also indicated some changes in the third as well. We have not modified the tests yet, because the chrome folks have almost the same implementation with similar structure, and we wanted to stay consistent with their implementation.
On the other hand I agree, that organizing the tests as you requested, will make it more maintainable. If you really insist to the changes, we will do it in a next commit.

@dati91
Copy link
Copy Markdown
Contributor

dati91 commented Oct 20, 2016

So the main reason behind wanting to be consistent with chrome is that we think these tests should be platform/browser independent. I think in the near (or at least not "that" far) future these tests should be in a shared repository where all implementing browser can find and use them. That beeing said I could totally see (here or later there) your recommendation where we move out all the duplicated code for easier and cleaner use. But AFAIK there will be a new, more dynamic testing api which will replace the current one (and will modify these tests also). This is the main reason why the current Testing API document is (almost) deprecated.

@jdm
Copy link
Copy Markdown
Member

jdm commented Oct 20, 2016

Good to know.

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-needs-rebase There are merge conflict errors. labels Nov 4, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit b468990 with merge a334747...

bors-servo pushed a commit 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
Copy link
Copy Markdown
Contributor

💔 Test failed - linux-dev

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Nov 4, 2016
@larsbergstrom
Copy link
Copy Markdown
Contributor

diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index c7679cc..a165ac6 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -170,6 +170,7 @@ dependencies = [
  "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
  "tinyfiledialogs 0.1.0 (git+https://github.com/jdm/tinyfiledialogs)",
  "util 0.0.1",
+ "uuid 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
 ]

You may need to ./mach cargo-update -p uuid

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 4, 2016
@jdm
Copy link
Copy Markdown
Member

jdm commented Nov 4, 2016

@bors-servo: r+

@bors-servo
Copy link
Copy Markdown
Contributor

📌 Commit ada0256 has been approved by jdm

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. labels Nov 4, 2016
@bors-servo
Copy link
Copy Markdown
Contributor

⌛ Testing commit ada0256 with merge dae007f...

bors-servo pushed a commit 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
Copy link
Copy Markdown
Contributor

@bors-servo bors-servo merged commit ada0256 into servo:master Nov 4, 2016
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 4, 2016
bors-servo pushed a commit that referenced this pull request Nov 7, 2016
Webbluetooth Async behaviour

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

Note: depends on #13612

The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec).

<!-- 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/13909)

<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Nov 7, 2016
WebBluetooth fixes for the wpt tests

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

Note: depends on #13612
WebBluetooth fixes for the failing wpt tests, excluding the `disconnect-during` tests cases, due to the lack of the event handling in the current implementation.
---

<!-- 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
- [x] There are tests for these changes OR

<!-- 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/13918)

<!-- Reviewable:end -->
bors-servo pushed a commit that referenced this pull request Nov 8, 2016
Webbluetooth Async behaviour

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

Note: depends on #13612

The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec).

<!-- 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/13909)

<!-- Reviewable:end -->
@dati91 dati91 mentioned this pull request Jan 17, 2017
5 tasks
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Feb 4, 2017
…se-queue); r=jdm

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

Note: depends on servo/servo#13612

The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec).

<!-- 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: 1153ca9841f458daf373471f3c65295abd872271
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 1, 2019
…se-queue); r=jdm

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

Note: depends on servo/servo#13612

The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec).

<!-- 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: 1153ca9841f458daf373471f3c65295abd872271

UltraBlame original commit: 30cc9f4ec923a5bb7fc43857675aa2c6bf572e47
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 1, 2019
…se-queue); r=jdm

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

Note: depends on servo/servo#13612

The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec).

<!-- 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: 1153ca9841f458daf373471f3c65295abd872271

UltraBlame original commit: 30cc9f4ec923a5bb7fc43857675aa2c6bf572e47
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 1, 2019
…se-queue); r=jdm

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

Note: depends on servo/servo#13612

The current WBT communication is synchronous. With this, it should work properly (except the disconnect function, which will need some more work, because the current implementation differ from the spec).

<!-- 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: 1153ca9841f458daf373471f3c65295abd872271

UltraBlame original commit: 30cc9f4ec923a5bb7fc43857675aa2c6bf572e47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants