cbb9631877
It's eaiser to do it in the builder code, rather than repeating this code in several places. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
/*
|
|
* Copyright 2016 (c) Anna Schumaker.
|
|
*/
|
|
#include <gui/builder.h>
|
|
#include <tests/test.h>
|
|
|
|
static unsigned int gui_clicked = 0;
|
|
|
|
void test_builder_clicked()
|
|
{
|
|
gui_clicked++;
|
|
}
|
|
|
|
static void test_builder()
|
|
{
|
|
int argc = 0;
|
|
GObject *object;
|
|
GtkWidget *widget;
|
|
|
|
test_equal((void *)test_get_gui_builder(), NULL);
|
|
test_equal((void *)gui_builder_object("button1"), NULL);
|
|
test_equal((void *)gui_builder_widget("button1"), NULL);
|
|
|
|
gtk_init(&argc, NULL);
|
|
gui_builder_init("tests/gui/builder.ui");
|
|
test_not_equal((void *)test_get_gui_builder(), NULL);
|
|
|
|
object = gui_builder_object("button1");
|
|
test_not_equal((void *)object, NULL);
|
|
test_equal(G_IS_OBJECT(object), true);
|
|
|
|
widget = gui_builder_widget("button1");
|
|
test_not_equal((void *)widget, NULL);
|
|
test_equal(GTK_IS_WIDGET(widget), true);
|
|
test_equal(GTK_IS_BUTTON(widget), true);
|
|
test_equal(gui_builder_widget_height("button1") > 0, true);
|
|
gtk_button_clicked(GTK_BUTTON(widget));
|
|
test_equal(gui_clicked, 1);
|
|
|
|
|
|
gtk_widget_destroy(gui_builder_widget("window1"));
|
|
gui_builder_deinit();
|
|
test_equal((void *)test_get_gui_builder(), NULL);
|
|
test_equal((void *)gui_builder_object("button1"), NULL);
|
|
test_equal((void *)gui_builder_widget("button1"), NULL);
|
|
}
|
|
|
|
DECLARE_UNIT_TESTS(
|
|
UNIT_TEST("GTK Builder", test_builder),
|
|
);
|