diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 78 | ||||
-rw-r--r-- | tests/Makefile.am | 122 | ||||
-rw-r--r-- | tests/indicator-test.cpp | 8 |
3 files changed, 83 insertions, 125 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..1f0d117 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,78 @@ +# libindicator-messages-service + +find_package(GMock) + +set( + HEADERS + ${CMAKE_SOURCE_DIR}/src/gactionmuxer.h + ${CMAKE_SOURCE_DIR}/src/dbus-data.h +) + +set( + SOURCES + ${CMAKE_SOURCE_DIR}/src/gactionmuxer.c +) + +set( + HEADERS_GEN + ${CMAKE_BINARY_DIR}/src/indicator-messages-service.h +) + +set( + SOURCES_GEN + ${CMAKE_BINARY_DIR}/src/indicator-messages-service.c +) + +set_source_files_properties(${HEADERS_GEN} ${SOURCES_GEN} PROPERTIES GENERATED TRUE) +set_source_files_properties(${HEADERS} ${SOURCES} PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_library("indicator-messages-service" STATIC ${HEADERS} ${HEADERS_GEN} ${SOURCES} ${SOURCES_GEN}) +target_include_directories("indicator-messages-service" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS}) +target_compile_definitions("indicator-messages-service" PUBLIC G_LOG_DOMAIN="Ayatana-Indicator-Messages") +target_link_libraries("indicator-messages-service") + +# test-gactionmuxer + +set_source_files_properties(gtest-menuitems.cpp PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_executable("test-gactionmuxer" test-gactionmuxer.cpp) +target_link_options("test-gactionmuxer" PRIVATE -no-pie) +target_include_directories("test-gactionmuxer" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS} "${CMAKE_SOURCE_DIR}/src") +target_link_libraries("test-gactionmuxer" "indicator-messages-service" ${PROJECT_DEPS_LIBRARIES} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES}) +if (ENABLE_COVERAGE) + target_link_libraries("test-gactionmuxer" "-lgcov") +endif() +add_test("test-gactionmuxer" "test-gactionmuxer") +add_dependencies("test-gactionmuxer" "indicator-messages-service") +set(COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} "test-gactionmuxer" PARENT_SCOPE) + +# gschemas.compiled + +set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES gschemas.compiled) +set_source_files_properties(gschemas.compiled GENERATED) +execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE COMPILE_SCHEMA_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE) +add_custom_command(OUTPUT gschemas.compiled COMMAND cp -f ${CMAKE_SOURCE_DIR}/data/org.ayatana.indicator.messages.gschema.xml ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${COMPILE_SCHEMA_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}) +add_custom_target("gschemas-compiled" ALL DEPENDS gschemas.compiled) + +# indicator-test + +pkg_check_modules(DBUSTEST REQUIRED dbustest-1) +set_source_files_properties(indicator-test.cpp PROPERTIES COMPILE_FLAGS ${COMPILE_FLAGS}) +add_executable("indicator-test" indicator-test.cpp) +target_link_options("indicator-test" PRIVATE -no-pie) +target_include_directories("indicator-test" PUBLIC ${PROJECT_DEPS_INCLUDE_DIRS} ${DBUSTEST_INCLUDE_DIRS} "${CMAKE_SOURCE_DIR}/libmessaging-menu") +target_link_libraries("indicator-test" "messaging-menu" ${PROJECT_DEPS_LIBRARIES} ${DBUSTEST_LIBRARIES} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES}) +target_compile_definitions( + "indicator-test" + PUBLIC + INDICATOR_MESSAGES_SERVICE_BINARY="${CMAKE_BINARY_DIR}/src/ayatana-indicator-messages-service" + SCHEMA_DIR="${CMAKE_CURRENT_BINARY_DIR}" + XDG_DATA_DIRS="${CMAKE_CURRENT_SOURCE_DIR}" +) +add_test("indicator-test" "indicator-test") +add_dependencies("indicator-test" "messaging-menu" "gschemas-compiled") +set(COVERAGE_TEST_TARGETS ${COVERAGE_TEST_TARGETS} "indicator-test" PARENT_SCOPE) + +# test-client.sh + +set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/test-client.sh" GENERATED) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test-client.sh" "export LD_LIBRARY_PATH=\"${CMAKE_BINARY_DIR}/libmessaging-menu\"; export GI_TYPELIB_PATH=\"${CMAKE_BINARY_DIR}/libmessaging-menu\"; export XDG_DATA_DIRS=\"${CMAKE_CURRENT_SOURCE_DIR}\"; python3 \"${CMAKE_CURRENT_SOURCE_DIR}/test-client.py\"") +add_test(NAME "test-client" COMMAND sh "${CMAKE_CURRENT_BINARY_DIR}/test-client.sh") diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index c6a3db6..0000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,122 +0,0 @@ -CLEANFILES= -check_LTLIBRARIES = libgtest.la -check_PROGRAMS = test-gactionmuxer - -TESTS = $(check_PROGRAMS) - -AM_CPPFLAGS = $(GTEST_CPPFLAGS) \ - -I${top_srcdir}/src - -###################################### -# Google Test -###################################### - -nodist_libgtest_la_SOURCES = \ - $(GTEST_SOURCE)/src/gtest-all.cc \ - $(GTEST_SOURCE)/src/gtest_main.cc -libgtest_la_CPPFLAGS = \ - $(GTEST_CPPFLAGS) -w \ - $(AM_CPPFLAGS) -libgtest_la_CXXFLAGS = \ - $(AM_CXXFLAGS) - -###################################### -# GActionMixer -###################################### - -test_gactionmuxer_SOURCES = \ - test-gactionmuxer.cpp - -test_gactionmuxer_CPPFLAGS = \ - $(APPLET_CFLAGS) \ - $(AM_CPPFLAGS) - -test_gactionmuxer_LDADD = \ - $(APPLET_LIBS) \ - libindicator-messages-service.la \ - libgtest.la - -###################################### -# Indicator Test -###################################### - -SCHEMA_COMPILED_DIR="$(abs_builddir)/gsettings-schemas-compiled/" - -indicator_test_SOURCES = \ - indicator-test.cpp - -indicator_test_CPPFLAGS = \ - -DINDICATOR_MESSAGES_SERVICE_BINARY="\"$(abs_top_builddir)/src/ayatana-indicator-messages-service\"" \ - -DSCHEMA_DIR="\"$(SCHEMA_COMPILED_DIR)\"" \ - -DXDG_DATA_DIRS="\"$(abs_srcdir)/\"" \ - -I$(top_srcdir)/libmessaging-menu \ - -std=c++11 \ - $(APPLET_CFLAGS) \ - $(DBUSTEST_CFLAGS) \ - $(AM_CPPFLAGS) - -indicator_test_LDADD = \ - $(APPLET_LIBS) \ - $(DBUSTEST_LIBS) \ - $(top_builddir)/libmessaging-menu/libmessaging-menu.la \ - libgtest.la \ - -lc -lpthread - -indicator-test.cpp: schemas-compiled.stamp - -schemas-compiled.stamp: $(top_srcdir)/data/*gschema.xml - @rm -rf $(SCHEMA_COMPILED_DIR) - @mkdir -p $(SCHEMA_COMPILED_DIR) - @cp -f $(top_srcdir)/data/*gschema.xml $(SCHEMA_COMPILED_DIR) - @`pkg-config gio-2.0 --variable glib_compile_schemas` $(SCHEMA_COMPILED_DIR) - @touch schemas-compiled.stamp - -CLEANFILES += schemas-compiled.stamp -TESTS += indicator-test -check_PROGRAMS += indicator-test - -###################################### -# Lib containing code under test -###################################### - -noinst_LTLIBRARIES = \ - libindicator-messages-service.la - -libindicator_messages_service_la_SOURCES = \ - $(top_builddir)/common/indicator-messages-service.c \ - $(top_builddir)/common/indicator-messages-service.h \ - $(top_srcdir)/src/gactionmuxer.c \ - $(top_srcdir)/src/gactionmuxer.h \ - $(top_srcdir)/src/dbus-data.h - -libindicator_messages_service_ladir = \ - $(includedir)/libayatana-indicator-messages-service/ - -libindicator_messages_service_la_CFLAGS = \ - $(APPLET_CFLAGS) \ - $(COVERAGE_CFLAGS) \ - -I$(top_builddir)/src \ - -I$(top_builddir)/common \ - -Wall \ - -Wl,-Bsymbolic-functions \ - -Wl,-z,defs \ - -Wl,--as-needed \ - -Wno-error=deprecated-declarations \ - -DG_LOG_DOMAIN=\"Ayatana-Indicator-Messages\" - -libindicator_messages_service_la_LIBADD = \ - $(APPLET_LIBS) - -libindicator_messages_service_la_LDFLAGS = \ - $(COVERAGE_LDFLAGS) - -###################################### -# Test client with dbusmock -###################################### - -TESTS_ENVIRONMENT = \ - export LD_LIBRARY_PATH=$(top_builddir)/libmessaging-menu/.libs; \ - export GI_TYPELIB_PATH=$(top_builddir)/libmessaging-menu; \ - export XDG_DATA_DIRS=$(abs_srcdir); - -TESTS += test-client.py diff --git a/tests/indicator-test.cpp b/tests/indicator-test.cpp index 4e76eea..afca37a 100644 --- a/tests/indicator-test.cpp +++ b/tests/indicator-test.cpp @@ -1,5 +1,6 @@ /* * Copyright © 2015 Canonical Ltd. + * Copyright © 2021 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +16,7 @@ * * Authors: * Ted Gould <ted@canonical.com> + * Robert Tari <robert@tari.in> */ #include <gtest/gtest.h> @@ -64,7 +66,7 @@ TEST_F(IndicatorTest, RootAction) { EXPECT_EVENTUALLY_ACTION_EXISTS("messages"); EXPECT_ACTION_STATE_TYPE("messages", G_VARIANT_TYPE("a{sv}")); - EXPECT_ACTION_STATE("messages", g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': <false>}")); + EXPECT_ACTION_STATE("messages", g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator', 'indicator-messages-offline-symbolic', 'indicator-messages-symbolic', 'indicator-symbolic']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': <false>}")); } TEST_F(IndicatorTest, SingleMessage) { @@ -146,8 +148,8 @@ TEST_F(IndicatorTest, MessageReply) { } TEST_F(IndicatorTest, IconNotification) { - auto normalicon = std::shared_ptr<GVariant>(g_variant_ref_sink(g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': <true>}")), [](GVariant *var) {if (var != nullptr) g_variant_unref(var); }); - auto blueicon = std::shared_ptr<GVariant>(g_variant_ref_sink(g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-new-offline', 'indicator-messages-new', 'indicator-messages', 'indicator']>)>, 'title': <'Notifications'>, 'accessible-desc': <'New Messages'>, 'visible': <true>}")), [](GVariant *var) {if (var != nullptr) g_variant_unref(var); }); + auto normalicon = std::shared_ptr<GVariant>(g_variant_ref_sink(g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-offline', 'indicator-messages', 'indicator', 'indicator-messages-offline-symbolic', 'indicator-messages-symbolic', 'indicator-symbolic']>)>, 'title': <'Notifications'>, 'accessible-desc': <'Messages'>, 'visible': <true>}")), [](GVariant *var) {if (var != nullptr) g_variant_unref(var); }); + auto blueicon = std::shared_ptr<GVariant>(g_variant_ref_sink(g_variant_new_parsed("{'icon': <('themed', <['indicator-messages-new-offline', 'indicator-messages-new', 'indicator-messages', 'indicator', 'indicator-messages-new-offline-symbolic', 'indicator-messages-new-symbolic', 'indicator-messages-symbolic', 'indicator-symbolic']>)>, 'title': <'Notifications'>, 'accessible-desc': <'New Messages'>, 'visible': <true>}")), [](GVariant *var) {if (var != nullptr) g_variant_unref(var); }); setActions("/org/ayatana/indicator/messages"); |