Add rudimentary test suite with a LUC Handler test script
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 13 Jun 2012 10:46:08 +0000 (11:46 +0100)
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>
Wed, 13 Jun 2012 11:47:48 +0000 (12:47 +0100)
For now the LUC Handler test only does the following:

  1. reset the LUC to be empty
  2. attempt to register one foreground app

In the future we have to add more tests to it.

Makefile.am
configure.ac
tests/Makefile.am [new file with mode: 0644]
tests/luc-handler/Makefile.am [new file with mode: 0644]
tests/luc-handler/test-luc-handler [new file with mode: 0755]

index 2a12980..b769f29 100644 (file)
@@ -1,7 +1,8 @@
 # vi:set ts=8 sw=8 noet ai nocindent:
 
 SUBDIRS =                                                              \
-       luc-handler
+       luc-handler                                                     \
+       tests
 
 .PHONY: ChangeLog
 
index 2ac99cc..e79defd 100644 (file)
@@ -97,4 +97,6 @@ AC_OUTPUT([
 Makefile
 luc-handler/Makefile
 luc-handler/org.genivi.LUCHandler1.gschema.xml
+tests/Makefile
+tests/luc-handler/Makefile
 ])
diff --git a/tests/Makefile.am b/tests/Makefile.am
new file mode 100644 (file)
index 0000000..150ed2c
--- /dev/null
@@ -0,0 +1,4 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+
+SUBDIRS =                                                              \
+       luc-handler
diff --git a/tests/luc-handler/Makefile.am b/tests/luc-handler/Makefile.am
new file mode 100644 (file)
index 0000000..b7c8512
--- /dev/null
@@ -0,0 +1,4 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+
+TESTS =                                                                        \
+       test-luc-handler
diff --git a/tests/luc-handler/test-luc-handler b/tests/luc-handler/test-luc-handler
new file mode 100755 (executable)
index 0000000..cb3d2cc
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+set -e
+
+# function to read the LastUserContext property
+get_luc()
+{
+  gdbus call -e \
+    -d org.genivi.LUCHandler1 \
+    -o /org/genivi/LUCHandler1 \
+    -m org.freedesktop.DBus.Properties.Get \
+    "org.genivi.LUCHandler1" \
+    "LastUserContext"
+}
+
+# function to make a registration call
+register()
+{
+  gdbus call -e \
+    -d org.genivi.LUCHandler1 \
+    -o /org/genivi/LUCHandler1 \
+    -m org.genivi.LUCHandler1.Register \
+    "$1" &> /dev/null
+}
+
+# function to fail with a reason
+fail()
+{
+  echo "ERROR: $1"
+  exit 1
+}
+
+# reset the LUC
+gsettings set org.genivi.LUCHandler1 last-user-context '{}'
+
+# assert that the LastUserContext property is empty now
+[[ "$(get_luc)" = "(<@a{sas} {}>,)" ]] \
+  || fail "LastUserContext out of sync with GSettings key after resetting"
+
+# register one app for foreground
+register '{ "foreground": [ "app1" ] }'
+
+# verify that the app was registered
+[[ "$(get_luc)" = "(<{'foreground': ['app1']}>,)" ]] \
+  || fail "Registration of a single foreground app was not applied"