diff options
Diffstat (limited to 'test')
-rwxr-xr-x | test/CMakeLists.txt | 65 | ||||
-rw-r--r-- | test/system-haptic.c | 160 | ||||
-rw-r--r-- | test/system-haptic2.c | 107 | ||||
-rw-r--r-- | test/system-haptic3.c | 142 | ||||
-rw-r--r-- | test/test_lock.c | 136 | ||||
-rw-r--r-- | test/test_ui.c | 127 |
6 files changed, 737 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100755 index 0000000..d312607 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,65 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-system-haptic") +SET(fw_test "capi-system-haptic-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED glib-2.0 ecore-x elementary ecore evas) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -g") +INCLUDE_DIRECTORIES(../include) + +#ADD_EXECUTABLE("system-sensor" system-sensor.c) +#TARGET_LINK_LIBRARIES("system-sensor" ${fw_name} ${${fw_test}_LDFLAGS}) + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + IF(EXISTS "${src_name}.edc") + ADD_CUSTOM_TARGET( + "${src_name}.edj" + COMMAND edje_cc + ${CMAKE_CURRENT_SOURCE_DIR}/${src_name}.edc + ${CMAKE_CURRENT_SOURCE_DIR}/${src_name}.edj + ) + ADD_DEPENDENCIES(${src_name} ${src_name}.edj) + ENDIF(EXISTS "${src_name}.edc") + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${pkgs_LDFLAGS} ${fw_name}) +ENDFOREACH() + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *.edj -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) diff --git a/test/system-haptic.c b/test/system-haptic.c new file mode 100644 index 0000000..6d6aaf7 --- /dev/null +++ b/test/system-haptic.c @@ -0,0 +1,160 @@ +/* + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * PROPRIETARY/CONFIDENTIAL + * + * This software is the confidential and proprietary information of SAMSUNG + * ELECTRONICS ("Confidential Information"). You agree and acknowledge that + * this software is owned by Samsung and you shall not disclose such + * Confidential Information and shall use it only in accordance with the terms + * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG + * make no representations or warranties about the suitability of the software, + * either express or implied, including but not limited to the implied + * warranties of merchantability, fitness for a particular purpose, or + * non-infringement. SAMSUNG shall not be liable for any damages suffered by + * licensee arising out of or related to this software. + * + */ + +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <glib.h> +#include <haptic.h> + +static GMainLoop *mainloop; +static int ptn_id; + +static void sig_quit(int signo) +{ + if(mainloop) + { + g_main_loop_quit(mainloop); + } +} + +static gboolean play_ptn(gpointer data) +{ + haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + }; + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + + return false; +} + +static gboolean stop_play(gpointer data) +{ + int err; + int id = (int)data; + + printf("-- stop!! [%d]\n", id); + err = haptic_stop_pattern(id); + if(err < 0){ + printf("-- error!! when stop play!!\n"); + } + + return false; +} +static gboolean stop_and_play(gpointer data) +{ + int err; + int id = (int)data; + + printf("-- stop!! [%d]\n", id); + err = haptic_stop_pattern(id); + if(err < 0){ + printf("-- error!! when stop play!!\n"); + } + +// g_timeout_add(6000, play_ptn, NULL); + g_timeout_add(10000, play_ptn, NULL); + + return false; +} + +static gboolean stop_device(gpointer data) +{ + haptic_stop_device(0); + + return false; +} + +int main(int argc, char *argv[]) +{ + haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_1, 3000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_3, 2000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_2, 3000}, + }; + + if(haptic_initialize() == HAPTIC_ERROR_NONE){ + printf("haptic device opened\n"); + }else{ + printf("haptic_open fail\n"); + } + + signal(SIGINT, sig_quit); + signal(SIGTERM, sig_quit); + signal(SIGQUIT, sig_quit); + + mainloop = g_main_loop_new(NULL, FALSE); + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(4000, stop_play, (gpointer)ptn_id); + + if(haptic_play_pattern(ptn, 7, 2, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(2000, stop_play, (gpointer)ptn_id); + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(7000, stop_play, (gpointer)ptn_id); + + if(haptic_play_pattern(ptn, 7, 3, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(10, stop_and_play, (gpointer)ptn_id); + + + g_timeout_add(4000, stop_device, NULL); + + + g_main_loop_run(mainloop); + g_main_loop_unref(mainloop); + + if(haptic_deinitialize() == HAPTIC_ERROR_NONE){ + printf("haptic device closed\n"); + }else{ + printf("haptic_close fail\n"); + } + + return 0; +} diff --git a/test/system-haptic2.c b/test/system-haptic2.c new file mode 100644 index 0000000..dc189ce --- /dev/null +++ b/test/system-haptic2.c @@ -0,0 +1,107 @@ +/* + * + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * PROPRIETARY/CONFIDENTIAL + * + * This software is the confidential and proprietary information of SAMSUNG + * ELECTRONICS ("Confidential Information"). You agree and acknowledge that + * this software is owned by Samsung and you shall not disclose such + * Confidential Information and shall use it only in accordance with the terms + * of the license agreement you entered into with SAMSUNG ELECTRONICS. SAMSUNG + * make no representations or warranties about the suitability of the software, + * either express or implied, including but not limited to the implied + * warranties of merchantability, fitness for a particular purpose, or + * non-infringement. SAMSUNG shall not be liable for any damages suffered by + * licensee arising out of or related to this software. + * + */ + +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <glib.h> +#include <haptic.h> + +#define TEST_IVT "/usr/share/immersion/01_Touch/touch_20ms_sharp.ivt" + +static GMainLoop *mainloop; + +static void sig_quit(int signo) +{ + if(mainloop) + { + g_main_loop_quit(mainloop); + } +} + +static char* error_msg(int err){ + switch(err){ + case HAPTIC_ERROR_NONE : + return "HAPTIC_ERROR_NONE"; + case HAPTIC_ERROR_INVALID_PARAMETER : + return "HAPTIC_ERROR_INVALID_PARAMETER"; + case HAPTIC_ERROR_NO_SUCH_FILE : + return "HAPTIC_ERROR_NO_SUCH_FILE"; + case HAPTIC_ERROR_NOT_SUPPORTED_FORMAT : + return "HAPTIC_ERROR_NOT_SUPPORTED_FORMAT"; + case HAPTIC_ERROR_NOT_INITIALIZED : + return "HAPTIC_ERROR_NOT_INITIALIZED"; + case HAPTIC_ERROR_OPERATION_FAILED : + return "HAPTIC_ERROR_OPERATION_FAILED"; + } + return "------??"; +} + +int main(int argc, char *argv[]) +{ + int count, i, err; + if(haptic_initialize() == HAPTIC_ERROR_NONE){ + printf("haptic device opened\n"); + }else{ + printf("haptic_open fail\n"); + } + + signal(SIGINT, sig_quit); + signal(SIGTERM, sig_quit); + signal(SIGQUIT, sig_quit); + + mainloop = g_main_loop_new(NULL, FALSE); + + haptic_get_count(&count); + + printf("count = %d\n", count); + + for(i=0; i<=count;i++){ + printf("play with device(%d)\n", i); + + if((err = haptic_vibrate_monotone(count, 1000)) < 0){ + printf("haptic play fail [%s]\n", error_msg(err)); + }else{ + printf("haptic play success\n"); + } + + if(haptic_stop_device(count) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + + if(haptic_vibrate_file(count, TEST_IVT, 1, HAPTIC_LEVEL_AUTO) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + } + + + g_main_loop_run(mainloop); + g_main_loop_unref(mainloop); + + if(haptic_deinitialize() == HAPTIC_ERROR_NONE){ + printf("haptic device closed\n"); + }else{ + printf("haptic_close fail\n"); + } + + return 0; +} diff --git a/test/system-haptic3.c b/test/system-haptic3.c new file mode 100644 index 0000000..9f48d4b --- /dev/null +++ b/test/system-haptic3.c @@ -0,0 +1,142 @@ +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <glib.h> +#include <haptic.h> + +static GMainLoop *mainloop; +static int ptn_id; + +static void sig_quit(int signo) +{ + if(mainloop) + { + g_main_loop_quit(mainloop); + } +} + +static gboolean play_ptn(gpointer data) +{ + haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + }; + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + + return false; +} + +static gboolean stop_play(gpointer data) +{ + int err; + int id = (int)data; + + printf("-- stop!! [%d]\n", id); + err = haptic_stop_pattern(id); + if(err < 0){ + printf("-- error!! when stop play!!\n"); + } + + return false; +} +static gboolean stop_and_play(gpointer data) +{ + int err; + int id = (int)data; + + printf("-- stop!! [%d]\n", id); + err = haptic_stop_pattern(id); + if(err < 0){ + printf("-- error!! when stop play!!\n"); + } + +// g_timeout_add(6000, play_ptn, NULL); + g_timeout_add(10000, play_ptn, NULL); + + return false; +} + +static gboolean stop_device(gpointer data) +{ + haptic_stop_device(0); + + return false; +} + +int main(int argc, char *argv[]) +{ + haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_1, 3000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_3, 2000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_2, 3000}, + }; + + if(haptic_initialize() == HAPTIC_ERROR_NONE){ + printf("haptic device opened\n"); + }else{ + printf("haptic_open fail\n"); + } + + signal(SIGINT, sig_quit); + signal(SIGTERM, sig_quit); + signal(SIGQUIT, sig_quit); + + mainloop = g_main_loop_new(NULL, FALSE); + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(4000, stop_play, (gpointer)ptn_id); + + if(haptic_play_pattern(ptn, 7, 2, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(2000, stop_play, (gpointer)ptn_id); + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(7000, stop_play, (gpointer)ptn_id); + + if(haptic_play_pattern(ptn, 7, 3, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + g_timeout_add(10, stop_and_play, (gpointer)ptn_id); + + + g_timeout_add(4000, stop_device, NULL); + + + g_main_loop_run(mainloop); + g_main_loop_unref(mainloop); + + if(haptic_deinitialize() == HAPTIC_ERROR_NONE){ + printf("haptic device closed\n"); + }else{ + printf("haptic_close fail\n"); + } + + return 0; +} diff --git a/test/test_lock.c b/test/test_lock.c new file mode 100644 index 0000000..30663e7 --- /dev/null +++ b/test/test_lock.c @@ -0,0 +1,136 @@ +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <glib.h> +#include <haptic.h> + +static GMainLoop *mainloop; +static int ptn_id; + +static void sig_quit(int signo) +{ + if(mainloop) + { + g_main_loop_quit(mainloop); + } + + if(haptic_deinitialize() == HAPTIC_ERROR_NONE){ + printf("haptic device closed\n"); + }else{ + printf("haptic_close fail\n"); + } +} + +static gboolean play_ptn(gpointer data) +{ + haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + }; + + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + + return false; +} + +static gboolean stop_play(gpointer data) +{ + int err; + int id = (int)data; + + printf("-- stop!! [%d]\n", id); + err = haptic_stop_pattern(id); + if(err < 0){ + printf("-- error!! when stop play!!\n"); + } + + return false; +} +static gboolean stop_and_play(gpointer data) +{ + int err; + int id = (int)data; + + printf("-- stop!! [%d]\n", id); + err = haptic_stop_pattern(id); + if(err < 0){ + printf("-- error!! when stop play!!\n"); + } + +// g_timeout_add(6000, play_ptn, NULL); + g_timeout_add(10000, play_ptn, NULL); + + return false; +} + +static gboolean stop_device(gpointer data) +{ + haptic_stop_device(0); + + return false; +} + +int main(int argc, char *argv[]) +{ + haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_1, 3000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_3, 2000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_0, 10}, + {0, HAPTIC_LEVEL_2, 3000}, + }; + + signal(SIGINT, sig_quit); + signal(SIGTERM, sig_quit); + signal(SIGQUIT, sig_quit); + + mainloop = g_main_loop_new(NULL, FALSE); + + if(haptic_initialize() == HAPTIC_ERROR_NONE){ + printf("haptic device opened\n"); + }else{ + printf("haptic_open fail\n"); + } + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + if(haptic_deinitialize() == HAPTIC_ERROR_NONE){ + printf("haptic device closed\n"); + }else{ + printf("haptic_close fail\n"); + } + if(haptic_initialize() == HAPTIC_ERROR_NONE){ + printf("haptic device opened\n"); + }else{ + printf("haptic_open fail\n"); + } + if(haptic_play_pattern(ptn, 7, 1, 0, &ptn_id) < 0){ + printf("haptic play fail\n"); + }else{ + printf("haptic play success\n"); + } + if(haptic_deinitialize() == HAPTIC_ERROR_NONE){ + printf("haptic device closed\n"); + }else{ + printf("haptic_close fail\n"); + } + + + g_main_loop_run(mainloop); + g_main_loop_unref(mainloop); + + return 0; +} diff --git a/test/test_ui.c b/test/test_ui.c new file mode 100644 index 0000000..3043536 --- /dev/null +++ b/test/test_ui.c @@ -0,0 +1,127 @@ + +#include <stdio.h> +#include <stdbool.h> +#include <stdlib.h> +#include <haptic.h> + +#include <Elementary.h> +#include <Ecore_X.h> + +static haptic_vibration_iter_s ptn[] = { + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_1, 1000}, + {0, HAPTIC_LEVEL_5, 1000}, +}; + +int ptn_id; + +static void _quit_cb(void *data, Evas_Object* obj, void* event_info) +{ + Evas_Object *win = (Evas_Object *) data; + elm_win_lower(win); +} + +static void _vibe_clicked_cb(void *data, Evas_Object* obj, void* event_info) +{ + printf("initialize!\n"); + haptic_initialize(); + printf("after initialize!\n"); + + printf("play pattern!\n"); + haptic_play_pattern(ptn, 7, 1, 0, &ptn_id); + printf("after play pattern!\n"); +} + +static void _stop_clicked_cb(void *data, Evas_Object* obj, void* event_info) +{ + int err; + printf("stop pattern!\n"); + err = haptic_stop_pattern(ptn_id); + printf("after stop pattern! [%d]\n", err); + + printf("deinitialize!\n"); + haptic_deinitialize(); + printf("after deinitialize!\n"); +} + +static void winmain() +{ + const char* name = "Hapti_UI_TEST"; + int w,h; + + Evas_Object* win; + Evas_Object* bg; + Evas_Object* main_layout; + Evas_Object* btns_box; + Evas_Object* btn_vibe; + Evas_Object* btn_stop; + + Evas* evas; + + win = elm_win_add(NULL, name, ELM_WIN_BASIC); + if(!win) + return; + + elm_win_title_set(win, name); + elm_win_borderless_set(win, EINA_TRUE); + elm_win_autodel_set(win, EINA_TRUE); + evas_object_smart_callback_add(win, "delete,request", _quit_cb, NULL); + ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + evas_object_resize(win, w, h); + + evas_object_show(win); + + evas = evas_object_evas_get(win); + + // set background + bg = elm_bg_add(win); + elm_bg_color_set(bg, 0xff, 0xff, 0xff); + evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, bg); + evas_object_show(bg); + + // Base Layout + main_layout = elm_layout_add(win); + elm_layout_theme_set(main_layout, "layout", "application", "default"); + evas_object_size_hint_weight_set(main_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(win, main_layout); + evas_object_show(main_layout); + + // Indicator + elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW); + + + // add box + btns_box = elm_box_add(win); + elm_box_horizontal_set(btns_box, EINA_TRUE); + elm_win_resize_object_add(win, btns_box); + elm_box_padding_set(btns_box, 10, 0); + evas_object_show(btns_box); + + // add Button + btn_vibe = elm_button_add(main_layout); + btn_stop = elm_button_add(main_layout); + elm_object_text_set(btn_vibe, "Vibe"); + elm_object_text_set(btn_stop, "Stop"); + evas_object_smart_callback_add(btn_vibe, "clicked", _vibe_clicked_cb, NULL); + evas_object_smart_callback_add(btn_stop, "clicked", _stop_clicked_cb, NULL); + + elm_box_pack_end(btns_box, btn_vibe); + elm_box_pack_end(btns_box, btn_stop); + evas_object_show(btn_vibe); + evas_object_show(btn_stop); +} + +EAPI_MAIN int elm_main(int argc, char** argv) +{ + winmain(); + + elm_run(); + elm_shutdown(); + return 0; +} +ELM_MAIN() |