DBUS_RUNNER=dbus-test-runner --max-wait=0

EXTRA_DIST = unity-webapps-applications/index.theme

AM_CPPFLAGS = \
	$(UNITY_WEBAPPS_CFLAGS) \
	$(UNITY_WEBAPPS_DAEMON_CFLAGS) \
	-DUNITY_WEBAPPS_ENABLE_DEBUG \
	-DTEST_SRCDIR=\"`readlink -f $(srcdir)`\" \
	-I$(top_srcdir)/src/ \
	-I$(top_srcdir)/src/context-daemon \
	-I$(top_srcdir)/src/context-daemon/resource-cache \
	-I$(top_srcdir)/src/context-daemon/util \
	-I$(top_srcdir)/src/context-daemon/interest-tracking \
	-I$(top_srcdir)/src/context-daemon/indicator \
	-I$(top_srcdir)/src/context-daemon/presence \
	-DUNITY_WEBAPPS_TEST_BUILD \
	$(UNITY_WEBAPPS_COVERAGE_CFLAGS)

REAL_TESTS = \
	test-action-manager \
	test-indicator-model \
	test-indicator-model-controller \
	test-interest-manager \
	test-interest-tracker

RUNNER_TESTS = \
	test-application-info-runner

noinst_PROGRAMS = \
	$(REAL_TESTS) \
	test-application-info

test-application-info-runner: test-application-info
	@echo "#!/bin/sh" > $@
	@echo export G_DEBUG=fatal_criticals >> $@
	@echo xvfb-run $(DBUS_RUNNER) --task ./test-application-info >> $@
	@echo rm -Rf test-output-files >> $@
	@chmod +x $@

test_application_info_SOURCES = \
	test-application-info.c \
	$(top_srcdir)/src/context-daemon/util/unity-webapps-dirs.c \
	$(top_srcdir)/src/unity-webapps-app-db.c \
	$(top_srcdir)/src/unity-webapps-string-utils.c \
	$(top_srcdir)/src/unity-webapps-desktop-infos.c \
	$(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-db.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-application-info.c \
	$(top_srcdir)/src/context-daemon/util/unity-webapps-icon-theme.c \
	$(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-cache.c \
	$(top_srcdir)/src/context-daemon/resource-cache/unity-webapps-resource-factory.c \
	$(top_srcdir)/src/context-daemon/util/unity-webapps-gio-utils.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-debug.c

test_application_info_LDADD = \
	$(UNITY_WEBAPPS_LIBS) \
	$(UNITY_WEBAPPS_DAEMON_LIBS) \
	$(UNITY_WEBAPPS_COVERAGE_LDFLAGS) 


test_action_manager_SOURCES = \
	test-action-manager.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \
	unity-webapps-window-tracker-mock.c \
	unity-webapps-window-tracker-mock.h \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \
	$(top_srcdir)/src/unity-webapps-string-utils.c \
	$(top_srcdir)/src/unity-webapps-desktop-infos.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-action-manager.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-debug.c 

test_action_manager_LDADD = \
	$(UNITY_WEBAPPS_LIBS) \
	$(UNITY_WEBAPPS_DAEMON_LIBS) \
	$(UNITY_WEBAPPS_COVERAGE_LDFLAGS) 

test_indicator_model_SOURCES = \
	test-indicator-model.c \
	$(top_srcdir)/src/context-daemon/indicator/unity-webapps-indicator-model.c

test_indicator_model_LDADD = \
	$(UNITY_WEBAPPS_DAEMON_LIBS) \
	$(UNITY_WEBAPPS_COVERAGE_LDFLAGS)



test_indicator_model_controller_SOURCES = \
	test-indicator-model-controller.c \
	$(top_srcdir)/src/context-daemon/indicator/unity-webapps-indicator-model.c \
	$(top_srcdir)/src/context-daemon/indicator/unity-webapps-indicator-model-controller.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \
	unity-webapps-window-tracker-mock.c \
	$(top_srcdir)/src/unity-webapps-string-utils.c \
	$(top_srcdir)/src/unity-webapps-desktop-infos.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-debug.c 

test_indicator_model_controller_LDADD = \
	$(UNITY_WEBAPPS_DAEMON_LIBS) \
	$(UNITY_WEBAPPS_LIBS) \
	$(UNITY_WEBAPPS_COVERAGE_LDFLAGS)

test_interest_manager_SOURCES = \
	test-interest-manager.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \
	$(top_srcdir)/src/unity-webapps-string-utils.c \
	$(top_srcdir)/src/unity-webapps-desktop-infos.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-debug.c 


test_interest_manager_LDADD = \
	$(UNITY_WEBAPPS_LIBS) \
	$(UNITY_WEBAPPS_DAEMON_LIBS) \
	$(UNITY_WEBAPPS_COVERAGE_LDFLAGS) 


test_interest_tracker_SOURCES = \
	test-interest-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-interest-manager.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker.c \
	$(top_srcdir)/src/context-daemon/interest-tracking/unity-webapps-window-tracker-dbus-controllable.c \
	unity-webapps-window-tracker-mock.c \
	$(top_srcdir)/src/unity-webapps-string-utils.c \
	$(top_srcdir)/src/unity-webapps-desktop-infos.c \
	$(top_srcdir)/src/context-daemon/unity-webapps-debug.c 


test_interest_tracker_LDADD = \
	$(UNITY_WEBAPPS_LIBS) \
	$(UNITY_WEBAPPS_DAEMON_LIBS) \
	$(UNITY_WEBAPPS_COVERAGE_LDFLAGS) 

TESTS = $(REAL_TESTS) $(RUNNER_TESTS)

CLEANFILES = $(RUNNER_TESTS) $(REAL_TESTS)
