Skip to content

Commit 4856bdd

Browse files
Align bluetooth tests with the spec (#51018)
1 parent 5116221 commit 4856bdd

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

Diff for: tools/webdriver/webdriver/bidi/modules/bluetooth.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,15 @@ def handle_request_device_prompt(self, context: str, prompt: str, accept: bool,
2323
}
2424

2525
@command
26-
def simulate_adapter(self, context: str, state: str) -> Mapping[str, Any]:
26+
def simulate_adapter(self, context: str, state: str, type_: str) -> Mapping[str, Any]:
2727
"""
2828
Represents a command `bluetooth.simulateAdapter` specified in
2929
https://webbluetoothcg.github.io/web-bluetooth/#bluetooth-simulateAdapter-command
3030
"""
3131
return {
3232
"context": context,
33-
"state": state
33+
"state": state,
34+
"type": type_
3435
}
3536

3637
@command

Diff for: tools/wptrunner/wptrunner/executors/asyncactions.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ async def __call__(self, payload):
5555
raise ValueError("Unexpected context type: %s" % context)
5656

5757
state = payload["state"]
58-
return await self.protocol.bidi_bluetooth.simulate_adapter(context, state)
58+
return await self.protocol.bidi_bluetooth.simulate_adapter(context,
59+
state,
60+
type_="create")
5961

6062
class BidiBluetoothSimulatePreconnectedPeripheralAction:
6163
name = "bidi.bluetooth.simulate_preconnected_peripheral"

Diff for: tools/wptrunner/wptrunner/executors/executorwebdriver.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ def setup(self):
138138

139139
async def simulate_adapter(self,
140140
context: str,
141-
state: str) -> None:
141+
state: str,
142+
type_: str) -> None:
142143
await self.webdriver.bidi_session.bluetooth.simulate_adapter(
143-
context=context, state=state)
144+
context=context, state=state, type_=type_)
144145

145146
async def simulate_preconnected_peripheral(self,
146147
context: str,

Diff for: tools/wptrunner/wptrunner/executors/protocol.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ async def handle_request_device_prompt(self,
355355
@abstractmethod
356356
async def simulate_adapter(self,
357357
context: str,
358-
state: str) -> None:
358+
state: str,
359+
type_: str) -> None:
359360
"""
360361
Creates a simulated bluetooth adapter.
361362
:param context: Browsing context to set the simulated adapter to.

Diff for: webdriver/tests/bidi/external/bluetooth/simulate_adapter/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ async def set_simulate_adapter(bidi_session, context, test_page, state):
1515
url=test_page, wait="complete")
1616

1717
await bidi_session.bluetooth.simulate_adapter(context=context["context"],
18-
state=state)
18+
state=state, type_="create")

Diff for: webdriver/tests/bidi/external/bluetooth/simulate_adapter/invalid.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88
async def test_state_invalid_type(bidi_session, top_context, state):
99
with pytest.raises(error.InvalidArgumentException):
1010
await bidi_session.bluetooth.simulate_adapter(
11-
context=top_context["context"], state=state)
11+
context=top_context["context"], state=state, type_="create")
1212

1313

1414
@pytest.mark.parametrize("state", ["", "invalid"])
1515
async def test_state_invalid_value(bidi_session, top_context, state):
1616
with pytest.raises(error.InvalidArgumentException):
1717
await bidi_session.bluetooth.simulate_adapter(
18-
context=top_context["context"], state=state)
18+
context=top_context["context"], state=state, type_="create")
1919

2020

2121
@pytest.mark.parametrize("context", [None, False, 42, {}, []])
2222
async def test_context_invalid_type(bidi_session, context):
2323
with pytest.raises(error.InvalidArgumentException):
2424
await bidi_session.bluetooth.simulate_adapter(
25-
context=context, state="powered-on")
25+
context=context, state="powered-on", type_="create")
2626

2727

2828
async def test_context_unknown_value(bidi_session):
2929
with pytest.raises(error.NoSuchFrameException):
3030
await bidi_session.bluetooth.simulate_adapter(
31-
context="UNKNOWN_CONTEXT", state="powered-on")
31+
context="UNKNOWN_CONTEXT", state="powered-on", type_="create")

Diff for: webdriver/tests/bidi/external/bluetooth/simulate_preconnected_peripheral/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ async def set_simulate_preconnected_peripheral(bidi_session, context, test_page,
66
await bidi_session.browsing_context.navigate(context=context['context'],
77
url=test_page, wait="complete")
88
await bidi_session.bluetooth.simulate_adapter(context=context["context"],
9-
state="powered-on")
9+
state="powered-on", type_="create")
1010
await bidi_session.bluetooth.simulate_preconnected_peripheral(
1111
context=context["context"],
1212
address=address, name=name,

0 commit comments

Comments
 (0)