[ElmSharp][Non-ACR] Added TC for test coverage 77/195777/3
authorJeonghyun Yun <jh0506.yun@samsung.com>
Tue, 18 Dec 2018 05:05:44 +0000 (14:05 +0900)
committerJeonghyun Yun <jh0506.yun@samsung.com>
Wed, 19 Dec 2018 07:42:39 +0000 (16:42 +0900)
Change-Id: I211670a0a0ea486c1d412117a44056d40d5a01c8
Signed-off-by: Jeonghyun Yun <jh0506.yun@samsung.com>
tct-suite-vs/Tizen.ElmSharp.Manual.Tests/testcase/TSEvasObject.cs [changed mode: 0644->0755]
tct-suite-vs/Tizen.ElmSharp.Manual.Tests/testcase/TSNaviItem.cs [new file with mode: 0755]
tct-suite-vs/Tizen.ElmSharp.Tests/Tizen.ElmSharp.Tests.csproj [changed mode: 0644->0755]
tct-suite-vs/Tizen.ElmSharp.Tests/testcase/TSEvasObject.cs
tct-suite-vs/Tizen.ElmSharp.Tests/testcase/TSImage.cs [changed mode: 0644->0755]
tct-suite-vs/Tizen.ElmSharpWearable.Tests/testcase/TSCircleSlider.cs

old mode 100644 (file)
new mode 100755 (executable)
index 19b7277..a4b8e02
@@ -33,11 +33,32 @@ namespace ElmSharp.Tests
         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()
         {
@@ -54,6 +75,11 @@ namespace ElmSharp.Tests
                 _box.Unrealize();
                 _box = null;
             }
+            if (_innerbox != null)
+            {
+                _innerbox.Unrealize();
+                _innerbox = null;
+            }
             if (_button != null)
             {
                 _button.Unrealize();
@@ -69,31 +95,12 @@ namespace ElmSharp.Tests
                 _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)
@@ -140,6 +147,12 @@ namespace ElmSharp.Tests
             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);
@@ -169,6 +182,65 @@ namespace ElmSharp.Tests
 
         [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", "-")]
@@ -178,7 +250,7 @@ namespace ElmSharp.Tests
         [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;
@@ -201,7 +273,7 @@ namespace ElmSharp.Tests
         [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)
             {
@@ -230,7 +302,7 @@ namespace ElmSharp.Tests
         [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)
             {
@@ -259,7 +331,7 @@ namespace ElmSharp.Tests
         [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;
@@ -282,7 +354,7 @@ namespace ElmSharp.Tests
         [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;
@@ -303,7 +375,7 @@ namespace ElmSharp.Tests
         [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)
             {
@@ -332,7 +404,7 @@ namespace ElmSharp.Tests
         [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)
             {
@@ -349,4 +421,4 @@ namespace ElmSharp.Tests
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/tct-suite-vs/Tizen.ElmSharp.Manual.Tests/testcase/TSNaviItem.cs b/tct-suite-vs/Tizen.ElmSharp.Manual.Tests/testcase/TSNaviItem.cs
new file mode 100755 (executable)
index 0000000..4b5aaee
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ *  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");
+            }
+        }
+    }
+}
old mode 100644 (file)
new mode 100755 (executable)
index 792bbed..739c3c8
@@ -13,6 +13,7 @@
 \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
index 978d86d..a0fbb43 100755 (executable)
@@ -31,16 +31,57 @@ namespace ElmSharp.Tests
 
         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()
         {
@@ -569,6 +610,49 @@ namespace ElmSharp.Tests
 
         [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", "-")]
@@ -578,8 +662,42 @@ namespace ElmSharp.Tests
         {
             _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]
old mode 100644 (file)
new mode 100755 (executable)
index 9973b0e..4c5bbb1
@@ -199,6 +199,31 @@ namespace ElmSharp.Tests
         }
 
         [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")]
index 60724d3..dbec5b1 100755 (executable)
@@ -32,6 +32,23 @@ namespace ElmSharp.Wearable.Tests
         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()
         {
@@ -375,5 +392,19 @@ namespace ElmSharp.Wearable.Tests
         {
             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
+}