mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-22 18:59:59 +08:00
Test Page{Up,Down} for Radiobox. (#493)
See: https://github.com/ArthurSonzogni/FTXUI/pull/491#issuecomment-1264335576
This commit is contained in:
parent
5ba29a9539
commit
ccfe22bc24
@ -160,6 +160,64 @@ TEST(RadioboxTest, NavigationHome) {
|
|||||||
EXPECT_EQ(selected, 0);
|
EXPECT_EQ(selected, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(RadioboxTest, NavigationPageDown) {
|
||||||
|
int selected = 0;
|
||||||
|
std::vector<std::string> entries = {"1", "2", "3", "4", "5", "6"};
|
||||||
|
auto radiobox = Radiobox(&entries, &selected) | yframe;
|
||||||
|
|
||||||
|
Screen screen(1, 3);
|
||||||
|
Render(screen, radiobox->Render());
|
||||||
|
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::PageDown));
|
||||||
|
EXPECT_EQ(selected, 0);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 2);
|
||||||
|
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::PageDown));
|
||||||
|
EXPECT_EQ(selected, 2);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 4);
|
||||||
|
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::PageDown));
|
||||||
|
EXPECT_EQ(selected, 4);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 5);
|
||||||
|
|
||||||
|
EXPECT_FALSE(radiobox->OnEvent(Event::PageDown));
|
||||||
|
EXPECT_EQ(selected, 5);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(RadioboxTest, NavigationPageUp) {
|
||||||
|
int selected = 5;
|
||||||
|
std::vector<std::string> entries = {"1", "2", "3", "4", "5", "6"};
|
||||||
|
auto radiobox = Radiobox(&entries, &selected) | yframe;
|
||||||
|
|
||||||
|
Screen screen(1, 3);
|
||||||
|
Render(screen, radiobox->Render());
|
||||||
|
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::PageUp));
|
||||||
|
EXPECT_EQ(selected, 5);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 3);
|
||||||
|
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::PageUp));
|
||||||
|
EXPECT_EQ(selected, 3);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 1);
|
||||||
|
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::PageUp));
|
||||||
|
EXPECT_EQ(selected, 1);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 0);
|
||||||
|
|
||||||
|
EXPECT_FALSE(radiobox->OnEvent(Event::PageUp));
|
||||||
|
EXPECT_EQ(selected, 0);
|
||||||
|
EXPECT_TRUE(radiobox->OnEvent(Event::Return));
|
||||||
|
EXPECT_EQ(selected, 0);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(RadioboxTest, NavigationEnd) {
|
TEST(RadioboxTest, NavigationEnd) {
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
std::vector<std::string> entries = {"1", "2", "3"};
|
std::vector<std::string> entries = {"1", "2", "3"};
|
||||||
|
Loading…
Reference in New Issue
Block a user