summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-gui/scrape-examples-color.goml
blob: 67c58826efc2691e226365fe3a4b9a0253af9353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Check that scrape example code blocks have the expected colors.
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
show-text: true

define-function: (
    "check-colors",
    (theme, highlight, highlight_focus, help_border, help_color, help_hover_border,
     help_hover_color),
    block {
        local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
        reload:
        wait-for: ".more-examples-toggle"
        assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
            "background-color": |highlight|,
        }, ALL)
        assert-css: (".scraped-example .example-wrap .rust span.highlight.focus", {
            "background-color": |highlight_focus|,
        }, ALL)

        assert-css: (".scraped-example-list .scrape-help", {
            "border-color": |help_border|,
            "color": |help_color|,
        })
        move-cursor-to: ".scraped-example-list .scrape-help"
        assert-css: (".scraped-example-list .scrape-help:hover", {
            "border-color": |help_hover_border|,
            "color": |help_hover_color|,
        })
        // Moving the cursor to another item to not break next runs.
        move-cursor-to: ".search-input"
    }
)

call-function: ("check-colors", {
    "theme": "ayu",
    "highlight": "rgb(91, 59, 1)",
    "highlight_focus": "rgb(124, 75, 15)",
    "help_border": "rgb(170, 170, 170)",
    "help_color": "rgb(238, 238, 238)",
    "help_hover_border": "rgb(255, 255, 255)",
    "help_hover_color": "rgb(255, 255, 255)",
})
call-function: ("check-colors", {
    "theme": "dark",
    "highlight": "rgb(91, 59, 1)",
    "highlight_focus": "rgb(124, 75, 15)",
    "help_border": "rgb(170, 170, 170)",
    "help_color": "rgb(238, 238, 238)",
    "help_hover_border": "rgb(255, 255, 255)",
    "help_hover_color": "rgb(255, 255, 255)",
})
call-function: ("check-colors", {
    "theme": "light",
    "highlight": "rgb(252, 255, 214)",
    "highlight_focus": "rgb(246, 253, 176)",
    "help_border": "rgb(85, 85, 85)",
    "help_color": "rgb(51, 51, 51)",
    "help_hover_border": "rgb(0, 0, 0)",
    "help_hover_color": "rgb(0, 0, 0)",
})

// Now testing the top and bottom background in case there is only one scraped examples.
goto: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html"

define-function: (
    "check-background",
    (theme, background_color_start, background_color_end),
    block {
        local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
        reload:
        assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
            "background-image": "linear-gradient(" + |background_color_start| + ", " +
                |background_color_end| + ")",
        })
        assert-css: (".scraped-example:not(.expanded) .code-wrapper::after", {
            "background-image": "linear-gradient(to top, " + |background_color_start| + ", " +
                |background_color_end| + ")",
        })
    },
)

call-function: ("check-background", {
    "theme": "ayu",
    "background_color_start": "rgb(15, 20, 25)",
    "background_color_end": "rgba(15, 20, 25, 0)",
})
call-function: ("check-background", {
    "theme": "dark",
    "background_color_start": "rgb(53, 53, 53)",
    "background_color_end": "rgba(53, 53, 53, 0)",
})
call-function: ("check-background", {
    "theme": "light",
    "background_color_start": "rgb(255, 255, 255)",
    "background_color_end": "rgba(255, 255, 255, 0)",
})