"This is the first paragraph and it should fit on the screen entirely.",
)
.add::<theme::TTDefaultText>(
theme::FONT_BOLD,
"Second, bold, paragraph should also fit on the screen whole I think.",
)
},
|_|Empty,
);
letexpected="<SwipePage active_page:0 page_count:1 content:<Paragraphs This is the first paragraph\nand it should fit on the\nscreen entirely.\nSecond, bold, paragraph\nshould also fit on the\nscreen whole I think.\n> buttons:<Empty > >";
assert_eq!(trace(&page),expected);
swipe_up(&mutpage);
assert_eq!(trace(&page),expected);
swipe_down(&mutpage);
assert_eq!(trace(&page),expected);
}
#[test]
fnparagraphs_one_long(){
letmutpage=SwipePage::new(
display::screen(),
theme::BG,
|area|{
Paragraphs::new(area)
.add::<theme::TTDefaultText>(
theme::FONT_BOLD,
"This is somewhat long paragraph that goes on and on and on and on and on and will definitely not fit on just a single screen. You have to swipe a bit to see all the text it contains I guess. There's just so much letters in it.",
)
},
|_|Empty,
);
letexpected1="<SwipePage active_page:0 page_count:2 content:<Paragraphs This is somewhat long\nparagraph that goes\non and on and on and\non and on and will\ndefinitely not fit on\njust a single screen.\nYou have to swipe a bit\nto see all the text it...\n> buttons:<Empty > >";
letexpected2="<SwipePage active_page:1 page_count:2 content:<Paragraphs contains I guess.\nThere's just so much\nletters in it.\n> buttons:<Empty > >";
assert_eq!(trace(&page),expected1);
swipe_down(&mutpage);
assert_eq!(trace(&page),expected1);
swipe_up(&mutpage);
assert_eq!(trace(&page),expected2);
swipe_up(&mutpage);
assert_eq!(trace(&page),expected2);
swipe_down(&mutpage);
assert_eq!(trace(&page),expected1);
}
#[test]
fnparagraphs_three_long(){
letmutpage=SwipePage::new(
display::screen(),
theme::BG,
|area|{
Paragraphs::new(area)
.add::<theme::TTDefaultText>(
theme::FONT_BOLD,
"This paragraph is using a bold font. It doesn't need to be all that long.",
)
.add::<theme::TTDefaultText>(
theme::FONT_MONO,
"And this one is using MONO. Monospace is nice for numbers, they have the same width and can be scanned quickly. Even if they span several pages or something.",
)
.add::<theme::TTDefaultText>(
theme::FONT_BOLD,
"Let's add another one for a good measure. This one should overflow all the way to the third page with a bit of luck.",
)
},
|_|Empty,
);
letexpected1="<SwipePage active_page:0 page_count:3 content:<Paragraphs This paragraph is\nusing a bold font. It\ndoesn't need to be all\nthat long.\nAnd this one is\nusing MONO.\nMonospace is nice\nfor numbers, they...\n> buttons:<Empty > >";
letexpected2="<SwipePage active_page:1 page_count:3 content:<Paragraphs have the same\nwidth and can be\nscanned quickly.\nEven if they span\nseveral pages or\nsomething.\nLet's add another one\nfor a good measure....\n> buttons:<Empty > >";
letexpected3="<SwipePage active_page:2 page_count:3 content:<Paragraphs This one should\noverflow all the way to\nthe third page with a\nbit of luck.\n> buttons:<Empty > >";