From b487632e51d79cc5afe9cd6b602218201f633318 Mon Sep 17 00:00:00 2001 From: Taehyub Kim Date: Wed, 22 Feb 2023 22:13:51 +0900 Subject: [PATCH] [NUI.Manual][TCSACR-487] Add DragAndDrop Manual Test Change-Id: I7551f9617e4cb458ad2d0dd88ebae704eef50311 --- .../testcase/TSDragAndDrop.cs | 145 +++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100755 tct-suite-vs/Tizen.NUI.Manual.Tests/testcase/TSDragAndDrop.cs diff --git a/tct-suite-vs/Tizen.NUI.Manual.Tests/testcase/TSDragAndDrop.cs b/tct-suite-vs/Tizen.NUI.Manual.Tests/testcase/TSDragAndDrop.cs new file mode 100755 index 0000000..64d00f3 --- /dev/null +++ b/tct-suite-vs/Tizen.NUI.Manual.Tests/testcase/TSDragAndDrop.cs @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2023 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.Tasks; +using NUnit.Framework; +using NUnit.Framework.TUnit; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; +using Tizen.NUI.Components; + +namespace Tizen.NUI.Tests +{ + [TestFixture] + [Description("Tizen.NUI.DragAndDrop test")] + public class DragAndDropTests + { + private ManualTestNUI _testPage; + private WearableManualTestNUI _wearTestPage; + private DragAndDrop dnd; + LongPressGestureDetector longPressed; + private Button _button, _button2, _shadowButton; + private float _pointSize = 20.0f; + private bool _isMobile = false; + private bool _isWearable = false; + + [SetUp] + public void Init() + { + dnd = DragAndDrop.Instance; + LogUtils.Write(LogUtils.INFO, LogUtils.TAG, "Preconditions for each TEST"); + _isMobile = ManualTest.IsMobile(); + _isWearable = ManualTest.IsWearable(); + if (_isWearable) + { + _pointSize = 2.0f; + _wearTestPage = WearableManualTestNUI.GetInstance(); + } + else + { + _pointSize = ManualTest.GetPointSize(); + _testPage = ManualTestNUI.GetInstance(); + } + } + + [TearDown] + public void Destroy() + { + // Destroy Resources + Window.Instance.GetDefaultLayer().Remove(_button); + _button.Dispose(); + _button = null; + + Window.Instance.GetDefaultLayer().Remove(_button2); + _button2.Dispose(); + _button2 = null; + } + + public void SourceFunc(DragSourceEventType type) + { + // Not Implemented + } + + public void TargetFunc(View targetView, DragEvent dragEvent) + { + if (dragEvent.DragType == DragType.Drop) + { + ManualTest.Confirm(); + } + } + + private void CreateDragAndDropTargets() + { + float BaseSize = Window.Instance.Size.Width * 0.22f; + float BasePadding = Window.Instance.Size.Width * 0.167f; + _button = new Button(); + _button.Text = "DragThis"; + _button.PointSize = _pointSize; + _button.Position = new Position(Window.Instance.Size.Width * 0.5f - (BaseSize + BasePadding / 2.0f), Window.Instance.Size.Height * 0.5f - (BaseSize / 2.0f)); + _button.Size = new Size(BaseSize, BaseSize); + _button.Show(); + + _button2 = new Button(); + _button2.Text = "DropHere"; + _button2.PointSize = _pointSize; + _button2.Position = new Position(Window.Instance.Size.Width * 0.5f + (BasePadding / 2.0f), Window.Instance.Size.Height * 0.5f - (BaseSize / 2.0f)); + _button2.Size = new Size(BaseSize, BaseSize); + _button2.Show(); + + Window.Instance.GetDefaultLayer().Add(_button); + Window.Instance.GetDefaultLayer().Add(_button2); + + dnd.AddListener(_button2, TargetFunc); + + longPressed = new LongPressGestureDetector(); + longPressed.Attach(_button); + longPressed.Detected += (s, e) => + { + if (e.LongPressGesture.State == Gesture.StateType.Started) + { + _shadowButton = new Button(); + _shadowButton.Text = "DragThis"; + _shadowButton.PointSize = _pointSize; + _shadowButton.Size = new Size(BaseSize / 2.0f, BaseSize / 2.0f); + DragData dragData; + dragData.MimeType = "text/uri-list"; + dragData.Data = "DragThis"; + dnd.StartDragAndDrop(_button, _shadowButton, dragData, SourceFunc); + } + }; + } + + [Test] + [Category("P1")] + [Description("Test: Check whether the drop event will be triggered when user drag and drop the button.")] + [Property("SPEC", "Tizen.NUI.DragAndDrop.AddListener M")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "MR")] + [Property("AUTHOR", "Taehyub Kim, taehyub.kim@samsung.com")] + [Precondition(1, "If test on TV, prepare mouse and connect to TV.")] + [Step(1, "Click run TC")] + [Step(2, "Longpress \"DragThis\" button.")] + [Step(3, "Move and drop \"DragThis\" button to \"DropHere\" button.")] + [Step(4, "TC will pass after touch or click.")] + [Postcondition(1, "NA")] + public async Task AddListener_CB() + { + CreateDragAndDropTargets(); + await ManualTest.WaitForConfirm(); + } + } +} -- 2.7.4