summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunkyeong Kim <jk0430.kim@samsung.com>2019-04-24 17:52:48 +0900
committerJunkyeong Kim <jk0430.kim@samsung.com>2019-04-24 18:46:01 +0900
commit1b17a2163e24d0ecf350e8ad453f1f72e9299f7b (patch)
tree716525a1d9c06b989a001eacdec24bfd0b5dd091
parent307f2ac3368b0e6e42768d41df18c4ac62824fdb (diff)
downloadws-testcase-1b17a2163e24d0ecf350e8ad453f1f72e9299f7b.tar.gz
ws-testcase-1b17a2163e24d0ecf350e8ad453f1f72e9299f7b.tar.bz2
ws-testcase-1b17a2163e24d0ecf350e8ad453f1f72e9299f7b.zip
wl-novice: add wl-dpms test
Change-Id: I22310fa801137e8da01de458ad42ae9447e06507 Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
-rw-r--r--packaging/ws-testcase.spec8
-rwxr-xr-xwl-novice/packaging/wl-novice.spec4
-rw-r--r--wl-novice/src/wl-dpms/CMakeLists.txt30
-rw-r--r--wl-novice/src/wl-dpms/wl-dpms-description.txt24
-rw-r--r--wl-novice/src/wl-dpms/wl-dpms.c197
5 files changed, 260 insertions, 3 deletions
diff --git a/packaging/ws-testcase.spec b/packaging/ws-testcase.spec
index 73220ac..ca264e6 100644
--- a/packaging/ws-testcase.spec
+++ b/packaging/ws-testcase.spec
@@ -57,6 +57,8 @@ BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(tizen-extension-server)
BuildRequires: pkgconfig(wayland-tbm-client)
+BuildRequires: pkgconfig(tizen-dpms-client)
+BuildRequires: pkgconfig(ecore-wl2)
%endif
%if 0%{?with_input}
BuildRequires: pkgconfig(efl)
@@ -128,7 +130,7 @@ Summary: Novice test framework for TPL
Requires: ws-testcase
Requires: libwayland-egl
Requires: libtpl-egl
-Requires: libwayland-client)
+Requires: libwayland-client
Requires: pixman
%description tpl-novice
%endif
@@ -142,6 +144,8 @@ Requires: libdrm
Requires: libcairo
Requires: libwayland-extension-server
Requires: libwayland-tbm-client
+Requires: libtizen-dpms-client
+Requires: ecore-wl2
%description wl-novice
%endif
@@ -156,7 +160,7 @@ Requires: elementary
Requires: libxkbcommon
Requires: capi-ui-efl-util
Requires: libwayland-client
-Requires: libwayland-extension-client)
+Requires: libwayland-extension-client
Requires: libwayland-egl
%description input-novice
%endif
diff --git a/wl-novice/packaging/wl-novice.spec b/wl-novice/packaging/wl-novice.spec
index 88b0402..7472d47 100755
--- a/wl-novice/packaging/wl-novice.spec
+++ b/wl-novice/packaging/wl-novice.spec
@@ -12,8 +12,10 @@ BuildRequires: pkgconfig(libdrm)
BuildRequires: pkgconfig(libtbm)
BuildRequires: pkgconfig(cairo)
BuildRequires: pkgconfig(tizen-extension-server)
+BuildRequires: pkgconfig(tizen-extension-client)
BuildRequires: pkgconfig(wayland-tbm-client)
-
+BuildRequires: pkgconfig(tizen-dpms-client)
+BuildRequires: pkgconfig(ecore-wl2)
%description
Window system test framework
diff --git a/wl-novice/src/wl-dpms/CMakeLists.txt b/wl-novice/src/wl-dpms/CMakeLists.txt
new file mode 100644
index 0000000..4dbdcf2
--- /dev/null
+++ b/wl-novice/src/wl-dpms/CMakeLists.txt
@@ -0,0 +1,30 @@
+CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
+INCLUDE(FindPkgConfig)
+
+SET(TEST_NAME "wl-dpms")
+
+SET(SRCS
+ ${TEST_NAME}.c
+#please write your test sources
+)
+
+pkg_check_modules(pkgs REQUIRED
+ #please write require pacakge
+ glib-2.0
+ wayland-client
+ tizen-extension-client
+ ecore-wl2
+ tizen-dpms-client
+)
+
+ADD_DEFINITIONS(${pkgs_CFLAGS} -g -fPIE -Wall -Werror -Wl,--as-needed -Wl,--rpath=/usr/lib -pie -DEFL_BETA_API_SUPPORT )
+
+ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.c ${SRCS})
+TARGET_LINK_LIBRARIES(${TEST_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(PROGRAMS ${TEST_NAME}
+ DESTINATION /usr/local/bin/novice/${TEST_NAME}
+)
+INSTALL(FILES ${TEST_NAME}-description.txt
+ DESTINATION /usr/local/bin/novice/${TEST_NAME}
+)
diff --git a/wl-novice/src/wl-dpms/wl-dpms-description.txt b/wl-novice/src/wl-dpms/wl-dpms-description.txt
new file mode 100644
index 0000000..db94ae9
--- /dev/null
+++ b/wl-novice/src/wl-dpms/wl-dpms-description.txt
@@ -0,0 +1,24 @@
+Title
+#Please write your test program Title
+#==========================================================================
+Default title
+
+Date
+#Please write Date
+#==========================================================================
+2014-00-00
+
+Author
+#Please write Author
+#==========================================================================
+Unknown
+
+Module
+#Please write your test program Module
+#==========================================================================
+Default
+
+Description
+#Please write your test program detail description
+#==========================================================================
+Default Description
diff --git a/wl-novice/src/wl-dpms/wl-dpms.c b/wl-novice/src/wl-dpms/wl-dpms.c
new file mode 100644
index 0000000..b60fa25
--- /dev/null
+++ b/wl-novice/src/wl-dpms/wl-dpms.c
@@ -0,0 +1,197 @@
+/*
+Copyright (C) 2015 - 2016 Samsung Electronics co., Ltd. All Rights Reserved.
+
+Contact:
+ SooChan Lim <sc1.lim@samsung.com>
+ Changyeon Lee <cyeon.lee@samsung.com>
+ JunKyeong Kim <jk0430.kim@samsung.com>
+ Boram Park <boram1288.park@samsung.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice (including the next
+paragraph) shall be included in all copies or substantial portions of the
+Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.
+*/
+
+#include <stdint.h>
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/param.h>
+#include <sys/mman.h>
+#include <stdlib.h>
+#include <sys/syscall.h>
+#include <poll.h>
+
+#include <glib.h>
+#include <glib-unix.h>
+#include <glib-object.h>
+
+#include <Ecore_Wl2.h>
+#include <wayland-client.h>
+#include <tizen-extension-client-protocol.h>
+#include <tizen-dpms-client-protocol.h>
+
+static char *app_name;
+
+static Ecore_Wl2_Display *wl2_display;
+static struct wl_display *display;
+static struct wl_registry *registry;
+static struct wl_output *wl_out;
+static struct tizen_dpms_manager *tz_dpms_mng = NULL;
+
+void
+usage(void)
+{
+ printf("usage: %s \n", app_name);
+ printf("%s output_num option(set1/get0) state\nex)\n", app_name);
+ printf("%s 1 0 => set dpms_on\n", app_name);
+ printf("%s 1 3 => set dpms_off\n", app_name);
+ printf("%s 0 0 => get state\n", app_name);
+
+ exit(0);
+}
+
+void
+_exit(int fail)
+{
+ if (tz_dpms_mng) {
+ tizen_dpms_manager_destroy(tz_dpms_mng);
+ tz_dpms_mng = NULL;
+ }
+
+ if (wl2_display) {
+ ecore_wl2_display_disconnect(wl2_display);
+ wl2_display = NULL;
+ }
+
+ ecore_wl2_shutdown();
+
+ if (fail)
+ exit(0);
+
+ exit(1);
+}
+
+static void
+dpms_handle_state(void *data, struct tizen_dpms_manager *tz_dpms, uint32_t mode, uint32_t error)
+{
+ printf("dpms_state_cb - mode:%d, error:%d\n", mode, error);
+}
+
+static const struct tizen_dpms_manager_listener dpms_listener = {
+ dpms_handle_state
+};
+
+static void
+handle_global(void *data, struct wl_registry *registry,
+ uint32_t name, const char *interface, uint32_t version)
+{
+ if (strcmp(interface, "wl_output") == 0) {
+ wl_out = wl_registry_bind(registry, name, &wl_output_interface, 2);
+ if (!wl_out) {
+ printf("handle wl_output bind fail\n");
+ _exit(1);
+ }
+ printf("get wl_output\n");
+ } else if (strcmp(interface, "tizen_dpms_manager") == 0) {
+ tz_dpms_mng = wl_registry_bind(registry, name, &tizen_dpms_manager_interface, 1);
+ if (!tz_dpms_mng) {
+ printf("handle tizen_dpms_manager bind fail\n");
+ _exit(1);
+ }
+ tizen_dpms_manager_add_listener(tz_dpms_mng, &dpms_listener, NULL);
+
+ printf("get dpms manager\n");
+ }
+}
+
+static void
+handle_global_remove(void *data, struct wl_registry *registry, uint32_t name)
+{
+}
+
+static const struct wl_registry_listener registry_listener = {
+ handle_global,
+ handle_global_remove
+};
+
+int main(int argc, char *argv[])
+{
+ char *opt;
+ int option;
+ char *sta;
+ int state = 0;
+
+ app_name = strdup (argv[0]);
+
+ if (argc != 3)
+ usage();
+
+ opt = strdup(argv[1]);
+ option = opt [0] - '0';
+ if (!(option == 0 || option == 1))
+ usage();
+
+ if (option == 1) {
+ sta = strdup(argv[2]);
+ state = sta [0] - '0';
+ if (!(state == 0 || state == 1 || state == 2 || state == 3))
+ usage();
+ }
+
+ if (ecore_wl2_init() <= 0) goto fail;
+
+ wl2_display = ecore_wl2_display_connect(NULL);
+ if (wl2_display == NULL) goto fail;
+
+ display = ecore_wl2_display_get(wl2_display);
+ if (display == NULL) goto fail;
+
+ registry = wl_display_get_registry(display);
+ if (registry == NULL) goto fail;
+
+ wl_registry_add_listener(registry, &registry_listener, NULL);
+ wl_display_roundtrip(display);
+
+ if (!wl_out || !tz_dpms_mng) {
+ printf("roundtrip fail\n");
+ _exit(1);
+ }
+
+ if (option == 1) {
+ tizen_dpms_manager_set_dpms(tz_dpms_mng, wl_out, state);
+ printf("set dpms %d\n", state);
+ } else {
+ tizen_dpms_manager_get_dpms(tz_dpms_mng, wl_out);
+ printf("get dpms\n");
+ }
+ wl_display_roundtrip(display);
+
+ printf("done\n");
+ return 1;
+
+fail:
+ printf("failed\n");
+
+ _exit(1);
+ return 0;
+}
+