aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-05-24 16:50:58 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-05-24 16:50:58 -0500
commitd8484ce5caf9fd5f4efb30368ccc9b70b1f38710 (patch)
treef4e80aaafadfc65baefda38972080359fd59a5c7 /tests
parentcaae4241b85412d6914d6fd1e0a9bac9da35c6f3 (diff)
downloadayatana-indicator-power-d8484ce5caf9fd5f4efb30368ccc9b70b1f38710.tar.gz
ayatana-indicator-power-d8484ce5caf9fd5f4efb30368ccc9b70b1f38710.tar.bz2
ayatana-indicator-power-d8484ce5caf9fd5f4efb30368ccc9b70b1f38710.zip
first draft of getting GSettings working in the unit tests before the schema is installed.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/test-indicator.cc27
2 files changed, 33 insertions, 4 deletions
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 <http://www.gnu.org/licenses/>.
#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);
}
-