Skip to content

Commit ee6da9d

Browse files
reillyeonchromium-wpt-export-bot
authored andcommitted
serial: Add manual test for control flow behavior
This test uses a device configured for loopback (with RTS and CTS) lines connected to validate that the RTS pin can be configured manually or automatically depending on the flow control configuration. Bug: 1287309 Change-Id: Id260d41fcb714529bf3e3754608db6485d2901e2 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3390190 Auto-Submit: Reilly Grant <[email protected]> Reviewed-by: Matt Reynolds <[email protected]> Commit-Queue: Matt Reynolds <[email protected]> Cr-Commit-Position: refs/heads/main@{#961185}
1 parent 466383c commit ee6da9d

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8">
5+
<title></title>
6+
<script src="/resources/testharness.js"></script>
7+
<script src="/resources/testharnessreport.js"></script>
8+
<script src="resources/common.js"></script>
9+
<script src="resources/manual.js"></script>
10+
</head>
11+
<body>
12+
<p>
13+
These tests require a connected serial device configured to act as a
14+
"loopback" device, with the TX and RX pins and RTS and CTS pins wired
15+
together.
16+
</p>
17+
<script>
18+
manual_serial_test(async (t, port) => {
19+
await port.open({
20+
baudRate: 115200,
21+
bufferSize: 255,
22+
flowControl: 'none'
23+
});
24+
t.add_cleanup(async () => {
25+
await port.close();
26+
});
27+
28+
await port.setSignals({ requestToSend: true });
29+
let signals = await port.getSignals();
30+
assert_true(signals.clearToSend);
31+
32+
await port.setSignals({ requestToSend: false });
33+
signals = await port.getSignals();
34+
assert_false(signals.clearToSend);
35+
}, 'Manual RTS control works with no flow control enabled');
36+
37+
manual_serial_test(async (t, port) => {
38+
await port.open({
39+
baudRate: 115200,
40+
bufferSize: 255,
41+
flowControl: 'hardware'
42+
});
43+
44+
const writer = port.writable.getWriter();
45+
t.add_cleanup(async () => {
46+
writer.releaseLock();
47+
await port.close();
48+
});
49+
50+
assert_true((await port.getSignals()).clearToSend);
51+
52+
const buffer = new Uint8Array(1);
53+
while ((await port.getSignals()).clearToSend) {
54+
await writer.write(buffer);
55+
}
56+
}, 'Hardware flow control automatically sets RTS pin');
57+
</script>
58+
</body>
59+
</html>

0 commit comments

Comments
 (0)