File: scrape-examples-layout.goml

package info (click to toggle)
rustc 1.86.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid
  • size: 913,560 kB
  • sloc: xml: 158,127; python: 35,921; javascript: 19,689; sh: 19,600; cpp: 18,906; ansic: 13,124; asm: 4,376; makefile: 708; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (110 lines) | stat: -rw-r--r-- 3,910 bytes parent folder | download | duplicates (7)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Check that the line number column has the correct layout.
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"

set-window-size: (1000, 1000)

// We move the mouse over the scraped example for the prev button to be generated.
move-cursor-to: ".scraped-example"

// Check that it's not zero.
assert-property-false: (
    ".more-scraped-examples .scraped-example span[data-nosnippet]",
    {"clientWidth": "0"}
)

// Check that examples with very long lines have the same width as ones that don't.
store-property: (
    ".more-scraped-examples .scraped-example:nth-child(2) span[data-nosnippet]",
    {"clientWidth": clientWidth},
)

assert-property: (
    ".more-scraped-examples .scraped-example:nth-child(3) span[data-nosnippet]",
    {"clientWidth": |clientWidth|}
)

assert-property: (
    ".more-scraped-examples .scraped-example:nth-child(4) span[data-nosnippet]",
    {"clientWidth": |clientWidth|}
)

assert-property: (
    ".more-scraped-examples .scraped-example:nth-child(5) span[data-nosnippet]",
    {"clientWidth": |clientWidth|}
)

assert-property: (
    ".more-scraped-examples .scraped-example:nth-child(6) span[data-nosnippet]",
    {"clientWidth": |clientWidth|}
)

// The "title" should be located at the right bottom corner of the code example.
store-position: (".scraped-example .example-wrap", {"x": x, "y": y})
assert-size: (".scraped-example .example-wrap", {"height": 130})
store-size: (".scraped-example .example-wrap", {"width": width, "height": height})
store-size: (".scraped-example .scraped-example-title", {
    "width": title_width,
    "height": title_height,
})
assert-position: (".scraped-example .scraped-example-title", {
    "x": |x| + |width| - |title_width| - 5,
    "y": |y| + |height| - |title_height| - 8,
})

store-size: (".more-scraped-examples .scraped-example .example-wrap", {"height": more_height})
assert: |more_height| > |height|
assert-size: (".more-scraped-examples .scraped-example .example-wrap", {
    "height": 250,
    "width": |width|,
})

// Check that for both mobile and desktop sizes, the buttons in scraped examples are displayed
// correctly.

store-value: (offset_y, 4)

// First with desktop
assert-position: (".scraped-example", {"y": 256})
assert-position: (".scraped-example .prev", {"y": 256 + |offset_y|})

// Gradient background should be at the top of the code block.
assert-css: (".scraped-example .example-wrap::before", {"top": "0px"})
assert-css: (".scraped-example .example-wrap::after", {"bottom": "0px"})

// Then with mobile
set-window-size: (600, 600)
store-size: (".scraped-example .scraped-example-title", {"height": title_height})
assert-position: (".scraped-example", {"y": 291})
assert-position: (".scraped-example .prev", {"y": 291 + |offset_y| + |title_height|})

define-function: (
    "check_title_and_code_position",
    [],
    block {
        // Title should be above the code.
        store-position: (".scraped-example .example-wrap", {"x": x, "y": y})
        store-size: (".scraped-example .scraped-example-title", { "height": title_height })

        assert-position: (".scraped-example .scraped-example-title", {
            "x": |x|, // same X position.
            "y": |y| - |title_height|,
        })

        // Line numbers should be right beside the code.
        compare-elements-position-near: (
            ".scraped-example .example-wrap span[data-nosnippet]",
            // On the first line, the code starts with `fn main` so we have a keyword.
            ".scraped-example .example-wrap .rust span.kw",
            // They're not exactly the same size but since they're on the same line,
            // it's kinda the same.
            {"y": 2},
        )
    }
)

// Check that the title is now above the code.
call-function: ("check_title_and_code_position", {})

// Then with small mobile
set-window-size: (300, 300)
call-function: ("check_title_and_code_position", {})