diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2015-05-26 23:12:32 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2015-05-26 23:12:38 +0900 |
commit | 95f315117a095b669242e8825c175950d17f9fa4 (patch) | |
tree | 95cd6931715103e75667c67aa903a919e3afd247 /test-app | |
parent | e2d0fd3305a95ef36c66d31c580bf64c79656059 (diff) | |
parent | 0675c26b3ccb723c39432088e28a1041d4d12260 (diff) | |
download | notification-95f315117a095b669242e8825c175950d17f9fa4.tar.gz notification-95f315117a095b669242e8825c175950d17f9fa4.tar.bz2 notification-95f315117a095b669242e8825c175950d17f9fa4.zip |
Merge branch 'tizen_2.4' of ssh://spin:29418/apps/home/notification into tizensubmit/tizen_mobile/20150529.103300submit/tizen_mobile/20150527.071719
Conflicts:
CMakeLists.txt
include/notification.h
include/notification_internal.h
include/notification_list.h
include/notification_status.h
include/notification_type.h
packaging/notification.spec
src/notification.c
src/notification_noti.c
test-app/CMakeLists.txt
test-app/main.c
Change-Id: I879a434de924aaf724679a42d26f2586ba616fde
Signed-off-by: Sung-jae Park <nicesj.park@samsung.com>
Diffstat (limited to 'test-app')
-rw-r--r-- | test-app/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test-app/main.c | 452 |
2 files changed, 404 insertions, 50 deletions
diff --git a/test-app/CMakeLists.txt b/test-app/CMakeLists.txt index 5d09def..efa40eb 100644 --- a/test-app/CMakeLists.txt +++ b/test-app/CMakeLists.txt @@ -35,7 +35,7 @@ FOREACH(flag ${test_app_pkgs_CFLAGS}) ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") -SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie ") +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") ADD_EXECUTABLE(notification-test-app ${TEST-APP-SRCS}) TARGET_LINK_LIBRARIES(notification-test-app ${test_app_pkgs_LDFLAGS} notification) diff --git a/test-app/main.c b/test-app/main.c index 229219a..95693ab 100644 --- a/test-app/main.c +++ b/test-app/main.c @@ -34,12 +34,15 @@ /* notification header */ #include <notification.h> #include <notification_status.h> +#include <notification_setting.h> +#include <notification_setting_internal.h> /*-----------------------------------------------------------------------------------------*/ /* types */ typedef enum testapp_menu_type { TESTAPP_MENU_TYPE_MAIN_MENU = 1, TESTAPP_MENU_TYPE_BASIC_TEST_MENU = 2, + TESTAPP_MENU_TYPE_SETTING_TEST_MENU = 3 } testapp_menu_type_e; /*-----------------------------------------------------------------------------------------*/ @@ -133,6 +136,7 @@ void testapp_show_menu (testapp_menu_type_e menu) testapp_print (" Notification test application \n"); testapp_print ("==========================================\n"); testapp_print ("1. Basic Test\n"); + testapp_print ("2. Setting Test\n"); testapp_print ("0. Exit \n"); testapp_print ("------------------------------------------\n"); break; @@ -145,6 +149,18 @@ void testapp_show_menu (testapp_menu_type_e menu) testapp_print (" 3. Post a notification on indicator\n"); testapp_print (" 4. Post status status message\n"); testapp_print (" 5. Delete all notification\n"); + testapp_print (" 6. Post a heads notification with a button\n"); + testapp_print (" 7. Post a notification with domain text\n"); + testapp_print ("------------------------------------------\n"); + break; + case TESTAPP_MENU_TYPE_SETTING_TEST_MENU: + testapp_print ("==========================================\n"); + testapp_print (" Setting test menu \n"); + testapp_print ("==========================================\n"); + testapp_print (" 1. Get setting list\n"); + testapp_print (" 2. Update setting\n"); + testapp_print (" 3. Update system setting\n"); + testapp_print (" 4. Refresh setting table\n"); testapp_print ("------------------------------------------\n"); break; default: @@ -175,6 +191,8 @@ static int testapp_add_a_notification() noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_INFO_3, "I'm Info 3", "INFO_3", NOTIFICATION_VARIABLE_TYPE_NONE); 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); + noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER); + noti_err = notification_post(noti_handle); if (noti_err != NOTIFICATION_ERROR_NONE) { @@ -182,7 +200,7 @@ static int testapp_add_a_notification() goto FINISH_OFF; } -FINISH_OFF: + FINISH_OFF: if (noti_handle) notification_free(noti_handle); @@ -202,7 +220,7 @@ static int testapp_test_post_notification() } -FINISH_OFF: + FINISH_OFF: return err; } @@ -225,8 +243,7 @@ static int testapp_test_post_notifications() } } - -FINISH_OFF: + FINISH_OFF: return err; } @@ -243,9 +260,9 @@ static int testapp_test_post_notification_on_indicator() } noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE); - noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE); + noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "This is very loooooooooooooooooooooooooooooooooooooooooong message", NOTIFICATION_VARIABLE_TYPE_NONE); - noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_INDICATOR); + noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_TICKER | NOTIFICATION_DISPLAY_APP_INDICATOR); if(noti_err != NOTIFICATION_ERROR_NONE) { testapp_print("notification_set_display_applist failed[%d]", noti_err); @@ -259,7 +276,7 @@ static int testapp_test_post_notification_on_indicator() goto FINISH_OFF; } -FINISH_OFF: + FINISH_OFF: if (noti_handle) notification_free(noti_handle); @@ -291,60 +308,389 @@ static int testapp_test_delete_all_notifications() return noti_err; } +static int testapp_test_post_heads_up_notification_with_button() +{ + notification_h noti_handle = NULL; + int noti_err = NOTIFICATION_ERROR_NONE; + int app_control_err = APP_CONTROL_ERROR_NONE; + int priv_id = 0; + int group_id = 0; + char *app_id = NULL; + app_control_h app_control = NULL; + time_t result = time(NULL); + char tag[100] = { 0, }; + + noti_handle = notification_create(NOTIFICATION_TYPE_NOTI); + + if (noti_handle == NULL) { + testapp_print("notification_create failed"); + goto FINISH_OFF; + } + + noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE); + noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "CONTENT", NOTIFICATION_VARIABLE_TYPE_NONE); + + noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_HEADS_UP | NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + snprintf(tag, 100, "%d", result); + + noti_err = notification_set_tag(noti_handle, tag); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_set_display_applist failed[%d]\n", noti_err); + goto FINISH_OFF; + } + + app_control_err = app_control_create(&app_control); + if (app_control_err != APP_CONTROL_ERROR_NONE ) { + testapp_print("app_control_create failed[%d]\n", app_control_err); + goto FINISH_OFF; + } + + app_control_err = app_control_set_app_id(app_control, "org.tizen.quickpanel"); + if (app_control_err != APP_CONTROL_ERROR_NONE ) { + testapp_print("app_control_set_app_id failed[%d]\n", app_control_err); + goto FINISH_OFF; + } + + noti_err = notification_set_event_handler(noti_handle, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, app_control); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_set_event_handler failed[%d]", noti_err); + goto FINISH_OFF; + } + + app_control_destroy(app_control); + app_control = NULL; + + noti_err = notification_post(noti_handle); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_post failed[%d]", noti_err); + goto FINISH_OFF; + } + + noti_err = notification_get_id(noti_handle, &group_id, &priv_id); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_get_id failed[%d]", noti_err); + goto FINISH_OFF; + } + + if (noti_handle) + notification_free(noti_handle); + noti_handle = NULL; + + noti_handle = notification_load(NULL, priv_id); + + if (noti_handle == NULL) { + testapp_print("notification_load failed"); + goto FINISH_OFF; + } + + noti_err = notification_get_event_handler(noti_handle, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, &app_control); + + if (noti_err != NOTIFICATION_ERROR_NONE ||app_control == NULL) { + testapp_print("notification_get_event_handler failed[%d]", noti_err); + goto FINISH_OFF; + } + + app_control_get_app_id(app_control, &app_id); + + if (app_id) { + testapp_print("result app_id [%s]\n", app_id); + free(app_id); + } + +FINISH_OFF: + + if (app_control) + app_control_destroy(app_control); + + if (noti_handle) + notification_free(noti_handle); + + return noti_err; +} + +static int testapp_test_post_notification_with_domain_text() +{ + notification_h noti_handle = NULL; + int noti_err = NOTIFICATION_ERROR_NONE; + int app_control_err = APP_CONTROL_ERROR_NONE; + int priv_id = 0; + int group_id = 0; + char *app_id = NULL; + time_t result = time(NULL); + char tag[100] = { 0, }; + + noti_handle = notification_create(NOTIFICATION_TYPE_NOTI); + + if (noti_handle == NULL) { + testapp_print("notification_create failed"); + goto FINISH_OFF; + } + + noti_err = notification_set_text_domain(noti_handle, "message", "/usr/apps/org.tizen.message/res/locale"); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_set_display_applist failed[%d]\n", noti_err); + goto FINISH_OFF; + } + + noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_TITLE, "I'm Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE); + noti_err = notification_set_text(noti_handle, NOTIFICATION_TEXT_TYPE_CONTENT, "I'm Content", "[%s] *** [%s]", + NOTIFICATION_VARIABLE_TYPE_STRING, "IDS_MSGF_BODY_NO_SUBJECT", + NOTIFICATION_VARIABLE_TYPE_STRING, "IDS_MSGF_POP_NEW_MESSAGE", + NOTIFICATION_VARIABLE_TYPE_NONE); + + noti_err = notification_set_display_applist(noti_handle, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_set_display_applist failed[%d]\n", noti_err); + goto FINISH_OFF; + } + + snprintf(tag, 100, "%d", result); + + noti_err = notification_set_tag(noti_handle, tag); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_set_tag failed[%d]\n", noti_err); + goto FINISH_OFF; + } + + noti_err = notification_post(noti_handle); + + if (noti_err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_post failed[%d]", noti_err); + goto FINISH_OFF; + } + +FINISH_OFF: + + + if (noti_handle) + notification_free(noti_handle); + + return noti_err; +} + static gboolean testapp_interpret_command_basic_test (int selected_number) { - gboolean go_to_loop = TRUE; + gboolean go_to_loop = TRUE; - switch (selected_number) { - case 1: - testapp_test_post_notification(); - break; + switch (selected_number) { + case 1: + testapp_test_post_notification(); + break; - case 2: - testapp_test_post_notifications(); - break; + case 2: + testapp_test_post_notifications(); + break; - case 3: - testapp_test_post_notification_on_indicator(); - break; + case 3: + testapp_test_post_notification_on_indicator(); + break; - case 4: - testapp_test_post_status_message(); - break; + case 4: + testapp_test_post_status_message(); + break; - case 5: - testapp_test_delete_all_notifications(); - break; + case 5: + testapp_test_delete_all_notifications(); + break; - case 0: - go_to_loop = FALSE; - break; + case 6: + testapp_test_post_heads_up_notification_with_button(); + break; - default: - break; - } + case 7: + testapp_test_post_notification_with_domain_text(); + break; - return go_to_loop; + case 0: + go_to_loop = FALSE; + break; + + default: + break; + } + + return go_to_loop; } void testapp_notification_main () { - gboolean go_to_loop = TRUE; - int menu_number = 0; + gboolean go_to_loop = TRUE; + int menu_number = 0; - while (go_to_loop) { - testapp_show_menu (TESTAPP_MENU_TYPE_BASIC_TEST_MENU); - testapp_show_prompt (TESTAPP_MENU_TYPE_BASIC_TEST_MENU); + while (go_to_loop) { + testapp_show_menu (TESTAPP_MENU_TYPE_BASIC_TEST_MENU); + testapp_show_prompt (TESTAPP_MENU_TYPE_BASIC_TEST_MENU); - if (0 >= scanf("%d", &menu_number)) - testapp_print("Invalid input"); + if (0 >= scanf("%d", &menu_number)) + testapp_print("Invalid input"); - go_to_loop = testapp_interpret_command_basic_test(menu_number); - } + go_to_loop = testapp_interpret_command_basic_test(menu_number); + } } /* Basic Test } ---------------------------------------------------------------*/ +/* Setting Test } ---------------------------------------------------------------*/ + +static int testapp_test_get_setting_list() +{ + int err = NOTIFICATION_ERROR_NONE; + int i = 0; + int count = 0; + char *package_name = NULL; + bool allow_to_notify = false; + bool do_not_disturb_except = false; + bool visibility_class = false; + notification_setting_h setting_array = NULL; + + notification_setting_get_setting_array(&setting_array, &count); + + testapp_print("count [%d]\n", count); + + for (i = 0; i < count; i++) { + notification_setting_get_package_name(setting_array + i, &package_name); + notification_setting_get_allow_to_notify(setting_array + i, &allow_to_notify); + notification_setting_get_do_not_disturb_except(setting_array + i, &do_not_disturb_except); + notification_setting_get_visibility_class(setting_array + i, &visibility_class); + + testapp_print("[%d] : package_name[%s], allow_to_notify[%d], do_not_disturb_except[%d], visibility_class[%d]\n" + ,i, package_name, allow_to_notify, do_not_disturb_except, visibility_class); + free(package_name); + } + + notification_setting_free_notification(setting_array); + + return err; +} + +static int testapp_test_update_setting() +{ + int err = NOTIFICATION_ERROR_NONE; + notification_setting_h setting = NULL; + + err = notification_setting_get_setting_by_package_name("org.tizen.internet", &setting); + + if (err != NOTIFICATION_ERROR_NONE || setting == NULL) { + testapp_print("notification_setting_get_setting_by_package_name failed [%d]", err); + } + else { + notification_setting_set_allow_to_notify(setting, 0); + notification_setting_update_setting(setting); + } + + return err; +} + +static int testapp_test_update_system_setting() +{ + int err = NOTIFICATION_ERROR_NONE; + bool do_not_disturb; + int visibility_class; + notification_system_setting_h system_setting = NULL; + + err = notification_system_setting_load_system_setting(&system_setting); + + if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) { + testapp_print("notification_system_setting_load_system_setting failed [%d]\n", err); + goto out; + } + + notification_system_setting_get_do_not_disturb(system_setting, &do_not_disturb); + testapp_print("do_not_disturb [%d]\n", do_not_disturb); + do_not_disturb = !do_not_disturb; + notification_system_setting_set_do_not_disturb(system_setting, do_not_disturb); + + notification_system_setting_get_visibility_class(system_setting, &visibility_class); + testapp_print("visibility_class [%d]\n", visibility_class); + visibility_class = !visibility_class; + notification_system_setting_set_visibility_class(system_setting, visibility_class); + + err = notification_system_setting_update_system_setting(system_setting); + + if (err != NOTIFICATION_ERROR_NONE || system_setting == NULL) { + testapp_print("notification_system_setting_update_system_setting failed [%d]\n", err); + goto out; + } + +out: + if (system_setting) + notification_system_setting_free_system_setting(system_setting); + + return err; +} + +static int testapp_test_refresh_setting_table() +{ + int err = NOTIFICATION_ERROR_NONE; + err = notification_setting_refresh_setting_table(); + + if (err != NOTIFICATION_ERROR_NONE) { + testapp_print("notification_setting_refresh_setting_table failed [%d]\n", err); + goto out; + } + +out: + + return err; +} + +static gboolean testapp_interpret_command_setting_test (int selected_number) +{ + gboolean go_to_loop = TRUE; + + switch (selected_number) { + case 1: + testapp_test_get_setting_list(); + break; + + case 2: + testapp_test_update_setting(); + break; + + case 3: + testapp_test_update_system_setting(); + break; + + case 4: + testapp_test_refresh_setting_table(); + break; + + case 0: + go_to_loop = FALSE; + break; + + default: + break; + } + + return go_to_loop; + +} + +void testapp_setting_main() +{ + gboolean go_to_loop = TRUE; + int menu_number = 0; + + while (go_to_loop) { + testapp_show_menu (TESTAPP_MENU_TYPE_SETTING_TEST_MENU); + testapp_show_prompt (TESTAPP_MENU_TYPE_SETTING_TEST_MENU); + + if (0 >= scanf("%d", &menu_number)) + testapp_print("Invalid input"); + + go_to_loop = testapp_interpret_command_setting_test(menu_number); + } +} +/* Setting Test } ---------------------------------------------------------------*/ /* Main { ---------------------------------------------------------------------*/ static gboolean testapp_interpret_command (int menu_number) @@ -356,6 +702,10 @@ static gboolean testapp_interpret_command (int menu_number) testapp_notification_main(); break; + case 2: + testapp_setting_main(); + break; + case 0: go_to_loop = FALSE; break; @@ -369,15 +719,19 @@ static gboolean testapp_interpret_command (int menu_number) void testapp_show_prompt (testapp_menu_type_e menu) { - switch (menu) { - case TESTAPP_MENU_TYPE_MAIN_MENU: - testapp_print ("[MAIN]# "); - break; - - case TESTAPP_MENU_TYPE_BASIC_TEST_MENU: - testapp_print ("[BASIC_TEST]# "); - break; - } + switch (menu) { + case TESTAPP_MENU_TYPE_MAIN_MENU: + testapp_print ("[MAIN]# "); + break; + + case TESTAPP_MENU_TYPE_BASIC_TEST_MENU: + testapp_print ("[BASIC_TEST]# "); + break; + + case TESTAPP_MENU_TYPE_SETTING_TEST_MENU: + testapp_print ("[SETTING_TEST]# "); + break; + } } int main (int argc, char *argv[]) |