From 9b6d8e63db85c30007b463e91f91a791969fa83f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 16:36:24 +0200 Subject: Adding upstream version 1:3.38.4. Signed-off-by: Daniel Baumann --- subprojects/libhandy/tests/meson.build | 59 +++++ subprojects/libhandy/tests/test-action-row.c | 129 +++++++++++ .../libhandy/tests/test-application-window.c | 30 +++ subprojects/libhandy/tests/test-avatar.c | 210 ++++++++++++++++++ .../libhandy/tests/test-carousel-indicator-dots.c | 53 +++++ .../libhandy/tests/test-carousel-indicator-lines.c | 53 +++++ subprojects/libhandy/tests/test-carousel.c | 246 ++++++++++++++++++++ subprojects/libhandy/tests/test-combo-row.c | 67 ++++++ subprojects/libhandy/tests/test-deck.c | 93 ++++++++ subprojects/libhandy/tests/test-expander-row.c | 153 +++++++++++++ subprojects/libhandy/tests/test-header-bar.c | 215 ++++++++++++++++++ subprojects/libhandy/tests/test-header-group.c | 68 ++++++ subprojects/libhandy/tests/test-keypad.c | 247 +++++++++++++++++++++ subprojects/libhandy/tests/test-leaflet.c | 109 +++++++++ .../libhandy/tests/test-preferences-group.c | 81 +++++++ subprojects/libhandy/tests/test-preferences-page.c | 80 +++++++ subprojects/libhandy/tests/test-preferences-row.c | 57 +++++ .../libhandy/tests/test-preferences-window.c | 42 ++++ subprojects/libhandy/tests/test-search-bar.c | 96 ++++++++ subprojects/libhandy/tests/test-squeezer.c | 161 ++++++++++++++ subprojects/libhandy/tests/test-swipe-group.c | 45 ++++ subprojects/libhandy/tests/test-value-object.c | 54 +++++ .../libhandy/tests/test-view-switcher-bar.c | 83 +++++++ subprojects/libhandy/tests/test-view-switcher.c | 83 +++++++ subprojects/libhandy/tests/test-window-handle.c | 30 +++ subprojects/libhandy/tests/test-window.c | 30 +++ 26 files changed, 2574 insertions(+) create mode 100644 subprojects/libhandy/tests/meson.build create mode 100644 subprojects/libhandy/tests/test-action-row.c create mode 100644 subprojects/libhandy/tests/test-application-window.c create mode 100644 subprojects/libhandy/tests/test-avatar.c create mode 100644 subprojects/libhandy/tests/test-carousel-indicator-dots.c create mode 100644 subprojects/libhandy/tests/test-carousel-indicator-lines.c create mode 100644 subprojects/libhandy/tests/test-carousel.c create mode 100644 subprojects/libhandy/tests/test-combo-row.c create mode 100644 subprojects/libhandy/tests/test-deck.c create mode 100644 subprojects/libhandy/tests/test-expander-row.c create mode 100644 subprojects/libhandy/tests/test-header-bar.c create mode 100644 subprojects/libhandy/tests/test-header-group.c create mode 100644 subprojects/libhandy/tests/test-keypad.c create mode 100644 subprojects/libhandy/tests/test-leaflet.c create mode 100644 subprojects/libhandy/tests/test-preferences-group.c create mode 100644 subprojects/libhandy/tests/test-preferences-page.c create mode 100644 subprojects/libhandy/tests/test-preferences-row.c create mode 100644 subprojects/libhandy/tests/test-preferences-window.c create mode 100644 subprojects/libhandy/tests/test-search-bar.c create mode 100644 subprojects/libhandy/tests/test-squeezer.c create mode 100644 subprojects/libhandy/tests/test-swipe-group.c create mode 100644 subprojects/libhandy/tests/test-value-object.c create mode 100644 subprojects/libhandy/tests/test-view-switcher-bar.c create mode 100644 subprojects/libhandy/tests/test-view-switcher.c create mode 100644 subprojects/libhandy/tests/test-window-handle.c create mode 100644 subprojects/libhandy/tests/test-window.c (limited to 'subprojects/libhandy/tests') diff --git a/subprojects/libhandy/tests/meson.build b/subprojects/libhandy/tests/meson.build new file mode 100644 index 0000000..c80e96e --- /dev/null +++ b/subprojects/libhandy/tests/meson.build @@ -0,0 +1,59 @@ +if get_option('tests') + +test_env = [ + 'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()), + 'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()), + 'G_DEBUG=gc-friendly,fatal-warnings', + 'GSETTINGS_BACKEND=memory', + 'PYTHONDONTWRITEBYTECODE=yes', + 'MALLOC_CHECK_=2', +] + +test_cflags = [ + '-DHDY_LOG_DOMAIN="Handy"', + '-DTEST_DATA_DIR="@0@/data"'.format(meson.current_source_dir()), +] + +test_link_args = [ + '-fPIC', +] + +test_names = [ + 'test-action-row', + 'test-application-window', + 'test-avatar', + 'test-carousel', + 'test-carousel-indicator-dots', + 'test-carousel-indicator-lines', + 'test-combo-row', + 'test-deck', + 'test-expander-row', + 'test-header-bar', + 'test-header-group', + 'test-keypad', + 'test-leaflet', + 'test-preferences-group', + 'test-preferences-page', + 'test-preferences-row', + 'test-preferences-window', + 'test-search-bar', + 'test-squeezer', + 'test-swipe-group', + 'test-value-object', + 'test-view-switcher', + 'test-view-switcher-bar', + 'test-window', + 'test-window-handle', +] + +foreach test_name : test_names + t = executable(test_name, [test_name + '.c'] + libhandy_generated_headers, + c_args: test_cflags, + link_args: test_link_args, + dependencies: libhandy_deps + [libhandy_dep], + pie: true, + ) + test(test_name, t, env: test_env) +endforeach + +endif diff --git a/subprojects/libhandy/tests/test-action-row.c b/subprojects/libhandy/tests/test-action-row.c new file mode 100644 index 0000000..b6ae3c6 --- /dev/null +++ b/subprojects/libhandy/tests/test-action-row.c @@ -0,0 +1,129 @@ +/* + * Copyright (C) 2018 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +gint activated; + +static void +activated_cb (GtkWidget *widget, gpointer data) +{ + activated++; +} + + +static void +test_hdy_action_row_add (void) +{ + g_autoptr (HdyActionRow) row = NULL; + GtkWidget *sw; + + row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ())); + g_assert_nonnull (row); + + sw = gtk_switch_new (); + g_assert_nonnull (sw); + + gtk_container_add (GTK_CONTAINER (row), sw); +} + + +static void +test_hdy_action_row_add_prefix (void) +{ + g_autoptr (HdyActionRow) row = NULL; + GtkWidget *radio; + + row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ())); + g_assert_nonnull (row); + + radio = gtk_radio_button_new (NULL); + g_assert_nonnull (radio); + + hdy_action_row_add_prefix (row, radio); +} + + +static void +test_hdy_action_row_subtitle (void) +{ + g_autoptr (HdyActionRow) row = NULL; + + row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ())); + g_assert_nonnull (row); + + g_assert_cmpstr (hdy_action_row_get_subtitle (row), ==, ""); + + hdy_action_row_set_subtitle (row, "Dummy subtitle"); + g_assert_cmpstr (hdy_action_row_get_subtitle (row), ==, "Dummy subtitle"); +} + + +static void +test_hdy_action_row_icon_name (void) +{ + g_autoptr (HdyActionRow) row = NULL; + + row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ())); + g_assert_nonnull (row); + + g_assert_null (hdy_action_row_get_icon_name (row)); + + hdy_action_row_set_icon_name (row, "dummy-icon-name"); + g_assert_cmpstr (hdy_action_row_get_icon_name (row), ==, "dummy-icon-name"); +} + + +static void +test_hdy_action_row_use_undeline (void) +{ + g_autoptr (HdyActionRow) row = NULL; + + row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ())); + g_assert_nonnull (row); + + g_assert_false (hdy_action_row_get_use_underline (row)); + + hdy_action_row_set_use_underline (row, TRUE); + g_assert_true (hdy_action_row_get_use_underline (row)); + + hdy_action_row_set_use_underline (row, FALSE); + g_assert_false (hdy_action_row_get_use_underline (row)); +} + + +static void +test_hdy_action_row_activate (void) +{ + g_autoptr (HdyActionRow) row = NULL; + + row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ())); + g_assert_nonnull (row); + + activated = 0; + g_signal_connect (row, "activated", G_CALLBACK (activated_cb), NULL); + + hdy_action_row_activate (row); + g_assert_cmpint (activated, ==, 1); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ActionRow/add", test_hdy_action_row_add); + g_test_add_func("/Handy/ActionRow/add_prefix", test_hdy_action_row_add_prefix); + g_test_add_func("/Handy/ActionRow/subtitle", test_hdy_action_row_subtitle); + g_test_add_func("/Handy/ActionRow/icon_name", test_hdy_action_row_icon_name); + g_test_add_func("/Handy/ActionRow/use_underline", test_hdy_action_row_use_undeline); + g_test_add_func("/Handy/ActionRow/activate", test_hdy_action_row_activate); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-application-window.c b/subprojects/libhandy/tests/test-application-window.c new file mode 100644 index 0000000..a745de6 --- /dev/null +++ b/subprojects/libhandy/tests/test-application-window.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_application_window_new (void) +{ + g_autoptr (GtkWidget) window = NULL; + + window = g_object_ref_sink (hdy_application_window_new ()); + g_assert_nonnull (window); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ApplicationWindow/new", test_hdy_application_window_new); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-avatar.c b/subprojects/libhandy/tests/test-avatar.c new file mode 100644 index 0000000..ad330ae --- /dev/null +++ b/subprojects/libhandy/tests/test-avatar.c @@ -0,0 +1,210 @@ +/* + * Copyright (C) 2020 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +#define TEST_ICON_NAME "avatar-default-symbolic" +#define TEST_STRING "Mario Rossi" +#define TEST_SIZE 128 + + +static gboolean +is_surface_empty (cairo_surface_t *surface) +{ + unsigned char * data; + guint length; + + cairo_surface_flush (surface); + data = cairo_image_surface_get_data (surface); + length = cairo_image_surface_get_width (surface) * cairo_image_surface_get_height (surface); + + for (int i = 0; i < length; i++) { + if (data[i] != 0) + return FALSE; + } + return TRUE; +} + +static GdkPixbuf * +load_null_image_func (gint size, + gpointer data) +{ + return NULL; +} + +static GdkPixbuf * +load_image_func (gint size, + GdkRGBA *color) +{ + GdkPixbuf *pixbuf; + cairo_surface_t *surface; + cairo_t *cr; + + surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, size, size); + cr = cairo_create (surface); + if (color != NULL) { + gdk_cairo_set_source_rgba (cr, color); + cairo_paint (cr); + } + pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, size, size); + + cairo_surface_destroy (surface); + cairo_destroy (cr); + return pixbuf; +} + + +static void +map_event_cb (GtkWidget *widget, GdkEvent *event, cairo_surface_t **surface) +{ + cairo_t *cr; + + g_assert (surface != NULL); + + *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, TEST_SIZE, TEST_SIZE); + cr = cairo_create (*surface); + gtk_widget_draw (widget, cr); + cairo_destroy (cr); + gtk_main_quit (); +} + + +static gboolean +did_draw_something (GtkWidget *widget) +{ + GtkWidget *window; + gboolean empty; + cairo_surface_t *surface; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + gtk_widget_set_events (widget, GDK_STRUCTURE_MASK); + g_signal_connect (widget, "map-event", G_CALLBACK (map_event_cb), &surface); + + gtk_window_resize (GTK_WINDOW (window), TEST_SIZE, TEST_SIZE); + gtk_container_add (GTK_CONTAINER (window), widget); + + gtk_widget_show (widget); + gtk_widget_show (window); + + gtk_main (); + + g_assert (surface); + g_assert (cairo_surface_status (surface) == CAIRO_STATUS_SUCCESS); + empty = is_surface_empty (surface); + + cairo_surface_destroy (surface); + gtk_widget_destroy (window); + + return !empty; +} + + +static void +test_hdy_avatar_generate (void) +{ + GtkWidget *avatar = hdy_avatar_new (TEST_SIZE, "", TRUE); + g_assert (HDY_IS_AVATAR (avatar)); + + g_assert_true (did_draw_something (GTK_WIDGET (avatar))); +} + + +static void +test_hdy_avatar_icon_name (void) +{ + HdyAvatar *avatar = HDY_AVATAR (hdy_avatar_new (128, NULL, TRUE)); + + g_assert_null (hdy_avatar_get_icon_name (avatar)); + hdy_avatar_set_icon_name (avatar, TEST_ICON_NAME); + g_assert_cmpstr (hdy_avatar_get_icon_name (avatar), ==, TEST_ICON_NAME); + + g_assert_true (did_draw_something (GTK_WIDGET (avatar))); +} + +static void +test_hdy_avatar_text (void) +{ + HdyAvatar *avatar = HDY_AVATAR (hdy_avatar_new (128, NULL, TRUE)); + + g_assert_null (hdy_avatar_get_text (avatar)); + hdy_avatar_set_text (avatar, TEST_STRING); + g_assert_cmpstr (hdy_avatar_get_text (avatar), ==, TEST_STRING); + + g_assert_true (did_draw_something (GTK_WIDGET (avatar))); +} + +static void +test_hdy_avatar_size (void) +{ + HdyAvatar *avatar = HDY_AVATAR (hdy_avatar_new (TEST_SIZE, NULL, TRUE)); + + g_assert_cmpint (hdy_avatar_get_size (avatar), ==, TEST_SIZE); + hdy_avatar_set_size (avatar, TEST_SIZE / 2); + g_assert_cmpint (hdy_avatar_get_size (avatar), ==, TEST_SIZE / 2); + + g_assert_true (did_draw_something (GTK_WIDGET (avatar))); +} + +static void +test_hdy_avatar_custom_image (void) +{ + GtkWidget *avatar; + GdkRGBA color; + + avatar = hdy_avatar_new (TEST_SIZE, NULL, TRUE); + + g_assert (HDY_IS_AVATAR (avatar)); + + hdy_avatar_set_image_load_func (HDY_AVATAR (avatar), + (HdyAvatarImageLoadFunc) load_image_func, + NULL, + NULL); + + g_object_ref (avatar); + g_assert_false (did_draw_something (avatar)); + + hdy_avatar_set_image_load_func (HDY_AVATAR (avatar), + NULL, + NULL, + NULL); + + g_assert_true (did_draw_something (avatar)); + + gdk_rgba_parse (&color, "#F00"); + hdy_avatar_set_image_load_func (HDY_AVATAR (avatar), + (HdyAvatarImageLoadFunc) load_image_func, + &color, + NULL); + + g_assert_true (did_draw_something (avatar)); + + hdy_avatar_set_image_load_func (HDY_AVATAR (avatar), + (HdyAvatarImageLoadFunc) load_null_image_func, + NULL, + NULL); + + g_assert_true (did_draw_something (avatar)); + + g_object_unref (avatar); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func ("/Handy/Avatar/generate", test_hdy_avatar_generate); + g_test_add_func ("/Handy/Avatar/custom_image", test_hdy_avatar_custom_image); + g_test_add_func ("/Handy/Avatar/icon_name", test_hdy_avatar_icon_name); + g_test_add_func ("/Handy/Avatar/text", test_hdy_avatar_text); + g_test_add_func ("/Handy/Avatar/size", test_hdy_avatar_size); + + return g_test_run (); +} diff --git a/subprojects/libhandy/tests/test-carousel-indicator-dots.c b/subprojects/libhandy/tests/test-carousel-indicator-dots.c new file mode 100644 index 0000000..bd02d10 --- /dev/null +++ b/subprojects/libhandy/tests/test-carousel-indicator-dots.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +gint notified; + +static void +notify_cb (GtkWidget *widget, gpointer data) +{ + notified++; +} + +static void +test_hdy_carousel_indicator_dots_carousel (void) +{ + g_autoptr (HdyCarouselIndicatorDots) dots = NULL; + HdyCarousel *carousel; + + dots = g_object_ref_sink (HDY_CAROUSEL_INDICATOR_DOTS (hdy_carousel_indicator_dots_new ())); + g_assert_nonnull (dots); + + notified = 0; + g_signal_connect (dots, "notify::carousel", G_CALLBACK (notify_cb), NULL); + + carousel = HDY_CAROUSEL (hdy_carousel_new ()); + g_assert_nonnull (carousel); + + g_assert_null (hdy_carousel_indicator_dots_get_carousel (dots)); + g_assert_cmpint (notified, ==, 0); + + hdy_carousel_indicator_dots_set_carousel (dots, carousel); + g_assert (hdy_carousel_indicator_dots_get_carousel (dots) == carousel); + g_assert_cmpint (notified, ==, 1); + + hdy_carousel_indicator_dots_set_carousel (dots, NULL); + g_assert_null (hdy_carousel_indicator_dots_get_carousel (dots)); + g_assert_cmpint (notified, ==, 2); +} + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/CarouselIndicatorDots/carousel", test_hdy_carousel_indicator_dots_carousel); + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-carousel-indicator-lines.c b/subprojects/libhandy/tests/test-carousel-indicator-lines.c new file mode 100644 index 0000000..dfccdd2 --- /dev/null +++ b/subprojects/libhandy/tests/test-carousel-indicator-lines.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +gint notified; + +static void +notify_cb (GtkWidget *widget, gpointer data) +{ + notified++; +} + +static void +test_hdy_carousel_indicator_lines_carousel (void) +{ + g_autoptr (HdyCarouselIndicatorLines) lines = NULL; + HdyCarousel *carousel; + + lines = g_object_ref_sink (HDY_CAROUSEL_INDICATOR_LINES (hdy_carousel_indicator_lines_new ())); + g_assert_nonnull (lines); + + notified = 0; + g_signal_connect (lines, "notify::carousel", G_CALLBACK (notify_cb), NULL); + + carousel = HDY_CAROUSEL (hdy_carousel_new ()); + g_assert_nonnull (carousel); + + g_assert_null (hdy_carousel_indicator_lines_get_carousel (lines)); + g_assert_cmpint (notified, ==, 0); + + hdy_carousel_indicator_lines_set_carousel (lines, carousel); + g_assert (hdy_carousel_indicator_lines_get_carousel (lines) == carousel); + g_assert_cmpint (notified, ==, 1); + + hdy_carousel_indicator_lines_set_carousel (lines, NULL); + g_assert_null (hdy_carousel_indicator_lines_get_carousel (lines)); + g_assert_cmpint (notified, ==, 2); +} + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/CarouselInidicatorLines/carousel", test_hdy_carousel_indicator_lines_carousel); + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-carousel.c b/subprojects/libhandy/tests/test-carousel.c new file mode 100644 index 0000000..45b2fec --- /dev/null +++ b/subprojects/libhandy/tests/test-carousel.c @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2019 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +gint notified; + +static void +notify_cb (GtkWidget *widget, gpointer data) +{ + notified++; +} + +static void +test_hdy_carousel_add_remove (void) +{ + HdyCarousel *carousel; + GtkWidget *child1, *child2, *child3; + + carousel = HDY_CAROUSEL (hdy_carousel_new ()); + + child1 = gtk_label_new (""); + child2 = gtk_label_new (""); + child3 = gtk_label_new (""); + + notified = 0; + g_signal_connect (carousel, "notify::n-pages", G_CALLBACK (notify_cb), NULL); + + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 0); + + gtk_container_add (GTK_CONTAINER (carousel), child1); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 1); + g_assert_cmpint (notified, ==, 1); + + hdy_carousel_prepend (carousel, child2); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 2); + g_assert_cmpint (notified, ==, 2); + + hdy_carousel_insert (carousel, child3, 1); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 3); + g_assert_cmpint (notified, ==, 3); + + hdy_carousel_reorder (carousel, child3, 0); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 3); + g_assert_cmpint (notified, ==, 3); + + gtk_container_remove (GTK_CONTAINER (carousel), child2); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 2); + g_assert_cmpint (notified, ==, 4); + + gtk_container_remove (GTK_CONTAINER (carousel), child1); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 1); + g_assert_cmpint (notified, ==, 5); + + gtk_container_remove (GTK_CONTAINER (carousel), child3); + g_assert_cmpuint (hdy_carousel_get_n_pages (carousel), ==, 0); + g_assert_cmpint (notified, ==, 6); + + g_object_unref (carousel); +} + +static void +test_hdy_carousel_scroll_to (void) +{ + HdyCarousel *carousel; + GtkWidget *child1, *child2, *child3; + + carousel = HDY_CAROUSEL (hdy_carousel_new ()); + + child1 = gtk_label_new (""); + child2 = gtk_label_new (""); + child3 = gtk_label_new (""); + + notified = 0; + g_signal_connect (carousel, "notify::position", G_CALLBACK (notify_cb), NULL); + + gtk_container_add (GTK_CONTAINER (carousel), child1); + gtk_container_add (GTK_CONTAINER (carousel), child2); + gtk_container_add (GTK_CONTAINER (carousel), child3); + + /* Since tests are done synchronously, avoid animations */ + hdy_carousel_set_animation_duration (carousel, 0); + + g_assert_cmpfloat(hdy_carousel_get_position (carousel), ==, 0); + g_assert_cmpint (notified, ==, 0); + + hdy_carousel_scroll_to (carousel, child3); + g_assert_cmpfloat(hdy_carousel_get_position (carousel), ==, 2); + g_assert_cmpint (notified, ==, 1); + + hdy_carousel_scroll_to (carousel, child2); + g_assert_cmpfloat(hdy_carousel_get_position (carousel), ==, 1); + g_assert_cmpint (notified, ==, 2); + + g_object_unref (carousel); +} + +static void +test_hdy_carousel_interactive (void) +{ + HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ()); + gboolean interactive; + + notified = 0; + g_signal_connect (carousel, "notify::interactive", G_CALLBACK (notify_cb), NULL); + + /* Accessors */ + g_assert_true (hdy_carousel_get_interactive (carousel)); + hdy_carousel_set_interactive (carousel, FALSE); + g_assert_false (hdy_carousel_get_interactive (carousel)); + g_assert_cmpint (notified, ==, 1); + + /* Property */ + g_object_set (carousel, "interactive", TRUE, NULL); + g_object_get (carousel, "interactive", &interactive, NULL); + g_assert_true (interactive); + g_assert_cmpint (notified, ==, 2); + + /* Setting the same value should not notify */ + hdy_carousel_set_interactive (carousel, TRUE); + g_assert_cmpint (notified, ==, 2); +} + +static void +test_hdy_carousel_spacing (void) +{ + HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ()); + guint spacing; + + notified = 0; + g_signal_connect (carousel, "notify::spacing", G_CALLBACK (notify_cb), NULL); + + /* Accessors */ + g_assert_cmpuint (hdy_carousel_get_spacing (carousel), ==, 0); + hdy_carousel_set_spacing (carousel, 12); + g_assert_cmpuint (hdy_carousel_get_spacing (carousel), ==, 12); + g_assert_cmpint (notified, ==, 1); + + /* Property */ + g_object_set (carousel, "spacing", 6, NULL); + g_object_get (carousel, "spacing", &spacing, NULL); + g_assert_cmpuint (spacing, ==, 6); + g_assert_cmpint (notified, ==, 2); + + /* Setting the same value should not notify */ + hdy_carousel_set_spacing (carousel, 6); + g_assert_cmpint (notified, ==, 2); +} + +static void +test_hdy_carousel_animation_duration (void) +{ + HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ()); + guint duration; + + notified = 0; + g_signal_connect (carousel, "notify::animation-duration", G_CALLBACK (notify_cb), NULL); + + /* Accessors */ + g_assert_cmpuint (hdy_carousel_get_animation_duration (carousel), ==, 250); + hdy_carousel_set_animation_duration (carousel, 200); + g_assert_cmpuint (hdy_carousel_get_animation_duration (carousel), ==, 200); + g_assert_cmpint (notified, ==, 1); + + /* Property */ + g_object_set (carousel, "animation-duration", 500, NULL); + g_object_get (carousel, "animation-duration", &duration, NULL); + g_assert_cmpuint (duration, ==, 500); + g_assert_cmpint (notified, ==, 2); + + /* Setting the same value should not notify */ + hdy_carousel_set_animation_duration (carousel, 500); + g_assert_cmpint (notified, ==, 2); +} + +static void +test_hdy_carousel_allow_mouse_drag (void) +{ + HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ()); + gboolean allow_mouse_drag; + + notified = 0; + g_signal_connect (carousel, "notify::allow-mouse-drag", G_CALLBACK (notify_cb), NULL); + + /* Accessors */ + g_assert_true (hdy_carousel_get_allow_mouse_drag (carousel)); + hdy_carousel_set_allow_mouse_drag (carousel, FALSE); + g_assert_false (hdy_carousel_get_allow_mouse_drag (carousel)); + g_assert_cmpint (notified, ==, 1); + + /* Property */ + g_object_set (carousel, "allow-mouse-drag", TRUE, NULL); + g_object_get (carousel, "allow-mouse-drag", &allow_mouse_drag, NULL); + g_assert_true (allow_mouse_drag); + g_assert_cmpint (notified, ==, 2); + + /* Setting the same value should not notify */ + hdy_carousel_set_allow_mouse_drag (carousel, TRUE); + g_assert_cmpint (notified, ==, 2); +} + +static void +test_hdy_carousel_reveal_duration (void) +{ + HdyCarousel *carousel = HDY_CAROUSEL (hdy_carousel_new ()); + guint duration; + + notified = 0; + g_signal_connect (carousel, "notify::reveal-duration", G_CALLBACK (notify_cb), NULL); + + /* Accessors */ + g_assert_cmpuint (hdy_carousel_get_reveal_duration (carousel), ==, 0); + hdy_carousel_set_reveal_duration (carousel, 200); + g_assert_cmpuint (hdy_carousel_get_reveal_duration (carousel), ==, 200); + g_assert_cmpint (notified, ==, 1); + + /* Property */ + g_object_set (carousel, "reveal-duration", 500, NULL); + g_object_get (carousel, "reveal-duration", &duration, NULL); + g_assert_cmpuint (duration, ==, 500); + g_assert_cmpint (notified, ==, 2); + + /* Setting the same value should not notify */ + hdy_carousel_set_reveal_duration (carousel, 500); + g_assert_cmpint (notified, ==, 2); +} + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/Carousel/add_remove", test_hdy_carousel_add_remove); + g_test_add_func("/Handy/Carousel/scroll_to", test_hdy_carousel_scroll_to); + g_test_add_func("/Handy/Carousel/interactive", test_hdy_carousel_interactive); + g_test_add_func("/Handy/Carousel/spacing", test_hdy_carousel_spacing); + g_test_add_func("/Handy/Carousel/animation_duration", test_hdy_carousel_animation_duration); + g_test_add_func("/Handy/Carousel/allow_mouse_drag", test_hdy_carousel_allow_mouse_drag); + g_test_add_func("/Handy/Carousel/reveal_duration", test_hdy_carousel_reveal_duration); + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-combo-row.c b/subprojects/libhandy/tests/test-combo-row.c new file mode 100644 index 0000000..12feea6 --- /dev/null +++ b/subprojects/libhandy/tests/test-combo-row.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2018 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_combo_row_set_for_enum (void) +{ + g_autoptr (HdyComboRow) row = NULL; + GListModel *model; + HdyEnumValueObject *value; + + row = g_object_ref_sink (HDY_COMBO_ROW (hdy_combo_row_new ())); + g_assert_nonnull (row); + + g_assert_null (hdy_combo_row_get_model (row)); + + hdy_combo_row_set_for_enum (row, GTK_TYPE_ORIENTATION, hdy_enum_value_row_name, NULL, NULL); + model = hdy_combo_row_get_model (row); + g_assert_true (G_IS_LIST_MODEL (model)); + + g_assert_cmpuint (g_list_model_get_n_items (model), ==, 2); + + value = g_list_model_get_item (model, 0); + g_assert_true (HDY_IS_ENUM_VALUE_OBJECT (value)); + g_assert_cmpstr (hdy_enum_value_object_get_nick (value), ==, "horizontal"); + + value = g_list_model_get_item (model, 1); + g_assert_true (HDY_IS_ENUM_VALUE_OBJECT (value)); + g_assert_cmpstr (hdy_enum_value_object_get_nick (value), ==, "vertical"); +} + + +static void +test_hdy_combo_row_use_subtitle (void) +{ + g_autoptr (HdyComboRow) row = NULL; + + row = g_object_ref_sink (HDY_COMBO_ROW (hdy_combo_row_new ())); + g_assert_nonnull (row); + + g_assert_false (hdy_combo_row_get_use_subtitle (row)); + + hdy_combo_row_set_use_subtitle (row, TRUE); + g_assert_true (hdy_combo_row_get_use_subtitle (row)); + + hdy_combo_row_set_use_subtitle (row, FALSE); + g_assert_false (hdy_combo_row_get_use_subtitle (row)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ComboRow/set_for_enum", test_hdy_combo_row_set_for_enum); + g_test_add_func("/Handy/ComboRow/use_subtitle", test_hdy_combo_row_use_subtitle); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-deck.c b/subprojects/libhandy/tests/test-deck.c new file mode 100644 index 0000000..e2c5677 --- /dev/null +++ b/subprojects/libhandy/tests/test-deck.c @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_deck_adjacent_child (void) +{ + g_autoptr (HdyDeck) deck = NULL; + GtkWidget *children[2]; + gint i; + GtkWidget *result; + + deck = HDY_DECK (hdy_deck_new ()); + g_assert_nonnull (deck); + + for (i = 0; i < 2; i++) { + children[i] = gtk_label_new (""); + g_assert_nonnull (children[i]); + + gtk_container_add (GTK_CONTAINER (deck), children[i]); + } + + hdy_deck_set_visible_child (deck, children[0]); + + result = hdy_deck_get_adjacent_child (deck, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_null (result); + + result = hdy_deck_get_adjacent_child (deck, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_true (result == children[1]); + + hdy_deck_set_visible_child (deck, children[1]); + + result = hdy_deck_get_adjacent_child (deck, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_true (result == children[0]); + + result = hdy_deck_get_adjacent_child (deck, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_null (result); +} + + +static void +test_hdy_deck_navigate (void) +{ + g_autoptr (HdyDeck) deck = NULL; + GtkWidget *children[2]; + gint i; + gboolean result; + + deck = HDY_DECK (hdy_deck_new ()); + g_assert_nonnull (deck); + + for (i = 0; i < 2; i++) { + children[i] = gtk_label_new (""); + g_assert_nonnull (children[i]); + + gtk_container_add (GTK_CONTAINER (deck), children[i]); + } + + hdy_deck_set_visible_child (deck, children[0]); + + result = hdy_deck_navigate (deck, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_false (result); + + result = hdy_deck_navigate (deck, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_true (result); + g_assert_true (hdy_deck_get_visible_child (deck) == children[1]); + + result = hdy_deck_navigate (deck, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_false (result); + + result = hdy_deck_navigate (deck, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_true (result); + g_assert_true (hdy_deck_get_visible_child (deck) == children[0]); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func ("/Handy/Deck/adjacent_child", test_hdy_deck_adjacent_child); + g_test_add_func ("/Handy/Deck/navigate", test_hdy_deck_navigate); + + return g_test_run (); +} diff --git a/subprojects/libhandy/tests/test-expander-row.c b/subprojects/libhandy/tests/test-expander-row.c new file mode 100644 index 0000000..b0625d9 --- /dev/null +++ b/subprojects/libhandy/tests/test-expander-row.c @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2018 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_expander_row_add (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + GtkWidget *sw; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + sw = gtk_switch_new (); + g_assert_nonnull (sw); + + gtk_container_add (GTK_CONTAINER (row), sw); +} + + +static void +test_hdy_expander_row_subtitle (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + g_assert_cmpstr (hdy_expander_row_get_subtitle (row), ==, ""); + + hdy_expander_row_set_subtitle (row, "Dummy subtitle"); + g_assert_cmpstr (hdy_expander_row_get_subtitle (row), ==, "Dummy subtitle"); +} + + +static void +test_hdy_expander_row_icon_name (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + g_assert_null (hdy_expander_row_get_icon_name (row)); + + hdy_expander_row_set_icon_name (row, "dummy-icon-name"); + g_assert_cmpstr (hdy_expander_row_get_icon_name (row), ==, "dummy-icon-name"); +} + + +static void +test_hdy_expander_row_use_undeline (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + g_assert_false (hdy_expander_row_get_use_underline (row)); + + hdy_expander_row_set_use_underline (row, TRUE); + g_assert_true (hdy_expander_row_get_use_underline (row)); + + hdy_expander_row_set_use_underline (row, FALSE); + g_assert_false (hdy_expander_row_get_use_underline (row)); +} + + +static void +test_hdy_expander_row_expanded (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + g_assert_false (hdy_expander_row_get_expanded (row)); + + hdy_expander_row_set_expanded (row, TRUE); + g_assert_true (hdy_expander_row_get_expanded (row)); + + hdy_expander_row_set_expanded (row, FALSE); + g_assert_false (hdy_expander_row_get_expanded (row)); +} + + +static void +test_hdy_expander_row_enable_expansion (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + g_assert_true (hdy_expander_row_get_enable_expansion (row)); + g_assert_false (hdy_expander_row_get_expanded (row)); + + hdy_expander_row_set_expanded (row, TRUE); + g_assert_true (hdy_expander_row_get_expanded (row)); + + hdy_expander_row_set_enable_expansion (row, FALSE); + g_assert_false (hdy_expander_row_get_enable_expansion (row)); + g_assert_false (hdy_expander_row_get_expanded (row)); + + hdy_expander_row_set_expanded (row, TRUE); + g_assert_false (hdy_expander_row_get_expanded (row)); + + hdy_expander_row_set_enable_expansion (row, TRUE); + g_assert_true (hdy_expander_row_get_enable_expansion (row)); + g_assert_true (hdy_expander_row_get_expanded (row)); +} + + +static void +test_hdy_expander_row_show_enable_switch (void) +{ + g_autoptr (HdyExpanderRow) row = NULL; + + row = g_object_ref_sink (HDY_EXPANDER_ROW (hdy_expander_row_new ())); + g_assert_nonnull (row); + + g_assert_false (hdy_expander_row_get_show_enable_switch (row)); + + hdy_expander_row_set_show_enable_switch (row, TRUE); + g_assert_true (hdy_expander_row_get_show_enable_switch (row)); + + hdy_expander_row_set_show_enable_switch (row, FALSE); + g_assert_false (hdy_expander_row_get_show_enable_switch (row)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ExpanderRow/add", test_hdy_expander_row_add); + g_test_add_func("/Handy/ExpanderRow/subtitle", test_hdy_expander_row_subtitle); + g_test_add_func("/Handy/ExpanderRow/icon_name", test_hdy_expander_row_icon_name); + g_test_add_func("/Handy/ExpanderRow/use_underline", test_hdy_expander_row_use_undeline); + g_test_add_func("/Handy/ExpanderRow/expanded", test_hdy_expander_row_expanded); + g_test_add_func("/Handy/ExpanderRow/enable_expansion", test_hdy_expander_row_enable_expansion); + g_test_add_func("/Handy/ExpanderRow/show_enable_switch", test_hdy_expander_row_show_enable_switch); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-header-bar.c b/subprojects/libhandy/tests/test-header-bar.c new file mode 100644 index 0000000..15064bf --- /dev/null +++ b/subprojects/libhandy/tests/test-header-bar.c @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_header_bar_pack (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + GtkWidget *widget; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + widget = gtk_switch_new (); + g_assert_nonnull (widget); + + hdy_header_bar_pack_start (bar, widget); + + widget = gtk_switch_new (); + g_assert_nonnull (widget); + + hdy_header_bar_pack_end (bar, widget); +} + + +static void +test_hdy_header_bar_title (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_null (hdy_header_bar_get_title (bar)); + + hdy_header_bar_set_title (bar, "Dummy title"); + g_assert_cmpstr (hdy_header_bar_get_title (bar), ==, "Dummy title"); + + hdy_header_bar_set_title (bar, NULL); + g_assert_null (hdy_header_bar_get_title (bar)); +} + + +static void +test_hdy_header_bar_subtitle (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_null (hdy_header_bar_get_subtitle (bar)); + + hdy_header_bar_set_subtitle (bar, "Dummy subtitle"); + g_assert_cmpstr (hdy_header_bar_get_subtitle (bar), ==, "Dummy subtitle"); + + hdy_header_bar_set_subtitle (bar, NULL); + g_assert_null (hdy_header_bar_get_subtitle (bar)); +} + + +static void +test_hdy_header_bar_custom_title (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + GtkWidget *widget; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_null (hdy_header_bar_get_custom_title (bar)); + + widget = gtk_switch_new (); + g_assert_nonnull (widget); + hdy_header_bar_set_custom_title (bar, widget); + g_assert (hdy_header_bar_get_custom_title (bar) == widget); + + hdy_header_bar_set_custom_title (bar, NULL); + g_assert_null (hdy_header_bar_get_custom_title (bar)); +} + + +static void +test_hdy_header_bar_show_close_button (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_false (hdy_header_bar_get_show_close_button (bar)); + + hdy_header_bar_set_show_close_button (bar, TRUE); + g_assert_true (hdy_header_bar_get_show_close_button (bar)); + + hdy_header_bar_set_show_close_button (bar, FALSE); + g_assert_false (hdy_header_bar_get_show_close_button (bar)); +} + + +static void +test_hdy_header_bar_has_subtitle (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_true (hdy_header_bar_get_has_subtitle (bar)); + + hdy_header_bar_set_has_subtitle (bar, FALSE); + g_assert_false (hdy_header_bar_get_has_subtitle (bar)); + + hdy_header_bar_set_has_subtitle (bar, TRUE); + g_assert_true (hdy_header_bar_get_has_subtitle (bar)); +} + + +static void +test_hdy_header_bar_decoration_layout (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_null (hdy_header_bar_get_decoration_layout (bar)); + + hdy_header_bar_set_decoration_layout (bar, ":"); + g_assert_cmpstr (hdy_header_bar_get_decoration_layout (bar), ==, ":"); + + hdy_header_bar_set_decoration_layout (bar, NULL); + g_assert_null (hdy_header_bar_get_decoration_layout (bar)); +} + + +static void +test_hdy_header_bar_centering_policy (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_cmpint (hdy_header_bar_get_centering_policy (bar), ==, HDY_CENTERING_POLICY_LOOSE); + + hdy_header_bar_set_centering_policy (bar, HDY_CENTERING_POLICY_STRICT); + g_assert_cmpint (hdy_header_bar_get_centering_policy (bar), ==, HDY_CENTERING_POLICY_STRICT); + + hdy_header_bar_set_centering_policy (bar, HDY_CENTERING_POLICY_LOOSE); + g_assert_cmpint (hdy_header_bar_get_centering_policy (bar), ==, HDY_CENTERING_POLICY_LOOSE); +} + + +static void +test_hdy_header_bar_transition_duration (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_cmpuint (hdy_header_bar_get_transition_duration (bar), ==, 200); + + hdy_header_bar_set_transition_duration (bar, 0); + g_assert_cmpuint (hdy_header_bar_get_transition_duration (bar), ==, 0); + + hdy_header_bar_set_transition_duration (bar, 1000); + g_assert_cmpuint (hdy_header_bar_get_transition_duration (bar), ==, 1000); +} + + +static void +test_hdy_header_bar_interpolate_size (void) +{ + g_autoptr (HdyHeaderBar) bar = NULL; + + bar = g_object_ref_sink (HDY_HEADER_BAR (hdy_header_bar_new ())); + g_assert_nonnull (bar); + + g_assert_false (hdy_header_bar_get_interpolate_size (bar)); + + hdy_header_bar_set_interpolate_size (bar, TRUE); + g_assert_true (hdy_header_bar_get_interpolate_size (bar)); + + hdy_header_bar_set_interpolate_size (bar, FALSE); + g_assert_false (hdy_header_bar_get_interpolate_size (bar)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/HeaderBar/pack", test_hdy_header_bar_pack); + g_test_add_func("/Handy/HeaderBar/title", test_hdy_header_bar_title); + g_test_add_func("/Handy/HeaderBar/subtitle", test_hdy_header_bar_subtitle); + g_test_add_func("/Handy/HeaderBar/custom_title", test_hdy_header_bar_custom_title); + g_test_add_func("/Handy/HeaderBar/show_close_button", test_hdy_header_bar_show_close_button); + g_test_add_func("/Handy/HeaderBar/has_subtitle", test_hdy_header_bar_has_subtitle); + g_test_add_func("/Handy/HeaderBar/decoration_layout", test_hdy_header_bar_decoration_layout); + g_test_add_func("/Handy/HeaderBar/centering_policy", test_hdy_header_bar_centering_policy); + g_test_add_func("/Handy/HeaderBar/transition_duration", test_hdy_header_bar_transition_duration); + g_test_add_func("/Handy/HeaderBar/interpolate_size", test_hdy_header_bar_interpolate_size); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-header-group.c b/subprojects/libhandy/tests/test-header-group.c new file mode 100644 index 0000000..632c1ff --- /dev/null +++ b/subprojects/libhandy/tests/test-header-group.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2017 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_header_group_decorate_all (void) +{ + g_autoptr (HdyHeaderGroup) hg = HDY_HEADER_GROUP (hdy_header_group_new ()); + gboolean decorate_all = FALSE; + + g_assert_false (hdy_header_group_get_decorate_all (hg)); + g_object_get (hg, "decorate-all", &decorate_all, NULL); + g_assert_false (decorate_all); + + hdy_header_group_set_decorate_all (hg, TRUE); + + g_assert_true (hdy_header_group_get_decorate_all (hg)); + g_object_get (hg, "decorate-all", &decorate_all, NULL); + g_assert_true (decorate_all); + + g_object_set (hg, "decorate-all", FALSE, NULL); + + g_assert_false (hdy_header_group_get_decorate_all (hg)); + g_object_get (hg, "decorate-all", &decorate_all, NULL); + g_assert_false (decorate_all); +} + + +static void +test_hdy_header_group_add_remove (void) +{ + g_autoptr (HdyHeaderGroup) hg = HDY_HEADER_GROUP (hdy_header_group_new ()); + g_autoptr (HdyHeaderBar) bar1 = HDY_HEADER_BAR (g_object_ref_sink (hdy_header_bar_new ())); + g_autoptr (GtkHeaderBar) bar2 = GTK_HEADER_BAR (g_object_ref_sink (gtk_header_bar_new ())); + + g_assert_cmpint (g_slist_length (hdy_header_group_get_children (hg)), ==, 0); + + hdy_header_group_add_header_bar (hg, bar1); + g_assert_cmpint (g_slist_length (hdy_header_group_get_children (hg)), ==, 1); + + hdy_header_group_add_gtk_header_bar (hg, bar2); + g_assert_cmpint (g_slist_length (hdy_header_group_get_children (hg)), ==, 2); + + hdy_header_group_remove_gtk_header_bar (hg, bar2); + g_assert_cmpint (g_slist_length (hdy_header_group_get_children (hg)), ==, 1); + + hdy_header_group_remove_header_bar (hg, bar1); + + g_assert_cmpint (g_slist_length (hdy_header_group_get_children (hg)), ==, 0); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/HeaderGroup/decorate_all", test_hdy_header_group_decorate_all); + g_test_add_func("/Handy/HeaderGroup/add_remove", test_hdy_header_group_add_remove); + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-keypad.c b/subprojects/libhandy/tests/test-keypad.c new file mode 100644 index 0000000..f33037a --- /dev/null +++ b/subprojects/libhandy/tests/test-keypad.c @@ -0,0 +1,247 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +gint notified; + + +static void +notify_cb (GtkWidget *widget, + gpointer data) +{ + notified++; +} + + +static void +test_hdy_keypad_row_spacing (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + guint row_spacing = 0; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + + notified = 0; + g_signal_connect (keypad, "notify::row-spacing", G_CALLBACK (notify_cb), NULL); + + g_assert_cmpuint (hdy_keypad_get_row_spacing (keypad), ==, 6); + g_object_get (keypad, "row-spacing", &row_spacing, NULL); + g_assert_cmpuint (row_spacing, ==, 6); + + hdy_keypad_set_row_spacing (keypad, 0); + g_assert_cmpint (notified, ==, 1); + + g_assert_cmpuint (hdy_keypad_get_row_spacing (keypad), ==, 0); + g_object_get (keypad, "row-spacing", &row_spacing, NULL); + g_assert_cmpuint (row_spacing, ==, 0); + + g_object_set (keypad, "row-spacing", 12, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_cmpuint (hdy_keypad_get_row_spacing (keypad), ==, 12); + g_object_get (keypad, "row-spacing", &row_spacing, NULL); + g_assert_cmpuint (row_spacing, ==, 12); + + g_assert_cmpint (notified, ==, 2); +} + + +static void +test_hdy_keypad_column_spacing (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + guint column_spacing = 0; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + + notified = 0; + g_signal_connect (keypad, "notify::column-spacing", G_CALLBACK (notify_cb), NULL); + + g_assert_cmpuint (hdy_keypad_get_column_spacing (keypad), ==, 6); + g_object_get (keypad, "column-spacing", &column_spacing, NULL); + g_assert_cmpuint (column_spacing, ==, 6); + + hdy_keypad_set_column_spacing (keypad, 0); + g_assert_cmpint (notified, ==, 1); + + g_assert_cmpuint (hdy_keypad_get_column_spacing (keypad), ==, 0); + g_object_get (keypad, "column-spacing", &column_spacing, NULL); + g_assert_cmpuint (column_spacing, ==, 0); + + g_object_set (keypad, "column-spacing", 12, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_cmpuint (hdy_keypad_get_column_spacing (keypad), ==, 12); + g_object_get (keypad, "column-spacing", &column_spacing, NULL); + g_assert_cmpuint (column_spacing, ==, 12); + + g_assert_cmpint (notified, ==, 2); +} + + +static void +test_hdy_keypad_letters_visible (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + gboolean letters_visible = FALSE; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + + notified = 0; + g_signal_connect (keypad, "notify::letters-visible", G_CALLBACK (notify_cb), NULL); + + g_assert_true (hdy_keypad_get_letters_visible (keypad)); + g_object_get (keypad, "letters-visible", &letters_visible, NULL); + g_assert_true (letters_visible); + + hdy_keypad_set_letters_visible (keypad, FALSE); + g_assert_cmpint (notified, ==, 1); + + g_assert_false (hdy_keypad_get_letters_visible (keypad)); + g_object_get (keypad, "letters-visible", &letters_visible, NULL); + g_assert_false (letters_visible); + + g_object_set (keypad, "letters-visible", TRUE, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_true (hdy_keypad_get_letters_visible (keypad)); + g_object_get (keypad, "letters-visible", &letters_visible, NULL); + g_assert_true (letters_visible); + + g_assert_cmpint (notified, ==, 2); +} + + +static void +test_hdy_keypad_symbols_visible (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + gboolean symbols_visible = TRUE; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + + notified = 0; + g_signal_connect (keypad, "notify::symbols-visible", G_CALLBACK (notify_cb), NULL); + + g_assert_false (hdy_keypad_get_symbols_visible (keypad)); + g_object_get (keypad, "symbols-visible", &symbols_visible, NULL); + g_assert_false (symbols_visible); + + hdy_keypad_set_symbols_visible (keypad, TRUE); + g_assert_cmpint (notified, ==, 1); + + g_assert_true (hdy_keypad_get_symbols_visible (keypad)); + g_object_get (keypad, "symbols-visible", &symbols_visible, NULL); + g_assert_true (symbols_visible); + + g_object_set (keypad, "symbols-visible", FALSE, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_false (hdy_keypad_get_symbols_visible (keypad)); + g_object_get (keypad, "symbols-visible", &symbols_visible, NULL); + g_assert_false (symbols_visible); + + g_assert_cmpint (notified, ==, 2); +} + + +static void +test_hdy_keypad_entry (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + g_autoptr (GtkEntry) entry = NULL; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + entry = g_object_ref_sink (GTK_ENTRY (gtk_entry_new ())); + + notified = 0; + g_signal_connect (keypad, "notify::entry", G_CALLBACK (notify_cb), NULL); + + g_assert_null (hdy_keypad_get_entry (keypad)); + + hdy_keypad_set_entry (keypad, entry); + g_assert_cmpint (notified, ==, 1); + + g_assert_true (hdy_keypad_get_entry (keypad) == entry); + + g_object_set (keypad, "entry", NULL, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_null (hdy_keypad_get_entry (keypad)); +} + + +static void +test_hdy_keypad_start_action (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + g_autoptr (GtkWidget) button = NULL; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + button = g_object_ref_sink (gtk_button_new ()); + + notified = 0; + g_signal_connect (keypad, "notify::start-action", G_CALLBACK (notify_cb), NULL); + + g_assert_nonnull (hdy_keypad_get_start_action (keypad)); + + hdy_keypad_set_start_action (keypad, button); + g_assert_cmpint (notified, ==, 1); + + g_assert_true (hdy_keypad_get_start_action (keypad) == button); + + g_object_set (keypad, "start-action", NULL, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_null (hdy_keypad_get_start_action (keypad)); +} + + +static void +test_hdy_keypad_end_action (void) +{ + g_autoptr (HdyKeypad) keypad = NULL; + g_autoptr (GtkWidget) button = NULL; + + keypad = g_object_ref_sink (HDY_KEYPAD (hdy_keypad_new (FALSE, TRUE))); + button = g_object_ref_sink (gtk_button_new ()); + + notified = 0; + g_signal_connect (keypad, "notify::end-action", G_CALLBACK (notify_cb), NULL); + + g_assert_nonnull (hdy_keypad_get_end_action (keypad)); + + hdy_keypad_set_end_action (keypad, button); + g_assert_cmpint (notified, ==, 1); + + g_assert_true (hdy_keypad_get_end_action (keypad) == button); + + g_object_set (keypad, "end-action", NULL, NULL); + g_assert_cmpint (notified, ==, 2); + + g_assert_null (hdy_keypad_get_end_action (keypad)); +} + + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func ("/Handy/Keypad/row_spacing", test_hdy_keypad_row_spacing); + g_test_add_func ("/Handy/Keypad/column_spacing", test_hdy_keypad_column_spacing); + g_test_add_func ("/Handy/Keypad/letters_visible", test_hdy_keypad_letters_visible); + g_test_add_func ("/Handy/Keypad/symbols_visible", test_hdy_keypad_symbols_visible); + g_test_add_func ("/Handy/Keypad/entry", test_hdy_keypad_entry); + g_test_add_func ("/Handy/Keypad/start_action", test_hdy_keypad_start_action); + g_test_add_func ("/Handy/Keypad/end_action", test_hdy_keypad_end_action); + + return g_test_run (); +} diff --git a/subprojects/libhandy/tests/test-leaflet.c b/subprojects/libhandy/tests/test-leaflet.c new file mode 100644 index 0000000..43afb3c --- /dev/null +++ b/subprojects/libhandy/tests/test-leaflet.c @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_leaflet_adjacent_child (void) +{ + g_autoptr (HdyLeaflet) leaflet = NULL; + GtkWidget *children[3]; + gint i; + GtkWidget *result; + + leaflet = HDY_LEAFLET (hdy_leaflet_new ()); + g_assert_nonnull (leaflet); + + for (i = 0; i < 3; i++) { + children[i] = gtk_label_new (""); + g_assert_nonnull (children[i]); + + gtk_container_add (GTK_CONTAINER (leaflet), children[i]); + } + + gtk_container_child_set (GTK_CONTAINER (leaflet), children[1], + "navigatable", FALSE, + NULL); + + hdy_leaflet_set_visible_child (leaflet, children[0]); + + result = hdy_leaflet_get_adjacent_child (leaflet, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_null (result); + + result = hdy_leaflet_get_adjacent_child (leaflet, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_true (result == children[2]); + + hdy_leaflet_set_visible_child (leaflet, children[1]); + + result = hdy_leaflet_get_adjacent_child (leaflet, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_true (result == children[0]); + + result = hdy_leaflet_get_adjacent_child (leaflet, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_true (result == children[2]); + + hdy_leaflet_set_visible_child (leaflet, children[2]); + + result = hdy_leaflet_get_adjacent_child (leaflet, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_true (result == children[0]); + + result = hdy_leaflet_get_adjacent_child (leaflet, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_null (result); +} + + +static void +test_hdy_leaflet_navigate (void) +{ + g_autoptr (HdyLeaflet) leaflet = NULL; + GtkWidget *children[3]; + gint i; + gboolean result; + + leaflet = HDY_LEAFLET (hdy_leaflet_new ()); + g_assert_nonnull (leaflet); + + for (i = 0; i < 3; i++) { + children[i] = gtk_label_new (""); + g_assert_nonnull (children[i]); + + gtk_container_add (GTK_CONTAINER (leaflet), children[i]); + } + + gtk_container_child_set (GTK_CONTAINER (leaflet), children[1], + "navigatable", FALSE, + NULL); + + hdy_leaflet_set_visible_child (leaflet, children[0]); + + result = hdy_leaflet_navigate (leaflet, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_false (result); + + result = hdy_leaflet_navigate (leaflet, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_true (result); + g_assert_true (hdy_leaflet_get_visible_child (leaflet) == children[2]); + + result = hdy_leaflet_navigate (leaflet, HDY_NAVIGATION_DIRECTION_FORWARD); + g_assert_false (result); + + result = hdy_leaflet_navigate (leaflet, HDY_NAVIGATION_DIRECTION_BACK); + g_assert_true (result); + g_assert_true (hdy_leaflet_get_visible_child (leaflet) == children[0]); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func ("/Handy/Leaflet/adjacent_child", test_hdy_leaflet_adjacent_child); + g_test_add_func ("/Handy/Leaflet/navigate", test_hdy_leaflet_navigate); + + return g_test_run (); +} diff --git a/subprojects/libhandy/tests/test-preferences-group.c b/subprojects/libhandy/tests/test-preferences-group.c new file mode 100644 index 0000000..d5c69ad --- /dev/null +++ b/subprojects/libhandy/tests/test-preferences-group.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_preferences_group_add (void) +{ + g_autoptr (HdyPreferencesGroup) group = NULL; + HdyPreferencesRow *row; + GtkWidget *widget; + + group = g_object_ref_sink (HDY_PREFERENCES_GROUP (hdy_preferences_group_new ())); + g_assert_nonnull (group); + + row = HDY_PREFERENCES_ROW (hdy_preferences_row_new ()); + g_assert_nonnull (row); + gtk_container_add (GTK_CONTAINER (group), GTK_WIDGET (row)); + + widget = gtk_switch_new (); + g_assert_nonnull (widget); + gtk_container_add (GTK_CONTAINER (group), widget); + + g_assert (G_TYPE_CHECK_INSTANCE_TYPE (gtk_widget_get_parent (GTK_WIDGET (row)), GTK_TYPE_LIST_BOX)); + g_assert (G_TYPE_CHECK_INSTANCE_TYPE (gtk_widget_get_parent (widget), GTK_TYPE_BOX)); +} + + +static void +test_hdy_preferences_group_title (void) +{ + g_autoptr (HdyPreferencesGroup) group = NULL; + + group = g_object_ref_sink (HDY_PREFERENCES_GROUP (hdy_preferences_group_new ())); + g_assert_nonnull (group); + + g_assert_cmpstr (hdy_preferences_group_get_title (group), ==, ""); + + hdy_preferences_group_set_title (group, "Dummy title"); + g_assert_cmpstr (hdy_preferences_group_get_title (group), ==, "Dummy title"); + + hdy_preferences_group_set_title (group, NULL); + g_assert_cmpstr (hdy_preferences_group_get_title (group), ==, ""); +} + + +static void +test_hdy_preferences_group_description (void) +{ + g_autoptr (HdyPreferencesGroup) group = NULL; + + group = g_object_ref_sink (HDY_PREFERENCES_GROUP (hdy_preferences_group_new ())); + g_assert_nonnull (group); + + g_assert_cmpstr (hdy_preferences_group_get_description (group), ==, ""); + + hdy_preferences_group_set_description (group, "Dummy description"); + g_assert_cmpstr (hdy_preferences_group_get_description (group), ==, "Dummy description"); + + hdy_preferences_group_set_description (group, NULL); + g_assert_cmpstr (hdy_preferences_group_get_description (group), ==, ""); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/PreferencesGroup/add", test_hdy_preferences_group_add); + g_test_add_func("/Handy/PreferencesGroup/title", test_hdy_preferences_group_title); + g_test_add_func("/Handy/PreferencesGroup/description", test_hdy_preferences_group_description); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-preferences-page.c b/subprojects/libhandy/tests/test-preferences-page.c new file mode 100644 index 0000000..5f6d15c --- /dev/null +++ b/subprojects/libhandy/tests/test-preferences-page.c @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_preferences_page_add (void) +{ + g_autoptr (HdyPreferencesPage) page = NULL; + HdyPreferencesGroup *group; + GtkWidget *widget; + + page = g_object_ref_sink (HDY_PREFERENCES_PAGE (hdy_preferences_page_new ())); + g_assert_nonnull (page); + + group = HDY_PREFERENCES_GROUP (hdy_preferences_group_new ()); + g_assert_nonnull (group); + gtk_container_add (GTK_CONTAINER (page), GTK_WIDGET (group)); + + widget = gtk_switch_new (); + g_assert_nonnull (widget); + g_test_expect_message (HDY_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't add children of type GtkSwitch to HdyPreferencesPage"); + gtk_container_add (GTK_CONTAINER (page), widget); + g_test_assert_expected_messages (); +} + + +static void +test_hdy_preferences_page_title (void) +{ + g_autoptr (HdyPreferencesPage) page = NULL; + + page = g_object_ref_sink (HDY_PREFERENCES_PAGE (hdy_preferences_page_new ())); + g_assert_nonnull (page); + + g_assert_null (hdy_preferences_page_get_title (page)); + + hdy_preferences_page_set_title (page, "Dummy title"); + g_assert_cmpstr (hdy_preferences_page_get_title (page), ==, "Dummy title"); + + hdy_preferences_page_set_title (page, NULL); + g_assert_null (hdy_preferences_page_get_title (page)); +} + + +static void +test_hdy_preferences_page_icon_name (void) +{ + g_autoptr (HdyPreferencesPage) page = NULL; + + page = g_object_ref_sink (HDY_PREFERENCES_PAGE (hdy_preferences_page_new ())); + g_assert_nonnull (page); + + g_assert_null (hdy_preferences_page_get_icon_name (page)); + + hdy_preferences_page_set_icon_name (page, "dummy-icon-name"); + g_assert_cmpstr (hdy_preferences_page_get_icon_name (page), ==, "dummy-icon-name"); + + hdy_preferences_page_set_icon_name (page, NULL); + g_assert_null (hdy_preferences_page_get_icon_name (page)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/PreferencesPage/add", test_hdy_preferences_page_add); + g_test_add_func("/Handy/PreferencesPage/title", test_hdy_preferences_page_title); + g_test_add_func("/Handy/PreferencesPage/icon_name", test_hdy_preferences_page_icon_name); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-preferences-row.c b/subprojects/libhandy/tests/test-preferences-row.c new file mode 100644 index 0000000..c4f1769 --- /dev/null +++ b/subprojects/libhandy/tests/test-preferences-row.c @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_preferences_row_title (void) +{ + g_autoptr (HdyPreferencesRow) row = NULL; + + row = g_object_ref_sink (HDY_PREFERENCES_ROW (hdy_preferences_row_new ())); + g_assert_nonnull (row); + + g_assert_null (hdy_preferences_row_get_title (row)); + + hdy_preferences_row_set_title (row, "Dummy title"); + g_assert_cmpstr (hdy_preferences_row_get_title (row), ==, "Dummy title"); + + hdy_preferences_row_set_title (row, NULL); + g_assert_null (hdy_preferences_row_get_title (row)); +} + + +static void +test_hdy_preferences_row_use_undeline (void) +{ + g_autoptr (HdyPreferencesRow) row = NULL; + + row = g_object_ref_sink (HDY_PREFERENCES_ROW (hdy_preferences_row_new ())); + g_assert_nonnull (row); + + g_assert_false (hdy_preferences_row_get_use_underline (row)); + + hdy_preferences_row_set_use_underline (row, TRUE); + g_assert_true (hdy_preferences_row_get_use_underline (row)); + + hdy_preferences_row_set_use_underline (row, FALSE); + g_assert_false (hdy_preferences_row_get_use_underline (row)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/PreferencesRow/title", test_hdy_preferences_row_title); + g_test_add_func("/Handy/PreferencesRow/use_underline", test_hdy_preferences_row_use_undeline); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-preferences-window.c b/subprojects/libhandy/tests/test-preferences-window.c new file mode 100644 index 0000000..32a0f8d --- /dev/null +++ b/subprojects/libhandy/tests/test-preferences-window.c @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_preferences_window_add (void) +{ + g_autoptr (HdyPreferencesWindow) window = NULL; + HdyPreferencesPage *page; + GtkWidget *widget; + + window = g_object_ref_sink (HDY_PREFERENCES_WINDOW (hdy_preferences_window_new ())); + g_assert_nonnull (window); + + page = HDY_PREFERENCES_PAGE (hdy_preferences_page_new ()); + g_assert_nonnull (page); + gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (page)); + + widget = gtk_switch_new (); + g_assert_nonnull (widget); + g_test_expect_message (HDY_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "Can't add children of type GtkSwitch to HdyPreferencesWindow"); + gtk_container_add (GTK_CONTAINER (window), widget); + g_test_assert_expected_messages (); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/PreferencesWindow/add", test_hdy_preferences_window_add); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-search-bar.c b/subprojects/libhandy/tests/test-search-bar.c new file mode 100644 index 0000000..9f90721 --- /dev/null +++ b/subprojects/libhandy/tests/test-search-bar.c @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2018 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_search_bar_add (void) +{ + g_autoptr (HdySearchBar) bar = NULL; + GtkWidget *entry; + + bar = g_object_ref_sink (HDY_SEARCH_BAR (hdy_search_bar_new ())); + g_assert_nonnull (bar); + + entry = gtk_entry_new (); + g_assert_nonnull (entry); + + gtk_container_add (GTK_CONTAINER (bar), entry); +} + + +static void +test_hdy_search_bar_connect_entry (void) +{ + g_autoptr (HdySearchBar) bar = NULL; + GtkWidget *box, *entry; + + bar = g_object_ref_sink (HDY_SEARCH_BAR (hdy_search_bar_new ())); + g_assert_nonnull (bar); + + box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); + g_assert_nonnull (box); + + entry = gtk_entry_new (); + g_assert_nonnull (entry); + + gtk_container_add (GTK_CONTAINER (box), entry); + gtk_container_add (GTK_CONTAINER (bar), box); + hdy_search_bar_connect_entry (bar, GTK_ENTRY (entry)); +} + + +static void +test_hdy_search_bar_search_mode (void) +{ + g_autoptr (HdySearchBar) bar = NULL; + + bar = g_object_ref_sink (HDY_SEARCH_BAR (hdy_search_bar_new ())); + g_assert_nonnull (bar); + + g_assert_false (hdy_search_bar_get_search_mode (bar)); + + hdy_search_bar_set_search_mode (bar, TRUE); + g_assert_true (hdy_search_bar_get_search_mode (bar)); + + hdy_search_bar_set_search_mode (bar, FALSE); + g_assert_false (hdy_search_bar_get_search_mode (bar)); +} + + +static void +test_hdy_search_bar_show_close_button (void) +{ + g_autoptr (HdySearchBar) bar = NULL; + + bar = g_object_ref_sink (HDY_SEARCH_BAR (hdy_search_bar_new ())); + g_assert_nonnull (bar); + + g_assert_false (hdy_search_bar_get_show_close_button (bar)); + + hdy_search_bar_set_show_close_button (bar, TRUE); + g_assert_true (hdy_search_bar_get_show_close_button (bar)); + + hdy_search_bar_set_show_close_button (bar, FALSE); + g_assert_false (hdy_search_bar_get_show_close_button (bar)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/SearchBar/add", test_hdy_search_bar_add); + g_test_add_func("/Handy/SearchBar/connect_entry", test_hdy_search_bar_connect_entry); + g_test_add_func("/Handy/SearchBar/search_mode", test_hdy_search_bar_search_mode); + g_test_add_func("/Handy/SearchBar/show_close_button", test_hdy_search_bar_show_close_button); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-squeezer.c b/subprojects/libhandy/tests/test-squeezer.c new file mode 100644 index 0000000..90a12e7 --- /dev/null +++ b/subprojects/libhandy/tests/test-squeezer.c @@ -0,0 +1,161 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_squeezer_homogeneous (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + g_assert_true (hdy_squeezer_get_homogeneous (squeezer)); + + hdy_squeezer_set_homogeneous (squeezer, FALSE); + g_assert_false (hdy_squeezer_get_homogeneous (squeezer)); + + hdy_squeezer_set_homogeneous (squeezer, TRUE); + g_assert_true (hdy_squeezer_get_homogeneous (squeezer)); +} + + +static void +test_hdy_squeezer_transition_duration (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + g_assert_cmpuint (hdy_squeezer_get_transition_duration (squeezer), ==, 200); + + hdy_squeezer_set_transition_duration (squeezer, 400); + g_assert_cmpuint (hdy_squeezer_get_transition_duration (squeezer), ==, 400); + + hdy_squeezer_set_transition_duration (squeezer, -1); + g_assert_cmpuint (hdy_squeezer_get_transition_duration (squeezer), ==, G_MAXUINT); +} + + +static void +test_hdy_squeezer_transition_type (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + g_assert_cmpuint (hdy_squeezer_get_transition_type (squeezer), ==, HDY_SQUEEZER_TRANSITION_TYPE_NONE); + + hdy_squeezer_set_transition_type (squeezer, HDY_SQUEEZER_TRANSITION_TYPE_CROSSFADE); + g_assert_cmpuint (hdy_squeezer_get_transition_type (squeezer), ==, HDY_SQUEEZER_TRANSITION_TYPE_CROSSFADE); + + hdy_squeezer_set_transition_type (squeezer, HDY_SQUEEZER_TRANSITION_TYPE_NONE); + g_assert_cmpuint (hdy_squeezer_get_transition_type (squeezer), ==, HDY_SQUEEZER_TRANSITION_TYPE_NONE); +} + + +static void +test_hdy_squeezer_transition_running (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + g_assert_false (hdy_squeezer_get_transition_running (squeezer)); +} + + +static void +test_hdy_squeezer_show_hide_child (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + GtkWidget *child; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + g_assert_null (hdy_squeezer_get_visible_child (squeezer)); + + child = gtk_label_new (""); + gtk_container_add (GTK_CONTAINER (squeezer), child); + g_assert_null (hdy_squeezer_get_visible_child (squeezer)); + + gtk_widget_show (child); + g_assert (hdy_squeezer_get_visible_child (squeezer) == child); + + gtk_widget_hide (child); + g_assert_null (hdy_squeezer_get_visible_child (squeezer)); + + gtk_widget_show (child); + g_assert (hdy_squeezer_get_visible_child (squeezer) == child); + + gtk_container_remove (GTK_CONTAINER (squeezer), child); + g_assert_null (hdy_squeezer_get_visible_child (squeezer)); +} + + +static void +test_hdy_squeezer_interpolate_size (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + g_assert_false (hdy_squeezer_get_interpolate_size (squeezer)); + + hdy_squeezer_set_interpolate_size (squeezer, TRUE); + g_assert_true (hdy_squeezer_get_interpolate_size (squeezer)); + + hdy_squeezer_set_interpolate_size (squeezer, FALSE); + g_assert_false (hdy_squeezer_get_interpolate_size (squeezer)); +} + + +static void +test_hdy_squeezer_child_enabled (void) +{ + g_autoptr (HdySqueezer) squeezer = NULL; + GtkWidget *child; + + squeezer = g_object_ref_sink (HDY_SQUEEZER (hdy_squeezer_new ())); + g_assert_nonnull (squeezer); + + child = gtk_label_new (""); + gtk_widget_show (child); + gtk_container_add (GTK_CONTAINER (squeezer), child); + g_assert_true (hdy_squeezer_get_child_enabled (squeezer, child)); + + hdy_squeezer_set_child_enabled (squeezer, child, FALSE); + g_assert_false (hdy_squeezer_get_child_enabled (squeezer, child)); + + hdy_squeezer_set_child_enabled (squeezer, child, TRUE); + g_assert_true (hdy_squeezer_get_child_enabled (squeezer, child)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ViewSwitcher/homogeneous", test_hdy_squeezer_homogeneous); + g_test_add_func("/Handy/ViewSwitcher/transition_duration", test_hdy_squeezer_transition_duration); + g_test_add_func("/Handy/ViewSwitcher/transition_type", test_hdy_squeezer_transition_type); + g_test_add_func("/Handy/ViewSwitcher/transition_running", test_hdy_squeezer_transition_running); + g_test_add_func("/Handy/ViewSwitcher/show_hide_child", test_hdy_squeezer_show_hide_child); + g_test_add_func("/Handy/ViewSwitcher/interpolate_size", test_hdy_squeezer_interpolate_size); + g_test_add_func("/Handy/ViewSwitcher/child_enabled", test_hdy_squeezer_child_enabled); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-swipe-group.c b/subprojects/libhandy/tests/test-swipe-group.c new file mode 100644 index 0000000..41b174f --- /dev/null +++ b/subprojects/libhandy/tests/test-swipe-group.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2019 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + +static void +test_hdy_swipe_group_add_remove (void) +{ + g_autoptr (HdySwipeGroup) group = NULL; + g_autoptr (HdySwipeable) swipeable1 = NULL; + g_autoptr (HdySwipeable) swipeable2 = NULL; + + group = hdy_swipe_group_new (); + + swipeable1 = HDY_SWIPEABLE (hdy_carousel_new ()); + swipeable2 = HDY_SWIPEABLE (hdy_carousel_new ()); + + g_assert_cmpint (g_slist_length (hdy_swipe_group_get_swipeables (group)), ==, 0); + + hdy_swipe_group_add_swipeable (group, swipeable1); + g_assert_cmpint (g_slist_length (hdy_swipe_group_get_swipeables (group)), ==, 1); + + hdy_swipe_group_add_swipeable (group, swipeable2); + g_assert_cmpint (g_slist_length (hdy_swipe_group_get_swipeables (group)), ==, 2); + + hdy_swipe_group_remove_swipeable (group, swipeable2); + g_assert_cmpint (g_slist_length (hdy_swipe_group_get_swipeables (group)), ==, 1); + + hdy_swipe_group_remove_swipeable (group, swipeable1); + g_assert_cmpint (g_slist_length (hdy_swipe_group_get_swipeables (group)), ==, 0); +} + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/SwipeGroup/add_remove", test_hdy_swipe_group_add_remove); + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-value-object.c b/subprojects/libhandy/tests/test-value-object.c new file mode 100644 index 0000000..3b9f03c --- /dev/null +++ b/subprojects/libhandy/tests/test-value-object.c @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2019 Red Hat Inc. + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_value_object_init (void) +{ + HdyValueObject *obj; + GValue value = G_VALUE_INIT; + gchar *str; + + g_value_init (&value, G_TYPE_STRING); + g_value_set_string (&value, "asdfasdf"); + obj = hdy_value_object_new (&value); + g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf"); + g_clear_object (&obj); + + obj = hdy_value_object_new_string ("asdfasdf"); + g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf"); + g_clear_object (&obj); + + obj = hdy_value_object_new_take_string (g_strdup ("asdfasdf")); + g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf"); + g_clear_object (&obj); + + obj = hdy_value_object_new_collect (G_TYPE_STRING, "asdfasdf"); + g_assert_cmpstr (hdy_value_object_get_string (obj), ==, "asdfasdf"); + + /* And check that _dup_string works too */ + str = hdy_value_object_dup_string (obj); + g_assert_cmpstr (str, ==, "asdfasdf"); + g_clear_pointer (&str, g_free); + g_clear_object (&obj); + + g_value_unset (&value); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ValueObject/init", test_hdy_value_object_init); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-view-switcher-bar.c b/subprojects/libhandy/tests/test-view-switcher-bar.c new file mode 100644 index 0000000..54538a6 --- /dev/null +++ b/subprojects/libhandy/tests/test-view-switcher-bar.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_view_switcher_bar_policy (void) +{ + g_autoptr (HdyViewSwitcherBar) bar = NULL; + + bar = g_object_ref_sink (HDY_VIEW_SWITCHER_BAR (hdy_view_switcher_bar_new ())); + g_assert_nonnull (bar); + + g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_NARROW); + + hdy_view_switcher_bar_set_policy (bar, HDY_VIEW_SWITCHER_POLICY_AUTO); + g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_AUTO); + + hdy_view_switcher_bar_set_policy (bar, HDY_VIEW_SWITCHER_POLICY_WIDE); + g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_WIDE); + + hdy_view_switcher_bar_set_policy (bar, HDY_VIEW_SWITCHER_POLICY_NARROW); + g_assert_cmpint (hdy_view_switcher_bar_get_policy (bar), ==, HDY_VIEW_SWITCHER_POLICY_NARROW); +} + + +static void +test_hdy_view_switcher_bar_stack (void) +{ + g_autoptr (HdyViewSwitcherBar) bar = NULL; + GtkStack *stack; + + bar = g_object_ref_sink (HDY_VIEW_SWITCHER_BAR (hdy_view_switcher_bar_new ())); + g_assert_nonnull (bar); + + stack = GTK_STACK (gtk_stack_new ()); + g_assert_nonnull (stack); + + g_assert_null (hdy_view_switcher_bar_get_stack (bar)); + + hdy_view_switcher_bar_set_stack (bar, stack); + g_assert (hdy_view_switcher_bar_get_stack (bar) == stack); + + hdy_view_switcher_bar_set_stack (bar, NULL); + g_assert_null (hdy_view_switcher_bar_get_stack (bar)); +} + + +static void +test_hdy_view_switcher_bar_reveal (void) +{ + g_autoptr (HdyViewSwitcherBar) bar = NULL; + + bar = g_object_ref_sink (HDY_VIEW_SWITCHER_BAR (hdy_view_switcher_bar_new ())); + g_assert_nonnull (bar); + + g_assert_false (hdy_view_switcher_bar_get_reveal (bar)); + + hdy_view_switcher_bar_set_reveal (bar, TRUE); + g_assert_true (hdy_view_switcher_bar_get_reveal (bar)); + + hdy_view_switcher_bar_set_reveal (bar, FALSE); + g_assert_false (hdy_view_switcher_bar_get_reveal (bar)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ViewSwitcherBar/policy", test_hdy_view_switcher_bar_policy); + g_test_add_func("/Handy/ViewSwitcherBar/stack", test_hdy_view_switcher_bar_stack); + g_test_add_func("/Handy/ViewSwitcherBar/reveal", test_hdy_view_switcher_bar_reveal); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-view-switcher.c b/subprojects/libhandy/tests/test-view-switcher.c new file mode 100644 index 0000000..2f6c89d --- /dev/null +++ b/subprojects/libhandy/tests/test-view-switcher.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2019 Purism SPC + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_view_switcher_policy (void) +{ + g_autoptr (HdyViewSwitcher) view_switcher = NULL; + + view_switcher = g_object_ref_sink (HDY_VIEW_SWITCHER (hdy_view_switcher_new ())); + g_assert_nonnull (view_switcher); + + g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_AUTO); + + hdy_view_switcher_set_policy (view_switcher, HDY_VIEW_SWITCHER_POLICY_NARROW); + g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_NARROW); + + hdy_view_switcher_set_policy (view_switcher, HDY_VIEW_SWITCHER_POLICY_WIDE); + g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_WIDE); + + hdy_view_switcher_set_policy (view_switcher, HDY_VIEW_SWITCHER_POLICY_AUTO); + g_assert_cmpint (hdy_view_switcher_get_policy (view_switcher), ==, HDY_VIEW_SWITCHER_POLICY_AUTO); +} + + +static void +test_hdy_view_switcher_narrow_ellipsize (void) +{ + g_autoptr (HdyViewSwitcher) view_switcher = NULL; + + view_switcher = g_object_ref_sink (HDY_VIEW_SWITCHER (hdy_view_switcher_new ())); + g_assert_nonnull (view_switcher); + + g_assert_cmpint (hdy_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_NONE); + + hdy_view_switcher_set_narrow_ellipsize (view_switcher, PANGO_ELLIPSIZE_END); + g_assert_cmpint (hdy_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_END); + + hdy_view_switcher_set_narrow_ellipsize (view_switcher, PANGO_ELLIPSIZE_NONE); + g_assert_cmpint (hdy_view_switcher_get_narrow_ellipsize (view_switcher), ==, PANGO_ELLIPSIZE_NONE); +} + + +static void +test_hdy_view_switcher_stack (void) +{ + g_autoptr (HdyViewSwitcher) view_switcher = NULL; + GtkStack *stack; + + view_switcher = g_object_ref_sink (HDY_VIEW_SWITCHER (hdy_view_switcher_new ())); + g_assert_nonnull (view_switcher); + + stack = GTK_STACK (gtk_stack_new ()); + g_assert_nonnull (stack); + + g_assert_null (hdy_view_switcher_get_stack (view_switcher)); + + hdy_view_switcher_set_stack (view_switcher, stack); + g_assert (hdy_view_switcher_get_stack (view_switcher) == stack); + + hdy_view_switcher_set_stack (view_switcher, NULL); + g_assert_null (hdy_view_switcher_get_stack (view_switcher)); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/ViewSwitcher/policy", test_hdy_view_switcher_policy); + g_test_add_func("/Handy/ViewSwitcher/narrow_ellipsize", test_hdy_view_switcher_narrow_ellipsize); + g_test_add_func("/Handy/ViewSwitcher/stack", test_hdy_view_switcher_stack); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-window-handle.c b/subprojects/libhandy/tests/test-window-handle.c new file mode 100644 index 0000000..190c667 --- /dev/null +++ b/subprojects/libhandy/tests/test-window-handle.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_window_handle_new (void) +{ + g_autoptr (GtkWidget) handle = NULL; + + handle = g_object_ref_sink (hdy_window_handle_new ()); + g_assert_nonnull (handle); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/WindowHandle/new", test_hdy_window_handle_new); + + return g_test_run(); +} diff --git a/subprojects/libhandy/tests/test-window.c b/subprojects/libhandy/tests/test-window.c new file mode 100644 index 0000000..4b286de --- /dev/null +++ b/subprojects/libhandy/tests/test-window.c @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Alexander Mikhaylenko + * + * SPDX-License-Identifier: LGPL-2.1+ + */ + +#include + + +static void +test_hdy_window_new (void) +{ + g_autoptr (GtkWidget) window = NULL; + + window = g_object_ref_sink (hdy_window_new ()); + g_assert_nonnull (window); +} + + +gint +main (gint argc, + gchar *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + hdy_init (); + + g_test_add_func("/Handy/Window/new", test_hdy_window_new); + + return g_test_run(); +} -- cgit v1.2.3