From d8484ce5caf9fd5f4efb30368ccc9b70b1f38710 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 24 May 2012 16:50:58 -0500 Subject: first draft of getting GSettings working in the unit tests before the schema is installed. --- tests/Makefile.am | 10 ++++++++-- tests/test-indicator.cc | 27 +++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 341abdd..8169e3a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,6 @@ TESTS = -CLEANFILES = +CLEANFILES = +BUILT_SOURCES = check_PROGRAMS = ### @@ -34,6 +35,11 @@ TEST_CPPFLAGS = \ $(INDICATOR_CFLAGS) \ $(COVERAGE_CFLAGS) +BUILT_SOURCES += gschemas.compiled +CLEANFILES += gschemas.compiled +gschemas.compiled: Makefile + @glib-compile-schemas --targetdir=$(abs_builddir) $(top_builddir)/data + TESTS += test-device check_PROGRAMS += test-device test_device_SOURCES = test-device.cc @@ -44,7 +50,7 @@ TESTS += test-indicator check_PROGRAMS += test-indicator test_indicator_SOURCES = test-indicator.cc test_indicator_LDADD = $(TEST_LIBS) -test_indicator_CPPFLAGS = $(TEST_CPPFLAGS) +test_indicator_CPPFLAGS = $(TEST_CPPFLAGS) -DSCHEMA_DIR="\"$(top_builddir)/tests/\"" ### ### diff --git a/tests/test-indicator.cc b/tests/test-indicator.cc index e3533e9..af494ee 100644 --- a/tests/test-indicator.cc +++ b/tests/test-indicator.cc @@ -22,6 +22,10 @@ with this program. If not, see . #include "device.h" #include "indicator-power.h" +/*** +**** +***/ + namespace { void ensure_glib_initialized () @@ -40,7 +44,27 @@ namespace **** ***/ -TEST(IndicatorTest, GObjectNew) +class IndicatorTest : public ::testing::Test +{ + protected: + + virtual void SetUp() + { + ensure_glib_initialized (); + g_setenv( "GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE); + g_message ("GSETTINGS_SCHEMA_DIR is %s", g_getenv("GSETTINGS_SCHEMA_DIR")); + } + + virtual void TearDown() + { + } +}; + +/*** +**** +***/ + +TEST_F(IndicatorTest, GObjectNew) { ensure_glib_initialized (); @@ -49,4 +73,3 @@ TEST(IndicatorTest, GObjectNew) ASSERT_TRUE (IS_INDICATOR_POWER(o)); g_object_unref (o); } - -- cgit v1.2.3