private static Label _resultlabel;
private static MainWindow _window = MainWindow.GetInstance();
private static Box _box;
+ private static Box _innerbox;
+ private static MyButton _mybtn;
+ private static bool _isInvalidate = false;
public EvasObjectTests() : base()
{
}
+ public class MyButton : Button
+ {
+ public MyButton(EvasObject parent) : base(parent)
+ {
+ }
+
+ protected override void OnInvalidate()
+ {
+ if (!_isInvalidate)
+ {
+ _isInvalidate = true;
+ Assert.True(true);
+ ManualTest.Confirm();
+ }
+ base.OnInvalidate();
+ }
+ }
+
[SetUp]
public static void Init()
{
_box.Unrealize();
_box = null;
}
+ if (_innerbox != null)
+ {
+ _innerbox.Unrealize();
+ _innerbox = null;
+ }
if (_button != null)
{
_button.Unrealize();
_evasObject.Unrealize();
_evasObject = null;
}
- }
-
- private static void CreateResultBox(string text1, string text2)
- {
- _resultlabel = new Label(_window)
+ if (_mybtn != null)
{
- Text = text1
- };
- _resultlabel.Show();
-
- _button = new Button(_window)
- {
- Text = text2,
- AlignmentX = -1,
- AlignmentY = -1,
- MinimumWidth = 100,
- MinimumHeight = 80,
- };
- _button.Show();
-
- _box = new Box(_window);
- _box.PackEnd(_resultlabel);
- _box.PackEnd(_button);
- _box.Show();
- _testPage.ExecuteTC(_box);
+ _mybtn.Unrealize();
+ _mybtn = null;
+ }
+ _isInvalidate = false;
}
private static void CreateResultLabel(string text)
ManualTest.Confirm();
}
+ private static void DeleteMyParentBox(object sender, EventArgs e)
+ {
+ _innerbox.Unrealize();
+ _innerbox = null;
+ }
+
private static void OnDeleted(object sender, EventArgs e)
{
Assert.True(true);
[Test]
[Category("P1")]
+ [Description("Check whether calling OnInvalidate method successful after deleting object.")]
+ [Property("SPEC", "ElmSharp.EvasObject.OnInvalidate M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ [Precondition(1, "NA")]
+ [Step(1, "Click Run TC")]
+ [Step(2, "Click ClickMe button")]
+ [Postcondition(1, "NA")]
+ public async Task OnInvalidate_Check()
+ {
+ _box = new Box(_window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1,
+ };
+ _box.Show();
+
+ _innerbox = new Box(_window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ };
+ _innerbox.Show();
+ _box.PackEnd(_innerbox);
+
+ _mybtn = new MyButton(_window)
+ {
+ Text = "MyButton",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ MinimumWidth = 100,
+ MinimumHeight = 80,
+ IsEnabled = false,
+ };
+ _mybtn.Show();
+ _innerbox.PackEnd(_mybtn);
+
+ _button = new Button(_window)
+ {
+ Text = "ClickMe",
+ AlignmentX = -1,
+ AlignmentY = -1,
+ MinimumWidth = 100,
+ MinimumHeight = 80,
+ };
+ _button.Show();
+ _button.Clicked += DeleteMyParentBox;
+ _box.PackEnd(_button);
+ _testPage.ExecuteTC(_box);
+ // Waits for user confirmation.
+ await ManualTest.WaitForConfirm();
+ _button.Clicked -= DeleteMyParentBox;
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Test: Handle event Deleted.")]
[Property("SPEC", "ElmSharp.EvasObject.Deleted E")]
[Property("SPEC_URL", "-")]
[Step(1, "Click Run TC")]
[Step(2, "Click button")]
[Postcondition(1, "NA")]
- public static async Task Deleted_EVENT()
+ public async Task Deleted_EVENT()
{
_evasObject = new Polygon(_window);
_evasObject.Deleted += OnDeleted;
[Step(2, "Pree Menu key")]
[Step(3, "Loose Menu key")]
[Postcondition(1, "NA")]
- public static async Task KeyUp_EVENT()
+ public async Task KeyUp_EVENT()
{
if (ElmSharpProfile.GetProfile().CompareTo(ElmSharpProfile.MobileProfile) == 0)
{
[Step(1, "Click Run TC")]
[Step(2, "Pree Menu key")]
[Postcondition(1, "NA")]
- public static async Task KeyDown_EVENT()
+ public async Task KeyDown_EVENT()
{
if (ElmSharpProfile.GetProfile().CompareTo(ElmSharpProfile.MobileProfile) == 0)
{
[Step(1, "Click Run TC")]
[Step(2, "Click button")]
[Postcondition(1, "NA")]
- public static async Task RenderPost_EVENT()
+ public async Task RenderPost_EVENT()
{
CreateResultButton("Test RenderPost event");
_evasObject.RenderPost += OnPost;
[Step(2, "Press back key")]
[Step(3, "Test case result will show automatically.")]
[Postcondition(1, "NA")]
- public static async Task BackButtonPressed_EVENT()
+ public async Task BackButtonPressed_EVENT()
{
CreateResultLabel("Press back key");
_window.BackButtonPressed += Confirm;
[Step(2, "Press menu key")]
[Step(3, "Test case result will show automatically.")]
[Postcondition(1, "NA")]
- public static async Task MoreButtonPressed_EVENT()
+ public async Task MoreButtonPressed_EVENT()
{
if (ElmSharpProfile.GetProfile().CompareTo(ElmSharpProfile.MobileProfile) != 0)
{
[Step(2, "Click 'Test Tooltip' button, and you will see a tooltip label.")]
[Step(3, "If it is, click Pass, or Fail.")]
[Postcondition(1, "NA")]
- public static async Task GetTooltipContentDelegate_CHECK()
+ public async Task GetTooltipContentDelegate_CHECK()
{
if (ElmSharpProfile.GetProfile().CompareTo(ElmSharpProfile.WearableProfile) == 0)
{
}
}
}
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+using System;
+using System.Threading;
+using System.Threading.Tasks;
+using NUnit.Framework;
+using NUnit.Framework.TUnit;
+using ElmSharp;
+using ElmSharpApplication.Tizen;
+
+namespace ElmSharp.Tests
+{
+ [TestFixture]
+ [Description("Testing ElmSharp.NaviItem class")]
+ public class NaviItemTests
+ {
+ private static TestPage _testPage = TestPage.GetInstance();
+ private static Window _window = MainWindow.GetInstance();
+ private static Naviframe _navi;
+ private static Button _btn;
+ private static Rectangle _rect;
+
+ [SetUp]
+ public static void Init()
+ {
+ LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST");
+ }
+
+ [TearDown]
+ public static void Destroy()
+ {
+ LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Postconditions for each TEST");
+ if (_navi != null)
+ {
+ _navi.Unrealize();
+ _navi = null;
+ }
+ if (_rect != null)
+ {
+ _rect.Unrealize();
+ _rect = null;
+ }
+ if (_btn != null)
+ {
+ _btn.Unrealize();
+ _btn = null;
+ }
+ }
+
+ private static void OnConfirm(object s, EventArgs e)
+ {
+ ManualTest.Confirm();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether Popped events which binded by OnInvalidate() can be invoked or not when NaviItem was popped.")]
+ [Property("SPEC", "ElmSharp.NaviItem.OnInvalidate E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ [Step(1, "Click Run TC")]
+ [Step(2, "Click 'Push' button")]
+ [Step(3, "Click navi back button")]
+ [Step(4, "The test result will show automatically.")]
+ [Postcondition(1, "NA")]
+ public async Task OnInvalidate_Check()
+ {
+ if (ElmSharpProfile.GetProfile().CompareTo(ElmSharpProfile.MobileProfile) == 0)
+ {
+ _navi = new Naviframe(_window)
+ {
+ PreserveContentOnPop = true,
+ DefaultBackButtonEnabled = true
+ };
+ _rect = new Rectangle(_window)
+ {
+ Geometry = new Rect(0, 0, 30, 30),
+ Color = Color.Blue
+ };
+ _btn = new Button(_window)
+ {
+ AlignmentX = -1,
+ AlignmentY = -1,
+ WeightX = 1,
+ WeightY = 1,
+ Text = "Push"
+ };
+ _navi.Push(_btn, "First Page");
+ NaviItem item;
+ _btn.Clicked += (s, e) =>
+ {
+ item = _navi.Push(_rect, "Second Page");
+ item.Popped += OnConfirm;
+ };
+
+ _navi.Show();
+ _testPage.ExecuteTCByPage(_navi);
+
+ await ManualTest.WaitForConfirm();
+ var niviframe = _testPage.getNavigationPage();
+ if (niviframe != null)
+ niviframe.Pop();
+ }
+ else
+ {
+ _testPage.UnlockUIButton();
+ Assert.Pass("Not Supported");
+ }
+ }
+ }
+}
\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
<DebugType>portable</DebugType>\r
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>\r
</PropertyGroup>\r
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
<DebugType>None</DebugType>\r
public class MyEvasObject : EvasObject
{
+ bool _isInstantiated;
+
+ public bool CheckOnInstantiated => _isInstantiated;
+
public MyEvasObject() : base()
{
}
+ protected override void OnInstantiated()
+ {
+ _isInstantiated = true;
+ base.OnInstantiated();
+ }
+
protected override IntPtr CreateHandle(EvasObject parent)
{
return IntPtr.Zero;
}
}
+ public class MyEvasObject2 : EvasObject
+ {
+ bool _isRealized;
+ bool _isUnrealized;
+
+ public bool CheckOnRealized => _isRealized;
+ public bool CheckOnUnrealize => _isUnrealized;
+
+ public MyEvasObject2() : base()
+ {
+ }
+
+ protected override void OnRealized()
+ {
+ _isRealized = true;
+ base.OnRealized();
+ }
+
+ protected override void OnUnrealize()
+ {
+ _isUnrealized = true;
+ base.OnUnrealize();
+ }
+
+ protected override IntPtr CreateHandle(EvasObject parent)
+ {
+ Layout layout = new Layout(parent);
+ return layout.Handle;
+ }
+ }
+
[SetUp]
public static void Init()
{
[Test]
[Category("P1")]
+ [Description("Check whether OnInstantiated is successfully invoked or not.")]
+ [Property("SPEC", "ElmSharp.EvasObject.OnInstantiated M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void OnInstantiated_CHECK()
+ {
+ MyEvasObject evasObject = new MyEvasObject();
+ Assert.True(evasObject.CheckOnInstantiated);
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether OnRealized is successfully invoked or not.")]
+ [Property("SPEC", "ElmSharp.EvasObject.OnRealized M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void OnRealized_CHECK()
+ {
+ MyEvasObject2 evasObject = new MyEvasObject2();
+ evasObject.Realize(_window);
+ Assert.True(evasObject.CheckOnRealized);
+ evasObject.Unrealize();
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether OnUnrealize is successfully invoked or not.")]
+ [Property("SPEC", "ElmSharp.EvasObject.OnUnrealize M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void OnUnrealize_CHECK()
+ {
+ MyEvasObject2 evasObject = new MyEvasObject2();
+ evasObject.Realize(_window);
+ evasObject.Unrealize();
+ Assert.True(evasObject.CheckOnUnrealize);
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Check whether implicit operator method work well")]
[Property("SPEC", "ElmSharp.EvasObject.implicit_operator M")]
[Property("SPEC_URL", "-")]
{
_evasObject = null;
IntPtr tem = _evasObject;
- Assert.AreEqual(IntPtr.Zero, tem, "implicit operator method method failed");
+ Assert.AreEqual(IntPtr.Zero, tem, "implicit operator method failed");
+
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether explicit operator method work well")]
+ [Property("SPEC", "ElmSharp.EvasObject.explicit_operator M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void explicit_operator_CHECK_METHOD()
+ {
+ var _obj = new Polygon(_window);
+ _obj.Geometry = new Rect(0, 0, 250, 250);
+ var _evasObj = (EvasObject)_obj;
+
+ Assert.AreEqual(_obj.Geometry.Width, _evasObj.Geometry.Width, "explicit operator method failed");
+
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check GetTextBlockGeometryByLineNumber method")]
+ [Property("SPEC", "ElmSharp.EvasObject.GetTextBlockGeometryByLineNumber M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void GetTextBlockGeometryByLineNumber_CHECK_METHOD()
+ {
+ int x = 0, y = 0, w = 0, h = 0;
+
+ _evasObject = new Entry(_window);
+ var ret = _evasObject.GetTextBlockGeometryByLineNumber(0, out x, out y, out w, out h);
+ Assert.IsTrue(ret, "GetTextBlockGeometryByLineNumber failed");
}
[Test]
}
[Test]
+ [Category("P1")]
+ [Description("Check Load(byte*) return value")]
+ [Property("SPEC", "ElmSharp.Image.Load M")]
+ [Property("COVPARAM", "byte*, long")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void Load_Byte_CHECK()
+ {
+ bool mark = false;
+ FileStream stream = new FileStream(Program.Current.DirectoryInfo.Resource + "test.jpg", FileMode.Open, FileAccess.Read);
+ MemoryStream memstream = new MemoryStream();
+ stream.CopyTo(memstream);
+ unsafe
+ {
+ byte[] dataArr = memstream.ToArray();
+ fixed (byte* data = &dataArr[0])
+ {
+ mark = _image.Load(data, dataArr.Length);
+ }
+ }
+ Assert.IsTrue(mark);
+ }
+
+ [Test]
[Category("P0")]
[Description("Check whether setting and getting BackgroundColor are equal.")]
[Property("SPEC", "ElmSharp.Image.BackgroundColor A")]
private static CircleSurface _circleSurface;
private static MainWindow _window = MainWindow.GetInstance();
+ public class MyCircleSlider : CircleSlider
+ {
+ bool _isRealized;
+
+ public bool CheckOnRealized => _isRealized;
+
+ public MyCircleSlider(EvasObject parent, CircleSurface surface) : base(parent, surface)
+ {
+ }
+
+ protected override void OnRealized()
+ {
+ _isRealized = true;
+ base.OnRealized();
+ }
+ }
+
[SetUp]
public static void Init()
{
{
Assert.AreEqual(_circleSurface, _circleSlider.CircleSurface, "Retrieved CircleSurface should be equal to set value");
}
+
+ [Test]
+ [Category("P1")]
+ [Description("Check whether OnRelaized is successfully invoked or not.")]
+ [Property("SPEC", "ElmSharp.Wearable.CircleSlider.OnRealized M")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "MR")]
+ [Property("AUTHOR", "Jeonghyun Yun, jh0506.yun@samsung.com")]
+ public void OnRealized_Check()
+ {
+ var slider = new MyCircleSlider(_window, _circleSurface);
+ slider.Realize(_window);
+ Assert.True(slider.CheckOnRealized);
+ }
}
-}
\ No newline at end of file
+}