public class ViewTests
{
private static string TAG = "NUI";
- private static string image_path = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
+ private static bool _flag = false;
+ private static string _imagePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "picture.png";
- private string VertexShader = " attribute mediump vec2 aPosition;\n" +
+ private string _vertexShader = " attribute mediump vec2 aPosition;\n" +
" uniform mediump mat4 uMvpMatrix;\n" +
" \n" +
" void main()\n" +
" mediump vec4 vertexPosition = vec4(aPosition, 0.0, 1.0);\n" +
" gl_Position = uMvpMatrix * vertexPosition;\n" +
" }\n";
- private string FragmentShader = " uniform mediump vec4 uColor;\n" +
+ private string _fragmentShader = " uniform mediump vec4 uColor;\n" +
" \n" +
" void main()\n" +
" {\n" +
public static void Init()
{
Tizen.Log.Info(TAG, "Init() is called!");
+ _flag = false;
App.MainTitleChangeText("ViewTests");
App.MainTitleChangeBackgroundColor(null);
}
Tizen.Log.Info(TAG, "Destroy() is called!");
}
+ private void viewEventCallback(object sender, EventArgs e)
+ {
+ _flag = true;
+ }
[Test]
[Category("P1")]
Assert.AreEqual(-1, actor.HierarchyDepth, "The actor is not in the hierarchy");
Window.Instance.GetDefaultLayer().Add(actor);
Assert.AreEqual(1, actor.HierarchyDepth, "The actor is in the hierarchy");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
Assert.AreEqual((position.X + parentPosition.X), actor.WorldPosition.X, "The WorldPosition.X of actor should be 7.0f now");
Assert.AreEqual((position.Y + parentPosition.Y), actor.WorldPosition.Y, "The WorldPosition.Y of actor should be 8.0f now");
Assert.AreEqual((position.Z + parentPosition.Z), actor.WorldPosition.Z, "The WorldPosition.Z of actor should be 9.0f now");
+ Window.Instance.GetDefaultLayer().Remove(parentActor);
}
[Test]
public void AddedToWindow_CHECK_EVENT()
{
View view = new View();
- bool flag = false;
- view.AddedToWindow += (obj, e) =>
- {
- flag = true;
- };
+ view.AddedToWindow += viewEventCallback;
Window.Instance.GetDefaultLayer().Add(view);
- Assert.IsTrue(flag, "The AddedToWindow Event has been triggerred!");
+ Assert.IsTrue(_flag, "The AddedToWindow Event has been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ view.AddedToWindow -= viewEventCallback;
}
[Test]
await Task.Delay(20);
Assert.AreEqual(size.Width, actorSize.Width, "The Width of actor should be 100.0f now");
Assert.AreEqual(size.Height, actorSize.Height, "The Height of actor should be 100.0f now");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
[Test]
Assert.Greater(actor.ScreenPosition.X, 0, "The X of the actor's ScreenPosition is not correct!");
Assert.Greater(actor.ScreenPosition.Y, 0, "The Y of the actor's ScreenPosition is not correct!");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
[Test]
Assert.Greater(actor.WorldScale.X, 0, "The WorldScale.X of actor should be 2.0f now");
Assert.Greater(actor.WorldScale.Y, 0, "The WorldScale.Y of actor should be 4.0f now");
Assert.Greater(actor.WorldScale.Z, 0, "The WorldScale.Z of actor should be 2.0f now");
+ Window.Instance.GetDefaultLayer().Remove(parentActor);
}
Window.Instance.GetDefaultLayer().Add(actorB);
Window.Instance.GetDefaultLayer().Add(actorC);
actorC.RaiseToTop();
+ Window.Instance.GetDefaultLayer().Remove(actorA);
+ Window.Instance.GetDefaultLayer().Remove(actorB);
+ Window.Instance.GetDefaultLayer().Remove(actorC);
}
catch (Exception e)
{
Window.Instance.GetDefaultLayer().Add(actorB);
Window.Instance.GetDefaultLayer().Add(actorC);
actorA.LowerToBottom();
+ Window.Instance.GetDefaultLayer().Remove(actorA);
+ Window.Instance.GetDefaultLayer().Remove(actorB);
+ Window.Instance.GetDefaultLayer().Remove(actorC);
}
catch (Exception e)
{
Window.Instance.GetDefaultLayer().Add(actor);
bool isOnStage = actor.IsOnWindow;
Assert.IsTrue(isOnStage, "The actor is on window now.");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
[Test]
parentActor.Add(childActor);
await Task.Delay(20);
Assert.Less(Math.Abs(rotation.Length() - (parentActor.WorldOrientation).Length()), 0.00001, "The parentActor's Orientation is not correct");
+ Window.Instance.GetDefaultLayer().Remove(parentActor);
}
[Test]
view.Flex = 2.0f;
Assert.AreEqual(2.0f, view.Flex, "The Flex value of View is not correct!");
+ Window.Instance.GetDefaultLayer().Remove(flexContainer);
}
[Test]
view3.CellVerticalAlignment = VerticalAlignmentType.Bottom;
table.Add(view3);
Assert.IsTrue(table.GetChildAt(new TableView.CellPosition(0, 0)) == view3, "The child at (0, 0) should be view3!");
+ Window.Instance.GetDefaultLayer().Remove(table);
}
Window.Instance.GetDefaultLayer().Add(leftView);
view.LeftFocusableView = leftView;
Assert.IsTrue((leftView == view.LeftFocusableView), "The value of view1's LeftFocusableView is not correct here");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ Window.Instance.GetDefaultLayer().Remove(leftView);
}
[Test]
Window.Instance.GetDefaultLayer().Add(rightView);
view.RightFocusableView = rightView;
Assert.IsTrue((rightView == view.RightFocusableView), "The value of view1's RightFocusableView is not correct here");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ Window.Instance.GetDefaultLayer().Remove(rightView);
}
[Test]
Window.Instance.GetDefaultLayer().Add(upView);
view.UpFocusableView = upView;
Assert.IsTrue((upView == view.UpFocusableView), "The value of view1's UpFocusableView is not correct here");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ Window.Instance.GetDefaultLayer().Remove(upView);
}
[Test]
Window.Instance.GetDefaultLayer().Add(downView);
view.DownFocusableView = downView;
Assert.IsTrue((downView == view.DownFocusableView), "The value of view1's DownFocusableView is not correct here");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ Window.Instance.GetDefaultLayer().Remove(downView);
}
[Test]
public void AddRenderer_CHECK_RETURN_VALUE()
{
/* TEST CODE */
- Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+ Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
//Create the geometry
Geometry geometry = new Geometry();
public void GetRendererAt_CHECK_RETURN_VALUE()
{
/* TEST CODE */
- Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+ Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
//Create the geometry
Geometry geometry = new Geometry();
public void RemoveRenderer_CHECK_RETURN_VALUE_WITH_INDEX()
{
/* TEST CODE */
- Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+ Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
//Create the geometry
Geometry geometry = new Geometry();
public void RemoveRenderer_CHECK_RETURN_VALUE()
{
/* TEST CODE */
- Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+ Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
//Create the geometry
Geometry geometry = new Geometry();
public void RendererCount_CHECK_RETURN_VALUE()
{
/* TEST CODE */
- Shader shader = new Shader(VertexShader, FragmentShader, Shader.Hint.Value.NONE);
+ Shader shader = new Shader(_vertexShader, _fragmentShader, Shader.Hint.Value.NONE);
//Create the geometry
Geometry geometry = new Geometry();
Assert.IsNotNull(animation, "The animation should be not null!");
Assert.IsInstanceOf<Animation>(animation, "Should return a instance of Animation class!");
+ Window.Instance.GetDefaultLayer().Remove(view);
}
[Test]
await Task.Delay(20);
Assert.AreEqual(100.0f, actor.GetRelayoutSize(DimensionType.Width), "The GetRelayoutSize does not work here!");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
[Test]
Window.Instance.GetDefaultLayer().Add(view);
try
{
- view.Unparent();
+ view.Unparent();\r
+ Window.Instance.GetDefaultLayer().Remove(view);
}
catch (Exception e)
{
Window.Instance.GetDefaultLayer().Add(view);
Assert.IsTrue(view.IsResourceReady(), "Should be true now!");
+ Window.Instance.GetDefaultLayer().Remove(view);
}
[Test]
Assert.Greater(localX, 0.0f, "The localX is not correct!");
Assert.IsTrue(ret, "ScreenToLocal() returns false!");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
catch (Exception e)
{
parentActor.Add(childActor);
Window.Instance.GetDefaultLayer().Add(parentActor);
Assert.AreEqual(1, parentActor.ChildCount, "The child count of parentActor should be 1");
+ Window.Instance.GetDefaultLayer().Remove(parentActor);
}
[Test]
await Task.Delay(300);
Assert.AreEqual(100, actor.CurrentSize.Width, "The Width of the actor's CurrentSize is not correct!");
Assert.AreEqual(100, actor.CurrentSize.Height, "The Height of the actor's CurrentSize is not correct!");
+ Window.Instance.GetDefaultLayer().Remove(actor);
}
[Test]
view.BackgroundColor = Color.Red;
Window.Instance.GetDefaultLayer().Add(view);
Assert.Greater(view.ID, 0, "Should be greater than zero!");
+ Window.Instance.GetDefaultLayer().Remove(view);
}
[Test]
Window.Instance.GetDefaultLayer().Add(view);
Layer layer = view.GetLayer();
Assert.IsNotNull(layer, "The layer of under the view Should be not null!");
+ Window.Instance.GetDefaultLayer().Remove(view);
}
[Test]
try
{
view.DoAction(0, 0, new PropertyValue(0));
+ Window.Instance.GetDefaultLayer().Remove(view);
}
catch (Exception e)
{
Assert.Greater(actor.WorldPosition.X, 0, "ChildActor's WorldPosition.X is incorrect");
Assert.Greater(actor.WorldPosition.Y, 0, "ChildActor's WorldPosition.Y is incorrect");
Assert.Greater(actor.WorldPosition.Z, 0, "ChildActor's WorldPosition.Z is incorrect");
+ Window.Instance.GetDefaultLayer().Remove(parentActor);
}
[Test]
view.BackgroundColor = new Color(1.0f, 0.0f, 0.0f, 1.0f);
view.Size2D = new Size2D(100, 100);
view.Hide();
- bool flag = false;
- view.VisibilityChanged += (obj, e) =>
- {
- flag = true;
- };
+ view.VisibilityChanged += viewEventCallback;
Window.Instance.GetDefaultLayer().Add(view);
view.Show();
await Task.Delay(200);
- Assert.IsTrue(flag, "The VisibilityChanged Event has been triggerred!");
+ Assert.IsTrue(_flag, "The VisibilityChanged Event has been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ view.VisibilityChanged -= viewEventCallback;
}
[Test]
FocusManager.Instance.SetCurrentFocusView(view);
await Task.Delay(200);
Assert.IsTrue(view.HasFocus(), "The view should hold the focus now");
+ Window.Instance.GetDefaultLayer().Remove(view);
}
view.Focusable = true;
Window.Instance.GetDefaultLayer().Add(view);
- bool flag = false;
- view.FocusGained += (obj, e) =>
- {
- flag = true;
- };
+ view.FocusGained += viewEventCallback;
FocusManager.Instance.SetCurrentFocusView(view);
- Assert.IsTrue(flag, "The FocusGained Event not been triggerred!");
+ Assert.IsTrue(_flag, "The FocusGained Event not been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ view.FocusGained -= viewEventCallback;
}
[Test]
view2.Focusable = true;
Window.Instance.GetDefaultLayer().Add(view);
Window.Instance.GetDefaultLayer().Add(view2);
- bool flag = false;
- view.FocusLost += (obj, e) =>
- {
- flag = true;
- };
+ view.FocusLost += viewEventCallback;
FocusManager.Instance.SetCurrentFocusView(view);
FocusManager.Instance.SetCurrentFocusView(view2);
- Assert.IsTrue(flag, "The FocusLost Event not been triggerred!");
+ Assert.IsTrue(_flag, "The FocusLost Event not been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ Window.Instance.GetDefaultLayer().Remove(view2);
+ view.FocusLost -= viewEventCallback;
}
[Test]
View parentView = new View();
parentView.Add(view);
Window.Instance.GetDefaultLayer().Add(parentView);
- parentView.Size = new Size(100.0f, 100.0f, 100.0f);
- Window.Instance.GetDefaultLayer().Add(view);
- bool flag = false;
- view.Relayout += (obj, e) =>
- {
- flag = true;
- };
- parentView.Size = new Size(200.0f, 300.0f, 200.0f);
+ parentView.Size2D = new Size2D(100, 100);
+ view.Relayout += viewEventCallback;
+ parentView.Size2D = new Size2D(200, 300);
await Task.Delay(200);
- Assert.IsTrue(flag, "The OnRelayoutEvent Event has been triggerred!");
+ Assert.IsTrue(_flag, "The OnRelayoutEvent Event has been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(parentView);
+ view.Relayout -= viewEventCallback;
}
[Test]
view.Size2D = new Size2D(200, 200);
view.BackgroundColor = Color.Red;
Window.Instance.GetDefaultLayer().Add(view);
- bool flag = false;
- view.RemovedFromWindow += (obj, e) =>
- {
- flag = true;
- };
+ view.RemovedFromWindow += viewEventCallback;
Window.Instance.GetDefaultLayer().Remove(view);
await Task.Delay(20);
- Assert.IsTrue(flag, "The OffStageEvent Event has been triggerred!");
+ Assert.IsTrue(_flag, "The OffStageEvent Event has been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ view.RemovedFromWindow -= viewEventCallback;
}
[Test]
public async Task ResourcesLoaded_CHECK_EVENT()
{
/* TEST CODE */
- ImageView view = new ImageView(image_path);
- bool flag = false;
- view.ResourcesLoaded += (obj, e) =>
- {
- flag = true;
- };
+ ImageView view = new ImageView(_imagePath);
+ view.ResourcesLoaded += viewEventCallback;
view.Size2D = new Size2D(100, 100);
//view.ResourceUrl = image_path;
Window.Instance.GetDefaultLayer().Add(view);
- Tizen.Log.Debug(TAG, "ResourceUrl=" + image_path);
+ Tizen.Log.Debug(TAG, "ResourceUrl=" + _imagePath);
await Task.Delay(500);
- Assert.IsTrue(flag, "ResourcesLoaded does not work!");
+ Assert.IsTrue(_flag, "ResourcesLoaded does not work!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ view.ResourcesLoaded -= viewEventCallback;
}
[Test]
View view = new View();
view.Name = "View";
view.LayoutDirection = ViewLayoutDirectionType.RTL;
- bool flag = false;
- view.LayoutDirectionChanged += (obj, e) =>
- {
- flag = true;
- };
+ view.LayoutDirectionChanged += viewEventCallback;
Window.Instance.GetDefaultLayer().Add(view);
view.LayoutDirection = ViewLayoutDirectionType.LTR;
await Task.Delay(20);
- Assert.IsTrue(flag, "The LayoutDirectionChanged Event has been triggerred!");
+ Assert.IsTrue(_flag, "The LayoutDirectionChanged Event has been triggerred!");
+ Window.Instance.GetDefaultLayer().Remove(view);
+ view.LayoutDirectionChanged -= viewEventCallback;
}
}