Skip to content

Commit ca2b74f

Browse files
committed
Auto merge of #115857 - notriddle:notriddle/gui-test-themes, r=GuillaumeGomez
rusdoc: add gui test for custom CSS themes Based on #115829 (comment)
2 parents dac91a8 + cbccf80 commit ca2b74f

File tree

6 files changed

+149
-1
lines changed

6 files changed

+149
-1
lines changed

tests/rustdoc-gui/sidebar-source-code.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
7373
// Only "another_folder" should be "open" in "lib2".
7474
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
7575
// All other trees should be collapsed.
76-
assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 9)
76+
assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 10)
7777

7878
// We now switch to mobile mode.
7979
set-window-size: (600, 600)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is automatically @generated by Cargo.
2+
# It is not intended for manual editing.
3+
version = 3
4+
5+
[[package]]
6+
name = "theme_css"
7+
version = "0.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "theme_css"
3+
version = "0.1.0"
4+
edition = "2018"
5+
6+
[lib]
7+
path = "lib.rs"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
:root {
2+
--main-background-color: red;
3+
--main-color: black;
4+
--settings-input-color: #2196f3;
5+
--settings-input-border-color: #717171;
6+
--settings-button-color: #000;
7+
--settings-button-border-focus: #717171;
8+
--sidebar-background-color: #f5f5f5;
9+
--sidebar-background-color-hover: #e0e0e0;
10+
--code-block-background-color: #f5f5f5;
11+
--scrollbar-track-background-color: #dcdcdc;
12+
--scrollbar-thumb-background-color: rgba(36, 37, 39, 0.6);
13+
--scrollbar-color: rgba(36, 37, 39, 0.6) #d9d9d9;
14+
--headings-border-bottom-color: #ddd;
15+
--border-color: #e0e0e0;
16+
--button-background-color: #fff;
17+
--right-side-color: grey;
18+
--code-attribute-color: #999;
19+
--toggles-color: #999;
20+
--toggle-filter: none;
21+
--search-input-focused-border-color: #66afe9;
22+
--copy-path-button-color: #999;
23+
--copy-path-img-filter: invert(50%);
24+
--copy-path-img-hover-filter: invert(35%);
25+
--codeblock-error-hover-color: rgb(255, 0, 0);
26+
--codeblock-error-color: rgba(255, 0, 0, .5);
27+
--codeblock-ignore-hover-color: rgb(255, 142, 0);
28+
--codeblock-ignore-color: rgba(255, 142, 0, .6);
29+
--warning-border-color: #ff8e00;
30+
--type-link-color: #ad378a;
31+
--trait-link-color: #6e4fc9;
32+
--assoc-item-link-color: #3873ad;
33+
--function-link-color: #ad7c37;
34+
--macro-link-color: #068000;
35+
--keyword-link-color: #3873ad;
36+
--mod-link-color: #3873ad;
37+
--link-color: #3873ad;
38+
--sidebar-link-color: #356da4;
39+
--sidebar-current-link-background-color: #fff;
40+
--search-result-link-focus-background-color: #ccc;
41+
--search-result-border-color: #aaa3;
42+
--search-color: #000;
43+
--search-error-code-background-color: #d0cccc;
44+
--search-results-alias-color: #000;
45+
--search-results-grey-color: #999;
46+
--search-tab-title-count-color: #888;
47+
--search-tab-button-not-selected-border-top-color: #e6e6e6;
48+
--search-tab-button-not-selected-background: #e6e6e6;
49+
--search-tab-button-selected-border-top-color: #0089ff;
50+
--search-tab-button-selected-background: #fff;
51+
--stab-background-color: #fff5d6;
52+
--stab-code-color: #000;
53+
--code-highlight-kw-color: #8959a8;
54+
--code-highlight-kw-2-color: #4271ae;
55+
--code-highlight-lifetime-color: #b76514;
56+
--code-highlight-prelude-color: #4271ae;
57+
--code-highlight-prelude-val-color: #c82829;
58+
--code-highlight-number-color: #718c00;
59+
--code-highlight-string-color: #718c00;
60+
--code-highlight-literal-color: #c82829;
61+
--code-highlight-attribute-color: #c82829;
62+
--code-highlight-self-color: #c82829;
63+
--code-highlight-macro-color: #3e999f;
64+
--code-highlight-question-mark-color: #ff9011;
65+
--code-highlight-comment-color: #8e908c;
66+
--code-highlight-doc-comment-color: #4d4d4c;
67+
--src-line-numbers-span-color: #c67e2d;
68+
--src-line-number-highlighted-background-color: #fdffd3;
69+
--test-arrow-color: #f5f5f5;
70+
--test-arrow-background-color: rgba(78, 139, 202, 0.2);
71+
--test-arrow-hover-color: #f5f5f5;
72+
--test-arrow-hover-background-color: rgb(78, 139, 202);
73+
--target-background-color: #fdffd3;
74+
--target-border-color: #ad7c37;
75+
--kbd-color: #000;
76+
--kbd-background: #fafbfc;
77+
--kbd-box-shadow-color: #c6cbd1;
78+
--rust-logo-filter: initial;
79+
/* match border-color; uses https://codepen.io/sosuke/pen/Pjoqqp */
80+
--crate-search-div-filter: invert(100%) sepia(0%) saturate(4223%) hue-rotate(289deg)
81+
brightness(114%) contrast(76%);
82+
--crate-search-div-hover-filter: invert(44%) sepia(18%) saturate(23%) hue-rotate(317deg)
83+
brightness(96%) contrast(93%);
84+
--crate-search-hover-border: #717171;
85+
--src-sidebar-background-selected: #fff;
86+
--src-sidebar-background-hover: #e0e0e0;
87+
--table-alt-row-background-color: #f5f5f5;
88+
--codeblock-link-background: #eee;
89+
--scrape-example-toggle-line-background: #ccc;
90+
--scrape-example-toggle-line-hover-background: #999;
91+
--scrape-example-code-line-highlight: #fcffd6;
92+
--scrape-example-code-line-highlight-focus: #f6fdb0;
93+
--scrape-example-help-border-color: #555;
94+
--scrape-example-help-color: #333;
95+
--scrape-example-help-hover-border-color: #000;
96+
--scrape-example-help-hover-color: #000;
97+
--scrape-example-code-wrapper-background-start: rgba(255, 255, 255, 1);
98+
--scrape-example-code-wrapper-background-end: rgba(255, 255, 255, 0);
99+
}
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// compile-flags: --theme custom-theme.css
2+
//! <div class="custom-text">custom text</div>

tests/rustdoc-gui/theme-change.goml

+33
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,36 @@ assert-local-storage: { "rustdoc-theme": "light" }
6565
reload:
6666
wait-for: "#settings"
6767
assert: "#preferred-light-theme.setting-line.hidden"
68+
69+
// Ensures that the custom theme feature is working as expected.
70+
go-to: "file://" + |DOC_PATH| + "/theme_css/index.html"
71+
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": "dark"}
72+
reload:
73+
74+
store-value: (background_light, "white")
75+
store-value: (background_dark, "#353535")
76+
store-value: (background_ayu, "#0f1419")
77+
store-value: (background_custom_theme, "red")
78+
79+
click: "#settings-menu"
80+
wait-for: "#theme-ayu"
81+
click: "#theme-ayu"
82+
// should be the ayu theme so let's check the color.
83+
wait-for-css: ("body", { "background-color": |background_ayu| })
84+
assert-local-storage: { "rustdoc-theme": "ayu" }
85+
assert-text: (".custom-text", "custom text")
86+
click: "#theme-light"
87+
// should be the light theme so let's check the color.
88+
wait-for-css: ("body", { "background-color": |background_light| })
89+
assert-local-storage: { "rustdoc-theme": "light" }
90+
assert-text: (".custom-text", "custom text")
91+
click: "#theme-dark"
92+
// Should be the dark theme so let's check the color.
93+
wait-for-css: ("body", { "background-color": |background_dark| })
94+
assert-local-storage: { "rustdoc-theme": "dark" }
95+
assert-text: (".custom-text", "custom text")
96+
click: "#theme-custom-theme"
97+
// Should be the custom theme so let's check the color.
98+
wait-for-css: ("body", { "background-color": |background_custom_theme| })
99+
assert-local-storage: { "rustdoc-theme": "custom-theme" }
100+
assert-text: (".custom-text", "custom text")

0 commit comments

Comments
 (0)