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