From d7d09532523814a145d7602a65542770d75c497c Mon Sep 17 00:00:00 2001 From: xianjimli Date: Thu, 17 Jan 2019 09:35:31 +0800 Subject: [PATCH] add test --- tests/gif_image_test.cc | 19 +++++++++++++++++++ tests/svg_image_test.cc | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/gif_image_test.cc create mode 100644 tests/svg_image_test.cc diff --git a/tests/gif_image_test.cc b/tests/gif_image_test.cc new file mode 100644 index 0000000000..36fa7036f5 --- /dev/null +++ b/tests/gif_image_test.cc @@ -0,0 +1,19 @@ +#include "widgets/window.h" +#include "gif_image/gif_image.h" +#include "gtest/gtest.h" + +TEST(GifImage, basic) { + value_t v; + value_t v1; + widget_t* w = window_create(NULL, 0, 0, 0, 0); + widget_t* img = gif_image_create(w, 0, 0, 100, 100); + + value_set_str(&v, "earth"); + ASSERT_EQ(widget_set_prop(img, WIDGET_PROP_IMAGE, &v), RET_OK); + ASSERT_EQ(widget_get_prop(img, WIDGET_PROP_IMAGE, &v1), RET_OK); + ASSERT_EQ(strcmp(value_str(&v), value_str(&v1)), 0); + ASSERT_EQ(widget_count_children(w), 1); + + widget_destroy(w); +} + diff --git a/tests/svg_image_test.cc b/tests/svg_image_test.cc new file mode 100644 index 0000000000..d7d2b69f5a --- /dev/null +++ b/tests/svg_image_test.cc @@ -0,0 +1,19 @@ +#include "widgets/window.h" +#include "svg_image/svg_image.h" +#include "gtest/gtest.h" + +TEST(SvgImage, basic) { + value_t v; + value_t v1; + widget_t* w = window_create(NULL, 0, 0, 0, 0); + widget_t* img = svg_image_create(w, 0, 0, 100, 100); + + value_set_str(&v, "earth"); + ASSERT_EQ(widget_set_prop(img, WIDGET_PROP_IMAGE, &v), RET_OK); + ASSERT_EQ(widget_get_prop(img, WIDGET_PROP_IMAGE, &v1), RET_OK); + ASSERT_EQ(strcmp(value_str(&v), value_str(&v1)), 0); + ASSERT_EQ(widget_count_children(w), 1); + + widget_destroy(w); +} +