d8c8c5ea161c7712ab85c2d55ab73b2c33d7db61
[test/tct/csharp/api.git] /
1 using System;\r
2 using Tizen;\r
3 using Tizen.Applications;\r
4 using System.Threading;\r
5 \r
6 namespace org.tizen.ApplicationManual.Tizen\r
7 {\r
8     class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication\r
9     {\r
10         protected override void OnPreCreate()\r
11         {\r
12             Log.Debug("TCT", "[TestCase][OnPreCreate][Application] Pass");\r
13             base.OnPreCreate();\r
14         }\r
15         protected override void OnCreate()\r
16         {\r
17             base.OnCreate();\r
18 \r
19             Log.Debug("TCT", "[TestCase][OnCreate][Application] Pass");\r
20 \r
21             LoadApplication(new App());\r
22         }\r
23 \r
24         protected override void OnResume()\r
25         {\r
26             Log.Debug("TCT", "[TestCase][OnResume][Application] Pass");\r
27             base.OnResume();\r
28         }\r
29 \r
30         protected override void OnPause()\r
31         {\r
32             Log.Debug("TCT", "[TestCase][OnPause][Application] Pass");\r
33             base.OnPause();\r
34         }\r
35 \r
36         protected override void OnTerminate()\r
37         {\r
38             Log.Debug("TCT", "Application::OnTerminate()");\r
39             Log.Debug("TCT", "[TestCase][OnTerminate][Application] Pass");\r
40             base.OnTerminate();\r
41         }\r
42 \r
43         protected override void OnAppControlReceived(AppControlReceivedEventArgs e)\r
44         {\r
45             Log.Debug("TCT", "Application::OnAppControlReceived()");\r
46             if (e.ReceivedAppControl != null)\r
47             {\r
48                 Log.Debug("TCT", "[TestCase][Test_Properties] ReceivedAppControl properties is not null");\r
49                 Log.Debug("TCT", "[TestCase][Test_Properties] ReceivedAppControl Type: " + e.ReceivedAppControl.GetType());\r
50             }\r
51             //logBuilder.AppendLine("TCT [TestCase][OnAppControlReceived] Pass");\r
52             Log.Debug("TCT", "[TestCase][OnAppControlReceived][Application] Pass");\r
53 \r
54             base.OnAppControlReceived(e);\r
55             ShowPropertiesInfo();\r
56         }\r
57 \r
58         protected override void OnLocaleChanged(LocaleChangedEventArgs e)\r
59         {\r
60             Log.Debug("TCT", "Application::OnLocaleChanged()");\r
61             if (e.Locale != null)\r
62             {\r
63                 Log.Debug("TCT", "[Test_Properties] Locale properties is not null");\r
64                 Log.Debug("TCT", "[Test_Properties] Current value of Locale : " + e.Locale);\r
65                 Log.Debug("TCT", "[Test_Properties] Locale type: " + e.Locale.GetType());\r
66             }\r
67             \r
68             Log.Debug("TCT", "[TestCase][OnLocaleChanged][Application] Pass");\r
69             base.OnLocaleChanged(e);\r
70         }\r
71 \r
72         protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)\r
73         {\r
74             Log.Debug("TCT", "Application::OnRegionFormatChanged()");\r
75             if (e != null)\r
76             {\r
77                 Log.Debug("TCT", "[Test_Properties] Region properties is not null");\r
78                 Log.Debug("TCT", "[Test_Properties] Current value of Region : " + e.Region);\r
79                 Log.Debug("TCT", "[Test_Properties] Region type: " + e.Region.GetType());\r
80             }\r
81 \r
82             Log.Debug("TCT", "[TestCase][OnRegionFormatChanged][Application] Pass");\r
83             base.OnRegionFormatChanged(e);\r
84         }\r
85 \r
86         protected override void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)\r
87         {\r
88             Log.Debug("TCT", "Application::OnDeviceOrientationChanged()");\r
89             if (e != null)\r
90             {\r
91                 Log.Debug("TCT", "[Test_Properties] DeviceOrientation properties is not null");\r
92                 Log.Debug("TCT", "[Test_Properties] Current value of DeviceOrientation : " + e.DeviceOrientation);\r
93                 Log.Debug("TCT", "[Test_Properties] DeviceOrientation type: " + e.DeviceOrientation.GetType());\r
94             }\r
95 \r
96             Log.Debug("TCT", "[TestCase][OnDeviceOrientationChanged][Application] Pass");\r
97             base.OnDeviceOrientationChanged(e);\r
98         }\r
99 \r
100         protected override void OnLowMemory(LowMemoryEventArgs e)\r
101         {\r
102             Log.Debug("TCT", "Application::OnLowMemory()");\r
103             if (e.LowMemoryStatus != LowMemoryStatus.None)\r
104             {\r
105                 Log.Debug("TCT", "[Test_Properties] LowMemoryStatus properties is not null");\r
106                 Log.Debug("TCT", "[Test_Properties] Current value of LowMemoryStatus : " + e.LowMemoryStatus.ToString());\r
107                 Log.Debug("TCT", "[Test_Properties] LowMemoryStatus type: " + e.LowMemoryStatus.GetType());\r
108             }\r
109             //logBuilder.AppendLine("TCT [TestCase][OnLowMemory] Pass");\r
110             Log.Debug("TCT", "[TestCase][OnLowMemory][Application] Pass");\r
111 \r
112             base.OnLowMemory(e);\r
113         }\r
114 \r
115         protected override void OnLowBattery(LowBatteryEventArgs e)\r
116         {\r
117             Log.Debug("TCT", "Application::OnLowBattery()");\r
118             if (e.LowBatteryStatus != LowBatteryStatus.None)\r
119             {\r
120                 Log.Debug("TCT", "[Test_Properties] LowBatteryStatus properties is not null");\r
121                 Log.Debug("TCT", "[Test_Properties] Current value of LowBatteryStatus : " + e.LowBatteryStatus.ToString());\r
122                 Log.Debug("TCT", "[Test_Properties] LowBatteryStatus type: " + e.LowBatteryStatus.GetType());\r
123             }\r
124 \r
125             Log.Debug("TCT", "[TestCase][OnLowBattery][Application] Pass");\r
126 \r
127             base.OnLowBattery(e);\r
128         }\r
129 \r
130         public override void Run(string[] args)\r
131         {\r
132             Created += Created_Event_Test;\r
133             AppControlReceived += AppControlReceived_Event_Test;\r
134             LocaleChanged += LocaleChanged_Event_Test;\r
135             LowMemory += LowMemory_Event_Test;\r
136             LowBattery += LowBattery_Event_Test;\r
137             Terminated += Terminated_Event_Test;\r
138             Paused += EventHandlerPaused;\r
139             Resumed += EventHandlerResumed;\r
140             DeviceOrientationChanged += DeviceOrientationCHanged_Event_Test;\r
141             RegionFormatChanged += RegionFormatChanged_Event_Test;\r
142 \r
143             Log.Debug("TCT", "[TestCase][Run][Application] Pass");\r
144 \r
145             base.Run(args);\r
146         }\r
147 \r
148         private void Terminated_Event_Test(object sender, EventArgs e)\r
149         {\r
150             /* \r
151                         * SCENARIO:\r
152                         * Launch app\r
153                         * -> If log show "Application::Terminated_Event_Test()" -> PASS\r
154                         */\r
155             Log.Debug("TCT", "Application::Terminated_Event_Test");\r
156             //logBuilder.AppendLine("TCT [TestCase][Terminated_Event_Test] Pass");\r
157             Log.Debug("TCT", "[TestCase][Terminated_Event_Test][Application] Pass");\r
158         }\r
159 \r
160         private void LocaleChanged_Event_Test(object sender, LocaleChangedEventArgs e)\r
161         {\r
162             /* \r
163                         * SCENARIO:\r
164                         * Launch app\r
165                         * -> If log show "Application::LocaleChanged_Event_Test()" -> PASS\r
166                         */\r
167             Log.Debug("TCT", "Application::LocaleChanged_Event_Test");\r
168             Log.Debug("TCT", "Application::LocaleChanged_Event_Test: new located - " + e.Locale);\r
169             //logBuilder.AppendLine("TCT [TestCase][LocaleChanged_Event_Test] Pass");\r
170             Log.Debug("TCT", "[TestCase][LocaleChanged_Event_Test][Application] Pass");\r
171         }\r
172 \r
173         private void RegionFormatChanged_Event_Test(object sender, RegionFormatChangedEventArgs e)\r
174         {\r
175             Log.Debug("TCT", "Application::RegionFormatChanged_Event_Test");\r
176             Log.Debug("TCT", "Application::RegionFormatChanged_Event_Test: new region - " + e.Region);\r
177             //logBuilder.AppendLine("TCT [TestCase][LocaleChanged_Event_Test] Pass");\r
178             Log.Debug("TCT", "[TestCase][RegionFormatChanged_Event_Test][Application] Pass");\r
179         }\r
180 \r
181         private void DeviceOrientationCHanged_Event_Test(object sender, DeviceOrientationEventArgs e)\r
182         {            \r
183             Log.Debug("TCT", "Application::DeviceOrientationCHanged_Event_Test");\r
184             Log.Debug("TCT", "Application::DeviceOrientationCHanged_Event_Test: new located - " + e.DeviceOrientation);\r
185             Log.Debug("TCT", "[TestCase][DeviceOrientationCHanged_Event_Test][Application] Pass");\r
186         }\r
187 \r
188         private void LowMemory_Event_Test(object sender, LowMemoryEventArgs e)\r
189         {\r
190             /* \r
191                         * SCENARIO:\r
192                         * Launch app\r
193                         * -> If log show "Application::LowMemory_Event_Test()" -> PASS\r
194                         */\r
195             Log.Debug("TCT", "Application::LowMemory_Event_Test");\r
196             if (e.LowMemoryStatus == LowMemoryStatus.None)\r
197             {\r
198                 Log.Debug("TCT", "Application::LowMemory_Event_Test: LowMemoryStatus.None");\r
199             }\r
200             else if (e.LowMemoryStatus == LowMemoryStatus.Normal)\r
201             {\r
202                 Log.Debug("TCT", "Application::LowMemory_Event_Test: LowMemoryStatus.Normal");\r
203             }\r
204             else if (e.LowMemoryStatus == LowMemoryStatus.SoftWarning)\r
205             {\r
206                 Log.Debug("TCT", "Application::LowMemory_Event_Test: LowMemoryStatus.SoftWarning");\r
207             }\r
208             else if (e.LowMemoryStatus == LowMemoryStatus.HardWarning)\r
209             {\r
210                 Log.Debug("TCT", "Application::LowMemory_Event_Test: LowMemoryStatus.HardWarning");\r
211             }\r
212             //logBuilder.AppendLine("TCT [TestCase][LowMemory_Event_Test] Pass");\r
213             Log.Debug("TCT", "[TestCase][LowMemory_Event_Test][Application] Pass");\r
214         }\r
215 \r
216         private void LowBattery_Event_Test(object sender, LowBatteryEventArgs e)\r
217         {\r
218             Log.Debug("TCT", "Application::LowBattery_Event_Test");\r
219 \r
220             if (e.LowBatteryStatus == LowBatteryStatus.CriticalLow)\r
221             {\r
222                 Log.Debug("TCT", "Application::LowBattery_Event_Test: LowMemoryStatus.CriticalLow");\r
223             }\r
224             Log.Debug("TCT", "[TestCase][LowBattery_Event_Test][Application] Pass");\r
225         }\r
226 \r
227         private void AppControlReceived_Event_Test(object sender, AppControlReceivedEventArgs e)\r
228         {\r
229             /* \r
230                         * SCENARIO:\r
231                         * Launch app\r
232                         * -> If log show "Application::AppControlReceived_Event_Test()" -> PASS\r
233                         */\r
234             Log.Debug("TCT", "Application::AppControlReceived_Event_Test");\r
235             //logBuilder.AppendLine("TCT [TestCase][AppControlReceived_Event_Test] Pass");\r
236             Log.Debug("TCT", "[TestCase][AppControlReceived_Event_Test][Application] Pass");\r
237         }\r
238 \r
239         private void Created_Event_Test(object sender, EventArgs e)\r
240         {\r
241             /* \r
242                         * SCENARIO:\r
243                         * Launch app\r
244                         * -> If log show "Application::Created_Event_Test()" -> PASS\r
245                         */\r
246             Log.Debug("TCT", "Application::Created_Event_Test");\r
247             //logBuilder.AppendLine("TCT [TestCase][Created_Event_Test] Pass");\r
248             Log.Debug("TCT", "[TestCase][Created_Event_Test][Application] Pass");\r
249         }\r
250         public void EventHandlerPaused(object sender, EventArgs e)\r
251         {\r
252             /* \r
253              * PRECONDITION\r
254              * 1. Open Application app.\r
255              * 2. Open other app.\r
256              */             \r
257             Log.Debug("TCT", "[TestCase][EventHandlerPaused][Application] Pass");\r
258         }\r
259         public void EventHandlerResumed(object sender, EventArgs e)\r
260         {\r
261             /* \r
262              * PRECONDITION\r
263              * 1. Open Application app.\r
264              * 2. Open other app.\r
265              * 3. Long press HOME button and tap to Applicaton shortcut.\r
266              */\r
267             Log.Debug("TCT", "Application Resumed event occur!");\r
268             Log.Debug("TCT", "[TestCase][EventHandlerResumed][Application] Pass");\r
269         }\r
270 \r
271         public override void Exit()\r
272         {\r
273             Log.Debug("TCT", "[TestCase][Exit][Application] Pass");\r
274             base.Exit();\r
275         }\r
276         void ShowPropertiesInfo()\r
277         {\r
278             if (base.ApplicationInfo != null)\r
279             {\r
280                 Log.Debug("TCT", "[Info] ApplicationInfo is not null");\r
281                 Log.Debug("TCT", "[Info] ApplicationInfo.ApplicationId = " + base.ApplicationInfo.ApplicationId);\r
282                 Log.Debug("TCT", "[Info] ApplicationInfo.ApplicationType = " + base.ApplicationInfo.ApplicationType);\r
283                 Log.Debug("TCT", "[Info] ApplicationInfo.ExecutablePath = " + base.ApplicationInfo.ExecutablePath);\r
284                 Log.Debug("TCT", "[Info] ApplicationInfo.ExternalSharedDataPath = " + base.ApplicationInfo.ExternalSharedDataPath);\r
285                 Log.Debug("TCT", "[Info] ApplicationInfo.IconPath = " + base.ApplicationInfo.IconPath);\r
286                 Log.Debug("TCT", "[Info] ApplicationInfo.IsNoDisplay = " + base.ApplicationInfo.IsNoDisplay);\r
287                 Log.Debug("TCT", "[Info] ApplicationInfo.IsOnBoot = " + base.ApplicationInfo.IsOnBoot);\r
288                 Log.Debug("TCT", "[Info] ApplicationInfo.IsPreload = " + base.ApplicationInfo.IsPreload);\r
289                 Log.Debug("TCT", "[Info] ApplicationInfo.Label = " + base.ApplicationInfo.Label);\r
290                 Log.Debug("TCT", "[Info] ApplicationInfo.Metadata Count = " + base.ApplicationInfo.Metadata.Count);\r
291                 foreach (var item in base.ApplicationInfo.Metadata)\r
292                 {\r
293                     Log.Debug("TCT", "[Info] ApplicationInfo.Metadata, Key: " + item.Key + " Value: " + item.Value);\r
294                 }\r
295                 Log.Debug("TCT", "[Info] ApplicationInfo.PackageId = " + base.ApplicationInfo.PackageId);\r
296                 Log.Debug("TCT", "[Info] ApplicationInfo.SharedDataPath = " + base.ApplicationInfo.SharedDataPath);\r
297                 Log.Debug("TCT", "[Info] ApplicationInfo.SharedResourcePath = " + base.ApplicationInfo.SharedResourcePath);\r
298                 Log.Debug("TCT", "[Info] ApplicationInfo.SharedTrustedPath = " + base.ApplicationInfo.SharedTrustedPath);\r
299             }\r
300             if (base.DirectoryInfo != null)\r
301             {\r
302                 Log.Debug("TCT", "[Info] DirectoryInfo is not null");\r
303                 Log.Debug("TCT", "[Info] DirectoryInfo.Cache = " + base.DirectoryInfo.Cache);\r
304                 Log.Debug("TCT", "[Info] DirectoryInfo.Data = " + base.DirectoryInfo.Data);\r
305                 Log.Debug("TCT", "[Info] DirectoryInfo.ExpansionPackageResource = " + base.DirectoryInfo.ExpansionPackageResource);\r
306                 Log.Debug("TCT", "[Info] DirectoryInfo.ExternalCache = " + base.DirectoryInfo.ExternalCache);\r
307                 Log.Debug("TCT", "[Info] DirectoryInfo.ExternalData = " + base.DirectoryInfo.ExternalData);\r
308                 Log.Debug("TCT", "[Info] DirectoryInfo.ExternalSharedData = " + base.DirectoryInfo.ExternalSharedData);\r
309                 Log.Debug("TCT", "[Info] DirectoryInfo.Resource = " + base.DirectoryInfo.Resource);\r
310                 Log.Debug("TCT", "[Info] DirectoryInfo.SharedData = " + base.DirectoryInfo.SharedData);\r
311                 Log.Debug("TCT", "[Info] DirectoryInfo.SharedResource = " + base.DirectoryInfo.SharedResource);\r
312                 Log.Debug("TCT", "[Info] DirectoryInfo.SharedTrusted = " + base.DirectoryInfo.SharedTrusted);\r
313             }\r
314 \r
315             Log.Debug("TCT", "[Info] Current == this : " + (Current == this));\r
316             Log.Debug("TCT", "[Info] Current.ApplicationInfo.ApplicationId = " + Current.ApplicationInfo.ApplicationId);\r
317         }\r
318 \r
319         static void Main(string[] args)\r
320         {\r
321             var app = new Program();\r
322             global::Xamarin.Forms.Platform.Tizen.Forms.Init(app);\r
323             app.Run(args);\r
324         }\r
325     }\r
326 }\r