summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunmi Ha <yunmi.ha@samsung.com>2021-01-04 15:57:25 +0900
committerYunmi Ha <yunmi.ha@samsung.com>2021-01-04 19:21:42 +0900
commite38108a0cc7ab40d02a218e070a96440eeb36918 (patch)
treeb0d17f3ac99a0f735304de2b59d86b94821f5e7a
parent1611e1cf7c5d8610273f5383512dacd3bddab764 (diff)
downloadlibsvi-e38108a0cc7ab40d02a218e070a96440eeb36918.tar.gz
libsvi-e38108a0cc7ab40d02a218e070a96440eeb36918.tar.bz2
libsvi-e38108a0cc7ab40d02a218e070a96440eeb36918.zip
Add API test tool
Change-Id: Ief52bbe3fc9e21ba63b0474967180406463cd67f Signed-off-by: Yunmi Ha <yunmi.ha@samsung.com>
-rw-r--r--CMakeLists.txt2
-rw-r--r--packaging/libfeedback.spec14
-rw-r--r--tests/CMakeLists.txt30
-rw-r--r--tests/main.c100
-rw-r--r--tests/test-feedback-internal.c349
-rw-r--r--tests/test-feedback-internal.h139
-rw-r--r--tests/test-feedback.c223
-rw-r--r--tests/test-feedback.h46
-rw-r--r--tests/test.h139
9 files changed, 1042 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c284c7c..4189a67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,3 +66,5 @@ INSTALL(FILES ${HEADERS} DESTINATION include/${PROJECT_NAME})
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${COMMON_PROFILE}/data/ DESTINATION share/${COMMON_PROFILE})
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${MOBILE_PROFILE}/data/ DESTINATION share/${MOBILE_PROFILE})
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${WEARABLE_PROFILE}/data/ DESTINATION share/${WEARABLE_PROFILE})
+
+ADD_SUBDIRECTORY(tests)
diff --git a/packaging/libfeedback.spec b/packaging/libfeedback.spec
index d1132f0..41f2e01 100644
--- a/packaging/libfeedback.spec
+++ b/packaging/libfeedback.spec
@@ -21,6 +21,7 @@ BuildRequires: pkgconfig(capi-media-wav-player)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(capi-system-info)
BuildRequires: pkgconfig(libsyscommon)
+
%if 0%{?gcov:1}
BuildRequires: lcov
%endif
@@ -77,6 +78,14 @@ Conflicts: svi-data-profile_mobile
%description -n svi-data-profile_wearable
default set for svi resource package (not for mobile or wearable).
+%package test
+Summary: Libfeedback test tool
+Group: System/Utilities
+Requires: libfeedback = %{version}-%{release}
+%description test
+Test-tool for libfeedback API.
+This package can be installed optional for API test.
+
%if 0%{?gcov:1}
%package gcov
Summary: Feedback library for (gcov)
@@ -168,6 +177,11 @@ ln -sf %{_datadir}/feedback.wearable %{_datadir}/feedback
%license LICENSE
%manifest svi-data.manifest
+%files test
+%manifest libfeedback.manifest
+%license LICENSE
+%{_bindir}/feedback-test
+
%if 0%{?gcov:1}
%files gcov
%{_datadir}/gcov/*
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..b8aeea2
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,30 @@
+SET(feedback_test "${PROJECT_NAME}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${feedback_test} REQUIRED
+ glib-2.0
+ dlog)
+
+FOREACH(flag ${${feedback_test}_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_CURRENT_SOURCE_DIR})
+
+SET(SRCS
+ main.c
+ test-feedback.c
+ test-feedback-internal.c
+)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -g -fno-omit-frame-pointer -Wall -fPIE")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie")
+
+ADD_DEFINITIONS("-DENABLE_TEST_DLOG")
+
+ADD_EXECUTABLE(${feedback_test} ${SRCS})
+TARGET_LINK_LIBRARIES(${feedback_test} ${PROJECT_NAME} ${${feedback_test}_LDFLAGS})
+
+INSTALL(TARGETS ${feedback_test} DESTINATION bin)
diff --git a/tests/main.c b/tests/main.c
new file mode 100644
index 0000000..b3313be
--- /dev/null
+++ b/tests/main.c
@@ -0,0 +1,100 @@
+#include <stdio.h>
+#include <strings.h>
+
+#include "test-feedback.h"
+#include "test-feedback-internal.h"
+
+#define LOG_RESULT(ret, func) printf("[%s] %s\n", (ret)? "PASS": "FAIL", func)
+
+void test_all()
+{
+ printf("---------------- FEEDBACK TEST -----------------\n");
+ printf(" For more details,\n");
+ printf(" check dlog with 'FEEDBACK_TEST' tag.\n");
+ printf("------------------------------------------------\n");
+
+ LOG_RESULT(TEST_FEEDBACK_INITIALIZE(), "TEST_FEEDBACK_INITIALIZE");
+ LOG_RESULT(TEST_FEEDBACK_DEINITIALIZE(), "TEST_FEEDBACK_DEINITIALIZE");
+ LOG_RESULT(TEST_FEEDBACK_IS_SUPPORTED_PATTERN(), "TEST_FEEDBACK_IS_SUPPORTED_PATTERN");
+ LOG_RESULT(TEST_FEEDBACK_PLAY(), "TEST_FEEDBACK_PLAY");
+ LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE(), "TEST_FEEDBACK_PLAY_TYPE");
+ LOG_RESULT(TEST_FEEDBACK_STOP(), "TEST_FEEDBACK_STOP");
+
+ TEST_INTERNAL_INIT();
+
+ LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_BY_NAME(), "TEST_FEEDBACK_PLAY_TYPE_BY_NAME");
+ LOG_RESULT(TEST_FEEDBACK_PLAY_INTERNAL(), "TEST_FEEDBACK_PLAY_INTERNAL");
+ LOG_RESULT(TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL(), "TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL");
+ LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_INTERNAL");
+ LOG_RESULT(TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(), "TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL");
+}
+
+void show_usage()
+{
+ printf("Usage: feedback-test [OPTION] ...\n");
+ printf("OPTION: \n");
+ printf(" -a\t\t\tTest all APIs\n");
+ printf(" -p <pattern name>\tPlay feedback with pattern name\n");
+ printf(" \t-s\t\tfeedback type sound\n");
+ printf(" \t-v\t\tfeedback type vibration\n");
+}
+
+void test_play(int argc, char **argv)
+{
+ int index = 1;
+ const char *name = NULL;
+ bool sound = false, vibration = false;
+
+ while(index < argc) {
+ if (0 == strcasecmp(argv[index], "-p")) {
+ if (name) {
+ show_usage();
+ break;
+ }
+ index++;
+ name = argv[index];
+ } else if (0 == strcasecmp(argv[index], "-s"))
+ sound = true;
+ else if (0 == strcasecmp(argv[index], "-v"))
+ vibration = true;
+ else {
+ show_usage();
+ return ;
+ }
+
+ index++;
+ }
+
+ if (!name) {
+ show_usage();
+ return;
+ }
+
+ if (!sound && !vibration)
+ feedback_play_by_name(name);
+ else if (sound)
+ printf("return: %s\n", feedback_play_sound_by_name(name));
+ else if (vibration)
+ printf("return: %s\n", feedback_play_vibration_by_name(name));
+
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 2) {
+ show_usage();
+ return 0;
+ }
+
+ if ((argc == 2) && (0 == strcasecmp(argv[1], "-a"))) {
+ test_all();
+ return 0;
+ }
+
+ if (argc >= 3)
+ test_play(argc, argv);
+ else
+ show_usage();
+
+ return 0;
+}
diff --git a/tests/test-feedback-internal.c b/tests/test-feedback-internal.c
new file mode 100644
index 0000000..841a5ca
--- /dev/null
+++ b/tests/test-feedback-internal.c
@@ -0,0 +1,349 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "test.h"
+#include "test-feedback-internal.h"
+
+static int pass;
+static int fail;
+
+static int pattern_s[ARRAY_SIZE(test_pattern)] = { -1, };
+static int pattern_i_s[ARRAY_SIZE(test_pattern_internal)] = { -1, };
+static int pattern_v[ARRAY_SIZE(test_pattern)] = { -1, };
+static int pattern_i_v[ARRAY_SIZE(test_pattern_internal)] = { -1, };
+
+static void test_play_type_by_name_p()
+{
+ int i;
+ char *name;
+ bool s_end = false, v_end = false;
+
+ feedback_initialize();
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern); i++)
+ {
+ if (pattern_s[i] == -1) s_end = true;
+ if (pattern_v[i] == -1) v_end = true;
+
+ if (s_end && v_end) break;
+
+ if (!s_end && (pattern_s[i] != -1)) {
+ name = strdup(test_pattern[pattern_s[i]].name);
+ RESULT(feedback_play_type_by_name("FEEDBACK_TYPE_SOUND", name), FEEDBACK_ERROR_NONE, name)
+ free(name);
+ }
+
+ if (!v_end && (pattern_v[i] != -1)) {
+ name = strdup(test_pattern[pattern_v[i]].name);
+ RESULT(feedback_play_type_by_name("FEEDBACK_TYPE_VIBRATION", name), FEEDBACK_ERROR_NONE, name);
+ free(name);
+ }
+
+ usleep(DELAY_TIME);
+ }
+
+ s_end = false;
+ v_end = false;
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern_internal); i++)
+ {
+ if (pattern_i_s[i] == -1) s_end = true;
+ if (pattern_i_v[i] == -1) v_end = true;
+
+ if (s_end && v_end) break;
+
+ if (!s_end && (pattern_i_s[i] != -1)) {
+ name = strdup(test_pattern_internal[pattern_i_s[i]].name);
+ RESULT(feedback_play_type_by_name("FEEDBACK_TYPE_SOUND", name), FEEDBACK_ERROR_NONE, name);
+ free(name);
+ }
+
+ if (!v_end && (pattern_i_v[i] != -1)) {
+ name = strdup(test_pattern_internal[pattern_i_v[i]].name);
+ RESULT(feedback_play_type_by_name("FEEDBACK_TYPE_VIBRATION", name), FEEDBACK_ERROR_NONE, name);
+ free(name);
+ }
+
+ usleep(DELAY_TIME);
+ }
+
+ feedback_deinitialize();
+}
+
+static void test_play_type_by_name_n()
+{
+ RESULT(feedback_play_type_by_name(NULL, "FEEDBACK_PATTERN_TAP"), FEEDBACK_ERROR_INVALID_PARAMETER, "type is null");
+
+ RESULT(feedback_play_type_by_name("FEEDBACK_TYPE_VIBRATION", NULL), FEEDBACK_ERROR_INVALID_PARAMETER, "pattern is null");
+
+ RESULT(feedback_play_type_by_name("INVALID_FEEDBACK_TYPE", "FEEDBACK_PATTERN_TAP"), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid feedback type");
+
+ RESULT(feedback_play_type_by_name("FEEDBACK_TYPE_SOUND", "INVALID_FEEDBACK_PATTERN"), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid feedback pattern");
+}
+
+bool TEST_FEEDBACK_PLAY_TYPE_BY_NAME(void)
+{
+ INIT();
+
+ test_play_type_by_name_p();
+ test_play_type_by_name_n();
+
+ REPORT_AND_RETURN();
+}
+
+static void test_play_internal_p()
+{
+ int i;
+
+ feedback_initialize();
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern_internal); i++)
+ {
+ RESULT(feedback_play_internal(test_pattern_internal[i].pattern), FEEDBACK_ERROR_NONE, test_pattern_internal[i].name);
+ usleep(DELAY_TIME);
+ }
+
+ feedback_deinitialize();
+}
+
+static void test_play_internal_n()
+{
+ RESULT(feedback_play_internal(FEEDBACK_PATTERN_TAP), FEEDBACK_ERROR_NOT_INITIALIZED, "not initialize");
+
+ feedback_initialize();
+ RESULT(feedback_play_internal(FEEDBACK_PATTERN_NONE), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid pattern");
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PLAY_INTERNAL(void)
+{
+ INIT();
+
+ test_play_internal_p();
+ test_play_internal_n();
+
+ REPORT_AND_RETURN();
+}
+
+static void test_play_soundpath_internal_p()
+{
+ int i;
+ struct _pattern_internal *pattern;
+
+ feedback_initialize();
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern_internal); i++)
+ {
+ if (pattern_i_s[i] == -1)
+ break;
+
+ pattern = &test_pattern_internal[pattern_i_s[i]];
+ if (pattern->path == NULL)
+ continue;
+
+ RESULT(feedback_play_soundpath_internal(pattern->pattern, pattern->path), FEEDBACK_ERROR_NONE, pattern->name);
+ usleep(DELAY_TIME);
+ }
+
+ feedback_deinitialize();
+}
+
+static void test_play_soundpath_internal_n()
+{
+ RESULT(feedback_play_soundpath_internal(FEEDBACK_PATTERN_TAP, "/usr/share/feedback/sound/operation/operation.wav"), FEEDBACK_ERROR_NOT_INITIALIZED, "not initialize");
+
+ feedback_initialize();
+
+ RESULT(feedback_play_soundpath_internal(FEEDBACK_PATTERN_NONE, "/usr/share/feedback/sound/operation/operation.wav"), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid pattern");
+ RESULT(feedback_play_soundpath_internal(FEEDBACK_PATTERN_TAP, NULL), FEEDBACK_ERROR_INVALID_PARAMETER, "NULL sound path");
+
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL(void)
+{
+ INIT();
+
+ test_play_soundpath_internal_p();
+ test_play_soundpath_internal_n();
+
+ REPORT_AND_RETURN();
+}
+
+static void test_play_type_internal_p()
+{
+ int i;
+ bool s_end = false, v_end = false;
+
+ feedback_initialize();
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern_internal); i++)
+ {
+ if (pattern_i_s[i] == -1) s_end = true;
+ if (pattern_i_v[i] == -1) v_end = true;
+
+ if (s_end && v_end) break;
+
+ if (!s_end && (pattern_i_s[i] != -1))
+ RESULT(feedback_play_type_internal(FEEDBACK_TYPE_SOUND, test_pattern_internal[pattern_i_s[i]].pattern), FEEDBACK_ERROR_NONE, test_pattern_internal[pattern_i_s[i]].name);
+
+ if (!v_end && (pattern_i_v[i] != -1))
+ RESULT(feedback_play_type_internal(FEEDBACK_TYPE_VIBRATION, test_pattern_internal[pattern_i_v[i]].pattern), FEEDBACK_ERROR_NONE, test_pattern_internal[pattern_i_v[i]].name);
+
+ usleep(DELAY_TIME);
+ }
+
+ feedback_deinitialize();
+}
+
+static void test_play_type_internal_n()
+{
+ RESULT(feedback_play_type_internal(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP), FEEDBACK_ERROR_NOT_INITIALIZED, "not initialize");
+
+ feedback_initialize();
+
+ RESULT(feedback_play_type_internal(FEEDBACK_TYPE_NONE, FEEDBACK_PATTERN_TAP), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid type");
+ RESULT(feedback_play_type_internal(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_NONE), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid pattern");
+
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PLAY_TYPE_INTERNAL(void)
+{
+ INIT();
+
+ test_play_type_internal_p();
+ test_play_type_internal_n();
+
+ REPORT_AND_RETURN();
+}
+static void test_play_type_soundpath_internal_p()
+{
+ int i;
+ bool s_end = false, v_end = false;
+ struct _pattern_internal *pattern;
+
+ feedback_initialize();
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern_internal); i++)
+ {
+ if (pattern_i_s[i] == -1) s_end = true;
+ if (pattern_i_v[i] == -1) v_end = true;
+
+ if (s_end && v_end) break;
+
+ if (!s_end && (pattern_i_s[i] != -1)) {
+ pattern = &test_pattern_internal[pattern_i_s[i]];
+ if (pattern->path != NULL)
+ RESULT(feedback_play_type_soundpath_internal(FEEDBACK_TYPE_SOUND, pattern->pattern, pattern->path), FEEDBACK_ERROR_NONE, pattern->name);
+ }
+
+ if (!v_end && (pattern_i_v[i] != -1)) {
+ pattern = &test_pattern_internal[pattern_i_v[i]];
+ RESULT(feedback_play_type_soundpath_internal(FEEDBACK_TYPE_VIBRATION, pattern->pattern, NULL), FEEDBACK_ERROR_NONE, pattern->name);
+ }
+
+ usleep(DELAY_TIME);
+ }
+
+ feedback_deinitialize();
+
+}
+
+static void test_play_type_soundpath_internal_n()
+{
+ RESULT(feedback_play_type_soundpath_internal(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP, "/usr/share/feedback/sound/operation/operation.wav"), FEEDBACK_ERROR_NOT_INITIALIZED, "not initialize");
+
+ feedback_initialize();
+
+ RESULT(feedback_play_type_soundpath_internal(FEEDBACK_TYPE_NONE, FEEDBACK_PATTERN_TAP, "/usr/share/feedback/sound/operation/operation.wav"), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid type");
+ RESULT(feedback_play_type_soundpath_internal(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_NONE, "/usr/share/feedback/sound/operation/operation.wav"), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid pattern");
+ RESULT(feedback_play_type_soundpath_internal(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP, NULL), FEEDBACK_ERROR_INVALID_PARAMETER, "invalid soundpath");
+
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(void)
+{
+ INIT();
+
+ test_play_type_soundpath_internal_p();
+ test_play_type_soundpath_internal_n();
+
+ REPORT_AND_RETURN();
+}
+
+const char *feedback_play_sound_by_name(const char *pattern_name)
+{
+ int ret;
+
+ feedback_initialize();
+ ret = feedback_play_type_by_name("FEEDBACK_TYPE_SOUND", (char *)pattern_name);
+ usleep(DELAY_TIME*10);
+ feedback_deinitialize();
+
+ return err_to_str(ret);
+}
+
+const char *feedback_play_vibration_by_name(const char *pattern_name)
+{
+ int ret;
+
+ feedback_initialize();
+ ret = feedback_play_type_by_name("FEEDBACK_TYPE_VIBRATION", (char *)pattern_name);
+ usleep(DELAY_TIME*10);
+ feedback_deinitialize();
+
+ return err_to_str(ret);
+}
+
+void feedback_play_by_name(const char *pattern_name)
+{
+ feedback_play_sound_by_name(pattern_name);
+ feedback_play_vibration_by_name(pattern_name);
+}
+
+static void init_supported_pattern(feedback_type_e type, int *pattern)
+{
+ int i, ret;
+ int idx_supported = 0;
+ bool status;
+
+ feedback_initialize();
+
+ for(i = 0; i < ARRAY_SIZE(test_pattern); i++) {
+ ret = feedback_is_supported_pattern(type, test_pattern[i].pattern, &status);
+ if ((ret == FEEDBACK_ERROR_NONE) && status)
+ pattern[idx_supported++] = i;
+ }
+ pattern[idx_supported] = -1;
+
+ feedback_deinitialize();
+}
+
+static void init_supported_pattern_i(feedback_type_e type, int *pattern_i)
+{
+ int i, ret;
+ int idx_supported = 0;
+ bool status;
+
+ feedback_initialize();
+
+ for(i = 0; i < ARRAY_SIZE(test_pattern_internal); i++) {
+ ret = feedback_is_supported_pattern(type, test_pattern_internal[i].pattern, &status);
+ if ((ret == FEEDBACK_ERROR_NONE) && status)
+ pattern_i[idx_supported++] = i;
+ }
+ pattern_i[idx_supported] = -1;
+
+ feedback_deinitialize();
+}
+
+void TEST_INTERNAL_INIT()
+{
+ init_supported_pattern(FEEDBACK_TYPE_SOUND, pattern_s);
+ init_supported_pattern(FEEDBACK_TYPE_VIBRATION, pattern_v);
+ init_supported_pattern_i(FEEDBACK_TYPE_SOUND, pattern_i_s);
+ init_supported_pattern_i(FEEDBACK_TYPE_VIBRATION, pattern_i_v);
+}
diff --git a/tests/test-feedback-internal.h b/tests/test-feedback-internal.h
new file mode 100644
index 0000000..1a47124
--- /dev/null
+++ b/tests/test-feedback-internal.h
@@ -0,0 +1,139 @@
+/*
+ * feedback-test
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TEST_FEEDBACK_INTERNAL_H__
+#define __TEST_FEEDBACK_INTERNAL_H__
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <feedback-internal.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+static struct _pattern_internal {
+ feedback_pattern_internal_e pattern;
+ const char *name;
+ const char *path;
+} test_pattern_internal[] = {
+ { FEEDBACK_PATTERN_SIP_BACKSPACE, "FEEDBACK_PATTERN_SIP_BACKSPACE", NULL },
+ { FEEDBACK_PATTERN_SIP_FUNCTION, "FEEDBACK_PATTERN_SIP_FUNCTION", NULL },
+ { FEEDBACK_PATTERN_SIP_FJKEY, "FEEDBACK_PATTERN_SIP_FJKEY", NULL },
+ { FEEDBACK_PATTERN_MAX_CHARACTER, "FEEDBACK_PATTERN_MAX_CHARACTER", NULL },
+ { FEEDBACK_PATTERN_MULTI_TAP, "FEEDBACK_PATTERN_MULTI_TAP", NULL },
+ { FEEDBACK_PATTERN_MESSAGE_ON_CALL, "FEEDBACK_PATTERN_MESSAGE_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_EMAIL_ON_CALL, "FEEDBACK_PATTERN_EMAIL_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_WAKEUP_ON_CALL, "FEEDBACK_PATTERN_WAKEUP_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_SCHEDULE_ON_CALL, "FEEDBACK_PATTERN_SCHEDULE_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_TIMER_ON_CALL, "FEEDBACK_PATTERN_TIMER_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_GENERAL_ON_CALL, "FEEDBACK_PATTERN_GENERAL_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_SMART_ALERT, "FEEDBACK_PATTERN_SMART_ALERT", NULL },
+ { FEEDBACK_PATTERN_CHARGERCONN_ON_CALL, "FEEDBACK_PATTERN_CHARGERCONN_ON_CALL", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL, "FEEDBACK_PATTERN_CHARGING_ERROR_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_FULLCHARGED_ON_CALL, "FEEDBACK_PATTERN_FULLCHARGED_ON_CALL", NULL },
+ { FEEDBACK_PATTERN_LOWBATT_ON_CALL, "FEEDBACK_PATTERN_LOWBATT_ON_CALL", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_LOCK_SWIPE, "FEEDBACK_PATTERN_LOCK_SWIPE", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_UNLOCK_SWIPE, "FEEDBACK_PATTERN_UNLOCK_SWIPE", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_GEOMETRIC_LOCK, "FEEDBACK_PATTERN_GEOMETRIC_LOCK", NULL },
+ { FEEDBACK_PATTERN_CALLCONNECT, "FEEDBACK_PATTERN_CALLCONNECT", NULL },
+ { FEEDBACK_PATTERN_DISCALLCONNECT, "FEEDBACK_PATTERN_DISCALLCONNECT", NULL },
+ { FEEDBACK_PATTERN_OUTGOING_CALL, "FEEDBACK_PATTERN_OUTGOING_CALL", NULL },
+ { FEEDBACK_PATTERN_MINUTEMINDER, "FEEDBACK_PATTERN_MINUTEMINDER", NULL },
+ { FEEDBACK_PATTERN_BT_PAIRING, "FEEDBACK_PATTERN_BT_PAIRING", NULL },
+ { FEEDBACK_PATTERN_BT_WAITING, "FEEDBACK_PATTERN_BT_WAITING", NULL },
+ { FEEDBACK_PATTERN_SCREEN_CAPTURE, "FEEDBACK_PATTERN_SCREEN_CAPTURE", "/usr/share/feedback/sound/operation/shutter.wav" },
+ { FEEDBACK_PATTERN_UV_PROCESSING, "FEEDBACK_PATTERN_UV_PROCESSING", NULL },
+ { FEEDBACK_PATTERN_SHEALTH_START, "FEEDBACK_PATTERN_SHEALTH_START", NULL },
+ { FEEDBACK_PATTERN_SHEALTH_PAUSE, "FEEDBACK_PATTERN_SHEALTH_PAUSE", NULL },
+ { FEEDBACK_PATTERN_SHEALTH_STOP, "FEEDBACK_PATTERN_SHEALTH_STOP", NULL },
+ { FEEDBACK_PATTERN_3RD_APPLICATION, "FEEDBACK_PATTERN_3RD_APPLICATION", NULL },
+ { FEEDBACK_PATTERN_TICK, "FEEDBACK_PATTERN_TICK", NULL },
+ { FEEDBACK_PATTERN_TRANSITION_CIRCULAR, "FEEDBACK_PATTERN_TRANSITION_CIRCULAR", NULL },
+ { FEEDBACK_PATTERN_TRANSITION_POP, "FEEDBACK_PATTERN_TRANSITION_POP", NULL },
+ { FEEDBACK_PATTERN_PROCESS, "FEEDBACK_PATTERN_PROCESS", NULL },
+ { FEEDBACK_PATTERN_MOVE_LIST, "FEEDBACK_PATTERN_MOVE_LIST", NULL },
+ { FEEDBACK_PATTERN_DISMISS, "FEEDBACK_PATTERN_DISMISS", NULL },
+ { FEEDBACK_PATTERN_CLOCK_SECOND_HAND, "FEEDBACK_PATTERN_CLOCK_SECOND_HAND", NULL },
+ { FEEDBACK_PATTERN_SPIRAL_DOWN, "FEEDBACK_PATTERN_SPIRAL_DOWN", NULL },
+ { FEEDBACK_PATTERN_MOVE_LIST_2, "FEEDBACK_PATTERN_MOVE_LIST_2", NULL },
+ { FEEDBACK_PATTERN_SPIRAL_UP, "FEEDBACK_PATTERN_SPIRAL_UP", NULL },
+ { FEEDBACK_PATTERN_SILENCE, "FEEDBACK_PATTERN_SILENCE", NULL },
+ { FEEDBACK_PATTERN_INACTIVE_TENSION, "FEEDBACK_PATTERN_INACTIVE_TENSION", NULL },
+ { FEEDBACK_PATTERN_INACTIVE_FINE, "FEEDBACK_PATTERN_INACTIVE_FINE", NULL },
+ { FEEDBACK_PATTERN_SHEALTH_NOTICE, "FEEDBACK_PATTERN_SHEALTH_NOTICE", NULL },
+ { FEEDBACK_PATTERN_SHEALTH_GENTLE_ALERT, "FEEDBACK_PATTERN_SHEALTH_GENTLE_ALERT", NULL },
+ { FEEDBACK_PATTERN_END_EFFECT_FINE, "FEEDBACK_PATTERN_END_EFFECT_FINE", NULL },
+ { FEEDBACK_PATTERN_CLICK_VALUE, "FEEDBACK_PATTERN_CLICK_VALUE", NULL },
+ { FEEDBACK_PATTERN_CLICK_FINE_TRAIN_1, "FEEDBACK_PATTERN_CLICK_FINE_TRAIN_1", NULL },
+ { FEEDBACK_PATTERN_CLICK_FINE, "FEEDBACK_PATTERN_CLICK_FINE", NULL },
+ { FEEDBACK_PATTERN_CLICK_SLIDER, "FEEDBACK_PATTERN_CLICK_SLIDER", NULL },
+ { FEEDBACK_PATTERN_CLICK_MEDIUM, "FEEDBACK_PATTERN_CLICK_MEDIUM", NULL },
+ { FEEDBACK_PATTERN_CLICK_STRONG, "FEEDBACK_PATTERN_CLICK_STRONG", NULL },
+ { FEEDBACK_PATTERN_TURN_RIGHT, "FEEDBACK_PATTERN_TURN_RIGHT", NULL },
+ { FEEDBACK_PATTERN_TURN_LEFT, "FEEDBACK_PATTERN_TURN_LEFT", NULL },
+ { FEEDBACK_PATTERN_FUNCTION, "FEEDBACK_PATTERN_FUNCTION", NULL },
+ { FEEDBACK_PATTERN_VOICE_START, "FEEDBACK_PATTERN_VOICE_START", NULL },
+ { FEEDBACK_PATTERN_VOICE_STOP, "FEEDBACK_PATTERN_VOICE_STOP", NULL },
+ { FEEDBACK_PATTERN_COMMUNICATION, "FEEDBACK_PATTERN_COMMUNICATION", NULL },
+ { FEEDBACK_PATTERN_HEARTBEAT, "FEEDBACK_PATTERN_HEARTBEAT", NULL },
+ { FEEDBACK_PATTERN_HEARTBEAT_FAST, "FEEDBACK_PATTERN_HEARTBEAT_FAST", NULL },
+ { FEEDBACK_PATTERN_SETTING_ON, "FEEDBACK_PATTERN_SETTING_ON", NULL },
+ { FEEDBACK_PATTERN_SETTING_OFF, "FEEDBACK_PATTERN_SETTING_OFF", NULL },
+ { FEEDBACK_PATTERN_CONNECT, "FEEDBACK_PATTERN_CONNECT", NULL },
+ { FEEDBACK_PATTERN_DISCONNECT, "FEEDBACK_PATTERN_DISCONNECT", NULL },
+ { FEEDBACK_PATTERN_HOURLY_ALERT, "FEEDBACK_PATTERN_HOURLY_ALERT", NULL },
+ { FEEDBACK_PATTERN_SAFETY_ALERT, "FEEDBACK_PATTERN_SAFETY_ALERT", NULL },
+ { FEEDBACK_PATTERN_ACCIDENT_DETECT, "FEEDBACK_PATTERN_ACCIDENT_DETECT", NULL },
+ { FEEDBACK_PATTERN_SEND_SOS_MESSAGE, "FEEDBACK_PATTERN_SEND_SOS_MESSAGE", NULL },
+ { FEEDBACK_PATTERN_END_SOS_MESSAGE, "FEEDBACK_PATTERN_END_SOS_MESSAGE", NULL },
+ { FEEDBACK_PATTERN_EMERGENCY_BUZZER, "FEEDBACK_PATTERN_EMERGENCY_BUZZER", NULL },
+ { FEEDBACK_PATTERN_SAFETY_LOW_POWER, "FEEDBACK_PATTERN_SAFETY_LOW_POWER", NULL },
+ { FEEDBACK_PATTERN_CMAS, "FEEDBACK_PATTERN_CMAS", NULL },
+ { FEEDBACK_PATTERN_RINGER, "FEEDBACK_PATTERN_RINGER", NULL },
+ { FEEDBACK_PATTERN_NOTIFICATION, "FEEDBACK_PATTERN_NOTIFICATION", NULL },
+ { FEEDBACK_PATTERN_INFO, "FEEDBACK_PATTERN_INFO", NULL },
+ { FEEDBACK_PATTERN_WARNING, "FEEDBACK_PATTERN_WARNING", NULL },
+ { FEEDBACK_PATTERN_ERROR, "FEEDBACK_PATTERN_ERROR", NULL },
+ { FEEDBACK_PATTERN_EMERGENCY, "FEEDBACK_PATTERN_EMERGENCY", NULL },
+ { FEEDBACK_PATTERN_INTERNAL_WAKEUP, "FEEDBACK_PATTERN_INTERNAL_WAKEUP", NULL },
+ { FEEDBACK_PATTERN_INTERNAL_TIMER, "FEEDBACK_PATTERN_INTERNAL_TIMER", NULL },
+ { FEEDBACK_PATTERN_TEMPERATURE_WARNING, "FEEDBACK_PATTERN_TEMPERATURE_WARNING", NULL },
+};
+
+bool TEST_FEEDBACK_PLAY_TYPE_BY_NAME(void);
+bool TEST_FEEDBACK_PLAY_INTERNAL(void);
+bool TEST_FEEDBACK_PLAY_SOUNDPATH_INTERNAL(void);
+bool TEST_FEEDBACK_PLAY_TYPE_INTERNAL(void);
+bool TEST_FEEDBACK_PLAY_TYPE_SOUNDPATH_INTERNAL(void);
+
+void TEST_INTERNAL_INIT(void);
+
+void feedback_play_by_name(const char *pattern_name);
+const char *feedback_play_sound_by_name(const char *pattern_name);
+const char * feedback_play_vibration_by_name(const char *pattern_name);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif //__TEST_FEEDBACK_INTERNAL_H__
diff --git a/tests/test-feedback.c b/tests/test-feedback.c
new file mode 100644
index 0000000..5cf7164
--- /dev/null
+++ b/tests/test-feedback.c
@@ -0,0 +1,223 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "test.h"
+#include "test-feedback.h"
+
+static int pass;
+static int fail;
+
+static void test_initialize_p(void)
+{
+ RESULT(feedback_initialize(), FEEDBACK_ERROR_NONE, "nomal test");
+ RESULT(feedback_initialize(), FEEDBACK_ERROR_NONE, "2nd test"); // checking multi initialize
+
+ feedback_deinitialize();
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_INITIALIZE(void)
+{
+ INIT();
+ test_initialize_p();
+ REPORT_AND_RETURN();
+}
+
+static void test_deinitialize_p(void)
+{
+ feedback_initialize();
+ feedback_initialize();
+
+ RESULT(feedback_deinitialize(), FEEDBACK_ERROR_NONE, "normal test");
+ RESULT(feedback_deinitialize(), FEEDBACK_ERROR_NONE, "2nd test");
+}
+
+static void test_deinitialize_n(void)
+{
+ RESULT(feedback_deinitialize(), FEEDBACK_ERROR_NOT_INITIALIZED, "without init");
+
+ feedback_initialize();
+ feedback_deinitialize();
+ RESULT(feedback_deinitialize(), FEEDBACK_ERROR_NOT_INITIALIZED, "duplicated");
+}
+
+bool TEST_FEEDBACK_DEINITIALIZE(void)
+{
+ INIT();
+ test_deinitialize_p();
+ test_deinitialize_n();
+ REPORT_AND_RETURN();
+}
+
+static void test_is_supported_pattern_p(void)
+{
+ int type, j;
+ bool status;
+
+ feedback_initialize();
+ for (type = FEEDBACK_TYPE_NONE+1; type < FEEDBACK_TYPE_END; type++) {
+ for (j = 0; j < ARRAY_SIZE(test_pattern); j++) {
+ RESULT(feedback_is_supported_pattern(type, test_pattern[j].pattern, &status),
+ FEEDBACK_ERROR_NONE, test_pattern[j].name);
+ }
+ }
+ feedback_deinitialize();
+}
+
+static void test_is_supported_pattern_n(void)
+{
+ bool status;
+
+ RESULT(feedback_is_supported_pattern(FEEDBACK_TYPE_SOUND, test_pattern[0].pattern, &status),
+ FEEDBACK_ERROR_NOT_INITIALIZED, "without init");
+
+ feedback_initialize();
+ RESULT(feedback_is_supported_pattern(FEEDBACK_TYPE_NONE, test_pattern[0].pattern, &status),
+ FEEDBACK_ERROR_INVALID_PARAMETER, "type none");
+ RESULT(feedback_is_supported_pattern(FEEDBACK_TYPE_END, test_pattern[0].pattern, &status),
+ FEEDBACK_ERROR_INVALID_PARAMETER, "type end");
+ RESULT(feedback_is_supported_pattern(FEEDBACK_TYPE_SOUND, test_pattern[0].pattern, NULL),
+ FEEDBACK_ERROR_INVALID_PARAMETER, "status NULL");
+ RESULT(feedback_is_supported_pattern(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_NONE, &status),
+ FEEDBACK_ERROR_INVALID_PARAMETER, "pattern NULL");
+ //RESULT(feedback_is_supported_pattern(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_END, &status),
+ // FEEDBACK_ERROR_INVALID_PARAMETER, "pattern end");
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_IS_SUPPORTED_PATTERN(void)
+{
+ INIT();
+ test_is_supported_pattern_p();
+ test_is_supported_pattern_n();
+ REPORT_AND_RETURN();
+}
+
+static void test_play_p(void)
+{
+ int i;
+
+ feedback_initialize();
+ for (i = 0; i < ARRAY_SIZE(test_pattern); ++i) {
+ RESULT(feedback_play(test_pattern[i].pattern), FEEDBACK_ERROR_NONE, test_pattern[i].name);
+ usleep(DELAY_TIME);
+ }
+ feedback_deinitialize();
+}
+
+static void test_play_n(void)
+{
+ RESULT(feedback_play(FEEDBACK_PATTERN_TAP), FEEDBACK_ERROR_NOT_INITIALIZED, "without init");
+
+ feedback_initialize();
+ RESULT(feedback_play(FEEDBACK_PATTERN_NONE), FEEDBACK_ERROR_INVALID_PARAMETER, "pattern NULL");
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PLAY(void)
+{
+ INIT();
+ test_play_p();
+ test_play_n();
+ REPORT_AND_RETURN();
+}
+
+static void INIT_PATTERN_LIST(feedback_type_e type, feedback_pattern_e *supported, int *nsupported, feedback_pattern_e *not_supported, int *n_not_supported)
+{
+ int idx_supported = 0, idx_not_supported = 0;
+ int i;
+ bool status;
+
+ if (!supported || !not_supported)
+ return;
+
+ memset(supported, -1, ARRAY_SIZE(test_pattern));
+ memset(not_supported, -1, ARRAY_SIZE(test_pattern));
+
+ feedback_initialize();
+
+ for (i = 0; i < ARRAY_SIZE(test_pattern); ++i) {
+ feedback_is_supported_pattern(type, test_pattern[i].pattern, &status);
+ if (status)
+ supported[idx_supported++] = i;
+ else
+ not_supported[idx_not_supported++] = i;
+ }
+ feedback_deinitialize();
+
+ if (nsupported) *nsupported = idx_supported;
+ if (n_not_supported) *n_not_supported = idx_not_supported;
+}
+
+static void test_play_type_p(feedback_type_e type, feedback_pattern_e *supported, int ncount)
+{
+ int i;
+
+ if (!supported)
+ return ;
+
+ feedback_initialize();
+ for (i = 0; i < ncount; i++) {
+ RESULT(feedback_play_type(type, test_pattern[supported[i]].pattern), FEEDBACK_ERROR_NONE, test_pattern[supported[i]].name);
+ }
+ feedback_deinitialize();
+}
+
+static void test_play_type_n(feedback_type_e type, feedback_pattern_e *notsupported, int ncount)
+{
+ int i;
+
+ if (!notsupported)
+ return ;
+
+ RESULT(feedback_play_type(type, FEEDBACK_PATTERN_TAP), FEEDBACK_ERROR_NOT_INITIALIZED, "without init");
+
+ feedback_initialize();
+ for (i = 0; i < ncount; i++) {
+ RESULT(feedback_play_type(type, test_pattern[notsupported[i]].pattern), FEEDBACK_ERROR_NOT_SUPPORTED, test_pattern[notsupported[i]].name);
+ }
+ feedback_deinitialize();
+}
+
+bool TEST_FEEDBACK_PLAY_TYPE(void)
+{
+ int type;
+ int nSupported = 0, nNotSupported = 0;
+ int *pSupported = malloc(ARRAY_SIZE(test_pattern)*sizeof(int));
+ int *pNotSupported = malloc(ARRAY_SIZE(test_pattern)*sizeof(int));
+
+ INIT();
+
+ for (type = FEEDBACK_TYPE_NONE+1; type < FEEDBACK_TYPE_END; type++) {
+ INIT_PATTERN_LIST(type, pSupported, &nSupported, pNotSupported, &nNotSupported);
+ test_play_type_p(type, pSupported, nSupported);
+ if (type != FEEDBACK_TYPE_VIBRATION)
+ test_play_type_n(type, pNotSupported, nNotSupported);
+ }
+
+ free(pSupported);
+ free(pNotSupported);
+
+ REPORT_AND_RETURN();
+}
+
+static void test_stop_p()
+{
+ feedback_initialize();
+ RESULT(feedback_stop(), FEEDBACK_ERROR_NONE, "normal test");
+ feedback_deinitialize();
+}
+
+static void test_stop_n()
+{
+ RESULT(feedback_stop(), FEEDBACK_ERROR_NOT_INITIALIZED, "without init");
+}
+
+bool TEST_FEEDBACK_STOP(void)
+{
+ INIT();
+ test_stop_p();
+ test_stop_n();
+ REPORT_AND_RETURN();
+}
diff --git a/tests/test-feedback.h b/tests/test-feedback.h
new file mode 100644
index 0000000..c8bddc0
--- /dev/null
+++ b/tests/test-feedback.h
@@ -0,0 +1,46 @@
+/*
+ * feedback-test
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TEST_FEEDBACK_H__
+#define __TEST_FEEDBACK_H__
+
+#include <stdio.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+bool TEST_FEEDBACK_INITIALIZE(void);
+bool TEST_FEEDBACK_DEINITIALIZE(void);
+bool TEST_FEEDBACK_IS_SUPPORTED_PATTERN(void);
+bool TEST_FEEDBACK_PLAY(void);
+bool TEST_FEEDBACK_PLAY_TYPE(void);
+bool TEST_FEEDBACK_STOP(void);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif //__TEST_FEEDBACK_H__
diff --git a/tests/test.h b/tests/test.h
new file mode 100644
index 0000000..0ec4fe0
--- /dev/null
+++ b/tests/test.h
@@ -0,0 +1,139 @@
+/*
+ * feedback-test
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __TEST_H__
+#define __TEST_H__
+
+#include <stdio.h>
+#include <feedback.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef ENABLE_TEST_DLOG
+ #define LOG_TAG "FEEDBACK_TEST"
+ #include <dlog.h>
+ #define _D(fmt, args...) SLOGD(fmt, ##args)
+ #define _W(fmt, args...) SLOGW(fmt, ##args)
+ #define _E(fmt, args...) SLOGE(fmt, ##args)
+#else
+ #define _D(x, ...)
+ #define _W(x, ...)
+ #define _E(x, ...)
+#endif
+
+static inline char * err_to_str(int err)
+{
+ switch (err) {
+ case FEEDBACK_ERROR_NONE: return "FEEDBACK_ERROR_NONE";
+ case FEEDBACK_ERROR_OPERATION_FAILED: return "FEEDBACK_ERROR_OPERATION_FAILED";
+ case FEEDBACK_ERROR_INVALID_PARAMETER: return "FEEDBACK_ERROR_INVALID_PARAMETER";
+ case FEEDBACK_ERROR_NOT_SUPPORTED: return "FEEDBACK_ERROR_NOT_SUPPORTED";
+ case FEEDBACK_ERROR_PERMISSION_DENIED: return "FEEDBACK_ERROR_PERMISSION_DENIED";
+ case FEEDBACK_ERROR_NOT_INITIALIZED: return "FEEDBACK_ERROR_NOT_INITIALIZED";
+ }
+ return "NULL";
+}
+
+#define INIT() pass=0; fail=0;
+#define REPORT_AND_RETURN() \
+ { \
+ if (fail > 0) \
+ _E("FAILED. (TOTAL: %d, PASS: %d, FAIL: %d)", pass+fail, pass, fail); \
+ else \
+ _D("SUCCESS. (TOTAL: %d, PASS: %d, FAIL: %d)", pass+fail, pass, fail); \
+ } \
+ return (fail > 0)? false: true
+
+#define RESULT(ret, expected, log) \
+ { \
+ if (ret == expected) { \
+ pass++; \
+ } else { \
+ _E("FAIL: %s (return: %s) %s", __func__, err_to_str(ret), log); \
+ fail++; \
+ } \
+ } \
+
+
+#define DELAY_TIME 100*1000 //100ms
+#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0]))
+
+static struct _pattern {
+ feedback_pattern_e pattern;
+ const char *name;
+ const char *path;
+} test_pattern[] = {
+ { FEEDBACK_PATTERN_TAP, "FEEDBACK_PATTERN_TAP", "/usr/share/feedback/sound/touch/touch.wav" },
+ { FEEDBACK_PATTERN_SIP, "FEEDBACK_PATTERN_SIP", "/usr/share/feedback/sound/touch/sip.wav" },
+ { FEEDBACK_PATTERN_KEY0, "FEEDBACK_PATTERN_KEY0", "/usr/share/feedback/sound/touch/key0.wav" },
+ { FEEDBACK_PATTERN_KEY1, "FEEDBACK_PATTERN_KEY1", "/usr/share/feedback/sound/touch/key1.wav" },
+ { FEEDBACK_PATTERN_KEY2, "FEEDBACK_PATTERN_KEY2", "/usr/share/feedback/sound/touch/key2.wav" },
+ { FEEDBACK_PATTERN_KEY3, "FEEDBACK_PATTERN_KEY3", "/usr/share/feedback/sound/touch/key3.wav" },
+ { FEEDBACK_PATTERN_KEY4, "FEEDBACK_PATTERN_KEY4", "/usr/share/feedback/sound/touch/key4.wav" },
+ { FEEDBACK_PATTERN_KEY5, "FEEDBACK_PATTERN_KEY5", "/usr/share/feedback/sound/touch/key5.wav" },
+ { FEEDBACK_PATTERN_KEY6, "FEEDBACK_PATTERN_KEY6", "/usr/share/feedback/sound/touch/key6.wav" },
+ { FEEDBACK_PATTERN_KEY7, "FEEDBACK_PATTERN_KEY7", "/usr/share/feedback/sound/touch/key7.wav" },
+ { FEEDBACK_PATTERN_KEY8, "FEEDBACK_PATTERN_KEY8", "/usr/share/feedback/sound/touch/key8.wav" },
+ { FEEDBACK_PATTERN_KEY9, "FEEDBACK_PATTERN_KEY9", "/usr/share/feedback/sound/touch/key9.wav" },
+ { FEEDBACK_PATTERN_KEY_STAR, "FEEDBACK_PATTERN_KEY_STAR", "/usr/share/feedback/sound/touch/keyasterisk.wav" },
+ { FEEDBACK_PATTERN_KEY_SHARP, "FEEDBACK_PATTERN_KEY_SHARP", "/usr/share/feedback/sound/touch/keysharp.wav" },
+ { FEEDBACK_PATTERN_KEY_BACK, "FEEDBACK_PATTERN_KEY_BACK", "/usr/share/feedback/sound/touch/touch.wav" },
+ { FEEDBACK_PATTERN_HOLD, "FEEDBACK_PATTERN_HOLD", NULL },
+ { FEEDBACK_PATTERN_HW_TAP, "FEEDBACK_PATTERN_HW_TAP", "/usr/share/feedback/sound/touch/touch.wav" },
+ { FEEDBACK_PATTERN_HW_HOLD, "FEEDBACK_PATTERN_HW_HOLD", NULL },
+ { FEEDBACK_PATTERN_MESSAGE, "FEEDBACK_PATTERN_MESSAGE", NULL },
+ { FEEDBACK_PATTERN_EMAIL, "FEEDBACK_PATTERN_EMAIL", NULL },
+ { FEEDBACK_PATTERN_WAKEUP, "FEEDBACK_PATTERN_WAKEUP", NULL },
+ { FEEDBACK_PATTERN_SCHEDULE, "FEEDBACK_PATTERN_SCHEDULE", NULL },
+ { FEEDBACK_PATTERN_TIMER, "FEEDBACK_PATTERN_TIMER", NULL },
+ { FEEDBACK_PATTERN_GENERAL, "FEEDBACK_PATTERN_GENERAL", NULL },
+ { FEEDBACK_PATTERN_POWERON, "FEEDBACK_PATTERN_POWERON", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_POWEROFF, "FEEDBACK_PATTERN_POWEROFF", NULL },
+ { FEEDBACK_PATTERN_CHARGERCONN, "FEEDBACK_PATTERN_CHARGERCONN", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_CHARGING_ERROR, "FEEDBACK_PATTERN_CHARGING_ERROR", NULL },
+ { FEEDBACK_PATTERN_FULLCHARGED, "FEEDBACK_PATTERN_FULLCHARGED", NULL },
+ { FEEDBACK_PATTERN_LOWBATT, "FEEDBACK_PATTERN_LOWBATT", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_LOCK, "FEEDBACK_PATTERN_LOCK", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_UNLOCK, "FEEDBACK_PATTERN_UNLOCK", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_VIBRATION_ON, "FEEDBACK_PATTERN_VIBRATION_ON", NULL },
+ { FEEDBACK_PATTERN_SILENT_OFF, "FEEDBACK_PATTERN_SILENT_OFF", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_BT_CONNECTED, "FEEDBACK_PATTERN_BT_CONNECTED", NULL },
+ { FEEDBACK_PATTERN_BT_DISCONNECTED, "FEEDBACK_PATTERN_BT_DISCONNECTED", NULL },
+ { FEEDBACK_PATTERN_LIST_REORDER, "FEEDBACK_PATTERN_LIST_REORDER", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_LIST_SLIDER, "FEEDBACK_PATTERN_LIST_SLIDER", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_VOLUME_KEY, "FEEDBACK_PATTERN_VOLUME_KEY", "/usr/share/feedback/sound/operation/operation.wav" },
+ { FEEDBACK_PATTERN_SYSTEM_SHORT, "FEEDBACK_PATTERN_SYSTEM_SHORT", NULL },
+ { FEEDBACK_PATTERN_SYSTEM_ERROR, "FEEDBACK_PATTERN_SYSTEM_ERROR", NULL },
+ { FEEDBACK_PATTERN_SYSTEM_LONG, "FEEDBACK_PATTERN_SYSTEM_LONG", NULL },
+ { FEEDBACK_PATTERN_SYSTEM_MID, "FEEDBACK_PATTERN_SYSTEM_MID", NULL },
+ { FEEDBACK_PATTERN_END_EFFECT, "FEEDBACK_PATTERN_END_EFFECT", NULL },
+ { FEEDBACK_PATTERN_GENERAL_STRONG_BUZZ, "FEEDBACK_PATTERN_GENERAL_STRONG_BUZZ", NULL },
+};
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif // __TEST_H__