Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lidaobing committed May 24, 2024
1 parent 10689ec commit 312583c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/iptux/UiHelperTest.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "gtest/gtest.h"

#include "iptux-utils/TestHelper.h"
#include "iptux/UiHelper.h"
#include <cstdlib>
#include <ctime>
Expand Down Expand Up @@ -43,3 +44,22 @@ TEST(UiHelper, StrFirstNonEmptyLine) {
ASSERT_EQ(StrFirstNonEmptyLine("\n b"), "b");
ASSERT_EQ(StrFirstNonEmptyLine(" \n b\n"), "b");
}

TEST(UiHelper, igtk_image_new_with_size) {
auto image =
igtk_image_new_with_size(testDataPath("iptux.png").c_str(), 100, 100);
ASSERT_NE(image, nullptr);
auto pixbuf = gtk_image_get_pixbuf(image);
ASSERT_EQ(gdk_pixbuf_get_width(pixbuf), 48);
ASSERT_EQ(gdk_pixbuf_get_height(pixbuf), 48);
g_object_unref(pixbuf);
g_object_unref(image);

image = igtk_image_new_with_size(testDataPath("iptux.png").c_str(), 20, 30);
ASSERT_NE(image, nullptr);
pixbuf = gtk_image_get_pixbuf(image);
ASSERT_EQ(gdk_pixbuf_get_width(pixbuf), 20);
ASSERT_EQ(gdk_pixbuf_get_height(pixbuf), 20);
g_object_unref(pixbuf);
g_object_unref(image);
}

0 comments on commit 312583c

Please sign in to comment.