2018-10-10 01:06:03 +08:00
|
|
|
#include "ftxui/dom/elements.hpp"
|
2019-01-07 00:10:35 +08:00
|
|
|
#include "ftxui/screen/screen.hpp"
|
2018-09-18 14:48:40 +08:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2019-01-12 22:00:08 +08:00
|
|
|
using namespace ftxui;
|
|
|
|
using namespace ftxui;
|
2018-09-18 14:48:40 +08:00
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenSmaller1) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(11,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text_", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenSmaller2) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(10,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenFit) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(12,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text_2", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenBigger1) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(13,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text_2 ", screen.ToString());
|
|
|
|
}
|
|
|
|
TEST(HBoxTest, ScreenBigger2) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(14,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text_2 ", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenSmaller1Flex) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
2019-01-05 09:03:49 +08:00
|
|
|
filler(),
|
2018-09-18 14:48:40 +08:00
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(11,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text_", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenSmaller2Flex) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
2019-01-05 09:03:49 +08:00
|
|
|
filler(),
|
2018-09-18 14:48:40 +08:00
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(10,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenFitFlex) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
2019-01-05 09:03:49 +08:00
|
|
|
filler(),
|
2018-09-18 14:48:40 +08:00
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(12,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1text_2", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenBigger1Flex) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
2019-01-05 09:03:49 +08:00
|
|
|
filler(),
|
2018-09-18 14:48:40 +08:00
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(13,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1 text_2", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(HBoxTest, ScreenBigger2Flex) {
|
|
|
|
auto root = hbox(
|
|
|
|
text(L"text_1"),
|
2019-01-05 09:03:49 +08:00
|
|
|
filler(),
|
2018-09-18 14:48:40 +08:00
|
|
|
text(L"text_2")
|
|
|
|
);
|
|
|
|
Screen screen(14,1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1 text_2", screen.ToString());
|
|
|
|
}
|