From 705eb1b42bd83149592a284a035b54c3346936da Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 26 Apr 2012 14:34:38 -0500 Subject: add scaffolding for indicator-session-service Google Testing with libdbustest --- tests/Makefile.am | 19 ++++++++++++++ tests/test-service.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 tests/Makefile.am create mode 100644 tests/test-service.cc (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..85df398 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,19 @@ +AM_CPPFLAGS = $(GTEST_CPPFLAGS) $(SESSIONSERVICE_CFLAGS) $(LIBDBUSTEST_CFLAGS) -I${top_srcdir}/src -Wall -Werror +AM_CXXFLAGS = $(GTEST_CXXFLAGS) + +check_PROGRAMS = test-service +test_service_SOURCES = test-service.cc +test_service_LDADD = $(SESSIONSERVICE_LIBS) $(LIBDBUSTEST_LIBS) libgtest.a + +check_LIBRARIES = libgtest.a +nodist_libgtest_a_SOURCES = \ + $(GTEST_SOURCE)/src/gtest-all.cc \ + $(GTEST_SOURCE)/src/gtest_main.cc + +check_SCRIPTS = test-service-runner.sh +test-service-runner.sh: Makefile.am + @echo "#!/bin/sh" > $@ + @echo $(top_builddir)/tests/test-service $(top_builddir)/src/indicator-session-service$(EXEEXT) 2\>/dev/null >> $@ + @chmod +x $@ + +TESTS = ${check_SCRIPTS} diff --git a/tests/test-service.cc b/tests/test-service.cc new file mode 100644 index 0000000..c3d2471 --- /dev/null +++ b/tests/test-service.cc @@ -0,0 +1,71 @@ +/* +Copyright 2012 Canonical Ltd. + +Authors: + Charles Kerr + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include "dbus-shared-names.h" + +/*** +**** +***/ + +static const char * the_executable = NULL; + +/** + * Fixture class for testing indicator-session-service with Google Test. + */ +class SessionServiceTest: public IndicatorServiceTest +{ + public: + virtual ~SessionServiceTest() {} + SessionServiceTest(): IndicatorServiceTest(INDICATOR_SESSION_DBUS_NAME, + INDICATOR_SESSION_DBUS_OBJECT, + the_executable) { } + public: + virtual void SetUp() { + wait_seconds(1); + IndicatorServiceTest::SetUp(); + } + virtual void TearDown() { + IndicatorServiceTest::TearDown(); + } +}; + + +/** + * Basic sanity test to see if we can account for all our menuitems. + */ +TEST_F(SessionServiceTest, HelloWorld) +{ + ASSERT_TRUE(true); +} + + +int +main (int argc, char *argv[]) +{ + if (argc < 2) { + fprintf (stderr, "Usage: appname /path/to/indicator-session-service"); + return -1; + } + the_executable = argv[1]; + fprintf (stdout, "executable is '%s'\n", the_executable); + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} -- cgit v1.2.3 From 1bab86efd3e4637d61e20364c2859982605850b1 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 26 Apr 2012 16:37:10 -0500 Subject: sync with the other indicatorsGTest automake rules --- tests/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 85df398..c03af4c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,9 +1,10 @@ -AM_CPPFLAGS = $(GTEST_CPPFLAGS) $(SESSIONSERVICE_CFLAGS) $(LIBDBUSTEST_CFLAGS) -I${top_srcdir}/src -Wall -Werror +AM_CPPFLAGS = $(GTEST_CPPFLAGS) $(INDICATOR_CFLAGS) -I${top_srcdir}/src -Wall -Werror AM_CXXFLAGS = $(GTEST_CXXFLAGS) check_PROGRAMS = test-service test_service_SOURCES = test-service.cc -test_service_LDADD = $(SESSIONSERVICE_LIBS) $(LIBDBUSTEST_LIBS) libgtest.a +test_service_LDADD = $(TEST_SERVICE_LIBS) libgtest.a +test_service_CPPFLAGS = $(TEST_SERVICE_CFLAGS) $(AM_CPPFLAGS) check_LIBRARIES = libgtest.a nodist_libgtest_a_SOURCES = \ -- cgit v1.2.3 From 123a7fec04d313d4d420249ab24a38eb587c3ef7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Apr 2012 09:43:45 -0500 Subject: Change the service path to be a define instead of passed on the command line --- tests/Makefile.am | 14 ++++++-------- tests/test-service.cc | 15 +-------------- 2 files changed, 7 insertions(+), 22 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index c03af4c..628056b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,20 +1,18 @@ + AM_CPPFLAGS = $(GTEST_CPPFLAGS) $(INDICATOR_CFLAGS) -I${top_srcdir}/src -Wall -Werror AM_CXXFLAGS = $(GTEST_CXXFLAGS) +TESTS = test-service check_PROGRAMS = test-service test_service_SOURCES = test-service.cc test_service_LDADD = $(TEST_SERVICE_LIBS) libgtest.a -test_service_CPPFLAGS = $(TEST_SERVICE_CFLAGS) $(AM_CPPFLAGS) +test_service_CPPFLAGS = \ + $(TEST_SERVICE_CFLAGS) \ + $(AM_CPPFLAGS) \ + -DINDICATOR_SERVICE_PATH="\"$(top_builddir)/src/indicator-session-service\"" check_LIBRARIES = libgtest.a nodist_libgtest_a_SOURCES = \ $(GTEST_SOURCE)/src/gtest-all.cc \ $(GTEST_SOURCE)/src/gtest_main.cc -check_SCRIPTS = test-service-runner.sh -test-service-runner.sh: Makefile.am - @echo "#!/bin/sh" > $@ - @echo $(top_builddir)/tests/test-service $(top_builddir)/src/indicator-session-service$(EXEEXT) 2\>/dev/null >> $@ - @chmod +x $@ - -TESTS = ${check_SCRIPTS} diff --git a/tests/test-service.cc b/tests/test-service.cc index c3d2471..cb10070 100644 --- a/tests/test-service.cc +++ b/tests/test-service.cc @@ -36,7 +36,7 @@ class SessionServiceTest: public IndicatorServiceTest virtual ~SessionServiceTest() {} SessionServiceTest(): IndicatorServiceTest(INDICATOR_SESSION_DBUS_NAME, INDICATOR_SESSION_DBUS_OBJECT, - the_executable) { } + INDICATOR_SERVICE_PATH) { } public: virtual void SetUp() { wait_seconds(1); @@ -56,16 +56,3 @@ TEST_F(SessionServiceTest, HelloWorld) ASSERT_TRUE(true); } - -int -main (int argc, char *argv[]) -{ - if (argc < 2) { - fprintf (stderr, "Usage: appname /path/to/indicator-session-service"); - return -1; - } - the_executable = argv[1]; - fprintf (stdout, "executable is '%s'\n", the_executable); - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} -- cgit v1.2.3 From f2298244150295340ce53a35ea6ff92433105f2c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 27 Apr 2012 09:47:59 -0500 Subject: Switch to using the xorg-gtest main so that we're running under a dummy Xserver --- tests/Makefile.am | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 628056b..5eca08a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,10 @@ -AM_CPPFLAGS = $(GTEST_CPPFLAGS) $(INDICATOR_CFLAGS) -I${top_srcdir}/src -Wall -Werror +AM_CPPFLAGS = \ + $(GTEST_CPPFLAGS) \ + $(XORG_GTEST_CPPFLAGS) \ + $(INDICATOR_CFLAGS) \ + -I${top_srcdir}/src \ + -Wall -Werror AM_CXXFLAGS = $(GTEST_CXXFLAGS) TESTS = test-service @@ -13,6 +18,7 @@ test_service_CPPFLAGS = \ check_LIBRARIES = libgtest.a nodist_libgtest_a_SOURCES = \ + $(XORG_GTEST_SOURCE)/src/xorg-gtest-all.cpp \ $(GTEST_SOURCE)/src/gtest-all.cc \ - $(GTEST_SOURCE)/src/gtest_main.cc + $(XORG_GTEST_SOURCE)/src/xorg-gtest_main.cpp -- cgit v1.2.3 From be262264e082cd4708b42b84f3d96f4a8cde0e93 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 11 Jul 2012 09:51:42 -0500 Subject: fix #include in test-service --- tests/test-service.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-service.cc b/tests/test-service.cc index d163db5..73d905b 100644 --- a/tests/test-service.cc +++ b/tests/test-service.cc @@ -19,7 +19,7 @@ with this program. If not, see . #include -#include "dbus-shared-names.h" +#include "shared-names.h" /*** **** -- cgit v1.2.3