3 using NUnit.Framework.TUnit;
5 using Tizen.NUI.Components;
6 using Tizen.NUI.BaseComponents;
7 using System.Collections.Generic;
8 using System.Threading.Tasks;
10 namespace Tizen.NUI.Components.Devel.Tests
12 using tlog = Tizen.Log;
15 [Description("Controls/Menu")]
18 private const string tag = "NUITEST";
19 private string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
21 internal class MyMenu : Menu
23 public MyMenu() : base()
26 public void OnDispose(DisposeTypes types)
59 tlog.Info(tag, "Init() is called!");
65 tlog.Info(tag, "Destroy() is called!");
70 [Description("Menu Scrim.")]
71 [Property("SPEC", "Tizen.NUI.Components.Menu.Scrim M")]
72 [Property("SPEC_URL", "-")]
73 [Property("CRITERIA", "MR")]
74 [Property("COVPARAM", "")]
75 [Property("AUTHOR", "guowei.wang@samsung.com")]
76 public void MenuScrim()
78 tlog.Debug(tag, $"MenuScrim START");
80 var testingTarget = new MyMenu();
81 Assert.IsNotNull(testingTarget, "null handle");
82 Assert.IsInstanceOf<Menu>(testingTarget, "Should return Menu instance.");
84 View scrim = new View()
86 BackgroundColor = Color.Red,
88 testingTarget.MyScrim = scrim;
89 testingTarget.MyScrim = scrim;
91 testingTarget.Dispose();
92 tlog.Debug(tag, $"MenuScrim END (OK)");
97 [Description("Menu GetRootView.")]
98 [Property("SPEC", "Tizen.NUI.Components.Menu.GetRootView M")]
99 [Property("SPEC_URL", "-")]
100 [Property("CRITERIA", "MR")]
101 [Property("COVPARAM", "")]
102 [Property("AUTHOR", "guowei.wang@samsung.com")]
103 public void MenuGetRootView()
105 tlog.Debug(tag, $"MenuGetRootView START");
107 var testingTarget = new MyMenu()
109 Size = new Size(100, 200),
110 BackgroundColor = Color.Green,
112 Assert.IsNotNull(testingTarget, "null handle");
113 Assert.IsInstanceOf<Menu>(testingTarget, "Should return Menu instance.");
115 NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(testingTarget);
117 testingTarget.HorizontalPositionToAnchor = Menu.RelativePosition.Start;
118 tlog.Debug(tag, "HorizontalPositionToAnchor :" + testingTarget.HorizontalPositionToAnchor);
120 testingTarget.VerticalPositionToAnchor = Menu.RelativePosition.Center;
121 tlog.Debug(tag, "HorizontalPositionToAnchor :" + testingTarget.HorizontalPositionToAnchor);
123 List<MenuItem> items = new List<MenuItem>();
124 MenuItem item = new MenuItem();
127 testingTarget.Items = items;
129 MenuItem item2 = new MenuItem();
131 testingTarget.Items = items;
133 View content = new View()
135 Size = new Size2D(100, 30),
137 testingTarget.MyContent = content;
139 View anchor1 = new View()
141 Size = new Size(100, 30),
142 BackgroundColor = Color.Cyan
144 testingTarget.Anchor = anchor1;
146 testingTarget.HorizontalPositionToAnchor = Menu.RelativePosition.Center;
147 tlog.Debug(tag, "HorizontalPositionToAnchor :" + testingTarget.HorizontalPositionToAnchor);
149 testingTarget.VerticalPositionToAnchor = Menu.RelativePosition.Start;
150 tlog.Debug(tag, "HorizontalPositionToAnchor :" + testingTarget.HorizontalPositionToAnchor);
152 View anchor2 = new View()
154 Size = new Size(100, 30),
155 BackgroundColor = Color.Black
157 testingTarget.Anchor = anchor2;
159 NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(testingTarget);
161 testingTarget.OnDispose(DisposeTypes.Explicit);
162 tlog.Debug(tag, $"MenuGetRootView END (OK)");
167 [Description("Menu OnRelayout.")]
168 [Property("SPEC", "Tizen.NUI.Components.Menu.OnRelayout M")]
169 [Property("SPEC_URL", "-")]
170 [Property("CRITERIA", "MR")]
171 [Property("COVPARAM", "")]
172 [Property("AUTHOR", "guowei.wang@samsung.com")]
173 public async Task MenuOnRelayout()
175 tlog.Debug(tag, $"MenuOnRelayout START");
177 var testingTarget = new MyMenu()
179 Size = new Size(100, 200),
180 BackgroundColor = Color.Green,
182 Assert.IsNotNull(testingTarget, "null handle");
183 Assert.IsInstanceOf<Menu>(testingTarget, "Should return Menu instance.");
185 View content = new View()
187 Size = new Size2D(100, 30),
189 testingTarget.MyContent = content;
191 NUIApplication.GetDefaultWindow().GetDefaultLayer().Add(testingTarget);
193 testingTarget.Size = new Size(50, 80);
194 testingTarget.BackgroundColor = Color.Blue;
196 await Task.Delay(200);
197 NUIApplication.GetDefaultWindow().GetDefaultLayer().Remove(testingTarget);
199 testingTarget.Dispose();
200 tlog.Debug(tag, $"MenuOnRelayout END (OK)");