|
1 | 1 | // Checks that the setting "line numbers" is working as expected.
|
2 | 2 | goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
3 | 3 |
|
| 4 | +// Otherwise, we can't check text color |
| 5 | +show-text: true |
| 6 | + |
4 | 7 | // We check that without this setting, there is no line number displayed.
|
5 | 8 | assert-false: "pre.example-line-numbers"
|
6 | 9 |
|
7 |
| -// We now set the setting to show the line numbers on code examples. |
8 |
| -local-storage: {"rustdoc-line-numbers": "true" } |
9 |
| -// We reload to make the line numbers appear. |
10 |
| -reload: |
11 |
| - |
12 |
| -// We wait for them to be added into the DOM by the JS... |
13 |
| -wait-for: "pre.example-line-numbers" |
14 |
| -// If the test didn't fail, it means that it was found! |
15 | 10 | // Let's now check some CSS properties...
|
16 |
| -assert-css: ("pre.example-line-numbers", { |
17 |
| - "margin": "0px", |
18 |
| - "padding": "13px 8px", |
19 |
| - "text-align": "right", |
| 11 | +define-function: ( |
| 12 | + "check-colors", |
| 13 | + (theme, color), |
| 14 | + [ |
| 15 | + // We now set the setting to show the line numbers on code examples. |
| 16 | + ("local-storage", { |
| 17 | + "rustdoc-theme": |theme|, |
| 18 | + "rustdoc-use-system-theme": "false", |
| 19 | + "rustdoc-line-numbers": "true" |
| 20 | + }), |
| 21 | + // We reload to make the line numbers appear and change theme. |
| 22 | + ("reload"), |
| 23 | + // We wait for them to be added into the DOM by the JS... |
| 24 | + ("wait-for", "pre.example-line-numbers"), |
| 25 | + // If the test didn't fail, it means that it was found! |
| 26 | + ("assert-css", ( |
| 27 | + "pre.example-line-numbers", |
| 28 | + { |
| 29 | + "color": |color|, |
| 30 | + "margin": "0px", |
| 31 | + "padding": "14px 8px", |
| 32 | + "text-align": "right", |
| 33 | + }, |
| 34 | + ALL, |
| 35 | + )), |
| 36 | + ], |
| 37 | +) |
| 38 | +call-function: ("check-colors", { |
| 39 | + "theme": "ayu", |
| 40 | + "color": "rgb(92, 103, 115)", |
20 | 41 | })
|
| 42 | +call-function: ("check-colors", { |
| 43 | + "theme": "dark", |
| 44 | + "color": "rgb(59, 145, 226)", |
| 45 | +}) |
| 46 | +call-function: ("check-colors", { |
| 47 | + "theme": "light", |
| 48 | + "color": "rgb(198, 126, 45)", |
| 49 | +}) |
| 50 | + |
21 | 51 | // The first code block has two lines so let's check its `<pre>` elements lists both of them.
|
22 | 52 | assert-text: ("pre.example-line-numbers", "1\n2")
|
23 | 53 |
|
|
0 commit comments