tests: Reshuffle IVI layout tests

Rename the IVI tests to be more consistent with the others, and invert
the naming of plugin/client to make it slightly more clear what's going
to happen. Handle the renaming by using wet_get_binary_path to rewrite
the local binaries.

As a side-effect, weston.ini ivi-shell-user-interface no longer needs to
be given as an absolute path.

Signed-off-by: Daniel Stone <daniels@collabora.com>

v2:

Call ivi-layout.ivi as ivi-layout-test-client.ivi to keep the same name
in both the file and the lookup, so that the module map does not need to
change the name.

Update code comments to reflect the new names.

Rename ivi_layout-test-plugin.c to ivi-layout-test-plugin.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Emre Ucan <eucan@de.adit-jv.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
diff --git a/Makefile.am b/Makefile.am
index d2025bc..3bce47a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1477,13 +1477,13 @@
 ivi_layout_internal_test_la_LDFLAGS = $(test_module_ldflags)
 ivi_layout_internal_test_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
 ivi_layout_internal_test_la_SOURCES =			\
-	tests/ivi_layout-internal-test.c
+	tests/ivi-layout-internal-test.c
 
 ivi_layout_test_la_LIBADD = $(test_module_libadd)
 ivi_layout_test_la_LDFLAGS = $(test_module_ldflags)
 ivi_layout_test_la_CFLAGS = $(AM_CFLAGS) $(COMPOSITOR_CFLAGS)
 ivi_layout_test_la_SOURCES =			\
-	tests/ivi_layout-test-plugin.c		\
+	tests/ivi-layout-test-plugin.c		\
 	tests/ivi-test.h			\
 	shared/helpers.h
 nodist_ivi_layout_test_la_SOURCES =		\
@@ -1500,17 +1500,17 @@
 ivi_shell_app_weston_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
 ivi_shell_app_weston_LDADD = libtest-client.la
 
-noinst_PROGRAMS += ivi-layout.ivi
+noinst_PROGRAMS += ivi-layout-test-client.ivi
 
-ivi_layout_ivi_SOURCES =			\
-	tests/ivi_layout-test.c 		\
+ivi_layout_test_client_ivi_SOURCES =			\
+	tests/ivi-layout-test-client.c 		\
 	tests/ivi-test.h			\
 	shared/helpers.h
-nodist_ivi_layout_ivi_SOURCES = 		\
+nodist_ivi_layout_test_client_ivi_SOURCES = 		\
 	protocol/ivi-application-protocol.c	\
 	protocol/ivi-application-client-protocol.h
-ivi_layout_ivi_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
-ivi_layout_ivi_LDADD = libtest-client.la
+ivi_layout_test_client_ivi_CFLAGS = $(AM_CFLAGS) $(TEST_CLIENT_CFLAGS)
+ivi_layout_test_client_ivi_LDADD = libtest-client.la
 endif
 
 if BUILD_SETBACKLIGHT
diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c
index 0e44df8..a0e49ba 100644
--- a/ivi-shell/hmi-controller.c
+++ b/ivi-shell/hmi-controller.c
@@ -676,6 +676,7 @@
 	struct hmi_server_setting *setting = MEM_ALLOC(sizeof(*setting));
 	struct weston_config *config = wet_get_config(ec);
 	struct weston_config_section *shell_section = NULL;
+	char *ivi_ui_config;
 
 	shell_section = weston_config_get_section(config, "ivi-shell",
 						  NULL, NULL);
@@ -704,7 +705,16 @@
 
 	weston_config_section_get_string(shell_section,
 					 "ivi-shell-user-interface",
-					 &setting->ivi_homescreen, NULL);
+					 &ivi_ui_config, NULL);
+	if (ivi_ui_config && ivi_ui_config[0] != '/') {
+		setting->ivi_homescreen = wet_get_binary_path(ivi_ui_config);
+		if (setting->ivi_homescreen)
+			free(ivi_ui_config);
+		else
+			setting->ivi_homescreen = ivi_ui_config;
+	} else {
+		setting->ivi_homescreen = ivi_ui_config;
+	}
 
 	return setting;
 }
diff --git a/ivi-shell/weston.ini.in b/ivi-shell/weston.ini.in
index 3f11e1c..a06d76e 100644
--- a/ivi-shell/weston.ini.in
+++ b/ivi-shell/weston.ini.in
@@ -1,9 +1,9 @@
 [core]
-shell=@plugin_prefix@ivi-shell.so
-modules=@plugin_prefix@hmi-controller.so
+shell=ivi-shell.so
+modules=hmi-controller.so
 
 [ivi-shell]
-ivi-shell-user-interface=@abs_top_builddir@/weston-ivi-shell-user-interface
+ivi-shell-user-interface=weston-ivi-shell-user-interface
 
 #developermode=true
 
@@ -38,7 +38,7 @@
 workspace-background-id=2001
 
 [input-method]
-path=@libexecdir@/weston-keyboard
+path=weston-keyboard
 
 [ivi-launcher]
 workspace-id=0
diff --git a/tests/ivi_layout-internal-test.c b/tests/ivi-layout-internal-test.c
similarity index 100%
rename from tests/ivi_layout-internal-test.c
rename to tests/ivi-layout-internal-test.c
diff --git a/tests/ivi_layout-test.c b/tests/ivi-layout-test-client.c
similarity index 97%
rename from tests/ivi_layout-test.c
rename to tests/ivi-layout-test-client.c
index d2f4c93..1922453 100644
--- a/tests/ivi_layout-test.c
+++ b/tests/ivi-layout-test-client.c
@@ -175,18 +175,18 @@
 /******************************** tests ********************************/
 
 /*
- * This is a test program, launched by ivi_layout-test-plugin.c. Each TEST()
+ * This is a test program, launched by ivi-layout-test-plugin.c. Each TEST()
  * is forked and exec'd as usual with the weston-test-runner framework.
  *
  * These tests make use of weston_test_runner global interface exposed by
- * ivi_layout-test-plugin.c. This allows these tests to trigger compositor-side
+ * ivi-layout-test-plugin.c. This allows these tests to trigger compositor-side
  * checks.
  *
- * See ivi_layout-test-plugin.c for further details.
+ * See ivi-layout-test-plugin.c for further details.
  */
 
 /**
- * RUNNER_TEST() names are defined in ivi_layout-test-plugin.c.
+ * RUNNER_TEST() names are defined in ivi-layout-test-plugin.c.
  * Each RUNNER_TEST name listed here uses the same simple initial client setup.
  */
 const char * const basic_test_names[] = {
diff --git a/tests/ivi_layout-test-plugin.c b/tests/ivi-layout-test-plugin.c
similarity index 98%
rename from tests/ivi_layout-test-plugin.c
rename to tests/ivi-layout-test-plugin.c
index 0fe9212..aa88a71 100644
--- a/tests/ivi_layout-test-plugin.c
+++ b/tests/ivi-layout-test-plugin.c
@@ -237,7 +237,8 @@
 	if (!launcher)
 		return -1;
 
-	if (weston_module_path_from_env("ivi-layout.ivi", launcher->exe,
+	if (weston_module_path_from_env("ivi-layout-test-client.ivi",
+					launcher->exe,
 					sizeof launcher->exe) == 0) {
 		weston_log("test setup failure: WESTON_MODULE_MAP not set\n");
 		return -1;
@@ -300,11 +301,12 @@
  * this module specially by loading it in ivi-shell.
  *
  * Once Weston init completes, this module launches one test program:
- * ivi-layout.ivi (ivi_layout-test.c). That program uses the weston-test-runner
- * framework to fork and exec each TEST() in ivi_layout-test.c with a fresh
+ * ivi-layout-test-client.ivi (ivi-layout-test-client.c).
+ * That program uses the weston-test-runner
+ * framework to fork and exec each TEST() in ivi-layout-test-client.c with a fresh
  * connection to the single compositor instance.
  *
- * Each TEST() in ivi_layout-test.c will bind to weston_test_runner global
+ * Each TEST() in ivi-layout-test-client.c will bind to weston_test_runner global
  * interface. A TEST() will set up the client state, and issue
  * weston_test_runner.run request to execute the compositor-side of the test.
  *
@@ -317,7 +319,7 @@
  * runner_assert_or_return(). This module catches the test program exit
  * code and passes it out of Weston to the test harness.
  *
- * A single TEST() in ivi_layout-test.c may use multiple RUNNER_TEST()s to
+ * A single TEST() in ivi-layout-test-client.c may use multiple RUNNER_TEST()s to
  * achieve multiple test points over a client action sequence.
  */
 
diff --git a/tests/weston-tests-env b/tests/weston-tests-env
index 63aad4a..4a352ff 100755
--- a/tests/weston-tests-env
+++ b/tests/weston-tests-env
@@ -34,7 +34,7 @@
 done
 
 for exe in weston-desktop-shell weston-keyboard weston-screenshooter \
-	   weston-simple-im ivi-layout.ivi; do \
+	   weston-simple-im ivi-layout-test-client.ivi; do \
 	WESTON_MODULE_MAP="${WESTON_MODULE_MAP}${exe}=${abs_builddir}/${exe};"
 done