2020-04-20 03:00:37 +08:00
|
|
|
// Copyright 2020 Arthur Sonzogni. All rights reserved.
|
|
|
|
// Use of this source code is governed by the MIT license that can be found in
|
|
|
|
// the LICENSE file.
|
|
|
|
|
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(VBoxTest, ScreenSmaller1) {
|
|
|
|
auto root = vbox(text(L"text_1"), text(L"text_2"));
|
|
|
|
Screen screen(6, 1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
2019-06-25 05:39:37 +08:00
|
|
|
EXPECT_EQ("text_1", screen.ToString());
|
2018-09-18 14:48:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(VBoxTest, ScreenFit) {
|
|
|
|
auto root = vbox(text(L"text_1"), text(L"text_2"));
|
|
|
|
Screen screen(6, 2);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1\ntext_2", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(VBoxTest, ScreenBigger1) {
|
|
|
|
auto root = vbox(text(L"text_1"), text(L"text_2"));
|
|
|
|
Screen screen(6, 3);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1\ntext_2\n ", screen.ToString());
|
|
|
|
}
|
|
|
|
TEST(VBoxTest, ScreenBigger2) {
|
|
|
|
auto root = vbox(text(L"text_1"), text(L"text_2"));
|
|
|
|
Screen screen(6, 4);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1\ntext_2\n \n ", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(VBoxTest, ScreenSmaller1Flex) {
|
2019-01-05 09:03:49 +08:00
|
|
|
auto root = vbox(text(L"text_1"), filler(), text(L"text_2"));
|
2018-09-18 14:48:40 +08:00
|
|
|
Screen screen(6, 1);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1", screen.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(VBoxTest, ScreenFitFlex) {
|
2019-01-05 09:03:49 +08:00
|
|
|
auto root = vbox(text(L"text_1"), filler(), text(L"text_2"));
|
2019-06-18 03:29:51 +08:00
|
|
|
Screen screen(7, 5);
|
2018-09-18 14:48:40 +08:00
|
|
|
Render(screen, root.get());
|
|
|
|
|
2019-06-18 03:29:51 +08:00
|
|
|
EXPECT_EQ(
|
2020-03-27 08:42:46 +08:00
|
|
|
"text_1 \n"
|
|
|
|
" \n"
|
|
|
|
" \n"
|
|
|
|
" \n"
|
|
|
|
"text_2 ",
|
|
|
|
screen.ToString());
|
2018-09-18 14:48:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(VBoxTest, ScreenBigger1Flex) {
|
2019-01-05 09:03:49 +08:00
|
|
|
auto root = vbox(text(L"text_1"), filler(), text(L"text_2"));
|
2018-09-18 14:48:40 +08:00
|
|
|
Screen screen(6, 3);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1\n \ntext_2", screen.ToString());
|
|
|
|
}
|
|
|
|
TEST(VBoxTest, ScreenBigger2Flex) {
|
2019-01-05 09:03:49 +08:00
|
|
|
auto root = vbox(text(L"text_1"), filler(), text(L"text_2"));
|
2018-09-18 14:48:40 +08:00
|
|
|
Screen screen(6, 4);
|
|
|
|
Render(screen, root.get());
|
|
|
|
|
|
|
|
EXPECT_EQ("text_1\n \n \ntext_2", screen.ToString());
|
|
|
|
}
|