mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2024-11-25 20:27:31 +08:00
Added tests for toggle component, OnEnter event
This commit is contained in:
parent
33a970530b
commit
177df31d41
@ -102,3 +102,37 @@ TEST(ToggleTest, OnChange) {
|
||||
EXPECT_FALSE(toggle.OnEvent(Event::ArrowLeft)); // Reached far left.
|
||||
EXPECT_EQ(counter, 4);
|
||||
}
|
||||
|
||||
TEST(ToggleTest, OnEnter) {
|
||||
Toggle toggle;
|
||||
toggle.entries = {L"1", L"2", L"3"};
|
||||
|
||||
int counter = 0;
|
||||
toggle.on_enter = [&] { counter++; };
|
||||
|
||||
EXPECT_FALSE(toggle.OnEvent(Event::ArrowLeft)); // Reached far left.
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 1);
|
||||
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::ArrowRight)); // [0] -> [1]
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 2);
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::ArrowRight)); // [1] -> [2]
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 3);
|
||||
|
||||
EXPECT_FALSE(toggle.OnEvent(Event::ArrowRight)); // Reached far right.
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 4);
|
||||
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::ArrowLeft)); // [2] -> [1]
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 5);
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::ArrowLeft)); // [1] -> [0]
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 6);
|
||||
|
||||
EXPECT_FALSE(toggle.OnEvent(Event::ArrowLeft)); // Reached far left.
|
||||
EXPECT_TRUE(toggle.OnEvent(Event::Return));
|
||||
EXPECT_EQ(counter, 7);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user