Add GUI tests for comments highlighting in items declaration

This commit is contained in:
Guillaume Gomez 2023-11-13 12:00:17 +01:00
parent 05bf5b764a
commit 768a614380
6 changed files with 118 additions and 1 deletions

View File

@ -0,0 +1,73 @@
// This test checks that comments in item declarations are highlighted.
go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
show-text: true
define-function: (
"check-item-decl-comment",
(theme, url, comment_color),
block {
go-to: |url|
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
reload:
assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
}
)
define-function: (
"check-items-for-theme",
(theme, comment_color),
block {
call-function: ("check-item-decl-comment", {
"theme": |theme|,
"url": "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html",
"comment_color": |comment_color|,
})
call-function: ("check-item-decl-comment", {
"theme": |theme|,
"url": "file://" + |DOC_PATH| + "/test_docs/private/struct.Struct.html",
"comment_color": |comment_color|,
})
call-function: ("check-item-decl-comment", {
"theme": |theme|,
"url": "file://" + |DOC_PATH| + "/test_docs/private/struct.Tuple.html",
"comment_color": |comment_color|,
})
call-function: ("check-item-decl-comment", {
"theme": |theme|,
"url": "file://" + |DOC_PATH| + "/test_docs/private/union.Union.html",
"comment_color": |comment_color|,
})
call-function: ("check-item-decl-comment", {
"theme": |theme|,
"url": "file://" + |DOC_PATH| + "/proc_macro_test/macro.make_answer.html",
"comment_color": |comment_color|,
})
call-function: ("check-item-decl-comment", {
"theme": |theme|,
"url": "file://" + |DOC_PATH| + "/proc_macro_test/derive.HelperAttr.html",
"comment_color": |comment_color|,
})
}
)
call-function: (
"check-items-for-theme",
{
"theme": "ayu",
"comment_color": "#788797",
}
)
call-function: (
"check-items-for-theme",
{
"theme": "dark",
"comment_color": "#8d8d8b",
}
)
call-function: (
"check-items-for-theme",
{
"theme": "light",
"comment_color": "#8e908c",
}
)

View File

@ -73,7 +73,7 @@ assert: "//*[@class='dir-entry' and @open]/*[text()='sub_mod']"
// Only "another_folder" should be "open" in "lib2".
assert: "//*[@class='dir-entry' and not(@open)]/*[text()='another_mod']"
// All other trees should be collapsed.
assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 10)
assert-count: ("//*[@id='src-sidebar']/details[not(text()='lib2') and not(@open)]", 11)
// We now switch to mobile mode.
set-window-size: (600, 600)

View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "proc_macro_test"
version = "0.1.0"

View File

@ -0,0 +1,8 @@
[package]
name = "proc_macro_test"
version = "0.1.0"
edition = "2021"
[lib]
path = "lib.rs"
proc-macro = true

View File

@ -0,0 +1,11 @@
use proc_macro::TokenStream;
#[proc_macro]
pub fn make_answer(_item: TokenStream) -> TokenStream {
"fn answer() -> u32 { 42 }".parse().unwrap()
}
#[proc_macro_derive(HelperAttr, attributes(helper))]
pub fn derive_helper_attr(_item: TokenStream) -> TokenStream {
TokenStream::new()
}

View File

@ -593,3 +593,21 @@ pub trait Foo<const W: usize> {
fn f(&mut self, fg: [u8; 3]) {}
}
}
pub mod private {
pub struct Tuple(u32, u8);
pub struct Struct {
a: u8,
}
pub union Union {
a: u8,
b: u16,
}
pub enum Enum {
A,
#[doc(hidden)]
B,
}
}