2da2fd53c8407b3b2d3c3ebc85339c0fbc28ac8d
[framework/appfw/alarm-manager.git] / test / test_redirection_20001.c
1 /*
2  *  alarm-manager
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Venkatesha Sarpangala <sarpangala.v@samsung.com>, Jayoun Lee <airjany@samsung.com>,
7  * Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #include<stdio.h>
24 #include<stdlib.h>
25 #include<glib.h>
26
27 #include "alarm.h"
28
29 int callback(alarm_id_t alarm_id)
30 {
31     int error;
32     time_t current_time;
33     time(&current_time);
34
35     printf("\nB:Alarm[%d] has expired at %s\n", alarm_id, ctime(&current_time));
36
37     return 0;
38
39 }
40
41
42
43 void create_test()
44 {
45     time_t current_time;
46     struct tm current_tm;
47     alarm_info_t alarm_info;
48
49     alarm_id_t alarm_id_1;
50     alarm_id_t alarm_id_2;
51     alarm_id_t alarm_id_3;
52
53     int error_code;
54         bool result = false;
55
56
57     time(&current_time);
58
59     printf("current time: %s\n", ctime(&current_time));
60     localtime_r(&current_time, &current_tm);
61
62     alarm_info.start.year = 0;
63     alarm_info.start.month = 0;
64     alarm_info.start.day = 0;
65
66     alarm_info.end.year = 2008;
67     alarm_info.end.month = 12;
68     alarm_info.end.day = 31;
69
70     alarm_info.start.hour = current_tm.tm_hour;
71     alarm_info.start.min = current_tm.tm_min+1;
72
73     alarm_info.mode.day_of_week = 0;
74     alarm_info.mode.repeat = ALARM_REPEAT_MODE_ONCE;
75
76     alarm_info.activation = true;
77     alarm_info.auto_powerup = false;
78         
79         alarm_info.alarm_type = LOCAL_TIME_FIXED;
80         
81         alarm_info.reserved_info = 20002;
82
83     result = alarm_create(&alarm_info, &alarm_id_1, &error_code);
84         if (!result)
85         {
86                 printf("test 1 failed: %d\n", error_code);
87         }
88
89         alarm_info.reserved_info = 20001;
90
91     result = alarm_create(&alarm_info, &alarm_id_2, &error_code);
92         if (!result)
93         {
94                 printf("test 2 failed: %d\n", error_code);
95         }
96
97         alarm_info.reserved_info = 0;
98
99     result = alarm_create(&alarm_info, &alarm_id_3, &error_code);
100         if (!result)
101         {
102                 printf("test 3 failed: %d\n", error_code);
103         }
104
105 }
106
107
108
109 int main(int argc, char** argv)
110 {
111     int error_code;
112     GMainLoop *mainloop;
113     mainloop = g_main_loop_new(NULL, FALSE);
114
115     alarm_init(&error_code);
116     alarm_set_cb(callback, &error_code);
117
118     create_test();
119
120     g_main_loop_run(mainloop);
121
122     alarm_fini(&error_code);
123 }