Fix a bug on notifciation_get_text.
[platform/core/api/notification.git] / test-app / main.c
1 /*
2  *  Test application for notification API
3  *
4  * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Kyuho Jo <kyuho.jo@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23
24 /* common header */
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <signal.h>
28 #include <sys/time.h>
29 #include <unistd.h>
30
31 /* open header */
32 #include <glib.h>
33
34 /* notification header */
35 #include <notification.h>
36 #include <notification_status.h>
37 #include <notification_setting.h>
38 #include <notification_setting_internal.h>
39
40 /*-----------------------------------------------------------------------------------------*/
41 /* types */
42 typedef enum testapp_menu_type {
43         TESTAPP_MENU_TYPE_MAIN_MENU = 1,
44         TESTAPP_MENU_TYPE_BASIC_TEST_MENU = 2,
45         TESTAPP_MENU_TYPE_SETTING_TEST_MENU = 3
46 } testapp_menu_type_e;
47
48 /*-----------------------------------------------------------------------------------------*/
49 /* function prototypes */
50 static void testapp_system_signal_handler (int signal_number);
51 void testapp_show_prompt (testapp_menu_type_e menu);
52
53 /*-----------------------------------------------------------------------------------------*/
54 /* implementation */
55 void testapp_print (char *fmt, ...)
56 {
57         va_list args = {0};
58         va_start(args, fmt);
59         vfprintf (stdout, fmt, args);
60         va_end (args);
61         fflush (stdout);
62 }
63
64 static gboolean testapp_initialize_testing ()
65 {
66         struct timeval tv_1, tv_2;
67         int interval;
68
69         /* register signal handler */
70         if ( signal (SIGINT, testapp_system_signal_handler) == SIG_ERR ) {
71                 testapp_print ("register signal handler fail\n");
72                 return FALSE;
73         }
74
75         if ( signal (SIGQUIT, testapp_system_signal_handler) == SIG_ERR ) {
76                 testapp_print ("register signal handler fail\n");
77                 return FALSE;
78         }
79
80         if ( signal (SIGTSTP, testapp_system_signal_handler) == SIG_ERR ) {
81                 testapp_print ("register signal handler fail\n");
82                 return FALSE;
83         }
84
85         if ( signal (SIGTERM, testapp_system_signal_handler) == SIG_ERR ) {
86                 testapp_print ("register signal handler fail\n");
87                 return FALSE;
88         }
89
90
91         gettimeofday(&tv_1, NULL);
92
93         /* TODO : initializing notification */
94
95         gettimeofday(&tv_2, NULL);
96         interval = tv_2.tv_usec - tv_1.tv_usec;
97         testapp_print("\t Initializing Proceed time %d us\n",interval);
98
99
100         return TRUE;
101 }
102
103 static gboolean testapp_finalize_testing ()
104 {
105         /* TODO : finalizing notification */
106
107         return TRUE;
108 }
109
110 static void testapp_system_signal_handler (int signal_number)
111 {
112         testapp_print ("signal:%d\n", signal_number);
113         switch (signal_number) {
114         case SIGQUIT:
115         case SIGINT:
116         case SIGTSTP:
117         case SIGTERM:
118                 testapp_finalize_testing();
119                 break;
120
121         default:
122                 testapp_print ("unhandled signal:%d\n", signal_number);
123                 break;
124         }
125         exit(0);
126 }
127
128
129
130
131 void testapp_show_menu (testapp_menu_type_e menu)
132 {
133         switch (menu) {
134         case TESTAPP_MENU_TYPE_MAIN_MENU:
135                 testapp_print ("==========================================\n");
136                 testapp_print ("    Notification test application \n");
137                 testapp_print ("==========================================\n");
138                 testapp_print ("1. Basic Test\n");
139                 testapp_print ("2. Setting Test\n");
140                 testapp_print ("0. Exit \n");
141                 testapp_print ("------------------------------------------\n");
142                 break;
143         case TESTAPP_MENU_TYPE_BASIC_TEST_MENU:
144                 testapp_print ("==========================================\n");
145                 testapp_print ("    Basic test menu \n");
146                 testapp_print ("==========================================\n");
147                 testapp_print (" 1.  Post a simple notification\n");
148                 testapp_print (" 2.  Post simple notifications repeatedly\n");
149                 testapp_print (" 3.  Post a notification on indicator\n");
150                 testapp_print (" 4.  Post status status message\n");
151                 testapp_print (" 5.  Delete all notification\n");
152                 testapp_print (" 6.  Post a heads notification with a button\n");
153                 testapp_print (" 7.  Post a notification with domain text\n");
154                 testapp_print ("------------------------------------------\n");
155                 break;
156         case TESTAPP_MENU_TYPE_SETTING_TEST_MENU:
157                 testapp_print ("==========================================\n");
158                 testapp_print ("    Setting test menu \n");
159                 testapp_print ("==========================================\n");
160                 testapp_print (" 1.  Get setting list\n");
161                 testapp_print (" 2.  Update setting\n");
162                 testapp_print (" 3.  Update system setting\n");
163                 testapp_print (" 4.  Refresh setting table\n");
164                 testapp_print ("------------------------------------------\n");
165                 break;
166         default:
167                 break;
168         }
169 }
170 /* Common { ------------------------------------------------------------------*/
171
172 static int testapp_add_a_notification()
173 {
174         notification_h noti_handle = NULL;
175         int noti_err = NOTIFICATION_ERROR_NONE;
176
177         noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
178
179         if (noti_handle == NULL) {
180                 testapp_print("notification_create failed");
181                 goto FINISH_OFF;
182         }
183
184         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
185         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE);
186         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, "3", "3", NOTIFICATION_VARIABLE_TYPE_NONE);
187         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_1, "I'm Info 1", "INFO_1", NOTIFICATION_VARIABLE_TYPE_NONE);
188         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, "I'm Info Sub 1", "INFO_SUB_1", NOTIFICATION_VARIABLE_TYPE_NONE);
189         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_2, "I'm Info 2", "INFO_2", NOTIFICATION_VARIABLE_TYPE_NONE);
190         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, "I'm Info Sub 2", "INFO_SUB_2", NOTIFICATION_VARIABLE_TYPE_NONE);
191         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_3, "I'm Info 3", "INFO_3", NOTIFICATION_VARIABLE_TYPE_NONE);
192         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, "I'm Info Sub 3", "INFO_SUB_3", NOTIFICATION_VARIABLE_TYPE_NONE);
193
194         noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER);
195
196         noti_err  = notification_post(noti_handle);
197
198         if (noti_err != NOTIFICATION_ERROR_NONE) {
199                 testapp_print("notification_post failed[%d]", noti_err);
200                 goto FINISH_OFF;
201         }
202
203         FINISH_OFF:
204         if (noti_handle)
205                 notification_free(noti_handle);
206
207         return noti_err;
208 }
209
210 /* Common } ------------------------------------------------------------------*/
211
212 /* Basic Test { --------------------------------------------------------------*/
213 static int testapp_test_post_notification()
214 {
215         int err = NOTIFICATION_ERROR_NONE;
216
217         if ((err = testapp_add_a_notification()) != NOTIFICATION_ERROR_NONE) {
218                 testapp_print("testapp_add_a_notification failed[%d]", err);
219                 goto FINISH_OFF;
220         }
221
222
223         FINISH_OFF:
224
225         return err;
226 }
227
228 static int testapp_test_post_notifications()
229 {
230         int err = NOTIFICATION_ERROR_NONE;
231         int repeat_count = 0;
232         int i = 0;
233
234         testapp_print("Input count : ");
235
236         if (0 >= scanf("%d", &repeat_count))
237                 testapp_print("Invalid input");
238
239         for (i = 0; i < repeat_count; i++) {
240                 if ((err = testapp_add_a_notification()) != NOTIFICATION_ERROR_NONE) {
241                         testapp_print("testapp_add_a_notification failed[%d]", err);
242                         goto FINISH_OFF;
243                 }
244         }
245
246         FINISH_OFF:
247         return err;
248 }
249
250 static int testapp_test_post_notification_on_indicator()
251 {
252         notification_h noti_handle = NULL;
253         int noti_err = NOTIFICATION_ERROR_NONE;
254
255         noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
256
257         if (noti_handle == NULL) {
258                 testapp_print("notification_create failed");
259                 goto FINISH_OFF;
260         }
261
262         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
263         noti_err  = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "This is very loooooooooooooooooooooooooooooooooooooooooong message", NOTIFICATION_VARIABLE_TYPE_NONE);
264
265         noti_err  = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR);
266
267         if(noti_err != NOTIFICATION_ERROR_NONE) {
268                 testapp_print("notification_set_display_applist failed[%d]", noti_err);
269                 goto FINISH_OFF;
270         }
271
272         noti_err  = notification_post(noti_handle);
273
274         if (noti_err != NOTIFICATION_ERROR_NONE) {
275                 testapp_print("notification_post failed[%d]", noti_err);
276                 goto FINISH_OFF;
277         }
278
279         FINISH_OFF:
280         if (noti_handle)
281                 notification_free(noti_handle);
282
283         return noti_err;
284 }
285
286 static int testapp_test_post_status_message()
287 {
288         int noti_err = NOTIFICATION_ERROR_NONE;
289
290
291         noti_err = notification_status_message_post("This is only a test");
292
293         if(noti_err != NOTIFICATION_ERROR_NONE) {
294                 testapp_print("notification_status_message_post failed[%d]", noti_err);
295         }
296
297         return noti_err;
298 }
299
300 static int testapp_test_delete_all_notifications()
301 {
302         int noti_err = NOTIFICATION_ERROR_NONE;
303
304         noti_err = notification_delete_all(NOTIFICATION_TYPE_NOTI);
305
306         testapp_print("notification_delete_all returns[%d]", noti_err);
307
308         return noti_err;
309 }
310
311 static int testapp_test_post_heads_up_notification_with_button()
312 {
313         notification_h noti_handle = NULL;
314         int noti_err = NOTIFICATION_ERROR_NONE;
315         int app_control_err = APP_CONTROL_ERROR_NONE;
316         int priv_id = 0;
317         int group_id = 0;
318         char *app_id = NULL;
319         app_control_h app_control = NULL;
320         time_t result = time(NULL);
321         char tag[100] = { 0, };
322
323         noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
324
325         if (noti_handle == NULL) {
326                 testapp_print("notification_create failed");
327                 goto FINISH_OFF;
328         }
329
330         noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
331         noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE);
332
333         noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_HEADS_UP | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
334
335         snprintf(tag, 100, "%d", result);
336
337         noti_err = notification_set_tag(noti_handle, tag);
338
339         if (noti_err != NOTIFICATION_ERROR_NONE) {
340                 testapp_print("notification_set_display_applist failed[%d]\n", noti_err);
341                 goto FINISH_OFF;
342         }
343
344         app_control_err = app_control_create(&app_control);
345         if (app_control_err != APP_CONTROL_ERROR_NONE ) {
346                 testapp_print("app_control_create failed[%d]\n", app_control_err);
347                 goto FINISH_OFF;
348         }
349
350         app_control_err = app_control_set_app_id(app_control, "org.tizen.quickpanel");
351         if (app_control_err != APP_CONTROL_ERROR_NONE ) {
352                 testapp_print("app_control_set_app_id failed[%d]\n", app_control_err);
353                 goto FINISH_OFF;
354         }
355
356         noti_err = notification_set_event_handler(noti_handle, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, app_control);
357
358         if (noti_err != NOTIFICATION_ERROR_NONE) {
359                 testapp_print("notification_set_event_handler failed[%d]", noti_err);
360                 goto FINISH_OFF;
361         }
362
363         app_control_destroy(app_control);
364         app_control = NULL;
365
366         noti_err = notification_post(noti_handle);
367
368         if (noti_err != NOTIFICATION_ERROR_NONE) {
369                 testapp_print("notification_post failed[%d]", noti_err);
370                 goto FINISH_OFF;
371         }
372
373         noti_err = notification_get_id(noti_handle, &group_id, &priv_id);
374
375         if (noti_err != NOTIFICATION_ERROR_NONE) {
376                 testapp_print("notification_get_id failed[%d]", noti_err);
377                 goto FINISH_OFF;
378         }
379
380         if (noti_handle)
381                 notification_free(noti_handle);
382         noti_handle = NULL;
383
384         noti_handle = notification_load(NULL, priv_id);
385
386         if (noti_handle == NULL) {
387                 testapp_print("notification_load failed");
388                 goto FINISH_OFF;
389         }
390
391         noti_err = notification_get_event_handler(noti_handle, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, &app_control);
392
393         if (noti_err != NOTIFICATION_ERROR_NONE ||app_control == NULL) {
394                 testapp_print("notification_get_event_handler failed[%d]", noti_err);
395                 goto FINISH_OFF;
396         }
397
398         app_control_get_app_id(app_control, &app_id);
399
400         if (app_id) {
401                 testapp_print("result app_id [%s]\n", app_id);
402                 free(app_id);
403         }
404
405 FINISH_OFF:
406
407         if (app_control)
408                 app_control_destroy(app_control);
409
410         if (noti_handle)
411                 notification_free(noti_handle);
412
413         return noti_err;
414 }
415
416 static int testapp_test_post_notification_with_domain_text()
417 {
418         notification_h noti_handle = NULL;
419         int noti_err = NOTIFICATION_ERROR_NONE;
420         int app_control_err = APP_CONTROL_ERROR_NONE;
421         int priv_id = 0;
422         int group_id = 0;
423         char *app_id = NULL;
424         time_t result = time(NULL);
425         char tag[100] = { 0, };
426
427         noti_handle = notification_create(NOTIFICATION_TYPE_NOTI);
428
429         if (noti_handle == NULL) {
430                 testapp_print("notification_create failed");
431                 goto FINISH_OFF;
432         }
433
434         noti_err = notification_set_text_domain(noti_handle, "message", "/usr/apps/org.tizen.message/res/locale");
435
436         if (noti_err != NOTIFICATION_ERROR_NONE) {
437                 testapp_print("notification_set_display_applist failed[%d]\n", noti_err);
438                 goto FINISH_OFF;
439         }
440
441         noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
442         noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "[%s] *** [%s]",
443                         NOTIFICATION_VARIABLE_TYPE_STRING, "IDS_MSGF_BODY_NO_SUBJECT",
444                         NOTIFICATION_VARIABLE_TYPE_STRING, "IDS_MSGF_POP_NEW_MESSAGE",
445                         NOTIFICATION_VARIABLE_TYPE_NONE);
446
447         noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
448
449         if (noti_err != NOTIFICATION_ERROR_NONE) {
450                 testapp_print("notification_set_display_applist failed[%d]\n", noti_err);
451                 goto FINISH_OFF;
452         }
453
454         snprintf(tag, 100, "%d", result);
455
456         noti_err = notification_set_tag(noti_handle, tag);
457
458         if (noti_err != NOTIFICATION_ERROR_NONE) {
459                 testapp_print("notification_set_tag failed[%d]\n", noti_err);
460                 goto FINISH_OFF;
461         }
462
463         noti_err = notification_post(noti_handle);
464
465         if (noti_err != NOTIFICATION_ERROR_NONE) {
466                 testapp_print("notification_post failed[%d]", noti_err);
467                 goto FINISH_OFF;
468         }
469
470 FINISH_OFF:
471
472
473         if (noti_handle)
474                 notification_free(noti_handle);
475
476         return noti_err;
477 }
478
479 static gboolean testapp_interpret_command_basic_test (int selected_number)
480 {
481         gboolean go_to_loop = TRUE;
482
483         switch (selected_number) {
484         case 1:
485                 testapp_test_post_notification();
486                 break;
487
488         case 2:
489                 testapp_test_post_notifications();
490                 break;
491
492         case 3:
493                 testapp_test_post_notification_on_indicator();
494                 break;
495
496         case 4:
497                 testapp_test_post_status_message();
498                 break;
499
500         case 5:
501                 testapp_test_delete_all_notifications();
502                 break;
503
504         case 6:
505                 testapp_test_post_heads_up_notification_with_button();
506                 break;
507
508         case 7:
509                 testapp_test_post_notification_with_domain_text();
510                 break;
511
512         case 0:
513                 go_to_loop = FALSE;
514                 break;
515
516         default:
517                 break;
518         }
519
520         return go_to_loop;
521
522 }
523
524 void testapp_notification_main ()
525 {
526         gboolean go_to_loop = TRUE;
527         int menu_number = 0;
528
529         while (go_to_loop) {
530                 testapp_show_menu (TESTAPP_MENU_TYPE_BASIC_TEST_MENU);
531                 testapp_show_prompt (TESTAPP_MENU_TYPE_BASIC_TEST_MENU);
532
533                 if (0 >= scanf("%d", &menu_number))
534                         testapp_print("Invalid input");
535
536                 go_to_loop = testapp_interpret_command_basic_test(menu_number);
537         }
538 }
539 /* Basic Test } ---------------------------------------------------------------*/
540
541 /* Setting Test } ---------------------------------------------------------------*/
542
543 static int testapp_test_get_setting_list()
544 {
545         int err = NOTIFICATION_ERROR_NONE;
546         int i = 0;
547         int count = 0;
548         char *package_name = NULL;
549         bool  allow_to_notify = false;
550         bool  do_not_disturb_except = false;
551         bool  visibility_class = false;
552         notification_setting_h setting_array = NULL;
553
554         notification_setting_get_setting_array(&setting_array, &count);
555
556         testapp_print("count [%d]\n", count);
557
558         for (i = 0; i < count; i++) {
559                 notification_setting_get_package_name(setting_array + i, &package_name);
560                 notification_setting_get_allow_to_notify(setting_array + i, &allow_to_notify);
561                 notification_setting_get_do_not_disturb_except(setting_array + i, &do_not_disturb_except);
562                 notification_setting_get_visibility_class(setting_array + i, &visibility_class);
563
564                 testapp_print("[%d] : package_name[%s], allow_to_notify[%d], do_not_disturb_except[%d], visibility_class[%d]\n"
565                                 ,i, package_name, allow_to_notify, do_not_disturb_except, visibility_class);
566                 free(package_name);
567         }
568
569         notification_setting_free_notification(setting_array);
570
571         return err;
572 }
573
574 static int testapp_test_update_setting()
575 {
576         int err = NOTIFICATION_ERROR_NONE;
577         notification_setting_h setting = NULL;
578
579         err = notification_setting_get_setting_by_package_name("org.tizen.internet", &setting);
580
581         if (err != NOTIFICATION_ERROR_NONE || setting == NULL) {
582                 testapp_print("notification_setting_get_setting_by_package_name failed [%d]", err);
583         }
584         else {
585                 notification_setting_set_allow_to_notify(setting, 0);
586                 notification_setting_update_setting(setting);
587         }
588
589         return err;
590 }
591
592 static int testapp_test_update_system_setting()
593 {
594         int err = NOTIFICATION_ERROR_NONE;
595         bool do_not_disturb;
596         int visibility_class;
597         notification_system_setting_h system_setting = NULL;
598
599         err = notification_system_setting_load_system_setting(&system_setting);
600
601         if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
602                 testapp_print("notification_system_setting_load_system_setting failed [%d]\n", err);
603                 goto out;
604         }
605
606         notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb);
607         testapp_print("do_not_disturb [%d]\n", do_not_disturb);
608         do_not_disturb = !do_not_disturb;
609         notification_system_setting_set_do_not_disturb(system_setting, do_not_disturb);
610
611         notification_system_setting_get_visibility_class(system_setting, &visibility_class);
612         testapp_print("visibility_class [%d]\n", visibility_class);
613         visibility_class = !visibility_class;
614         notification_system_setting_set_visibility_class(system_setting, visibility_class);
615
616         err = notification_system_setting_update_system_setting(system_setting);
617
618         if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) {
619                 testapp_print("notification_system_setting_update_system_setting failed [%d]\n", err);
620                 goto out;
621         }
622
623 out:
624         if (system_setting)
625                 notification_system_setting_free_system_setting(system_setting);
626
627         return err;
628 }
629
630 static int testapp_test_refresh_setting_table()
631 {
632         int err = NOTIFICATION_ERROR_NONE;
633         err = notification_setting_refresh_setting_table();
634
635         if (err != NOTIFICATION_ERROR_NONE) {
636                 testapp_print("notification_setting_refresh_setting_table failed [%d]\n", err);
637                 goto out;
638         }
639
640 out:
641
642         return err;
643 }
644
645 static gboolean testapp_interpret_command_setting_test (int selected_number)
646 {
647         gboolean go_to_loop = TRUE;
648
649         switch (selected_number) {
650         case 1:
651                 testapp_test_get_setting_list();
652                 break;
653
654         case 2:
655                 testapp_test_update_setting();
656                 break;
657
658         case 3:
659                 testapp_test_update_system_setting();
660                 break;
661
662         case 4:
663                 testapp_test_refresh_setting_table();
664                 break;
665
666         case 0:
667                 go_to_loop = FALSE;
668                 break;
669
670         default:
671                 break;
672         }
673
674         return go_to_loop;
675
676 }
677
678 void testapp_setting_main()
679 {
680         gboolean go_to_loop = TRUE;
681         int menu_number = 0;
682
683         while (go_to_loop) {
684                 testapp_show_menu (TESTAPP_MENU_TYPE_SETTING_TEST_MENU);
685                 testapp_show_prompt (TESTAPP_MENU_TYPE_SETTING_TEST_MENU);
686
687                 if (0 >= scanf("%d", &menu_number))
688                         testapp_print("Invalid input");
689
690                 go_to_loop = testapp_interpret_command_setting_test(menu_number);
691         }
692 }
693 /* Setting Test } ---------------------------------------------------------------*/
694
695 /* Main { ---------------------------------------------------------------------*/
696 static gboolean testapp_interpret_command (int menu_number)
697 {
698         gboolean go_to_loop = TRUE;
699
700         switch (menu_number) {
701         case 1:
702                 testapp_notification_main();
703                 break;
704
705         case 2:
706                 testapp_setting_main();
707                 break;
708
709         case 0:
710                 go_to_loop = FALSE;
711                 break;
712
713         default:
714                 break;
715         }
716
717         return go_to_loop;
718 }
719
720 void testapp_show_prompt (testapp_menu_type_e menu)
721 {
722         switch (menu) {
723         case TESTAPP_MENU_TYPE_MAIN_MENU:
724                 testapp_print ("[MAIN]# ");
725                 break;
726
727         case TESTAPP_MENU_TYPE_BASIC_TEST_MENU:
728                 testapp_print ("[BASIC_TEST]# ");
729                 break;
730
731         case TESTAPP_MENU_TYPE_SETTING_TEST_MENU:
732                 testapp_print ("[SETTING_TEST]# ");
733                 break;
734         }
735 }
736
737 int main (int argc, char *argv[])
738 {
739         gboolean go_to_loop = TRUE;
740         int menu_number = 0;
741
742         if ( testapp_initialize_testing() == FALSE ) {
743                 testapp_print ("Initializing failed.\n");
744                 exit(0);
745         }
746
747         while (go_to_loop) {
748                 testapp_show_menu (TESTAPP_MENU_TYPE_MAIN_MENU);
749                 testapp_show_prompt (TESTAPP_MENU_TYPE_MAIN_MENU);
750                 if (0 >= scanf ("%d", &menu_number))
751                         testapp_print("Invalid input");
752                 go_to_loop = testapp_interpret_command (menu_number);
753         }
754
755         testapp_finalize_testing();
756
757         exit(0);
758 }
759 /* Main } ---------------------------------------------------------------------*/
760