From 718b8fb9a7f87744478e49217a201bb6c5104a15 Mon Sep 17 00:00:00 2001 From: ArthurSonzogni Date: Sun, 5 Nov 2023 10:27:14 +0100 Subject: [PATCH] Revert "Added some checkbox tests" This reverts commit fd0b5ef1f219da43d44ae7c58419eef9da273278. --- cmake/ftxui_test.cmake | 1 - src/ftxui/component/checkbox_test.cpp | 128 -------------------------- 2 files changed, 129 deletions(-) delete mode 100644 src/ftxui/component/checkbox_test.cpp diff --git a/cmake/ftxui_test.cmake b/cmake/ftxui_test.cmake index b570d1f9..0b9a86df 100644 --- a/cmake/ftxui_test.cmake +++ b/cmake/ftxui_test.cmake @@ -9,7 +9,6 @@ include(cmake/ftxui_find_google_test.cmake) add_executable(ftxui-tests src/ftxui/component/animation_test.cpp src/ftxui/component/button_test.cpp - src/ftxui/component/checkbox_test.cpp src/ftxui/component/collapsible_test.cpp src/ftxui/component/component_test.cpp src/ftxui/component/component_test.cpp diff --git a/src/ftxui/component/checkbox_test.cpp b/src/ftxui/component/checkbox_test.cpp deleted file mode 100644 index fefe6a91..00000000 --- a/src/ftxui/component/checkbox_test.cpp +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright 2022 Arthur Sonzogni. All rights reserved. -// Use of this source code is governed by the MIT license that can be found in -// the LICENSE file. -#include // for operator""s, chrono_literals -#include // for __shared_ptr_access, shared_ptr, allocator -#include // for string - -#include "ftxui/component/component.hpp" // for Button, Horizontal -#include "ftxui/component/component_base.hpp" // for ComponentBase -#include "ftxui/component/component_options.hpp" // for ButtonOption -#include "ftxui/component/event.hpp" // for Event, Event::Return, Event::ArrowLeft, Event::ArrowRight -#include "ftxui/component/mouse.hpp" // for Mouse, Mouse::Left, Mouse::Pressed -#include "ftxui/dom/node.hpp" // for Render -#include "ftxui/screen/screen.hpp" // for Screen -#include "ftxui/screen/terminal.hpp" // for SetColorSupport, Color, TrueColor -#include "gtest/gtest.h" // for AssertionResult, Message, TestPartResult, EXPECT_EQ, Test, EXPECT_FALSE, EXPECT_TRUE, TEST - -// NOLINTBEGIN -namespace ftxui { - -using namespace std::chrono_literals; - -TEST(CheckboxTest, Basic) { - bool checked1 = false; - bool checked2 = false; - auto checkbox1 = Checkbox("Checkbox 1", &checked1); - auto checkbox2 = Checkbox("Checkbox 2", &checked2); - - int selected = 0; - auto container = Container::Horizontal( - { - checkbox1, - checkbox2 - }, - &selected); - - (void)container->Render(); - - EXPECT_FALSE(checked1); - EXPECT_FALSE(checked2); - EXPECT_TRUE(checkbox1->Focused()); - EXPECT_FALSE(checkbox2->Focused()); - - container->OnEvent(Event::ArrowLeft); - - EXPECT_FALSE(checked1); - EXPECT_FALSE(checked2); - EXPECT_TRUE(checkbox1->Focused()); - EXPECT_FALSE(checkbox2->Focused()); - - container->OnEvent(Event::ArrowRight); - - EXPECT_FALSE(checked1); - EXPECT_FALSE(checked2); - EXPECT_FALSE(checkbox1->Focused()); - EXPECT_TRUE(checkbox2->Focused()); - - container->OnEvent(Event::ArrowRight); - - EXPECT_FALSE(checked1); - EXPECT_FALSE(checked2); - EXPECT_FALSE(checkbox1->Focused()); - EXPECT_TRUE(checkbox2->Focused()); - - container->OnEvent(Event::Return); - - EXPECT_FALSE(checked1); - EXPECT_TRUE(checked2); - EXPECT_FALSE(checkbox1->Focused()); - EXPECT_TRUE(checkbox2->Focused()); - - container->OnEvent(Event::Return); - - EXPECT_FALSE(checked1); - EXPECT_FALSE(checked2); - EXPECT_FALSE(checkbox1->Focused()); - EXPECT_TRUE(checkbox2->Focused()); - - container->OnEvent(Event::ArrowLeft); - container->OnEvent(Event::Return); - - EXPECT_TRUE(checked1); - EXPECT_FALSE(checked2); - EXPECT_TRUE(checkbox1->Focused()); - EXPECT_FALSE(checkbox2->Focused()); -} - -TEST(CheckboxTest, DragClick) { - bool checked1 = false; - auto checkbox1 = Checkbox("Checkbox 1", &checked1); - - auto container = Container::Horizontal( - { - checkbox1 - }); - - (void)container->Render(); - - Event leftMousePress = Event::Mouse("", {Mouse::Button::Left, Mouse::Motion::Pressed}); - Event leftMouseRelease = Event::Mouse("", {Mouse::Button::Left, Mouse::Motion::Released}); - - EXPECT_FALSE(checked1); - - checkbox1->OnEvent(leftMousePress); - - EXPECT_TRUE(checked1); - - checkbox1->OnEvent(leftMousePress); - checkbox1->OnEvent(leftMousePress); - checkbox1->OnEvent(leftMousePress); - - EXPECT_TRUE(checked1); - - checkbox1->OnEvent(leftMouseRelease); - - EXPECT_TRUE(checked1); - - checkbox1->OnEvent(leftMousePress); - - EXPECT_FALSE(checked1); - - checkbox1->OnEvent(leftMouseRelease); - - EXPECT_FALSE(checked1); -} - -} // namespace ftxui -// NOLINTEND