Revise testsuite code 92/182992/6 accepted/tizen_5.0_unified accepted/tizen/5.0/unified/20181102.014719 accepted/tizen/unified/20180702.062938 submit/tizen/20180702.014131 submit/tizen_5.0/20181101.000002
authorSeungbae Shin <seungbae.shin@samsung.com>
Fri, 29 Jun 2018 11:27:57 +0000 (20:27 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Fri, 29 Jun 2018 11:57:28 +0000 (20:57 +0900)
rename testsuite and include to package

[Version] 0.2.1
[Issue Type] Revision

Change-Id: I556a85af08053ea3d3e35a70611bc5e7f2855ca5

packaging/capi-media-tone-player.spec
test/CMakeLists.txt
test/multimedia_tone_player_test.c [deleted file]
test/tone_player_test.c [new file with mode: 0755]

index 0780885dba6b3fc02513ee656cf9a624379f2805..a47a8dd0dd169abdda6aea267450d9d9934445ed 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       capi-media-tone-player
 Summary:    A tone player library in Tizen C API
-Version:    0.2.0
+Version:    0.2.1
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -50,6 +50,7 @@ make %{?jobs:-j%jobs}
 %manifest %{name}.manifest
 %license LICENSE
 %{_libdir}/libcapi-media-tone-player.so.*
+%{_bindir}/*
 
 %files devel
 %manifest %{name}.manifest
index 07a6abf1a0e7ca097b79a299208c6d7c54dbbf97..67b26f33b2d2393ac1bed53d000c57b5ffec40b7 100644 (file)
@@ -16,3 +16,5 @@ FOREACH(src ${sources})
     ADD_EXECUTABLE(${src_name} ${src})
     TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
 ENDFOREACH()
+
+INSTALL(TARGETS tone_player_test DESTINATION bin)
diff --git a/test/multimedia_tone_player_test.c b/test/multimedia_tone_player_test.c
deleted file mode 100755 (executable)
index 7aa38dd..0000000
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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.
-*/
-
-#include <stdio.h>
-#include <tone_player.h>
-#include <glib.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
-#include <getopt.h>
-#include <sound_manager.h>
-
-#define TONE_FIRST          TONE_TYPE_DTMF_0
-#define TONE_LAST           TONE_TYPE_USER_DEFINED_HIGH_FRE
-
-static GMainLoop *g_mainloop = NULL;
-static GThread *event_thread;
-
-gpointer GmainThread(gpointer data)
-{
-       g_mainloop = g_main_loop_new(NULL, 0);
-       g_main_loop_run(g_mainloop);
-
-       return NULL;
-}
-
-void help()
-{
-       printf("Usage : ");
-       printf("multimedia_tone_player_test [OPTION]\n\n"
-                       "  -f, --from                from which tone type\n"
-                       "  -t, --to                  to which tone type\n"
-                       "  -d, --duration            duration(ms)\n"
-                       "  -s, --sleep               sleep time after play start(ms)\n"
-                       "  -h, --help                help\n");
-}
-
-static void stream_focus_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
-                       sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data)
-{
-       return;
-}
-
-
-void tone_play_test(int from, int to, int duration, int sleep_time)
-{
-       int i;
-       sound_stream_info_h stream_info;
-
-       printf("From : %2d,   To : %2d,    Duration : %4d,  sleep_time : %4d\n", from, to, duration, sleep_time);
-
-       if (from < TONE_FIRST || to < TONE_FIRST || duration < 0 || from > to || from > TONE_LAST || to > TONE_LAST || sleep_time < 0) {
-               printf("Wrong Parameter\n");
-               return;
-       }
-       
-       if (sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, stream_focus_cb, NULL, &stream_info)) {
-               printf("failed to create stream info\n");
-               return;
-       }
-
-       for (i = from; i <= to; i++) {
-               printf("Play Tone : %d\n", i);
-               tone_player_start_new(i, stream_info, duration, NULL);
-               usleep(sleep_time * 1000);
-       }
-       
-       sound_manager_destroy_stream_information(stream_info);
-}
-
-int main(int argc, char **argv)
-{
-       GError *gerr = NULL;
-       int from = TONE_TYPE_DTMF_0, to = TONE_TYPE_DTMF_S;
-       int duration = 500, sleep_time = -1;
-
-       while (1) {
-               int opt;
-               int opt_idx = 0;
-
-               static struct option long_options[] = {
-                       {"from", required_argument, 0, 'f'},
-                       {"to", required_argument, 0, 't'},
-                       {"duration", required_argument, 0, 'd'},
-                       {"sleep", required_argument, 0, 's'},
-                       {"help", no_argument, 0, 'h'},
-                       {0, 0, 0, 0}
-               };
-
-               if ((opt = getopt_long(argc, argv, "f:t:d:s:h", long_options, &opt_idx)) == -1)
-                       break;
-
-               switch (opt) {
-               case 'f':
-                       from = atoi(optarg);
-                       break;
-               case 't':
-                       to = atoi(optarg);
-                       break;
-               case 'd':
-                       duration = atoi(optarg);
-                       break;
-               case 's':
-                       sleep_time = atoi(optarg);
-                       break;
-               case 'h':
-               default:
-                       help();
-                       return 0;
-               }
-       }
-
-       if (sleep_time == -1)
-               sleep_time = duration;
-
-       if (!g_thread_supported())
-               g_thread_init(NULL);
-
-       event_thread = g_thread_create(GmainThread, NULL, 1, &gerr);
-
-       tone_play_test(from, to, duration, sleep_time);
-
-       return 0;
-}
diff --git a/test/tone_player_test.c b/test/tone_player_test.c
new file mode 100755 (executable)
index 0000000..0c7ab3f
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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.
+*/
+
+#include <stdio.h>
+#include <tone_player.h>
+#include <glib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <sound_manager.h>
+
+#define TONE_FIRST          TONE_TYPE_DTMF_0
+#define TONE_LAST           TONE_TYPE_USER_DEFINED_HIGH_FRE
+
+static GMainLoop *g_mainloop;
+static GThread *event_thread;
+
+static gpointer _g_mainloop_thread(gpointer data)
+{
+       g_mainloop = g_main_loop_new(NULL, 0);
+
+       g_print("now run mainloop %p\n", g_mainloop);
+       g_main_loop_run(g_mainloop);
+       g_print("mainloop %p quit...\n", g_mainloop);
+
+       g_main_loop_unref(g_mainloop);
+
+       return NULL;
+}
+
+static gboolean _g_timeout_cb(gpointer data)
+{
+       int id = (int)data;
+       int ret = 0;
+
+       g_print("< Stopping id(%d), ", id);
+       ret = tone_player_stop(id);
+       g_print("Done! ret=0x%X >", ret);
+
+       return FALSE;
+}
+
+
+static void _help()
+{
+       g_print("Usage : ");
+       g_print("tone_player_test [OPTION]\n\n"
+                       "  -f, --from                from which tone type\n"
+                       "  -t, --to                  to which tone type\n"
+                       "  -d, --duration            duration(ms)\n"
+                       "  -s, --sleep               sleep time after play start(ms)\n"
+                       "  -h, --help                help\n");
+}
+
+static void _stream_focus_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state,
+                       sound_stream_focus_change_reason_e reason, int sound_behavior, const char *extra_info, void *user_data)
+{
+       g_print("stream focus callback invoked...\n");
+       return;
+}
+
+
+static void _tone_play_test(int from, int to, int duration, int sleep_time)
+{
+       int i, j;
+       int id = -1;
+       sound_stream_info_h stream_info = NULL;
+
+       g_print("From : %2d,   To : %2d,    Duration : %4d,  sleep_time : %4d\n", from, to, duration, sleep_time);
+
+       if (from < TONE_FIRST || to < TONE_FIRST || duration < 0 || from > to || from > TONE_LAST || to > TONE_LAST || sleep_time < 0) {
+               g_print("Wrong Parameter\n");
+               return;
+       }
+
+       if (sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, _stream_focus_cb, NULL, &stream_info)) {
+               g_print("failed to create stream info\n");
+               return;
+       }
+
+       for (i = from; i <= to; i++) {
+               g_print("* Playing Tone : %3d -> ", i);
+               tone_player_start_new(i, stream_info, duration, &id);
+               g_print("id(%d) ", id);
+
+               if (duration != sleep_time)
+                       g_timeout_add(sleep_time, _g_timeout_cb, (void *)id);
+
+               for (j = 0; j < sleep_time / 100; j++) {
+                       g_print(".");
+                       usleep(100*1000);
+               }
+
+               usleep(1000*1000);
+               g_print(" *\n");
+       }
+
+       sound_manager_destroy_stream_information(stream_info);
+
+       g_main_loop_quit(g_mainloop);
+}
+
+int main(int argc, char **argv)
+{
+       int from = TONE_TYPE_DTMF_0, to = TONE_TYPE_DTMF_S;
+       int duration = 500, sleep_time = -1;
+
+       while (1) {
+               int opt;
+               int opt_idx = 0;
+
+               static struct option long_options[] = {
+                       {"from", required_argument, 0, 'f'},
+                       {"to", required_argument, 0, 't'},
+                       {"duration", required_argument, 0, 'd'},
+                       {"sleep", required_argument, 0, 's'},
+                       {"help", no_argument, 0, 'h'},
+                       {0, 0, 0, 0}
+               };
+
+               if ((opt = getopt_long(argc, argv, "f:t:d:s:h", long_options, &opt_idx)) == -1)
+                       break;
+
+               switch (opt) {
+               case 'f':
+                       from = atoi(optarg);
+                       if (from < TONE_FIRST)
+                               from = TONE_FIRST;
+                       else if (from > TONE_LAST)
+                               from = TONE_LAST;
+                       break;
+               case 't':
+                       to = atoi(optarg);
+                       if (to < TONE_FIRST)
+                               to = TONE_FIRST;
+                       else if (to > TONE_LAST)
+                               to = TONE_LAST;
+                       break;
+               case 'd':
+                       duration = atoi(optarg);
+                       break;
+               case 's':
+                       sleep_time = atoi(optarg);
+                       break;
+               case 'h':
+               default:
+                       _help();
+                       return 0;
+               }
+       }
+
+       if (sleep_time == -1)
+               sleep_time = duration;
+
+       event_thread = g_thread_new(NULL, _g_mainloop_thread, NULL);
+
+       _tone_play_test(from, to, duration, sleep_time);
+
+       g_print("Now join the thread, ");
+       g_thread_join(event_thread);
+       g_print("Done, QUIT testsuite\n");
+
+       return 0;
+}