Pekka Paalanen | 0eb0941 | 2015-03-23 13:55:06 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2015 Collabora, Ltd. |
| 3 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 4 | * Permission is hereby granted, free of charge, to any person obtaining |
| 5 | * a copy of this software and associated documentation files (the |
| 6 | * "Software"), to deal in the Software without restriction, including |
| 7 | * without limitation the rights to use, copy, modify, merge, publish, |
| 8 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 9 | * permit persons to whom the Software is furnished to do so, subject to |
| 10 | * the following conditions: |
Pekka Paalanen | 0eb0941 | 2015-03-23 13:55:06 +0200 | [diff] [blame] | 11 | * |
Bryce Harrington | 2cc9297 | 2015-06-11 15:39:40 -0700 | [diff] [blame] | 12 | * The above copyright notice and this permission notice (including the |
| 13 | * next paragraph) shall be included in all copies or substantial |
| 14 | * portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 20 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 21 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 22 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
Pekka Paalanen | 0eb0941 | 2015-03-23 13:55:06 +0200 | [diff] [blame] | 24 | */ |
| 25 | |
| 26 | #include "config.h" |
| 27 | |
| 28 | #include <stdio.h> |
| 29 | #include <string.h> |
| 30 | |
| 31 | #include "weston-test-client-helper.h" |
| 32 | #include "ivi-application-client-protocol.h" |
Pekka Paalanen | 431ec06 | 2019-11-11 17:17:57 +0200 | [diff] [blame] | 33 | #include "weston-test-fixture-compositor.h" |
| 34 | #include "test-config.h" |
| 35 | |
| 36 | static enum test_result_code |
| 37 | fixture_setup(struct weston_test_harness *harness) |
| 38 | { |
| 39 | struct compositor_setup setup; |
| 40 | |
| 41 | compositor_setup_defaults(&setup); |
| 42 | setup.shell = SHELL_IVI; |
Pekka Paalanen | 080d85b | 2020-01-24 13:14:27 +0200 | [diff] [blame] | 43 | setup.logging_scopes = "log,test-harness-plugin,proto"; |
Pekka Paalanen | 431ec06 | 2019-11-11 17:17:57 +0200 | [diff] [blame] | 44 | |
Igor Matheus Andrade Torrente | d8e09af | 2020-09-07 11:19:01 -0300 | [diff] [blame] | 45 | weston_ini_setup(&setup, |
| 46 | cfgln("[core]"), |
| 47 | cfgln("shell=%s", "ivi-shell.so"), |
| 48 | cfgln("modules=", "hmi-controller.so"), |
| 49 | |
| 50 | cfgln("[ivi-shell]"), |
| 51 | cfgln("ivi-shell-user-interface=%s", "weston-ivi-shell-user-interface"), |
| 52 | cfgln("cursor-theme=%s", "default"), |
| 53 | cfgln("cursor-size=%d", 32), |
| 54 | cfgln("base-layer-id=%d", 1000), |
| 55 | cfgln("base-layer-id-offset=%d", 10000), |
| 56 | cfgln("workspace-background-layer-id=%d", 2000), |
| 57 | cfgln("workspace-layer-id=%d", 3000), |
| 58 | cfgln("application-layer-id=%d", 4000), |
| 59 | cfgln("transition-duration=%d", 300), |
| 60 | cfgln("background-image=%s", WESTON_DATA_DIR "/background.png"), |
| 61 | cfgln("background-id=%d", 1001), |
| 62 | cfgln("panel-image=%s", WESTON_DATA_DIR "/panel.png"), |
| 63 | cfgln("panel-id=%d", 1002), |
| 64 | cfgln("surface-id-offset=%d", 10), |
| 65 | cfgln("tiling-image=%s", WESTON_DATA_DIR "/tiling.png"), |
| 66 | cfgln("tiling-id=%d", 1003), |
| 67 | cfgln("sidebyside-image=%s", WESTON_DATA_DIR "/sidebyside.png"), |
| 68 | cfgln("sidebyside-id=%d", 1004), |
| 69 | cfgln("fullscreen-image=%s", WESTON_DATA_DIR "/fullscreen.png"), |
| 70 | cfgln("fullscreen-id=%d", 1005), |
| 71 | cfgln("random-image=%s", WESTON_DATA_DIR "/random.png"), |
| 72 | cfgln("random-id=%d", 1006), |
| 73 | cfgln("home-image=%s", WESTON_DATA_DIR "/home.png"), |
| 74 | cfgln("home-id=%d", 1007), |
| 75 | cfgln("workspace-background-color=%s", "0x99000000"), |
| 76 | cfgln("workspace-background-id=%d", 2001), |
| 77 | |
| 78 | cfgln("[ivi-launcher]"), |
| 79 | cfgln("workspace-id=%d", 0), |
| 80 | cfgln("icon-id=%d", 4001), |
| 81 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_flower.png"), |
| 82 | cfgln("path=%s", BINDIR "/weston-flower"), |
| 83 | |
| 84 | cfgln("[ivi-launcher]"), |
| 85 | cfgln("workspace-id=%d", 0), |
| 86 | cfgln("icon-id=%d", 4002), |
| 87 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_clickdot.png"), |
| 88 | cfgln("path=%s", BINDIR "/weston-clickdot"), |
| 89 | |
| 90 | cfgln("[ivi-launcher]"), |
| 91 | cfgln("workspace-id=%d", 1), |
| 92 | cfgln("icon-id=%d", 4003), |
| 93 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_simple-egl.png"), |
| 94 | cfgln("path=%s", BINDIR "/weston-simple-egl"), |
| 95 | |
| 96 | cfgln("[ivi-launcher]"), |
| 97 | cfgln("workspace-id=%d", 1), |
| 98 | cfgln("icon-id=%d", 4004), |
| 99 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_simple-shm.png"), |
| 100 | cfgln("path=%s", BINDIR "/weston-simple-shm"), |
| 101 | |
| 102 | cfgln("[ivi-launcher]"), |
| 103 | cfgln("workspace-id=%d", 2), |
| 104 | cfgln("icon-id=%d", 4005), |
| 105 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_smoke.png"), |
| 106 | cfgln("path=%s", BINDIR "/weston-smoke"), |
| 107 | |
| 108 | cfgln("[ivi-launcher]"), |
| 109 | cfgln("workspace-id=%d", 3), |
| 110 | cfgln("icon-id=%d", 4006), |
| 111 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_flower.png"), |
| 112 | cfgln("path=%s", BINDIR "/weston-flower"), |
| 113 | |
| 114 | cfgln("[ivi-launcher]"), |
| 115 | cfgln("workspace-id=%d", 3), |
| 116 | cfgln("icon-id=%d", 4007), |
| 117 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_clickdot.png"), |
| 118 | cfgln("path=%s", BINDIR "/weston-clickdot"), |
| 119 | |
| 120 | cfgln("[ivi-launcher]"), |
| 121 | cfgln("workspace-id=%d", 3), |
| 122 | cfgln("icon-id=%d", 4008), |
| 123 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_simple-egl.png"), |
| 124 | cfgln("path=%s", BINDIR "/weston-simple-egl"), |
| 125 | |
| 126 | cfgln("[ivi-launcher]"), |
| 127 | cfgln("workspace-id=%d", 3), |
| 128 | cfgln("icon-id=%d", 4009), |
| 129 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_simple-shm.png"), |
| 130 | cfgln("path=%s", BINDIR "/weston-simple-shm"), |
| 131 | |
| 132 | cfgln("[ivi-launcher]"), |
| 133 | cfgln("workspace-id=%d", 3), |
| 134 | cfgln("icon-id=%d", 4010), |
| 135 | cfgln("icon=%s", WESTON_DATA_DIR "/icon_ivi_smoke.png"), |
| 136 | cfgln("path=%s", BINDIR "/weston-smoke") |
| 137 | ); |
| 138 | |
Pekka Paalanen | 431ec06 | 2019-11-11 17:17:57 +0200 | [diff] [blame] | 139 | return weston_test_harness_execute_as_client(harness, &setup); |
| 140 | } |
| 141 | DECLARE_FIXTURE_SETUP(fixture_setup); |
Pekka Paalanen | 0eb0941 | 2015-03-23 13:55:06 +0200 | [diff] [blame] | 142 | |
| 143 | static struct ivi_application * |
| 144 | get_ivi_application(struct client *client) |
| 145 | { |
| 146 | struct global *g; |
| 147 | struct global *global_iviapp = NULL; |
Pekka Paalanen | 9551dd7 | 2019-11-05 16:47:10 +0200 | [diff] [blame] | 148 | struct ivi_application *iviapp; |
Pekka Paalanen | 0eb0941 | 2015-03-23 13:55:06 +0200 | [diff] [blame] | 149 | |
| 150 | wl_list_for_each(g, &client->global_list, link) { |
| 151 | if (strcmp(g->interface, "ivi_application")) |
| 152 | continue; |
| 153 | |
| 154 | if (global_iviapp) |
| 155 | assert(0 && "multiple ivi_application objects"); |
| 156 | |
| 157 | global_iviapp = g; |
| 158 | } |
| 159 | |
| 160 | assert(global_iviapp && "no ivi_application found"); |
| 161 | |
| 162 | assert(global_iviapp->version == 1); |
| 163 | |
| 164 | iviapp = wl_registry_bind(client->wl_registry, global_iviapp->name, |
| 165 | &ivi_application_interface, 1); |
| 166 | assert(iviapp); |
| 167 | |
| 168 | return iviapp; |
| 169 | } |
| 170 | |
| 171 | TEST(ivi_application_exists) |
| 172 | { |
| 173 | struct client *client; |
| 174 | struct ivi_application *iviapp; |
| 175 | |
| 176 | client = create_client(); |
| 177 | iviapp = get_ivi_application(client); |
| 178 | client_roundtrip(client); |
| 179 | |
Pekka Paalanen | 12a138d | 2019-11-06 15:59:33 +0200 | [diff] [blame] | 180 | testlog("Successful bind: %p\n", iviapp); |
Pekka Paalanen | 080d85b | 2020-01-24 13:14:27 +0200 | [diff] [blame] | 181 | |
Pekka Paalanen | b64d411 | 2021-06-15 16:20:08 +0300 | [diff] [blame] | 182 | ivi_application_destroy(iviapp); |
Pekka Paalanen | 080d85b | 2020-01-24 13:14:27 +0200 | [diff] [blame] | 183 | client_destroy(client); |
Pekka Paalanen | 0eb0941 | 2015-03-23 13:55:06 +0200 | [diff] [blame] | 184 | } |