diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2022-04-18 09:52:01 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2022-04-18 09:52:01 +0200 |
commit | 674f52bf5867791059988af02089f3a8b82eeb98 (patch) | |
tree | 34f4b825c00cc9abc4171620cd5155c3e024203c /tests | |
parent | 0af960dbde56d5d950997250acd4e53eb16223a5 (diff) | |
download | weechat-674f52bf5867791059988af02089f3a8b82eeb98.zip |
core: add bar item "spacer"
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/tests.cpp | 1 | ||||
-rw-r--r-- | tests/unit/gui/test-gui-bar-window.cpp | 456 |
4 files changed, 459 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b46c1184b..a0a0c862c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -42,6 +42,7 @@ set(LIB_WEECHAT_UNIT_TESTS_CORE_SRC unit/core/test-core-url.cpp unit/core/test-core-utf8.cpp unit/core/test-core-util.cpp + unit/gui/test-gui-bar-window.cpp unit/gui/test-gui-buffer.cpp unit/gui/test-gui-chat.cpp unit/gui/test-gui-color.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index 01b6b2e06..d4c610f6a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,6 +39,7 @@ lib_weechat_unit_tests_core_a_SOURCES = unit/core/test-core-arraylist.cpp \ unit/core/test-core-url.cpp \ unit/core/test-core-utf8.cpp \ unit/core/test-core-util.cpp \ + unit/gui/test-gui-bar-window.cpp \ unit/gui/test-gui-buffer.cpp \ unit/gui/test-gui-chat.cpp \ unit/gui/test-gui-color.cpp \ diff --git a/tests/tests.cpp b/tests/tests.cpp index 923d5caca..08a8e3318 100644 --- a/tests/tests.cpp +++ b/tests/tests.cpp @@ -79,6 +79,7 @@ IMPORT_TEST_GROUP(CoreUrl); IMPORT_TEST_GROUP(CoreUtf8); IMPORT_TEST_GROUP(CoreUtil); /* GUI */ +IMPORT_TEST_GROUP(GuiBarWindow); IMPORT_TEST_GROUP(GuiBuffer); IMPORT_TEST_GROUP(GuiChat); IMPORT_TEST_GROUP(GuiColor); diff --git a/tests/unit/gui/test-gui-bar-window.cpp b/tests/unit/gui/test-gui-bar-window.cpp new file mode 100644 index 000000000..af489b10b --- /dev/null +++ b/tests/unit/gui/test-gui-bar-window.cpp @@ -0,0 +1,456 @@ +/* + * test-gui-bar-window.cpp - test bar window functions + * + * Copyright (C) 2022 Sébastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <https://www.gnu.org/licenses/>. + */ + +#include "CppUTest/TestHarness.h" + +extern "C" +{ +#include <string.h> +#include "src/gui/gui-bar-window.h" +#include "src/gui/gui-color.h" +#include "src/gui/gui-window.h" + +extern int gui_bar_window_item_is_spacer (const char *item); +} + +TEST_GROUP(GuiBarWindow) +{ +}; + +/* + * Tests functions: + * gui_bar_window_valid + */ + +TEST(GuiBarWindow, Valid) +{ + LONGS_EQUAL(0, gui_bar_window_valid (NULL)); + LONGS_EQUAL(0, gui_bar_window_valid ((struct t_gui_bar_window *)0x1)); + + LONGS_EQUAL(1, gui_bar_window_valid (gui_windows->bar_windows)); + + LONGS_EQUAL(0, gui_bar_window_valid (gui_windows->bar_windows + 1)); +} + +/* + * Tests functions: + * gui_bar_window_search_bar + */ + +TEST(GuiBarWindow, SearchBar) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_search_by_xy + */ + +TEST(GuiBarWindow, SearchByXy) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_get_size + */ + +TEST(GuiBarWindow, GetSize) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_calculate_pos_size + */ + +TEST(GuiBarWindow, CalculatePosSize) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_find_pos + */ + +TEST(GuiBarWindow, FindPos) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_content_alloc + */ + +TEST(GuiBarWindow, ContentAlloc) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_content_free + */ + +TEST(GuiBarWindow, ContentFree) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_content_build_item + */ + +TEST(GuiBarWindow, ContentBuildItem) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_content_build + */ + +TEST(GuiBarWindow, ContentBuild) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_content_get + */ + +TEST(GuiBarWindow, ContentGet) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_item_is_spacer + */ + +TEST(GuiBarWindow, ItemIsSpacer) +{ + char str_spacer[16]; + + LONGS_EQUAL(0, gui_bar_window_item_is_spacer (NULL)); + LONGS_EQUAL(0, gui_bar_window_item_is_spacer ("")); + + snprintf (str_spacer, sizeof (str_spacer), + "%c", + GUI_COLOR_COLOR_CHAR); + LONGS_EQUAL(0, gui_bar_window_item_is_spacer (str_spacer)); + + snprintf (str_spacer, sizeof (str_spacer), + "%c%c", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_BAR_CHAR); + LONGS_EQUAL(0, gui_bar_window_item_is_spacer (str_spacer)); + + snprintf (str_spacer, sizeof (str_spacer), + "%c%c%c", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_BAR_CHAR, + GUI_COLOR_BAR_SPACER); + LONGS_EQUAL(1, gui_bar_window_item_is_spacer (str_spacer)); + + snprintf (str_spacer, sizeof (str_spacer), + "%c%c%c ", + GUI_COLOR_COLOR_CHAR, + GUI_COLOR_BAR_CHAR, + GUI_COLOR_BAR_SPACER); + LONGS_EQUAL(0, gui_bar_window_item_is_spacer (str_spacer)); +} + +/* + * Tests functions: + * gui_bar_window_content_get_with_filling + */ + +TEST(GuiBarWindow, ContentGetWithFilling) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_can_use_spacer + */ + +TEST(GuiBarWindow, CanUseSpacer) +{ + struct t_gui_bar *bar; + struct t_gui_bar_window *bar_window; + + bar = gui_bar_search ("title"); + CHECK(bar); + bar_window = gui_bar_window_search_bar (gui_windows, bar); + CHECK(bar_window); + LONGS_EQUAL(1, gui_bar_window_can_use_spacer (bar_window)); + + bar = gui_bar_search ("status"); + CHECK(bar); + bar_window = gui_bar_window_search_bar (gui_windows, bar); + CHECK(bar_window); + LONGS_EQUAL(1, gui_bar_window_can_use_spacer (bar_window)); + + bar = gui_bar_search ("input"); + CHECK(bar); + bar_window = gui_bar_window_search_bar (gui_windows, bar); + CHECK(bar_window); + LONGS_EQUAL(0, gui_bar_window_can_use_spacer (bar_window)); +} + +/* + * Tests functions: + * gui_bar_window_compute_spacers_size + */ + +TEST(GuiBarWindow, ComputeSpacersSize) +{ + int *spacers; + + POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (-1, 0, 0)); + POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (10, 0, 0)); + POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (10, 20, 0)); + POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (10, 20, 0)); + + /* length on screen == bar window width */ + POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (20, 20, 3)); + + /* length on screen > bar window width */ + POINTERS_EQUAL(NULL, gui_bar_window_compute_spacers_size (25, 20, 3)); + + /* single spacer */ + spacers = gui_bar_window_compute_spacers_size (10, 20, 1); + CHECK(spacers); + LONGS_EQUAL(10, spacers[0]); + free (spacers); + + /* 2 spacers */ + spacers = gui_bar_window_compute_spacers_size (10, 20, 2); + CHECK(spacers); + LONGS_EQUAL(5, spacers[0]); + LONGS_EQUAL(5, spacers[1]); + free (spacers); + + /* 3 spacers */ + spacers = gui_bar_window_compute_spacers_size (10, 20, 3); + CHECK(spacers); + LONGS_EQUAL(4, spacers[0]); + LONGS_EQUAL(3, spacers[1]); + LONGS_EQUAL(3, spacers[2]); + free (spacers); + + /* 4 spacers */ + spacers = gui_bar_window_compute_spacers_size (10, 20, 4); + CHECK(spacers); + LONGS_EQUAL(3, spacers[0]); + LONGS_EQUAL(3, spacers[1]); + LONGS_EQUAL(2, spacers[2]); + LONGS_EQUAL(2, spacers[3]); + free (spacers); + + /* 12 spacers */ + spacers = gui_bar_window_compute_spacers_size (10, 20, 12); + CHECK(spacers); + LONGS_EQUAL(1, spacers[0]); + LONGS_EQUAL(1, spacers[1]); + LONGS_EQUAL(1, spacers[2]); + LONGS_EQUAL(1, spacers[3]); + LONGS_EQUAL(1, spacers[4]); + LONGS_EQUAL(1, spacers[5]); + LONGS_EQUAL(1, spacers[6]); + LONGS_EQUAL(1, spacers[7]); + LONGS_EQUAL(1, spacers[8]); + LONGS_EQUAL(1, spacers[9]); + LONGS_EQUAL(0, spacers[10]); + LONGS_EQUAL(0, spacers[11]); + free (spacers); +} + +/* + * Tests functions: + * gui_bar_window_coords_add + */ + +TEST(GuiBarWindow, CoordsAdd) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_coords_free + */ + +TEST(GuiBarWindow, CoordsFree) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_insert + */ + +TEST(GuiBarWindow, Insert) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_new + */ + +TEST(GuiBarWindow, New) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_get_current_size + */ + +TEST(GuiBarWindow, GetCurrentSize) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_get_max_size_in_window + */ + +TEST(GuiBarWindow, GetMaxSizeInWindow) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_get_max_size + */ + +TEST(GuiBarWindow, GetMaxSize) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_set_current_size + */ + +TEST(GuiBarWindow, SetCurrentSize) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_free + */ + +TEST(GuiBarWindow, Free) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_remove_unused_bars + */ + +TEST(GuiBarWindow, RemoveUnusedBars) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_add_missing_bars + */ + +TEST(GuiBarWindow, AddMissingBars) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_scroll + */ + +TEST(GuiBarWindow, Scroll) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_update_cb + */ + +TEST(GuiBarWindow, UpdateCb) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_hdata_bar_window_cb + */ + +TEST(GuiBarWindow, HdataBarWindowCb) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_add_to_infolist + */ + +TEST(GuiBarWindow, AddToInfolist) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * gui_bar_window_print_log + */ + +TEST(GuiBarWindow, PrintLog) +{ + /* TODO: write tests */ +} |