2021-12-11 17:58:25 +01:00
|
|
|
#include <gtest/gtest-message.h> // for Message
|
|
|
|
|
#include <gtest/gtest-test-part.h> // for SuiteApiResolver, TestFactoryImpl, TestPartResult
|
2021-05-01 20:40:35 +02:00
|
|
|
#include <memory> // for allocator
|
|
|
|
|
|
2022-04-28 10:43:31 +02:00
|
|
|
#include "ftxui/dom/elements.hpp" // for gauge, gaugeUp
|
2022-01-07 11:03:54 +01:00
|
|
|
#include "ftxui/dom/node.hpp" // for Render
|
|
|
|
|
#include "ftxui/screen/screen.hpp" // for Screen
|
|
|
|
|
#include "gtest/gtest_pred_impl.h" // for Test, EXPECT_EQ, TEST
|
2018-10-09 19:06:03 +02:00
|
|
|
|
2022-04-17 15:47:20 +02:00
|
|
|
namespace ftxui {
|
2018-10-09 19:06:03 +02:00
|
|
|
|
2022-02-06 19:17:21 +01:00
|
|
|
TEST(GaugeTest, ZeroHorizontal) {
|
2018-10-09 19:06:03 +02:00
|
|
|
auto root = gauge(0);
|
2020-03-22 22:32:44 +01:00
|
|
|
Screen screen(11, 1);
|
2020-05-20 21:23:59 +02:00
|
|
|
Render(screen, root);
|
2018-10-09 19:06:03 +02:00
|
|
|
|
|
|
|
|
EXPECT_EQ(" ", screen.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-06 19:17:21 +01:00
|
|
|
TEST(GaugeTest, HalfHorizontal) {
|
2018-10-09 19:06:03 +02:00
|
|
|
auto root = gauge(0.5);
|
2020-03-22 22:32:44 +01:00
|
|
|
Screen screen(11, 1);
|
2020-05-20 21:23:59 +02:00
|
|
|
Render(screen, root);
|
2018-10-09 19:06:03 +02:00
|
|
|
|
2022-04-17 15:47:20 +02:00
|
|
|
#if defined(FTXUI_MICROSOFT_TERMINAL_FALLBACK)
|
|
|
|
|
EXPECT_EQ("█████▌ ", screen.ToString());
|
|
|
|
|
#else
|
2019-01-06 16:10:57 +01:00
|
|
|
EXPECT_EQ("█████▍ ", screen.ToString());
|
2022-04-17 15:47:20 +02:00
|
|
|
#endif
|
2018-10-09 19:06:03 +02:00
|
|
|
}
|
|
|
|
|
|
2022-02-06 19:17:21 +01:00
|
|
|
TEST(GaugeTest, OneHorizontal) {
|
2018-10-09 19:06:03 +02:00
|
|
|
auto root = gauge(1.0);
|
2020-03-22 22:32:44 +01:00
|
|
|
Screen screen(11, 1);
|
2020-05-20 21:23:59 +02:00
|
|
|
Render(screen, root);
|
2018-10-09 19:06:03 +02:00
|
|
|
|
|
|
|
|
EXPECT_EQ("███████████", screen.ToString());
|
|
|
|
|
}
|
2020-08-16 00:24:18 +02:00
|
|
|
|
2022-02-06 19:17:21 +01:00
|
|
|
TEST(GaugeTest, ZeroVertical) {
|
|
|
|
|
auto root = gaugeUp(0);
|
|
|
|
|
Screen screen(1, 11);
|
|
|
|
|
Render(screen, root);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" ",
|
|
|
|
|
screen.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(GaugeTest, HalfVertical) {
|
|
|
|
|
auto root = gaugeUp(0.5);
|
|
|
|
|
Screen screen(1, 11);
|
|
|
|
|
Render(screen, root);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
" \r\n"
|
|
|
|
|
"▄\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█",
|
|
|
|
|
screen.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(GaugeTest, OneVertical) {
|
|
|
|
|
auto root = gaugeUp(1.0);
|
|
|
|
|
Screen screen(1, 11);
|
|
|
|
|
Render(screen, root);
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█\r\n"
|
|
|
|
|
"█",
|
|
|
|
|
screen.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-17 15:47:20 +02:00
|
|
|
} // namespace ftxui
|
|
|
|
|
|
2020-08-16 00:24:18 +02: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.
|