2 using System.Runtime.InteropServices;
3 using Tizen.Applications;
5 using Tizen.NUI.UIComponents;
6 using Tizen.NUI.BaseComponents;
7 using Tizen.NUI.Constants;
10 namespace NUIApplicationsManualWearableTests
13 /// A sample of NUIApplication
15 class NUIApplicationsManualWearableTests : NUIApplication
17 public delegate void AddIdleTest();
18 public void OnButtonPressed()
20 Log.Fatal("TCT", "Call Exit()");
23 protected override void OnPreCreate()
25 Log.Fatal("TCT", "[TestCase][OnPreCreate][NUIApplication] Pass");
28 protected override void OnCreate()
32 PushButton pauseButton = new PushButton();
33 pauseButton.Size2D = new Size2D(120, 60);
34 pauseButton.Position2D = new Position2D(-150, -300);
35 pauseButton.Label = CreateTextVisual("Pause", Color.White);
36 pauseButton.Clicked += (obj, ee) =>
41 Window.Instance.GetDefaultLayer().Add(pauseButton);
\r
44 PushButton resumeButton = new PushButton();
45 resumeButton.Size2D = new Size2D(120, 60);
46 resumeButton.Position2D = new Position2D(-30, -300);
47 resumeButton.Label = CreateTextVisual("Resume", Color.White);
48 resumeButton.Clicked += (obj, e) =>
53 Window.Instance.GetDefaultLayer().Add(resumeButton);
55 PushButton exitButton = new PushButton();
56 exitButton.Size2D = new Size2D(120, 60);
57 exitButton.Position2D = new Position2D(-150, -150);
58 exitButton.Label = CreateTextVisual("Exit", Color.White);
60 exitButton.Clicked += (obj, e) =>
65 Window.Instance.GetDefaultLayer().Add(exitButton);
67 PushButton addIdleButton = new PushButton();
68 addIdleButton.Size2D = new Size2D(120, 60);
69 addIdleButton.Position2D = new Position2D(-30, -150);
70 addIdleButton.Label = CreateTextVisual("AddIdle", Color.White);
71 addIdleButton.Clicked += (obj, e) =>
73 AddIdleTest addIdleTest = new AddIdleTest(MyDelegate);
78 Window.Instance.GetDefaultLayer().Add(addIdleButton);
80 pauseButton.DownFocusableView = resumeButton;
81 resumeButton.UpFocusableView = pauseButton;
82 resumeButton.DownFocusableView = exitButton;
83 exitButton.UpFocusableView = resumeButton;
84 exitButton.DownFocusableView = addIdleButton;
85 addIdleButton.UpFocusableView = exitButton;
88 FocusManager.Instance.SetCurrentFocusView(pauseButton);
91 Log.Fatal("TCT", "[TestCase][OnCreate][NUIApplication] Pass");
94 private PropertyMap CreateTextVisual(string text, Color color)
96 PropertyMap map = new PropertyMap();
97 map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text));
98 map.Add(TextVisualProperty.Text, new PropertyValue(text));
99 map.Add(TextVisualProperty.TextColor, new PropertyValue(color));
100 map.Add(TextVisualProperty.PointSize, new PropertyValue(6.0f));
101 map.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue("CENTER"));
102 map.Add(TextVisualProperty.VerticalAlignment, new PropertyValue("BOTTOM"));
105 public static void MyDelegate()
107 Log.Fatal("TCT", "[TestCase][AddIdle][NUIApplication] Pass");
110 protected override void OnResume()
112 Log.Fatal("TCT", "[TestCase][OnResume][NUIApplication] Pass");
116 protected override void OnPause()
118 Log.Fatal("TCT", "[TestCase][OnPause][NUIApplication] Pass");
122 protected override void OnTerminate()
124 Log.Fatal("TCT", "NUIApplication::OnTerminate()");
125 Log.Fatal("TCT", "[TestCase][OnTerminate][NUIApplication] Pass");
129 protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
131 Log.Fatal("TCT", "NUIApplication::OnAppControlReceived()");
132 if (e.ReceivedAppControl != null)
134 Log.Fatal("TCT", "[TestCase][Test_Properties] ReceivedAppControl properties is not null");
135 Log.Fatal("TCT", "[TestCase][Test_Properties] ReceivedAppControl Type: " + e.ReceivedAppControl.GetType());
137 Log.Fatal("TCT", "[TestCase][OnAppControlReceived][NUIApplication] Pass");
139 base.OnAppControlReceived(e);
140 ShowPropertiesInfo();
143 protected override void OnLocaleChanged(LocaleChangedEventArgs e)
145 Log.Fatal("TCT", "NUIApplication::OnLocaleChanged()");
146 if (e.Locale != null)
148 Log.Fatal("TCT", "[Test_Properties] Locale properties is not null");
149 Log.Fatal("TCT", "[Test_Properties] Current value of Locale : " + e.Locale);
150 Log.Fatal("TCT", "[Test_Properties] Locale type: " + e.Locale.GetType());
153 Log.Fatal("TCT", "[TestCase][OnLocaleChanged][NUIApplication] Pass");
154 base.OnLocaleChanged(e);
157 protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
159 Log.Fatal("TCT", "NUIApplication::OnRegionFormatChanged()");
162 Log.Fatal("TCT", "[Test_Properties] Region properties is not null");
163 Log.Fatal("TCT", "[Test_Properties] Current value of Region : " + e.Region);
164 Log.Fatal("TCT", "[Test_Properties] Region type: " + e.Region.GetType());
167 Log.Fatal("TCT", "[TestCase][OnRegionFormatChanged][NUIApplication] Pass");
168 base.OnRegionFormatChanged(e);
171 protected override void OnDeviceOrientationChanged(DeviceOrientationEventArgs e)
173 Log.Fatal("TCT", "NUIApplication::OnDeviceOrientationChanged()");
176 Log.Fatal("TCT", "[Test_Properties] DeviceOrientation properties is not null");
177 Log.Fatal("TCT", "[Test_Properties] Current value of DeviceOrientation : " + e.DeviceOrientation);
178 Log.Fatal("TCT", "[Test_Properties] DeviceOrientation type: " + e.DeviceOrientation.GetType());
181 Log.Fatal("TCT", "[TestCase][OnDeviceOrientationChanged][NUIApplication] Pass");
182 base.OnDeviceOrientationChanged(e);
185 protected override void OnLowMemory(LowMemoryEventArgs e)
187 Log.Fatal("TCT", "NUIApplication::OnLowMemory()");
188 if (e.LowMemoryStatus != LowMemoryStatus.None)
190 Log.Fatal("TCT", "[Test_Properties] LowMemoryStatus properties is not null");
191 Log.Fatal("TCT", "[Test_Properties] Current value of LowMemoryStatus : " + e.LowMemoryStatus.ToString());
192 Log.Fatal("TCT", "[Test_Properties] LowMemoryStatus type: " + e.LowMemoryStatus.GetType());
194 Log.Fatal("TCT", "[TestCase][OnLowMemory][NUIApplication] Pass");
199 protected override void OnLowBattery(LowBatteryEventArgs e)
201 Log.Fatal("TCT", "NUIApplication::OnLowBattery()");
202 if (e.LowBatteryStatus != LowBatteryStatus.None)
204 Log.Fatal("TCT", "[Test_Properties] LowBatteryStatus properties is not null");
205 Log.Fatal("TCT", "[Test_Properties] Current value of LowBatteryStatus : " + e.LowBatteryStatus.ToString());
206 Log.Fatal("TCT", "[Test_Properties] LowBatteryStatus type: " + e.LowBatteryStatus.GetType());
209 Log.Fatal("TCT", "[TestCase][OnLowBattery][NUIApplication] Pass");
211 base.OnLowBattery(e);
214 public override void Run(string[] args)
216 Created += Created_Event_Test;
217 AppControlReceived += AppControlReceived_Event_Test;
218 LocaleChanged += LocaleChanged_Event_Test;
219 LowMemory += LowMemory_Event_Test;
220 LowBattery += LowBattery_Event_Test;
221 Terminated += Terminated_Event_Test;
222 Paused += Paused_Event_Test;
223 Resumed += Resumed_Event_Test;
224 DeviceOrientationChanged += DeviceOrientationCHanged_Event_Test;
225 RegionFormatChanged += RegionFormatChanged_Event_Test;
227 Log.Fatal("TCT", "[TestCase][Run][NUIApplication] Pass");
232 private void Terminated_Event_Test(object sender, EventArgs e)
237 * -> If log show "NUIApplication::Terminated_Event_Test()" -> PASS
239 Log.Fatal("TCT", "NUIApplication::Terminated_Event_Test");
240 Log.Fatal("TCT", "[TestCase][Terminated_Event_Test][NUIApplication] Pass");
243 private void LocaleChanged_Event_Test(object sender, LocaleChangedEventArgs e)
248 * -> If log show "NUIApplication::LocaleChanged_Event_Test()" -> PASS
250 Log.Fatal("TCT", "NUIApplication::LocaleChanged_Event_Test");
251 Log.Fatal("TCT", "NUIApplication::LocaleChanged_Event_Test: new located - " + e.Locale);
252 Log.Fatal("TCT", "[TestCase][LocaleChanged_Event_Test][NUIApplication] Pass");
255 private void RegionFormatChanged_Event_Test(object sender, RegionFormatChangedEventArgs e)
257 Log.Fatal("TCT", "NUIApplication::RegionFormatChanged_Event_Test");
258 Log.Fatal("TCT", "NUIApplication::RegionFormatChanged_Event_Test: new region - " + e.Region);
259 Log.Fatal("TCT", "[TestCase][RegionFormatChanged_Event_Test][NUIApplication] Pass");
262 private void DeviceOrientationCHanged_Event_Test(object sender, DeviceOrientationEventArgs e)
264 Log.Fatal("TCT", "NUIApplication::DeviceOrientationCHanged_Event_Test");
265 Log.Fatal("TCT", "NUIApplication::DeviceOrientationCHanged_Event_Test: new located - " + e.DeviceOrientation);
266 Log.Fatal("TCT", "[TestCase][DeviceOrientationCHanged_Event_Test][NUIApplication] Pass");
269 private void LowMemory_Event_Test(object sender, LowMemoryEventArgs e)
274 * -> If log show "NUIApplication::LowMemory_Event_Test()" -> PASS
276 Log.Fatal("TCT", "NUIApplication::LowMemory_Event_Test");
277 if (e.LowMemoryStatus == LowMemoryStatus.None)
279 Log.Fatal("TCT", "NUIApplication::LowMemory_Event_Test: LowMemoryStatus.None");
281 else if (e.LowMemoryStatus == LowMemoryStatus.Normal)
283 Log.Fatal("TCT", "NUIApplication::LowMemory_Event_Test: LowMemoryStatus.Normal");
285 else if (e.LowMemoryStatus == LowMemoryStatus.SoftWarning)
287 Log.Fatal("TCT", "NUIApplication::LowMemory_Event_Test: LowMemoryStatus.SoftWarning");
289 else if (e.LowMemoryStatus == LowMemoryStatus.HardWarning)
291 Log.Fatal("TCT", "NUIApplication::LowMemory_Event_Test: LowMemoryStatus.HardWarning");
293 Log.Fatal("TCT", "[TestCase][LowMemory_Event_Test][NUIApplication] Pass");
296 private void LowBattery_Event_Test(object sender, LowBatteryEventArgs e)
298 Log.Fatal("TCT", "NUIApplication::LowBattery_Event_Test");
300 if (e.LowBatteryStatus == LowBatteryStatus.CriticalLow)
302 Log.Fatal("TCT", "NUIApplication::LowBattery_Event_Test: LowMemoryStatus.CriticalLow");
304 Log.Fatal("TCT", "[TestCase][LowBattery_Event_Test][NUIApplication] Pass");
307 private void AppControlReceived_Event_Test(object sender, AppControlReceivedEventArgs e)
312 * -> If log show "NUIApplication::AppControlReceived_Event_Test()" -> PASS
314 Log.Fatal("TCT", "NUIApplication::AppControlReceived_Event_Test");
315 Log.Fatal("TCT", "[TestCase][AppControlReceived_Event_Test][NUIApplication] Pass");
318 private void Created_Event_Test(object sender, EventArgs e)
323 * -> If log show "NUIApplication::Created_Event_Test()" -> PASS
325 Log.Fatal("TCT", "NUIApplication::Created_Event_Test");
326 Log.Fatal("TCT", "[TestCase][Created_Event_Test][NUIApplication] Pass");
328 public void Paused_Event_Test(object sender, EventArgs e)
332 * 1. Open NUIApplication app.
335 Log.Fatal("TCT", "[TestCase][Paused_Event_Test][NUIApplication] Pass");
337 public void Resumed_Event_Test(object sender, EventArgs e)
341 * 1. Open NUIApplication app.
343 * 3. Long press HOME button and tap to NUIApplicaton shortcut.
345 Log.Fatal("TCT", "NUIApplication Resumed event occur!");
346 Log.Fatal("TCT", "[TestCase][Resumed_Event_Test][NUIApplication] Pass");
349 public override void Exit()
351 Log.Fatal("TCT", "[TestCase][Exit][NUIApplication] Pass");
354 void ShowPropertiesInfo()
356 if (base.ApplicationInfo != null)
358 Log.Fatal("TCT", "[Info] ApplicationInfo is not null");
359 Log.Fatal("TCT", "[Info] ApplicationInfo.ApplicationId = " + base.ApplicationInfo.ApplicationId);
360 Log.Fatal("TCT", "[Info] ApplicationInfo.ApplicationType = " + base.ApplicationInfo.ApplicationType);
361 Log.Fatal("TCT", "[Info] ApplicationInfo.ExecutablePath = " + base.ApplicationInfo.ExecutablePath);
362 Log.Fatal("TCT", "[Info] ApplicationInfo.ExternalSharedDataPath = " + base.ApplicationInfo.ExternalSharedDataPath);
363 Log.Fatal("TCT", "[Info] ApplicationInfo.IconPath = " + base.ApplicationInfo.IconPath);
364 Log.Fatal("TCT", "[Info] ApplicationInfo.IsNoDisplay = " + base.ApplicationInfo.IsNoDisplay);
365 Log.Fatal("TCT", "[Info] ApplicationInfo.IsOnBoot = " + base.ApplicationInfo.IsOnBoot);
366 Log.Fatal("TCT", "[Info] ApplicationInfo.IsPreload = " + base.ApplicationInfo.IsPreload);
367 Log.Fatal("TCT", "[Info] ApplicationInfo.Label = " + base.ApplicationInfo.Label);
368 Log.Fatal("TCT", "[Info] ApplicationInfo.Metadata Count = " + base.ApplicationInfo.Metadata.Count);
369 foreach (var item in base.ApplicationInfo.Metadata)
371 Log.Fatal("TCT", "[Info] ApplicationInfo.Metadata, Key: " + item.Key + " Value: " + item.Value);
373 Log.Fatal("TCT", "[Info] ApplicationInfo.PackageId = " + base.ApplicationInfo.PackageId);
374 Log.Fatal("TCT", "[Info] ApplicationInfo.SharedDataPath = " + base.ApplicationInfo.SharedDataPath);
375 Log.Fatal("TCT", "[Info] ApplicationInfo.SharedResourcePath = " + base.ApplicationInfo.SharedResourcePath);
376 Log.Fatal("TCT", "[Info] ApplicationInfo.SharedTrustedPath = " + base.ApplicationInfo.SharedTrustedPath);
378 if (base.DirectoryInfo != null)
380 Log.Fatal("TCT", "[Info] DirectoryInfo is not null");
381 Log.Fatal("TCT", "[Info] DirectoryInfo.Cache = " + base.DirectoryInfo.Cache);
382 Log.Fatal("TCT", "[Info] DirectoryInfo.Data = " + base.DirectoryInfo.Data);
383 Log.Fatal("TCT", "[Info] DirectoryInfo.ExpansionPackageResource = " + base.DirectoryInfo.ExpansionPackageResource);
384 Log.Fatal("TCT", "[Info] DirectoryInfo.ExternalCache = " + base.DirectoryInfo.ExternalCache);
385 Log.Fatal("TCT", "[Info] DirectoryInfo.ExternalData = " + base.DirectoryInfo.ExternalData);
386 Log.Fatal("TCT", "[Info] DirectoryInfo.ExternalSharedData = " + base.DirectoryInfo.ExternalSharedData);
387 Log.Fatal("TCT", "[Info] DirectoryInfo.Resource = " + base.DirectoryInfo.Resource);
388 Log.Fatal("TCT", "[Info] DirectoryInfo.SharedData = " + base.DirectoryInfo.SharedData);
389 Log.Fatal("TCT", "[Info] DirectoryInfo.SharedResource = " + base.DirectoryInfo.SharedResource);
390 Log.Fatal("TCT", "[Info] DirectoryInfo.SharedTrusted = " + base.DirectoryInfo.SharedTrusted);
393 Log.Fatal("TCT", "[Info] Current == this : " + (Current == this));
394 Log.Fatal("TCT", "[Info] Current.ApplicationInfo.ApplicationId = " + Current.ApplicationInfo.ApplicationId);
400 static void Main(string[] args)
402 Log.Warn("WATCH", "[TestCase][TCT] Main ");
404 NUIApplicationsManualWearableTests app = new NUIApplicationsManualWearableTests();