4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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.
34 #include "email-api-init.h"
37 #include "testapp-utility.h"
38 #include "testapp-account.h"
39 #include "testapp-mail.h"
40 #include "testapp-mailbox.h"
41 #include "testapp-rule.h"
42 #include "testapp-thread.h"
43 #include "testapp-others.h"
46 /* function prototype */
47 static void testapp_system_signal_handler (int signal_number);
51 static gboolean testapp_initialize_testing ()
53 struct timeval tv_1, tv_2;
57 /* register signal handler */
58 if ( signal (SIGINT, testapp_system_signal_handler) == SIG_ERR ) {
59 testapp_print ("register signal handler fail\n");
63 if ( signal (SIGQUIT, testapp_system_signal_handler) == SIG_ERR ) {
64 testapp_print ("register signal handler fail\n");
68 if ( signal (SIGTSTP, testapp_system_signal_handler) == SIG_ERR ) {
69 testapp_print ("register signal handler fail\n");
73 if ( signal (SIGTERM, testapp_system_signal_handler) == SIG_ERR ) {
74 testapp_print ("register signal handler fail\n");
79 gettimeofday(&tv_1, NULL);
81 if ( email_service_begin() != EMAIL_ERROR_NONE ) {
82 testapp_print ("unexpected error: opening email service fail\n");
85 gettimeofday(&tv_2, NULL);
86 interval = tv_2.tv_usec - tv_1.tv_usec;
87 testapp_print("\t email_service_begin Proceed time %d us\n",interval);
89 gettimeofday(&tv_1, NULL);
90 if ( (error = email_open_db()) != EMAIL_ERROR_NONE) {
91 testapp_print("email_open_db failed [%d]\n", error);
93 gettimeofday(&tv_2, NULL);
94 interval = tv_2.tv_usec - tv_1.tv_usec;
95 testapp_print("\t email_open_db Proceed time %d us\n",interval);
100 static gboolean testapp_finalize_testing ()
104 if ( (error = email_close_db()) != EMAIL_ERROR_NONE) {
105 testapp_print("email_close_db failed [%d]\n", error);
108 if ( email_service_end() != EMAIL_ERROR_NONE) {
109 testapp_print ("unexpected error: closing email service fail \n");
115 static void testapp_system_signal_handler (int signal_number)
117 testapp_print ("signal:%d\n", signal_number);
118 switch (signal_number) {
123 testapp_finalize_testing();
127 testapp_print ("unhandled signal:%d\n", signal_number);
134 static gboolean testapp_interpret_command (int menu_number)
136 gboolean go_to_loop = TRUE;
138 switch (menu_number) {
140 testapp_account_main();
148 email_test_mailbox_main();
155 email_test_rule_main();
159 testapp_thread_main();
163 testapp_others_main();
175 int main (int argc, char *argv[])
177 gboolean go_to_loop = TRUE;
179 int result_from_scanf = 0;
181 if ( testapp_initialize_testing() == FALSE ) {
182 testapp_print ("email-serivce is not ready\n");
187 testapp_show_menu (EMAIL_MAIN_MENU);
188 testapp_show_prompt (EMAIL_MAIN_MENU);
190 result_from_scanf = scanf ("%d", &menu_number);
192 go_to_loop = testapp_interpret_command (menu_number);
195 testapp_finalize_testing();