tests: Build gtk builder test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
8f8e4a4459
commit
1710c8076a
|
@ -6,9 +6,12 @@ endif()
|
||||||
|
|
||||||
# Handle files that depend on CONFIG_TESTING_DIR
|
# Handle files that depend on CONFIG_TESTING_DIR
|
||||||
list(REMOVE_ITEM core ${PROJECT_SOURCE_DIR}/core/file.c)
|
list(REMOVE_ITEM core ${PROJECT_SOURCE_DIR}/core/file.c)
|
||||||
|
list(REMOVE_ITEM gui ${PROJECT_SOURCE_DIR}/gui/ocarina.c)
|
||||||
list(APPEND corefiles ${PROJECT_SOURCE_DIR}/core/file.c)
|
list(APPEND corefiles ${PROJECT_SOURCE_DIR}/core/file.c)
|
||||||
|
|
||||||
add_subdirectory(Music/)
|
|
||||||
|
|
||||||
add_library(corelib OBJECT EXCLUDE_FROM_ALL ${core})
|
add_library(corelib OBJECT EXCLUDE_FROM_ALL ${core})
|
||||||
|
add_library(guilib OBJECT EXCLUDE_FROM_ALL ${gui} ${core})
|
||||||
|
|
||||||
|
add_subdirectory(Music/)
|
||||||
add_subdirectory(core/)
|
add_subdirectory(core/)
|
||||||
|
add_subdirectory(gui/)
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
Include(../UnitTest.cmake)
|
||||||
|
|
||||||
|
function(gui_unit_test name)
|
||||||
|
unit_test(Gui ${name} guilib "${corefiles}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
gui_unit_test(Builder)
|
|
@ -24,7 +24,7 @@ def GuiTest(name):
|
||||||
|
|
||||||
|
|
||||||
env.UsePackage("gmodule-export-2.0")
|
env.UsePackage("gmodule-export-2.0")
|
||||||
res += [ GuiTest("builder") ]
|
gui_objs += [ env.Object("../../gui/builder.c") ]
|
||||||
res += [ GuiTest("settings") ]
|
res += [ GuiTest("settings") ]
|
||||||
res += [ GuiTest("model") ]
|
res += [ GuiTest("model") ]
|
||||||
res += [ GuiTest("view") ]
|
res += [ GuiTest("view") ]
|
||||||
|
|
|
@ -17,34 +17,37 @@ static void test_builder()
|
||||||
GObject *object;
|
GObject *object;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
test_equal((void *)test_get_gui_builder(), NULL);
|
g_assert_null(test_get_gui_builder());
|
||||||
test_equal((void *)gui_builder_object("button1"), NULL);
|
g_assert_null(gui_builder_object("button1"));
|
||||||
test_equal((void *)gui_builder_widget("button1"), NULL);
|
g_assert_null(gui_builder_widget("button1"));
|
||||||
|
|
||||||
gtk_init(&argc, NULL);
|
gtk_init(&argc, NULL);
|
||||||
gui_builder_init("tests/gui/builder.ui");
|
gui_builder_init("tests/gui/builder.ui");
|
||||||
test_not_equal((void *)test_get_gui_builder(), NULL);
|
g_assert_nonnull(test_get_gui_builder());
|
||||||
|
|
||||||
object = gui_builder_object("button1");
|
object = gui_builder_object("button1");
|
||||||
test_not_equal((void *)object, NULL);
|
g_assert_nonnull(object);
|
||||||
test_equal(G_IS_OBJECT(object), true);
|
g_assert_true(G_IS_OBJECT(object));
|
||||||
|
|
||||||
widget = gui_builder_widget("button1");
|
widget = gui_builder_widget("button1");
|
||||||
test_not_equal((void *)widget, NULL);
|
g_assert_nonnull(widget);
|
||||||
test_equal(GTK_IS_WIDGET(widget), true);
|
g_assert_true(GTK_IS_WIDGET(widget));
|
||||||
test_equal(GTK_IS_BUTTON(widget), true);
|
g_assert_true(GTK_IS_BUTTON(widget));
|
||||||
test_equal(gui_builder_widget_height("button1") > 0, true);
|
g_assert_cmpint(gui_builder_widget_height("button1"), >, 0);
|
||||||
gtk_button_clicked(GTK_BUTTON(widget));
|
gtk_button_clicked(GTK_BUTTON(widget));
|
||||||
test_equal(gui_clicked, 1);
|
g_assert_cmpuint(gui_clicked, ==, 1);
|
||||||
|
|
||||||
|
|
||||||
gtk_widget_destroy(gui_builder_widget("window1"));
|
gtk_widget_destroy(gui_builder_widget("window1"));
|
||||||
gui_builder_deinit();
|
gui_builder_deinit();
|
||||||
test_equal((void *)test_get_gui_builder(), NULL);
|
g_assert_null(test_get_gui_builder());
|
||||||
test_equal((void *)gui_builder_object("button1"), NULL);
|
g_assert_null(gui_builder_object("button1"));
|
||||||
test_equal((void *)gui_builder_widget("button1"), NULL);
|
g_assert_null(gui_builder_widget("button1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_UNIT_TESTS(
|
int main(int argc, char **argv)
|
||||||
UNIT_TEST("GTK Builder", test_builder),
|
{
|
||||||
);
|
g_test_init(&argc, &argv, NULL);
|
||||||
|
g_test_add_func("/Gui/Builder", test_builder);
|
||||||
|
return g_test_run();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue