From: Xianbing Teng Date: Fri, 10 Apr 2020 10:29:05 +0000 (+0800) Subject: [NUI.Wearable][Non-ACR] Removing deprecated apis X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fb57495f807e839402fd48d965d0bb8d90e2f95;p=test%2Ftct%2Fcsharp%2Fapi.git [NUI.Wearable][Non-ACR] Removing deprecated apis Change-Id: Iadaaa1e89c95b71d3bb8e96c8937881ba0a46fc9 --- diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/ManualTestPage.cs b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/ManualTestPage.cs index a00fc36e8..999238d2a 100755 --- a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/ManualTestPage.cs +++ b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/ManualTestPage.cs @@ -23,79 +23,161 @@ using NUnit.Framework.Interfaces; using NUnit.Framework.TUnit; using System.Reflection; using Tizen.NUI.BaseComponents; -using Tizen.NUI.UIComponents; +using Tizen.NUI.Components; +using Tizen.Applications; namespace Tizen.NUI.Wearable.Tests { class ManualTestNUI { + class ListBridge : FlexibleView.Adapter + { + private List _mDatas; + private List _mlistItem; + + public ListBridge(List datas, List item) + { + _mDatas = datas; + _mlistItem = item; + } + + public void UpdateItemData(List item) + { + _mlistItem = item; + } + + public override FlexibleView.ViewHolder OnCreateViewHolder(int viewType) + { + FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new Button()); + return viewHolder; + } + + public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position) + { + string testcaseName = "#." + (position + 1).ToString() + _mDatas[position]; + string resultText = "[" + _mlistItem[(int)position].Result + "]"; + string text = testcaseName + resultText; + + Button btn = holder.ItemView as Button; + if (btn) + { + btn.Focusable = true; + btn.Text = text; + btn.Name = position.ToString(); + btn.PointSize = (Window.Instance.Size.Width / Window.Instance.Dpi.Length()) * 1.06f; + btn.Size = new Size(Window.Instance.Size.Width * 0.4f, Window.Instance.Size.Height * 0.046f); + btn.Style.Text.TextColor = new Color(0, 0, 0, 1); + btn.Style.ImageShadow = new ImageShadow + { + Url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_btn_shadow.png", + Border = new Rectangle(5, 5, 5, 5) + }; + btn.Style.BackgroundImage = new Selector + { + Focused = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_point_btn_normal.png", + Other = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_toggle_btn_normal.png" + }; + btn.FocusGained += OnFocusGained; + btn.FocusLost += OnFocusLost; + btn.Style.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); + btn.ParentOrigin = Position.ParentOriginTopLeft; + btn.PivotPoint = PivotPoint.TopLeft; + btn.TextAlignment = HorizontalAlignment.Begin; + btn.CellIndex = new Vector2(position, 0); + } + } + + public override void OnDestroyViewHolder(FlexibleView.ViewHolder holder) + { + if (holder.ItemView != null) + { + Button btn = holder.ItemView as Button; + btn.FocusGained -= OnFocusGained; + btn.FocusLost -= OnFocusLost; + holder.ItemView.Dispose(); + } + } + + public override int GetItemCount() + { + return _mDatas.Count; + } + + private void OnFocusGained(object sender, EventArgs e) + { + Button btn = sender as Button; + btn.Style.BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_point_btn_normal.png"; + } + + private void OnFocusLost(object sender, EventArgs e) + { + Button btn = sender as Button; + btn.Style.BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_toggle_btn_normal.png"; + } + + } + private List _tcIDList; private List _listItem; private TSettings _tsettings; private TRunner _tRunner; - private NavigationButton _pressButton = NavigationButton.NA; - private PushButton passButton, failButton, blockButton, homeButton, preButton, nextButton, doneButton; - private TextLabel notRun; + private Button _passButton, _failButton, _blockButton, _homeButton, _preButton, _nextButton, _doneButton; + private TextLabel _notRun; private const string STEP_ATTRIBUTE_NAME = "NUnit.Framework.StepAttribute"; private const string PRECONDITION_ATTRIBUTE_NAME = "NUnit.Framework.PreconditionAttribute"; private const string POSTCONDITION_ATTRIBUTE_NAME = "NUnit.Framework.PostconditionAttribute"; //For TV KantM //private static float PointSize = 30.0f; //private static float ButtonSizeWidth = 200; - private static float PointSize = 5.0f; - private static float PixelSize = 20.0f; + private static float _pointSize = 5.0f; + private static float _pixelSize = 20.0f; //Save the information of every single test case - private List TCInfoList; - private List CurrentTCInfo; + private List _tcInfoList; + private List _currentTCInfo; - private static ManualTestNUI instance; - private static Object lockObject = new object(); + private static ManualTestNUI _instance; + private static Object _lockObject = new object(); //Show the result of all the test case private TextLabel _summaryLabel; - ScrollView _scrollView; private View _initView; private View _detailView; - private TableView _initList; - private TableView _detailList; private View _caseView; - private TableView _buttonContainer; + private FlexibleView _initList; + private ListBridge _adapter; + private TableView _detailList; + private View _buttonContainer; + private View _buttonContainer2; private TableView _firstPageContainer; - private PushButton run; - private PushButton runButton; - private PushButton[] buttonList; + private Button _run; + private Button _runButton; //Always save the current TC number; - private int CurrentTCNum = 0; - - private const float RowSpacing = 0.0f; - private const float TopMargin = 0.0f; - private const float BottomMargin = 0.0f; - private const float SideMargin = 5.0f; - private const float ItemHeight = 30.0f; + private int _currentTCNum = 0; public static ManualTestNUI GetInstance() { - lock (lockObject) + lock (_lockObject) { - if (instance == null) + if (_instance == null) { - instance = new ManualTestNUI(); + _instance = new ManualTestNUI(); } } - return instance; + return _instance; } private ManualTestNUI() { Initialize(); } + public void Initialize() { Tizen.Log.Fatal("NUI", "NUI Initialize"); - PointSize = (1.0f / Window.Instance.Dpi.Length()) * 2000.0f; + _pointSize = (1.0f / Window.Instance.Dpi.Length()) * 2000.0f; RunType.Value = RunType.MANUAL; _tRunner = new TRunner(); _tRunner.LoadTestsuite(); @@ -115,7 +197,6 @@ namespace Tizen.NUI.Wearable.Tests Tizen.Log.Fatal("NUI", "TCT : TCName:" + nameTc.ToString()); } - _tsettings = TSettings.GetInstance(); _tsettings.IsManual = true; @@ -126,8 +207,8 @@ namespace Tizen.NUI.Wearable.Tests window.BackgroundColor = Color.White; _summaryLabel = new TextLabel(); - _summaryLabel.PixelSize = PixelSize; - _summaryLabel.Size2D = new Size2D((int)Window.Instance.Size.Width, 60); + _summaryLabel.PixelSize = _pixelSize; + _summaryLabel.Size = new Size((int)Window.Instance.Size.Width, 60); _summaryLabel.ParentOrigin = Position.ParentOriginTopLeft; _summaryLabel.PivotPoint = PivotPoint.TopLeft; _summaryLabel.Position = new Position(0, 5, 0); @@ -138,7 +219,7 @@ namespace Tizen.NUI.Wearable.Tests window.GetDefaultLayer().Add(_summaryLabel); _initView = new View(); - _initView.Size2D = new Size2D((int)Window.Instance.Size.Width, (int)Window.Instance.Size.Height - 65); + _initView.Size = new Size((int)Window.Instance.Size.Width, (int)Window.Instance.Size.Height - 65); _initView.ParentOrigin = Position.ParentOriginTopLeft; _initView.PivotPoint = PivotPoint.TopLeft; _initView.Position = new Position(0.0f, 70.0f, 0.0f); @@ -146,7 +227,7 @@ namespace Tizen.NUI.Wearable.Tests _initView.Show(); _detailView = new View(); - _initView.Size2D = new Size2D((int)Window.Instance.Size.Width, (int)Window.Instance.Size.Height - 65); + _detailView.Size = new Size((int)Window.Instance.Size.Width, (int)Window.Instance.Size.Height - 65); _detailView.ParentOrigin = Position.ParentOriginTopLeft; _detailView.PivotPoint = PivotPoint.TopLeft; _detailView.Position = new Position(0.0f, 70.0f, 0.0f); @@ -156,87 +237,78 @@ namespace Tizen.NUI.Wearable.Tests window.GetDefaultLayer().Add(_initView); window.GetDefaultLayer().Add(_detailView); - FocusManager.Instance.SetCurrentFocusView(run); + FocusManager.Instance.SetCurrentFocusView(_run); } - void InitializeFirstPage() + void SetCommonButtonStyle(Button btn, string text) { - //Create Run Button, when you Click it, then the first test case will be executed. - doneButton = new PushButton(); - doneButton.Focusable = true; - doneButton.LabelText = "Done"; - doneButton.Clicked += (obj, ee) => + if (!btn) return; + btn.Focusable = true; + btn.Text = text; + btn.PointSize = _pointSize; + btn.Size = new Size(Window.Instance.Size.Width * 0.06f, Window.Instance.Size.Height * 0.046f); + btn.Style.Text.TextColor = new Color(0, 0, 0, 1); + btn.Style.ImageShadow = new ImageShadow { - TSettings.GetInstance().SubmitManualResult(); - return false; + Url = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_btn_shadow.png", + Border = new Rectangle(5, 5, 5, 5) }; - - run = new PushButton(); - run.LabelText = "Runner"; - run.Clicked += (obj, ee) => - { - Tizen.Log.Fatal("NUI", "Check all the test case from the first one."); - CurrentTCNum = 0; - _initView.Hide(); - _caseView.Hide(); - UpdateDetailPage(); - _detailView.Show(); - FocusManager.Instance.SetCurrentFocusView(runButton); - return false; + btn.Style.BackgroundImage = new Selector + { + Focused = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_point_btn_normal.png", + Other = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_toggle_btn_normal.png" }; + btn.Style.BackgroundImageBorder = new Rectangle(5, 5, 5, 5); + btn.ParentOrigin = Position.ParentOriginTopLeft; + btn.PivotPoint = PivotPoint.TopLeft; + btn.FocusGained += OnFocusGained; + btn.FocusLost += OnFocusLost; + } + + void InitializeFirstPage() + { + //Create Run Button, when you Click it, then the first test case will be executed. + _doneButton = new Button(); + SetCommonButtonStyle(_doneButton, "Done"); + _doneButton.ClickEvent += OnDoneButtonClicked; - run.RightFocusableView = doneButton; - doneButton.LeftFocusableView = run; + _run = new Button(); + SetCommonButtonStyle(_run, "Runner"); + _run.ClickEvent += OnRunnerButtonClicked; + _run.RightFocusableView = _doneButton; + _doneButton.LeftFocusableView = _run; //To show all the test case information(Number _className._TCName [result]). - _initList = new TableView((uint)_tcIDList.Count, 1); + _initList = new FlexibleView(); + _initList.Position = new Position(0, Window.Instance.Size.Height * 0.0925f); + _initList.Size = new Size(Window.Instance.Size.Width * 0.5f, Window.Instance.Size.Height * 0.79f); + _adapter = new ListBridge(_tcIDList, _listItem); + _initList.SetAdapter(_adapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL); + _initList.SetLayoutManager(layoutManager); + _initList.FocusedItemIndex = 0; _initList.Focusable = true; - _initList.CellPadding = new Vector2(0, 0); - _initList.Size2D = new Size2D(Window.Instance.Size.Width - 50, _tcIDList.Count * 50); - _initList.ParentOrigin = Position.ParentOriginTopLeft; - _initList.PivotPoint = PivotPoint.TopLeft; - _initList.Position = new Position(0.0f, 0.0f, 0.0f); - CreateInitList(); - - run.DownFocusableView = _initList; - doneButton.DownFocusableView = _initList; - _initList.UpFocusableView = run; - - _firstPageContainer = new TableView(2, 2); + _initList.ItemClickEvent += OnItemClickEvent; + _initList.FocusGained += OnInitListFocusGained; + _initList.FocusLost += OnInitListFocusLost; + _initList.KeyEvent += OnInitListKeyEvent; + + _firstPageContainer = new TableView(1, 2); _firstPageContainer.PivotPoint = Position.PivotPointTopLeft; _firstPageContainer.ParentOrigin = Position.ParentOriginTopLeft; - _firstPageContainer.Position = new Position(0, 3, 0); - _firstPageContainer.Size2D = new Size2D((int)Window.Instance.Size.Width - 200, 200); - _firstPageContainer.Focusable = (true); + _firstPageContainer.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.1f); + _firstPageContainer.Focusable = true; _firstPageContainer.SetCellAlignment(new TableView.CellPosition(0, 0), HorizontalAlignmentType.Right, VerticalAlignmentType.Center); _firstPageContainer.SetCellAlignment(new TableView.CellPosition(0, 1), HorizontalAlignmentType.Center, VerticalAlignmentType.Center); - _firstPageContainer.SetCellAlignment(new TableView.CellPosition(1), HorizontalAlignmentType.Center, VerticalAlignmentType.Center); - _firstPageContainer.CellPadding = new Vector2(0, 0); - - _firstPageContainer.AddChild(doneButton, new TableView.CellPosition(0, 0)); - _firstPageContainer.AddChild(run, new TableView.CellPosition(0, 1)); - - - _scrollView = new ScrollView(); - _scrollView.ClippingMode = ClippingModeType.ClipChildren; - _scrollView.BackgroundColor = Color.Transparent; - _scrollView.Size2D = new Size2D(Window.Instance.Size.Width, Window.Instance.Size.Height); - _scrollView.Position2D = new Position2D(0, 0); - _scrollView.Scrolling = true; - - PropertyMap rulerMap = new PropertyMap(); - rulerMap.Add((int)ScrollModeType.XAxisScrollEnabled, new PropertyValue(false)); - rulerMap.Add((int)ScrollModeType.YAxisScrollEnabled, new PropertyValue(true)); - rulerMap.Add((int)ScrollModeType.YAxisSnapToInterval, new PropertyValue(100)); - rulerMap.Add((int)ScrollModeType.YAxisScrollBoundary, new PropertyValue(60 * (_tcIDList.Count+1))); - _scrollView.ScrollMode = rulerMap; - - _scrollView.Add(_initList); - _firstPageContainer.AddChild(_scrollView, new TableView.CellPosition(1, 0, 1, 2)); + _firstPageContainer.AddChild(_doneButton, new TableView.CellPosition(0, 0)); + _firstPageContainer.AddChild(_run, new TableView.CellPosition(0, 1)); + _run.DownFocusableView = _initList; + _doneButton.DownFocusableView = _initList; _initView.Add(_firstPageContainer); + _initView.Add(_initList); Tizen.Log.Fatal("NUI", "TCT : InitializeFirstPage:"); - FocusManager.Instance.SetCurrentFocusView(run); + FocusManager.Instance.SetCurrentFocusView(_run); } //Update the Test Page before you want to show it(Click Run/Pre/nect Button, or Click on item in the List). @@ -251,7 +323,7 @@ namespace Tizen.NUI.Wearable.Tests { _detailList = new TableView(23, 1); _detailList.Focusable = true; - _detailList.Size2D = new Size2D(Window.Instance.Size.Width - 50, 500); + _detailList.Size = new Size(Window.Instance.Size.Width - 50, 500); _detailList.ParentOrigin = Position.ParentOriginTopLeft; _detailList.PivotPoint = PivotPoint.TopLeft; _detailList.Position = new Position(0.0f, 0.0f, 0.0f); @@ -259,15 +331,31 @@ namespace Tizen.NUI.Wearable.Tests _detailView.Add(_detailList); //To Place the function button, such as PASS, FAIL..... - _buttonContainer = new TableView(2, 4); - _buttonContainer.SetSizeModeFactor(new Vector3(0.0f, 0.9f, 0.0f)); - _buttonContainer.PivotPoint = PivotPoint.TopCenter; + _buttonContainer = new View(); + _buttonContainer.PivotPoint = PivotPoint.TopLeft; _buttonContainer.ParentOrigin = Position.ParentOriginTopLeft; - _buttonContainer.Position = new Position(0, Window.Instance.Size.Height * 0.6f, 0); - _buttonContainer.Size2D = new Size2D((int)Window.Instance.Size.Width, 300); - _buttonContainer.Focusable = (true); + _buttonContainer.Position = new Position(0, Window.Instance.Size.Height * 0.68f, 0); + _buttonContainer.Size = new Size(Window.Instance.Size.Width * 0.8f, Window.Instance.Size.Height * 0.1f); + _buttonContainer.Focusable = true; + + _buttonContainer2 = new View(); + _buttonContainer2.PivotPoint = PivotPoint.TopLeft; + _buttonContainer2.ParentOrigin = Position.ParentOriginTopLeft; + _buttonContainer2.Position = new Position(0, Window.Instance.Size.Height * 0.8f, 0); + _buttonContainer2.Size = new Size(Window.Instance.Size.Width * 0.8f, Window.Instance.Size.Height * 0.1f); + _buttonContainer2.Focusable = true; + + var flexlayout = new FlexLayout(); + flexlayout.Direction = FlexLayout.FlexDirection.Row; + flexlayout.Justification = FlexLayout.FlexJustification.SpaceBetween; + _buttonContainer.Layout = flexlayout; + var flexlayout2 = new FlexLayout(); + flexlayout2.Direction = FlexLayout.FlexDirection.Row; + flexlayout2.Justification = FlexLayout.FlexJustification.SpaceBetween; + _buttonContainer2.Layout = flexlayout2; CreateButtons(); _detailView.Add(_buttonContainer); + _detailView.Add(_buttonContainer2); } //To show the detail information of the test case @@ -281,163 +369,83 @@ namespace Tizen.NUI.Wearable.Tests _detailView.Remove(_detailList); _detailList.Dispose(); } - Tizen.Log.Fatal("NUI", "Print the CurrentTCNum here::" + CurrentTCNum); + Tizen.Log.Fatal("NUI", "Print the CurrentTCNum here::" + _currentTCNum); _detailList = new TableView(10, 1); _detailList.Focusable = true; - _detailList.Size2D = new Size2D(Window.Instance.Size.Width - 50, 400); + _detailList.Size = new Size(Window.Instance.Size.Width * 0.9739f, Window.Instance.Size.Height * 0.3703f); _detailList.ParentOrigin = Position.ParentOriginTopLeft; _detailList.PivotPoint = PivotPoint.TopLeft; _detailList.Position = new Position(0.0f, 0.0f, 0.0f); CreateDetailList(); _detailView.Add(_detailList); - if (notRun) + if (_notRun) { - notRun.Text = _listItem[CurrentTCNum].Result; + _notRun.Text = _listItem[_currentTCNum].Result; } } //Create all the function buttons here, such as PASS, FAIL..... void CreateButtons() { - - notRun = new TextLabel(); - notRun.SizeWidth = 200; - notRun.PixelSize = PixelSize; - notRun.HorizontalAlignment = HorizontalAlignment.Begin; - notRun.Text = "Not Run"; - - passButton = new PushButton(); - passButton.Focusable = true; - passButton.LabelText = "Pass"; - passButton.Clicked += (obj, ee) => - { - - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.PASS; - ManualTest.Confirm(); - } - Tizen.Log.Fatal("TBT", "Pass Button clicked!"); - return true; - }; - - failButton = new PushButton(); - failButton.Focusable = true; - failButton.LabelText = "Fail"; - failButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.FAIL; - ManualTest.Confirm(); - } - Tizen.Log.Fatal("TBT", "Fail Button clicked!"); - return true; - }; - - blockButton = new PushButton(); - blockButton.Focusable = true; - blockButton.LabelText = "Block"; - blockButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.BLOCK; - ManualTest.Confirm(); - } - return true; - }; - - runButton = new PushButton(); - runButton.Focusable = true; - runButton.LabelText = "Run"; - runButton.Clicked += (obj, ee) => - { - Clear(); - //should update the _caseView by the test case - _pressButton = NavigationButton.NA; - _tsettings.Testcase_ID = _tcIDList[CurrentTCNum]; - _tsettings.TCResult = ""; - _tRunner.Execute(); - return true; - }; - - homeButton = new PushButton(); - homeButton.Focusable = true; - homeButton.LabelText = "Home"; - homeButton.Clicked += (obj, ee) => - { - Clear(); - _pressButton = NavigationButton.Home; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - _detailView.Hide(); - _initView.Show(); - FocusManager.Instance.SetCurrentFocusView(run); - } - return true; - }; - - preButton = new PushButton(); - preButton.Focusable = true; - preButton.LabelText = "<<"; - preButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - if (CurrentTCNum != 0) - { - CurrentTCNum--; - notRun.Text = _listItem[CurrentTCNum].Result; - ManualTest.Confirm(); - UpdateDetailPage(); - } - } - return true; - }; - nextButton = new PushButton(); - nextButton.Focusable = true; - nextButton.LabelText = ">>"; - nextButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - if (CurrentTCNum + 1 != ResultNumber.Total) - { - Tizen.Log.Fatal("NUI", "Print the [not run] CurrentTCNum::" + CurrentTCNum); - CurrentTCNum++; - notRun.Text = _listItem[CurrentTCNum].Result; - UpdateDetailPage(); - } - return true; - }; - - _buttonContainer.AddChild(passButton, new TableView.CellPosition(0, 0)); - _buttonContainer.AddChild(failButton, new TableView.CellPosition(0, 1)); - _buttonContainer.AddChild(blockButton, new TableView.CellPosition(0, 2)); - _buttonContainer.AddChild(runButton, new TableView.CellPosition(0, 3)); - _buttonContainer.AddChild(homeButton, new TableView.CellPosition(1, 0)); - _buttonContainer.AddChild(notRun, new TableView.CellPosition(1, 1)); - _buttonContainer.AddChild(preButton, new TableView.CellPosition(1, 2)); - _buttonContainer.AddChild(nextButton, new TableView.CellPosition(1, 3)); + _notRun = new TextLabel(); + _notRun.HorizontalAlignment = HorizontalAlignment.Begin; + _notRun.PointSize = _pointSize; + _notRun.Text = "Not Run"; + _notRun.Size = new Size(Window.Instance.Size.Width * 0.06f, Window.Instance.Size.Height * 0.046f); + + _passButton = new Button(); + SetCommonButtonStyle(_passButton, "Pass"); + _passButton.ClickEvent += OnPassButtonClicked; + _failButton = new Button(); + SetCommonButtonStyle(_failButton, "Fail"); + _failButton.ClickEvent += OnFailButtonClicked; + + _blockButton = new Button(); + SetCommonButtonStyle(_blockButton, "Block"); + _blockButton.ClickEvent += OnBlockButtonClicked; + + _runButton = new Button(); + SetCommonButtonStyle(_runButton, "Run"); + _runButton.ClickEvent += OnRunButtonClicked; + + _homeButton = new Button(); + SetCommonButtonStyle(_homeButton, "Home"); + _homeButton.ClickEvent += OnHomeButtonClicked; + + _preButton = new Button(); + SetCommonButtonStyle(_preButton, "<<"); + _preButton.ClickEvent += OnPreButtonClicked; + + _nextButton = new Button(); + SetCommonButtonStyle(_nextButton, ">>"); + _nextButton.ClickEvent += OnNextButtonClicked; + + _runButton.DownFocusableView = _nextButton; + _runButton.LeftFocusableView = _blockButton; + _runButton.RightFocusableView = _homeButton; + _blockButton.LeftFocusableView = _failButton; + _blockButton.RightFocusableView = _runButton; + _failButton.RightFocusableView = _blockButton; + _failButton.LeftFocusableView = _passButton; + _passButton.RightFocusableView = _failButton; + _passButton.DownFocusableView = _homeButton; + _homeButton.UpFocusableView = _passButton; + _homeButton.LeftFocusableView = _runButton; + _homeButton.RightFocusableView = _preButton; + _preButton.UpFocusableView = _runButton; + _preButton.LeftFocusableView = _homeButton; + _preButton.RightFocusableView = _nextButton; + _nextButton.UpFocusableView = _runButton; + _nextButton.LeftFocusableView = _preButton; + + _buttonContainer.Add(_passButton); + _buttonContainer.Add(_failButton); + _buttonContainer.Add(_blockButton); + _buttonContainer.Add(_runButton); + _buttonContainer2.Add(_homeButton); + _buttonContainer2.Add(_notRun); + _buttonContainer2.Add(_preButton); + _buttonContainer2.Add(_nextButton); } public void ExecuteTC(View view) @@ -462,7 +470,7 @@ namespace Tizen.NUI.Wearable.Tests { if (e.Key.KeyPressedName == "Down") { - FocusManager.Instance.SetCurrentFocusView(passButton); + FocusManager.Instance.SetCurrentFocusView(_passButton); } } @@ -478,7 +486,7 @@ namespace Tizen.NUI.Wearable.Tests if (e.Key.KeyPressedName == "Up") { Tizen.Log.Fatal("NUI", "Set current focus view :: doneButton"); - FocusManager.Instance.SetCurrentFocusView(doneButton); + FocusManager.Instance.SetCurrentFocusView(_doneButton); } } return false; @@ -493,7 +501,7 @@ namespace Tizen.NUI.Wearable.Tests if (e.Key.KeyPressedName == "Down") { Tizen.Log.Fatal("NUI", "Set current focus view :: run"); - FocusManager.Instance.SetCurrentFocusView(run); + FocusManager.Instance.SetCurrentFocusView(_run); } } return false; @@ -509,11 +517,120 @@ namespace Tizen.NUI.Wearable.Tests public void ClearTestCase(View view) { - FocusManager.Instance.SetCurrentFocusView(runButton); + FocusManager.Instance.SetCurrentFocusView(_runButton); Tizen.Log.Fatal("NUI", "Clear test case!"); _detailView.Remove(view); } + public void Dispose() + { + if (_passButton) + { + _passButton.ClickEvent -= OnPassButtonClicked; + _passButton.FocusGained -= OnFocusGained; + _passButton.FocusLost -= OnFocusLost; + _passButton.GetParent()?.Remove(_passButton); + _passButton.Dispose(); + _passButton = null; + } + if (_failButton) + { + _failButton.ClickEvent -= OnFailButtonClicked; + _failButton.FocusGained -= OnFocusGained; + _failButton.FocusLost -= OnFocusLost; + _failButton.GetParent()?.Remove(_failButton); + _failButton.Dispose(); + _failButton = null; + } + if (_blockButton) + { + _blockButton.ClickEvent -= OnBlockButtonClicked; + _blockButton.FocusGained -= OnFocusGained; + _blockButton.FocusLost -= OnFocusLost; + _blockButton.GetParent()?.Remove(_blockButton); + _blockButton.Dispose(); + _blockButton = null; + } + if (_runButton) + { + _runButton.ClickEvent -= OnRunButtonClicked; + _runButton.FocusGained -= OnFocusGained; + _runButton.FocusLost -= OnFocusLost; + _runButton.GetParent()?.Remove(_runButton); + _runButton.Dispose(); + _runButton = null; + } + if (_homeButton) + { + _homeButton.ClickEvent -= OnHomeButtonClicked; + _homeButton.FocusGained -= OnFocusGained; + _homeButton.FocusLost -= OnFocusLost; + _homeButton.GetParent()?.Remove(_homeButton); + _homeButton.Dispose(); + _homeButton = null; + } + if (_preButton) + { + _preButton.ClickEvent -= OnPreButtonClicked; + _preButton.FocusGained -= OnFocusGained; + _preButton.FocusLost -= OnFocusLost; + _preButton.GetParent()?.Remove(_preButton); + _preButton.Dispose(); + _preButton = null; + } + if (_nextButton) + { + _nextButton.ClickEvent -= OnNextButtonClicked; + _nextButton.FocusGained -= OnFocusGained; + _nextButton.FocusLost -= OnFocusLost; + _nextButton.GetParent()?.Remove(_nextButton); + _nextButton.Dispose(); + _nextButton = null; + } + + if(_detailView) + { + _detailView.GetParent()?.Remove(_detailView); + _detailView.Dispose(); + _detailView = null; + } + if (_initList) + { + _initList.ItemClickEvent -= OnItemClickEvent; + _initList.FocusGained -= OnInitListFocusGained; + _initList.FocusLost -= OnInitListFocusLost; + _initList.KeyEvent -= OnInitListKeyEvent; + _initList.GetParent()?.Remove(_initList); + _initList.Dispose(); + _initList = null; + } + if (_doneButton) + { + _doneButton.ClickEvent -= OnDoneButtonClicked; + _doneButton.FocusGained -= OnFocusGained; + _doneButton.FocusLost -= OnFocusLost; + _doneButton.GetParent()?.Remove(_doneButton); + _doneButton.Dispose(); + _doneButton = null; + } + if (_run) + { + _run.ClickEvent -= OnRunnerButtonClicked; + _run.FocusGained -= OnFocusGained; + _run.FocusLost -= OnFocusLost; + _run.GetParent()?.Remove(_run); + _run.Dispose(); + _run = null; + } + + if (_initView) + { + _initView.GetParent()?.Remove(_initView); + _initView.Dispose(); + _initView = null; + } + } + //Use to update the _summaryLabel. private void SetSummaryResult() { @@ -530,58 +647,10 @@ namespace Tizen.NUI.Wearable.Tests return map; } - private void CreateInitList() - { - int tcNum = _tcIDList.Count; - Tizen.Log.Fatal("NUI", "_tcIDList.Count: " + _tcIDList.Count); - buttonList = new PushButton[tcNum]; - for (int index = 0; index < tcNum; index++) - { - string name = _tcIDList[index]; - string testcaseName = "#." + (index + 1).ToString() + name; - string resultText = "[" + _listItem[(int)index].Result + "]"; - string text = testcaseName + resultText; - buttonList[index] = new PushButton(); - buttonList[index].CellIndex = new Vector2(index, 0); - buttonList[index].Name = index.ToString(); - buttonList[index].Focusable = true; - buttonList[index].Label = CreateTextMap(PointSize, text); - buttonList[index].ParentOrigin = Position.ParentOriginTopLeft; - buttonList[index].PivotPoint = PivotPoint.TopLeft; - buttonList[index].Position = new Position(0.0f, 0.0f, 0.0f); - buttonList[index].Clicked += (obj, e) => - { - PushButton button = obj as PushButton; - - Tizen.Log.Fatal("TBT", "Item clicked!!::" + button.Name); - CurrentTCNum = int.Parse(button.Name); - _initView.Hide(); - UpdateDetailPage(); - _caseView.Hide(); - _detailView.Show(); - FocusManager.Instance.SetCurrentFocusView(runButton); - return false; - }; - buttonList[index].FocusGained += ManualTestNUI_FocusGained; - _initList.AddChild(buttonList[index], new TableView.CellPosition((uint)index, 0)); - - } - } - - private void ManualTestNUI_FocusGained(object sender, EventArgs e) - { - var item = sender as PushButton; - if (item != null) - { - uint idx = UInt32.Parse(item.Name); - _scrollView.ScrollTo(new Vector2(0, 30 * idx)); - } - } - private void CreateDetailList() { Tizen.Log.Fatal("NUI", "Print the CreateDetailList::"); - int senNum = CurrentTCInfo.Count; + int senNum = _currentTCInfo.Count; for (int index = 0; index < senNum; index++) { TextLabel description = new TextLabel(); @@ -590,8 +659,8 @@ namespace Tizen.NUI.Wearable.Tests description.Position = new Position(0.0f, 0.0f, 0.0f); description.Size2D = new Size2D((int)Window.Instance.Size.Width - 20, 50); description.HorizontalAlignment = HorizontalAlignment.Begin; - description.PointSize = PointSize; - description.Text = CurrentTCInfo[(int)index]; + description.PointSize = _pointSize; + description.Text = _currentTCInfo[(int)index]; _detailList.AddChild(description, new TableView.CellPosition((uint)index, 0)); } } @@ -603,7 +672,7 @@ namespace Tizen.NUI.Wearable.Tests ResultNumber.Pass = 0; ResultNumber.Fail = 0; ResultNumber.Block = 0; - TCInfoList = new List(); + _tcInfoList = new List(); foreach (KeyValuePair pair in _tRunner.GetTestList()) { List preconditions = new List(); @@ -628,7 +697,7 @@ namespace Tizen.NUI.Wearable.Tests postconditions.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); } } - TCInfoList.Add(new TestcaseInfo + _tcInfoList.Add(new TestcaseInfo { TestcaseName = pair.Key, Preconditions = preconditions, @@ -642,25 +711,25 @@ namespace Tizen.NUI.Wearable.Tests //The data in CurrentTCInfo list will be show in _detailList. void UpdateCurrentTCInfo() { - CurrentTCInfo = new List(); - Tizen.Log.Fatal("NUI", "Print the CurrentTCNum::" + CurrentTCNum); - CurrentTCInfo.Add("DESCRIPTION:#" + (CurrentTCNum + 1)); - string[] str = TCInfoList[CurrentTCNum].TestcaseName.Split('.'); - CurrentTCInfo.Add("CLASS:" + str[str.Length - 2]); - CurrentTCInfo.Add("METHOD:" + str[str.Length - 1]); - for(int index = 0; index < TCInfoList[CurrentTCNum].Preconditions.Count; index++) + _currentTCInfo = new List(); + Tizen.Log.Fatal("NUI", "Print the CurrentTCNum::" + _currentTCNum); + _currentTCInfo.Add("DESCRIPTION:#" + (_currentTCNum + 1)); + string[] str = _tcInfoList[_currentTCNum].TestcaseName.Split('.'); + _currentTCInfo.Add("CLASS:" + str[str.Length - 2]); + _currentTCInfo.Add("METHOD:" + str[str.Length - 1]); + for(int index = 0; index < _tcInfoList[_currentTCNum].Preconditions.Count; index++) { - CurrentTCInfo.Add(TCInfoList[CurrentTCNum].Preconditions[index]); + _currentTCInfo.Add(_tcInfoList[_currentTCNum].Preconditions[index]); } - for(int index = 0; index < TCInfoList[CurrentTCNum].Steps.Count; index++ ) + for(int index = 0; index < _tcInfoList[_currentTCNum].Steps.Count; index++ ) { - CurrentTCInfo.Add(TCInfoList[CurrentTCNum].Steps[index]); + _currentTCInfo.Add(_tcInfoList[_currentTCNum].Steps[index]); } - for(int index = 0; index < TCInfoList[CurrentTCNum].Postconditions.Count; index++ ) + for(int index = 0; index < _tcInfoList[_currentTCNum].Postconditions.Count; index++ ) { - CurrentTCInfo.Add(TCInfoList[CurrentTCNum].Postconditions[index]); + _currentTCInfo.Add(_tcInfoList[_currentTCNum].Postconditions[index]); } - Tizen.Log.Fatal("NUI", "The CurrentTCNum::" + CurrentTCNum); + Tizen.Log.Fatal("NUI", "The CurrentTCNum::" + _currentTCNum); } private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) @@ -668,19 +737,19 @@ namespace Tizen.NUI.Wearable.Tests //Test when will this event will be triggered Tizen.Log.Fatal("NUI", "OnSingleTestDone has been triggered!"); // check old result - if (_listItem[CurrentTCNum].Result.Contains(StrResult.FAIL)) + if (_listItem[_currentTCNum].Result.Contains(StrResult.FAIL)) { ResultNumber.Fail = ResultNumber.Fail - 1; } - else if (_listItem[CurrentTCNum].Result.Contains(StrResult.PASS)) + else if (_listItem[_currentTCNum].Result.Contains(StrResult.PASS)) { ResultNumber.Pass = ResultNumber.Pass - 1; } - else if (_listItem[CurrentTCNum].Result.Contains(StrResult.BLOCK)) + else if (_listItem[_currentTCNum].Result.Contains(StrResult.BLOCK)) ResultNumber.Block = ResultNumber.Block - 1; // Update new result - _listItem[CurrentTCNum].Result = e.Result; + _listItem[_currentTCNum].Result = e.Result; if (e.Result.Contains(StrResult.PASS)) { ResultNumber.Pass += 1; @@ -694,34 +763,222 @@ namespace Tizen.NUI.Wearable.Tests ResultNumber.Block += 1; } - _initList.RemoveChildAt(new TableView.CellPosition((uint)CurrentTCNum, 0)); - string name = _tcIDList[CurrentTCNum]; - string testcaseName = "#." + (CurrentTCNum + 1).ToString() + name; - string resultText = "[" + _listItem[(int)CurrentTCNum].Result + "]"; - string text = testcaseName + resultText; - PushButton button = new PushButton(); - button.CellIndex = new Vector2(CurrentTCNum, 0); - button.Name = CurrentTCNum.ToString(); - button.Focusable = true; - button.Label = CreateTextMap(PointSize, text); - button.ParentOrigin = Position.ParentOriginTopLeft; - button.PivotPoint = PivotPoint.TopLeft; - button.Position = new Position(0.0f, 0.0f, 0.0f); - button.Clicked += (obj, ee) => - { - Tizen.Log.Fatal("NUI", "Item clicked clicked!!::" + ((int)button.CellIndex.X).ToString()); - CurrentTCNum = (int)button.CellIndex.X; - _initView.Hide(); - UpdateDetailPage(); - _caseView.Hide(); - _detailView.Show(); - FocusManager.Instance.SetCurrentFocusView(runButton); - return false; - }; - _initList.AddChild(button, new TableView.CellPosition((uint)CurrentTCNum, 0)); + FlexibleView.ViewHolder holder = _initList?.FindViewHolderForAdapterPosition(_currentTCNum); + if (holder != null) + { + string testcaseName = "#." + (_currentTCNum + 1).ToString() + _tcIDList[_currentTCNum]; + string resultText = "[" + _listItem[(int)_currentTCNum].Result + "]"; + string text = testcaseName + resultText; + Button btn = holder.ItemView as Button; + btn.Text = text; + _adapter?.UpdateItemData(_listItem); + } + SetSummaryResult(); - notRun.Text = _listItem[CurrentTCNum].Result; + _notRun.Text = _listItem[_currentTCNum].Result; + } + + private void OnItemClickEvent(object sender, FlexibleView.ItemClickEventArgs e) + { + Button button = e.ClickedView.ItemView as Button; + if (button) + { + Tizen.Log.Fatal("NUI", "Item clicked!!::" + button.Name); + _currentTCNum = int.Parse(button.Name); + _initView.Hide(); + UpdateDetailPage(); + _caseView.Hide(); + _detailView.Show(); + FocusManager.Instance.SetCurrentFocusView(_runButton); + } + } + + private void OnInitListFocusGained(object sender, EventArgs e) + { + FlexibleView.ViewHolder holder = _initList?.FindViewHolderForAdapterPosition(0); + if (holder != null && holder.ItemView != null) + { + FocusManager.Instance.SetCurrentFocusView(holder.ItemView); + _currentTCNum = 0; + } + } + + private void OnInitListFocusLost(object sender, EventArgs e) + { + _currentTCNum = 0; + } + + private bool OnInitListKeyEvent(object sender, View.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + Tizen.Log.Fatal("NUI", "KeyEvent~KeyPressedName = " + e.Key.KeyPressedName + ",KeyCode = " + e.Key.KeyCode); + if (e.Key.KeyPressedName == "Up") + { + if (_currentTCNum == 0) + { + FocusManager.Instance.SetCurrentFocusView(_run); + } + else + { + FlexibleView.ViewHolder holder = _initList?.FindViewHolderForAdapterPosition(_currentTCNum - 1); + if (holder != null && holder.ItemView != null) + { + FocusManager.Instance.SetCurrentFocusView(holder.ItemView); + _currentTCNum--; + } + } + } + else if (e.Key.KeyPressedName == "Down") + { + if (_currentTCNum == _initList.ChildCount - 1) + { + _currentTCNum = 0; + } + else + { + _currentTCNum++; + } + FlexibleView.ViewHolder holder = _initList?.FindViewHolderForAdapterPosition(_currentTCNum); + if (holder != null && holder.ItemView != null) + { + FocusManager.Instance.SetCurrentFocusView(holder.ItemView); + } + } + else if (e.Key.KeyPressedName == "Return") + { + _initView.Hide(); + UpdateDetailPage(); + _caseView.Hide(); + _detailView.Show(); + FocusManager.Instance.SetCurrentFocusView(_runButton); + } + } + return true; + } + + private void OnDoneButtonClicked(object sender, Button.ClickEventArgs e) + { + TSettings.GetInstance().SubmitManualResult(); + } + + private void OnRunnerButtonClicked(object sender, Button.ClickEventArgs e) + { + Tizen.Log.Fatal("NUI", "Check all the test case from the first one."); + _currentTCNum = 0; + _initView.Hide(); + _caseView.Hide(); + UpdateDetailPage(); + _detailView.Show(); + FocusManager.Instance.SetCurrentFocusView(_runButton); } + + private void OnPassButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.PASS; + ManualTest.Confirm(); + } + Tizen.Log.Fatal("TBT", "Pass Button clicked!"); + } + + private void OnFailButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.FAIL; + ManualTest.Confirm(); + } + Tizen.Log.Fatal("TBT", "Fail Button clicked!"); + } + + private void OnBlockButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.BLOCK; + ManualTest.Confirm(); + } + } + + private void OnRunButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + //should update the _caseView by the test case + _tsettings.Testcase_ID = _tcIDList[_currentTCNum]; + _tsettings.TCResult = ""; + _tRunner.Execute(); + } + + private void OnHomeButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + _detailView.Hide(); + _initView.Show(); + FocusManager.Instance.SetCurrentFocusView(_run); + } + } + + private void OnPreButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + if (_currentTCNum != 0) + { + _currentTCNum--; + _notRun.Text = _listItem[_currentTCNum].Result; + ManualTest.Confirm(); + UpdateDetailPage(); + } + } + } + + private void OnNextButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + if (_currentTCNum + 1 != ResultNumber.Total) + { + Tizen.Log.Fatal("NUI", "Print the [not run] CurrentTCNum::" + _currentTCNum); + _currentTCNum++; + _notRun.Text = _listItem[_currentTCNum].Result; + UpdateDetailPage(); + } + } + + private void OnFocusGained(object sender, EventArgs e) + { + Button btn = sender as Button; + btn.Style.BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_point_btn_normal.png"; + } + + private void OnFocusLost(object sender, EventArgs e) + { + Button btn = sender as Button; + btn.Style.BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/rectangle_toggle_btn_normal.png"; + } + } } diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/Program.cs b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/Program.cs index 68bc5dae4..70978081f 100755 --- a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/Program.cs +++ b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/Program.cs @@ -36,6 +36,24 @@ namespace Tizen.NUI.Wearable.Tests } } + protected override void OnTerminate() + { + //Tizen.Log.Fatal("NUI", "### OnTerminate() START!"); + if (ManualTest.IsWearable()) + { + WearableManualTestNUI.GetInstance().Dispose(); + } + else + { + ManualTestNUI.GetInstance().Dispose(); + } + + Exit(); + base.OnTerminate(); + + //Tizen.Log.Fatal("NUI", "### OnTerminate() END!"); + } + static void Main(string[] args) { Tizen.Log.Fatal("NUI", "Manual TCT for NUI start!"); diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/WearableManualTestPage.cs b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/WearableManualTestPage.cs index 6fc37d671..392713aeb 100755 --- a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/WearableManualTestPage.cs +++ b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/WearableManualTestPage.cs @@ -23,67 +23,246 @@ using NUnit.Framework.Interfaces; using NUnit.Framework.TUnit; using System.Reflection; using Tizen.NUI.BaseComponents; -using Tizen.NUI.UIComponents; +using Tizen.NUI.Components; namespace Tizen.NUI.Wearable.Tests { class WearableManualTestNUI { - private bool _isSelectRunButton; + class ListBridge : FlexibleView.Adapter + { + private List _mDatas; + private List _mlistItem; + + public ListBridge(List datas, List item) + { + _mDatas = datas; + _mlistItem = item; + } + + public void UpdateItemData(List item) + { + _mlistItem = item; + } + + public override FlexibleView.ViewHolder OnCreateViewHolder(int viewType) + { + FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new ListItemView()); + return viewHolder; + } + + public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position) + { + string testcaseID = "#." + (position + 1).ToString(); + string caseName = _mDatas[position]; + string resultText = "[" + _mlistItem[(int)position].Result + "]"; + + ListItemView item = holder.ItemView as ListItemView; + if (item) + { + item.Size = new Size(Window.Instance.Size.Width, 120); + item.Name = position.ToString(); + item.CaseID = testcaseID; + item.CaseName = caseName; + item.CaseResult = resultText; + } + } + + public override void OnDestroyViewHolder(FlexibleView.ViewHolder holder) + { + if (holder.ItemView != null) + { + holder.ItemView.Dispose(); + } + } + + public override int GetItemCount() + { + return _mDatas.Count; + } + } + + class ListItemView : View + { + private TextLabel _mID; + private TextLabel _mName; + private TextLabel _mResult; + + public ListItemView() + { + WidthResizePolicy = ResizePolicyType.FillToParent; + HeightResizePolicy = ResizePolicyType.FillToParent; + + _mID = new TextLabel(); + _mID.TextColor = Color.White; + _mID.PointSize = 4.0f; + _mID.VerticalAlignment = VerticalAlignment.Center; + _mID.ParentOrigin = NUI.ParentOrigin.TopLeft; + _mID.PivotPoint = NUI.PivotPoint.TopLeft; + _mID.Size2D = new Size2D(40, _scrollHeight); + _mID.Position2D = new Position2D(0, 0); + Add(_mID); + + _mName = new TextLabel(); + _mName.ParentOrigin = NUI.ParentOrigin.TopLeft; + _mName.PivotPoint = NUI.PivotPoint.TopLeft; + _mName.Position = new Position(33, 0.0f, 0.0f); + _mName.Size = new Size(255, _scrollHeight); + _mName.VerticalAlignment = VerticalAlignment.Bottom; + _mName.PointSize = 4.0f; + _mName.TextColor = Color.Green; + _mName.MultiLine = true; + _mName.BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/tw_bottom_btn_bg.png"; + Add(_mName); + + _mResult = new TextLabel(); + _mResult.TextColor = Color.White; + _mResult.PointSize = 3.0f; + _mResult.ParentOrigin = NUI.ParentOrigin.TopLeft; + _mResult.PivotPoint = NUI.PivotPoint.TopLeft; + _mResult.Position = new Position(285.0f, 0.0f, 0.0f); + _mResult.Size2D = new Size2D(65, _scrollHeight); + _mResult.VerticalAlignment = VerticalAlignment.Center; + _mResult.HorizontalAlignment = HorizontalAlignment.Center; + Add(_mResult); + } + + public string CaseID + { + get + { + return _mID.Text; + } + set + { + _mID.Text = value; + } + } + + public string CaseName + { + get + { + return _mName.Text; + } + set + { + _mName.Text = value; + } + } + + public string CaseResult + { + get + { + return _mResult.Text; + } + set + { + _mResult.Text = value; + } + } + } + + class DetailListBridge : FlexibleView.Adapter + { + private List _mDatas; + + public DetailListBridge(List datas) + { + _mDatas = datas; + } + + public override FlexibleView.ViewHolder OnCreateViewHolder(int viewType) + { + FlexibleView.ViewHolder viewHolder = new FlexibleView.ViewHolder(new TextLabel()); + return viewHolder; + } + + public override void OnBindViewHolder(FlexibleView.ViewHolder holder, int position) + { + TextLabel label = holder.ItemView as TextLabel; + if (label) + { + label.TextColor = Color.White; + label.ParentOrigin = ParentOrigin.TopLeft; + label.PivotPoint = PivotPoint.TopLeft; + label.Position = new Position(0.0f, 0.0f, 0.0f); + label.Size = new Size(Window.Instance.Size.Width - 100, _detailScrollHeight); + label.HorizontalAlignment = HorizontalAlignment.Begin; + label.VerticalAlignment = VerticalAlignment.Center; + label.PointSize = 3.0f; + label.MultiLine = true; + label.Text = _mDatas[position]; + } + } + + public override void OnDestroyViewHolder(FlexibleView.ViewHolder holder) + { + if (holder.ItemView != null) + { + holder.ItemView.Dispose(); + } + } + + public override int GetItemCount() + { + return _mDatas.Count; + } + } + private List _tcIDList; private List _listItem; private TSettings _tsettings; private TRunner _tRunner; private NavigationButton _pressButton = NavigationButton.NA; - private PushButton passButton, failButton, blockButton, homeButton, preButton, nextButton, doneButton; - private TextLabel notRun; + private Button _passButton, _failButton, _blockButton, _homeButton, _preButton, _nextButton, _doneButton; + private TextLabel _notRun; private const string STEP_ATTRIBUTE_NAME = "NUnit.Framework.StepAttribute"; private const string PRECONDITION_ATTRIBUTE_NAME = "NUnit.Framework.PreconditionAttribute"; private const string POSTCONDITION_ATTRIBUTE_NAME = "NUnit.Framework.PostconditionAttribute"; - private static float PointSize = 5.0f; + private static float _pointSize = 5.0f; //Save the information of every single test case - private List TCInfoList; - private List CurrentTCInfo; + private List _tcInfoList; + private List _currentTCInfo; - private static WearableManualTestNUI instance; - private static Object lockObject = new object(); + private static WearableManualTestNUI _instance; + private static Object _lockObject = new object(); //Show the result of all the test case private TextLabel _summaryLabel1, _summaryLabel2, _description; private View _initView; private View _detailView; - - private ScrollView _initList; - private ScrollView _detailList; - + private FlexibleView _initList; + private ListBridge _adapter; + private FlexibleView _detailList; + private DetailListBridge _adapter_detail; private View _caseView; - private PushButton run; - private PushButton runButton; - private PushButton[] buttonList; - - private TextLabel[] resultList; + private Button _run; + private Button _runButton; //Always save the current TC number; - private int CurrentTCNum = 0; + private int _currentTCNum = 0; private static int _scrollWidth = Window.Instance.Size.Width; private static int _scrollHeight = 120; private static int _detailScrollHeight = 60; + private bool _isSelectRunButton; public static WearableManualTestNUI GetInstance() { - lock (lockObject) + lock (_lockObject) { - if (instance == null) + if (_instance == null) { - instance = new WearableManualTestNUI(); + _instance = new WearableManualTestNUI(); } } - return instance; + return _instance; } private WearableManualTestNUI() @@ -100,8 +279,9 @@ namespace Tizen.NUI.Wearable.Tests { _isSelectRunButton = false; Window.Instance.BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 1.0f); - Tizen.Log.Fatal("NUI", "Initialize========================================="); - PointSize = (1.0f / Window.Instance.Dpi.Length()) * 2000.0f; + Tizen.Log.Fatal("ManualTCT", "Initialize========================================="); + Tizen.Log.Fatal("ManualTCT", $"App resource path: {Tizen.Applications.Application.Current.DirectoryInfo.Resource}"); + _pointSize = (1.0f / Window.Instance.Dpi.Length()) * 2000.0f; RunType.Value = RunType.MANUAL; _tRunner = new TRunner(); _tRunner.LoadTestsuite(); @@ -115,10 +295,10 @@ namespace Tizen.NUI.Wearable.Tests _tcIDList.Add(pair.Key); count++; } - Tizen.Log.Fatal("NUI", "TCT : count:" + count.ToString()); + Tizen.Log.Fatal("ManualTCT", "TCT : count:" + count.ToString()); foreach (String nameTc in _tcIDList) { - Tizen.Log.Fatal("NUI", "TCT : TCName:" + nameTc.ToString()); + Tizen.Log.Fatal("ManualTCT", "TCT : TCName:" + nameTc.ToString()); } @@ -174,68 +354,59 @@ namespace Tizen.NUI.Wearable.Tests window.GetDefaultLayer().Add(_detailView); } + void SetCommonButtonStyle(Button btn, string text, int? left = null) + { + if (null == btn) return; + btn.Style.Text.Text = text; + btn.Style.Text.TextColor = Color.Green; + if (left.HasValue) // for detail buttons + { + btn.Style.Text.Position = new Position(left.Value, 0); + btn.Style.Text.Size = new Size(30, 30); + btn.Style.Text.PointSize = _pointSize; + } + else // for home buttons + { + btn.Style.Text.PointSize = 6.0f; + } + btn.Style.Text.VerticalAlignment = VerticalAlignment.Bottom; + btn.Style.Text.HorizontalAlignment = HorizontalAlignment.Center; + btn.Style.BackgroundImage = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "/images/tw_bottom_btn_bg.png"; + } + void InitializeFirstPage() { //Create Run Button, when you Click it, then the first test case will be executed. - doneButton = new PushButton(); - doneButton.Size2D = new Size2D(120, 60); - doneButton.Position2D = new Position2D(-150, -200); - //doneButton.Position2D = new Position2D(50, 0); - doneButton.Label = CreateTextVisual("Done", Color.White); - doneButton.Clicked += (obj, ee) => - { - TSettings.GetInstance().SubmitManualResult(); - return false; - }; - - run = new PushButton(); - run.Size2D = new Size2D(120, 60); - run.Position2D = new Position2D(20, -200); - //run.Position2D = new Position2D(180, 0); - run.Label = CreateTextVisual("Runner", Color.White); ; - run.Clicked += (obj, ee) => - { - Tizen.Log.Fatal("NUI", "Check all the test case from the first one."); - CurrentTCNum = 0; - _initView.Hide(); - _caseView.Hide(); - UpdateDetailPage(); - _detailView.Show(); - return false; - }; - - _initList = new ScrollView(); - _initList.Size2D = new Size2D(_scrollWidth, _scrollHeight); - _initList.ParentOrigin = ParentOrigin.TopLeft; - _initList.PivotPoint = PivotPoint.TopLeft; - _initList.Position2D = new Position2D(0, 80); - _initList.ClippingMode = ClippingModeType.ClipChildren; + _doneButton = new Button(); + _doneButton.Size = new Size(120, 60); + _doneButton.Position = new Position(30, 0);//-150, -200 + SetCommonButtonStyle(_doneButton, "Done"); + _doneButton.ClickEvent += OnDoneButtonClicked; + + _run = new Button(); + _run.Size = new Size(120, 60); + _run.Position = new Position(180, 0); //20, -200 + SetCommonButtonStyle(_run, "Runner"); + _run.ClickEvent += OnRunnerButtonClicked; + CreateInitList(); - _initView.Add(doneButton); - _initView.Add(run); + _initView.Add(_doneButton); + _initView.Add(_run); _initView.Add(_initList); - Tizen.Log.Fatal("NUI", "TCT : InitializeFirstPage:"); + Tizen.Log.Fatal("ManualTCT", "TCT : InitializeFirstPage:"); } //Update the Test Page before you want to show it(Click Run/Pre/nect Button, or Click on item in the List). void UpdateDetailPage() { UpdateCurrentTCInfo(); - Tizen.Log.Fatal("NUI", "UpdateDetailPage::::::::::::::::::::::"); + Tizen.Log.Fatal("ManualTCT", "UpdateDetailPage::::::::::::::::::::::"); CreateTestCase(); } void InitializeDetailPage() { - _detailList = new ScrollView(); - _detailList.BackgroundColor = Color.Black; - _detailList.Size2D = new Size2D(_scrollWidth - 100, _detailScrollHeight); - _detailList.ParentOrigin = ParentOrigin.TopLeft; - _detailList.PivotPoint = PivotPoint.TopLeft; - _detailList.Position2D = new Position2D(30, 20); - _detailList.ClippingMode = ClippingModeType.ClipChildren; - _description = new TextLabel(); _description.TextColor = Color.White; _description.PointSize = 3.0f; @@ -246,7 +417,6 @@ namespace Tizen.NUI.Wearable.Tests _detailView.Add(_description); CreateDetailList(); - _detailView.Add(_detailList); //To Place the function button, such as PASS, FAIL..... CreateButtons(); @@ -263,22 +433,15 @@ namespace Tizen.NUI.Wearable.Tests _detailView.Remove(_detailList); _detailList.Dispose(); } - Tizen.Log.Fatal("NUI", "Print the CurrentTCNum here::" + CurrentTCNum); + Tizen.Log.Fatal("ManualTCT", "Print the CurrentTCNum here::" + _currentTCNum); - _detailList = new ScrollView(); - _detailList.BackgroundColor = Color.Black; - _detailList.Size2D = new Size2D(_scrollWidth - 100, _detailScrollHeight); - _detailList.ParentOrigin = ParentOrigin.TopLeft; - _detailList.PivotPoint = PivotPoint.TopLeft; - _detailList.Position2D = new Position2D(30, 20); - _detailList.ClippingMode = ClippingModeType.ClipChildren; CreateDetailList(); - _detailView.Add(_detailList); - if (notRun) + if (_notRun) { - notRun.Text = _listItem[CurrentTCNum].Result; + _notRun.Text = _listItem[_currentTCNum].Result; } } + private TextLabel CreateTextLabel(string textStr, int left) { TextLabel text = new TextLabel(); @@ -289,187 +452,81 @@ namespace Tizen.NUI.Wearable.Tests text.PointSize = 5.0f; text.VerticalAlignment = VerticalAlignment.Bottom; text.HorizontalAlignment = HorizontalAlignment.Center; - text.Size2D = new Size2D(30, 30); - text.Position2D = new Position2D(left, 0); + text.Size = new Size(30, 30); + text.Position = new Position(left, 0); return text; } + //Create all the function buttons here, such as PASS, FAIL..... void CreateButtons() { - - notRun = new TextLabel(); - notRun.TextColor = Color.White; - notRun.Size2D = new Size2D(40, 30); - notRun.PointSize = 2.5f; - notRun.Position2D = new Position2D(260, 118); - notRun.HorizontalAlignment = HorizontalAlignment.Center; - notRun.VerticalAlignment = VerticalAlignment.Center; - notRun.MultiLine = true; - notRun.Text = "Not Run"; - - TextLabel pass = CreateTextLabel("P", 20); - passButton = new PushButton(); - passButton.Size2D = new Size2D(70, 30); - passButton.Position2D = new Position2D(0, 0); - passButton.LabelText = ""; - passButton.Add(pass); - passButton.Clicked += (obj, ee) => - { - - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.PASS; - ManualTest.Confirm(); - } - Tizen.Log.Fatal("TBT", "Pass Button clicked!"); - return true; - }; - - TextLabel fail = CreateTextLabel("F", 20); - failButton = new PushButton(); - failButton.Size2D = new Size2D(70, 30); - failButton.Position2D = new Position2D(72, 0); - failButton.LabelText = ""; - failButton.Add(fail); - failButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.FAIL; - ManualTest.Confirm(); - } - Tizen.Log.Fatal("TBT", "Fail Button clicked!"); - return true; - }; - - TextLabel block = CreateTextLabel("B", 20); - blockButton = new PushButton(); - blockButton.Size2D = new Size2D(70, 30); - blockButton.Position2D = new Position2D(144, 0); - blockButton.LabelText = ""; - blockButton.Add(block); - blockButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.BLOCK; - ManualTest.Confirm(); - } - return true; - }; - - TextLabel run = CreateTextLabel("R", 20); - runButton = new PushButton(); - runButton.Size2D = new Size2D(70, 30); - runButton.Position2D = new Position2D(216, 0); - runButton.LabelText = ""; - runButton.Add(run); - runButton.Clicked += (obj, ee) => - { - if(_isSelectRunButton == false) - { - _isSelectRunButton = true; - Clear(); - //should update the _caseView by the test case - _pressButton = NavigationButton.NA; - _tsettings.Testcase_ID = _tcIDList[CurrentTCNum]; - _tsettings.TCResult = ""; - _tRunner.Execute(); - } - return true; - }; - - TextLabel home = CreateTextLabel("H", 15); - homeButton = new PushButton(); - homeButton.Size2D = new Size2D(60, 30); - homeButton.Position2D = new Position2D(15, 32); - homeButton.LabelText = ""; - homeButton.Add(home); - homeButton.Clicked += (obj, ee) => - { - Clear(); - _pressButton = NavigationButton.Home; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - _detailView.Hide(); - _initView.Show(); - } - return true; - }; - - TextLabel pre = CreateTextLabel("<<", 15); - preButton = new PushButton(); - preButton.Size2D = new Size2D(60, 30); - preButton.Position2D = new Position2D(128, 32); - preButton.LabelText = ""; - preButton.Add(pre); - preButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - if (CurrentTCNum != 0) - { - CurrentTCNum--; - notRun.Text = _listItem[CurrentTCNum].Result; - ManualTest.Confirm(); - UpdateDetailPage(); - } - } - return true; - }; - - TextLabel next = CreateTextLabel(">>", 15); - nextButton = new PushButton(); - nextButton.Size2D = new Size2D(60, 30); - nextButton.Position2D = new Position2D(193, 32); - nextButton.Add(next); - nextButton.LabelText = ""; - nextButton.Clicked += (obj, ee) => - { - Clear(); - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - if (CurrentTCNum + 1 != ResultNumber.Total) - { - Tizen.Log.Fatal("NUI", "Print the [not run] CurrentTCNum::" + CurrentTCNum); - CurrentTCNum++; - notRun.Text = _listItem[CurrentTCNum].Result; - UpdateDetailPage(); - } - return true; - }; + _passButton = new Button(); + SetCommonButtonStyle(_passButton, "P", 20); + _passButton.Size = new Size(70, 30); + _passButton.Position = new Position(0, 0); + _passButton.ClickEvent += OnPassButtonClicked; + + _failButton = new Button(); + SetCommonButtonStyle(_failButton, "F", 20); + _failButton.Size = new Size(70, 30); + _failButton.Position = new Position(72, 0); + _failButton.ClickEvent += OnFailButtonClicked; + + _blockButton = new Button(); + SetCommonButtonStyle(_blockButton, "B", 20); + _blockButton.Size = new Size(70, 30); + _blockButton.Position = new Position(144, 0); + _blockButton.ClickEvent += OnBlockButtonClicked; + + _runButton = new Button(); + SetCommonButtonStyle(_runButton, "R", 20); + _runButton.Size = new Size(70, 30); + _runButton.Position = new Position(216, 0); + _runButton.ClickEvent += OnRunButtonClicked; + + _homeButton = new Button(); + SetCommonButtonStyle(_homeButton, "H", 15); + _homeButton.Size = new Size(60, 30); + _homeButton.Position = new Position(15, 32); + _homeButton.ClickEvent += OnHomeButtonClicked; + + _notRun = new TextLabel(); + _notRun.TextColor = Color.White; + _notRun.Size = new Size(40, 30); + _notRun.PointSize = 2.5f; + _notRun.Position = new Position(82, 32); + _notRun.HorizontalAlignment = HorizontalAlignment.Center; + _notRun.VerticalAlignment = VerticalAlignment.Center; + _notRun.MultiLine = true; + _notRun.Text = "Not Run"; + + _preButton = new Button(); + SetCommonButtonStyle(_preButton, "<<", 15); + _preButton.Size = new Size(60, 30); + _preButton.Position = new Position(128, 32); + _preButton.ClickEvent += OnPreButtonClicked; + + _nextButton = new Button(); + SetCommonButtonStyle(_nextButton, ">>", 15); + _nextButton.Size = new Size(60, 30); + _nextButton.Position = new Position(193, 32); + + _nextButton.ClickEvent += OnNextButtonClicked; View buttonView = new View(); buttonView.ParentOrigin = ParentOrigin.TopLeft; buttonView.PivotPoint = PivotPoint.TopLeft; - buttonView.Size2D = new Size2D(Window.Instance.Size.Width, 80); - buttonView.Position2D = new Position2D(-140, 120); - - buttonView.Add(passButton); - buttonView.Add(failButton); - buttonView.Add(blockButton); - buttonView.Add(runButton); - buttonView.Add(homeButton); - buttonView.Add(notRun); - buttonView.Add(preButton); - buttonView.Add(nextButton); + buttonView.Size = new Size(Window.Instance.Size.Width-30, 80); + buttonView.Position = new Position(40, 180); // 30, 150 + + buttonView.Add(_passButton); + buttonView.Add(_failButton); + buttonView.Add(_blockButton); + buttonView.Add(_runButton); + buttonView.Add(_homeButton); + buttonView.Add(_notRun); + buttonView.Add(_preButton); + buttonView.Add(_nextButton); _detailView.Add(buttonView); } @@ -478,7 +535,7 @@ namespace Tizen.NUI.Wearable.Tests Tizen.Log.Fatal("ManualTCT", "Execute the manual test case!"); _caseView = view; - _caseView.ParentOrigin = Position.ParentOriginTopLeft; + _caseView.ParentOrigin = ParentOrigin.TopLeft; _caseView.PivotPoint = PivotPoint.TopLeft; _caseView.Position = new Position(40.0f, 120.0f, 0.0f); _detailView.Add(_caseView); @@ -495,10 +552,98 @@ namespace Tizen.NUI.Wearable.Tests public void ClearTestCase(View view) { - Tizen.Log.Fatal("NUI", "Clear test case!"); + Tizen.Log.Fatal("ManualTCT", "Clear test case!"); _detailView.Remove(view); } + public void Dispose() + { + if (_passButton) + { + _passButton.ClickEvent -= OnPassButtonClicked; + _passButton.GetParent()?.Remove(_passButton); + _passButton.Dispose(); + _passButton = null; + } + if (_failButton) + { + _failButton.ClickEvent -= OnFailButtonClicked; + _failButton.GetParent()?.Remove(_failButton); + _failButton.Dispose(); + _failButton = null; + } + if (_blockButton) + { + _blockButton.ClickEvent -= OnBlockButtonClicked; + _blockButton.GetParent()?.Remove(_blockButton); + _blockButton.Dispose(); + _blockButton = null; + } + if (_runButton) + { + _runButton.ClickEvent -= OnRunButtonClicked; + _runButton.GetParent()?.Remove(_runButton); + _runButton.Dispose(); + _runButton = null; + } + if (_homeButton) + { + _homeButton.ClickEvent -= OnHomeButtonClicked; + _homeButton.GetParent()?.Remove(_homeButton); + _homeButton.Dispose(); + _homeButton = null; + } + if (_preButton) + { + _preButton.ClickEvent -= OnPreButtonClicked; + _preButton.GetParent()?.Remove(_preButton); + _preButton.Dispose(); + _preButton = null; + } + if (_nextButton) + { + _nextButton.ClickEvent -= OnNextButtonClicked; + _nextButton.GetParent()?.Remove(_nextButton); + _nextButton.Dispose(); + _nextButton = null; + } + + if (_detailView) + { + _detailView.GetParent()?.Remove(_detailView); + _detailView.Dispose(); + _detailView = null; + } + if (_initList) + { + _initList.ItemClickEvent -= OnItemClickEvent; + _initList.GetParent()?.Remove(_initList); + _initList.Dispose(); + _initList = null; + } + if (_doneButton) + { + _doneButton.ClickEvent -= OnDoneButtonClicked; + _doneButton.GetParent()?.Remove(_doneButton); + _doneButton.Dispose(); + _doneButton = null; + } + if (_run) + { + _run.ClickEvent -= OnRunnerButtonClicked; + _run.GetParent()?.Remove(_run); + _run.Dispose(); + _run = null; + } + + if (_initView) + { + _initView.GetParent()?.Remove(_initView); + _initView.Dispose(); + _initView = null; + } + } + //Use to update the _summaryLabel. private void SetSummaryResult() { @@ -508,140 +653,40 @@ namespace Tizen.NUI.Wearable.Tests Tizen.Log.Fatal("ManualTCT", "Set the result Text"); } - private PropertyMap CreateTextMap(float pointSize, string text) - { - PropertyMap map = new PropertyMap(); - map.Insert("visualType", new PropertyValue("TEXT")); - map.Insert("pointSize", new PropertyValue(pointSize)); - map.Insert("text", new PropertyValue(text)); - return map; - } - private void CreateInitList() { - int tcNum = _tcIDList.Count; - buttonList = new PushButton[tcNum]; - resultList = new TextLabel[tcNum]; - for (int index = 0; index < tcNum; index++) - { - string name = _tcIDList[index]; - string testcaseName = "#." + (index + 1).ToString(); - Tizen.Log.Fatal("ManualTCT", "name: " + name); - TextLabel label = new TextLabel(); - label.TextColor = Color.White; - label.Text = testcaseName; - label.PointSize = 4.0f; - label.VerticalAlignment = VerticalAlignment.Center; - label.ParentOrigin = ParentOrigin.TopLeft; - label.PivotPoint = PivotPoint.TopLeft; - label.Size2D = new Size2D(40, _scrollHeight); - label.Position2D = new Position2D(0, 0); - - - TextLabel nameLabel = new TextLabel(); - nameLabel.ParentOrigin = ParentOrigin.TopLeft; - nameLabel.PivotPoint = PivotPoint.TopLeft; - nameLabel.Text = name; - nameLabel.VerticalAlignment = VerticalAlignment.Bottom; - nameLabel.PointSize = 4.0f; - nameLabel.TextColor = Color.White; - nameLabel.MultiLine = true; - nameLabel.Size2D = new Size2D(245, _scrollHeight); - nameLabel.Position2D = new Position2D(5, 0); - nameLabel.TextColor = Color.White; - - string resultText = "[" + _listItem[(int)index].Result + "]"; - buttonList[index] = new PushButton(); - buttonList[index].Name = index.ToString(); - buttonList[index].ParentOrigin = ParentOrigin.TopLeft; - buttonList[index].PivotPoint = PivotPoint.TopLeft; - buttonList[index].Position = new Position(33, 0.0f, 0.0f); - buttonList[index].Size2D = new Size2D(255, _scrollHeight); - buttonList[index].LabelText = ""; - buttonList[index].Add(nameLabel); - buttonList[index].Clicked += (obj, e) => - { - PushButton button = obj as PushButton; - - Tizen.Log.Fatal("TBT", "Item clicked!!!!!!!!!!!!!!::" + button.Name); - CurrentTCNum = int.Parse(button.Name); - _initView.Hide(); - UpdateDetailPage(); - _caseView.Hide(); - _detailView.Show(); - return false; - }; - - resultList[index] = new TextLabel(); - resultList[index].TextColor = Color.White; - resultList[index].PointSize = 3.0f; - resultList[index].Name = index.ToString(); - resultList[index].Text = resultText; - resultList[index].ParentOrigin = ParentOrigin.TopLeft; - resultList[index].PivotPoint = PivotPoint.TopLeft; - resultList[index].Position = new Position(285.0f, 0.0f, 0.0f); - resultList[index].Size2D = new Size2D(65, _scrollHeight); - resultList[index].VerticalAlignment = VerticalAlignment.Center; - resultList[index].HorizontalAlignment = HorizontalAlignment.Center; - - View pageActor = new View(); - pageActor.WidthResizePolicy = ResizePolicyType.FillToParent; - pageActor.HeightResizePolicy = ResizePolicyType.FillToParent; - pageActor.ParentOrigin = ParentOrigin.TopLeft; - pageActor.PivotPoint = PivotPoint.TopLeft; - pageActor.Position = new Position(0, index * _scrollHeight, 0.0f); - - pageActor.Add(label); - pageActor.Add(buttonList[index]); - pageActor.Add(resultList[index]); - _initList.Add(pageActor); - } - _initList.SetAxisAutoLock(false); - PropertyMap rulerMapY = new PropertyMap(); - rulerMapY.Add((int)ScrollModeType.XAxisScrollEnabled, new PropertyValue(false)); - rulerMapY.Add((int)ScrollModeType.YAxisScrollEnabled, new PropertyValue(true)); - rulerMapY.Add((int)ScrollModeType.YAxisSnapToInterval, new PropertyValue(_scrollHeight)); - rulerMapY.Add((int)ScrollModeType.YAxisScrollBoundary, new PropertyValue(_scrollHeight * tcNum)); - _initList.ScrollMode = rulerMapY; - - Tizen.Log.Fatal("ManualTCT", "Initial ScrollView"); + Tizen.Log.Fatal("ManualTCT", "CreateInitList"); + _initList = new FlexibleView(); + _initList.ParentOrigin = ParentOrigin.TopLeft; + _initList.PivotPoint = PivotPoint.TopLeft; + _initList.Size = new Size(Window.Instance.Size.Width, 120); //400 + _initList.Position = new Position(0, 80); //0, 80 + _initList.ClippingMode = ClippingModeType.ClipChildren; + _adapter = new ListBridge(_tcIDList, _listItem); + _initList.SetAdapter(_adapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL); + _initList.SetLayoutManager(layoutManager); + _initList.FocusedItemIndex = 0; + _initList.ItemClickEvent += OnItemClickEvent; } private void CreateDetailList() { - Tizen.Log.Fatal("NUI", "Print the CreateDetailList::count: " + CurrentTCInfo.Count); - int senNum = CurrentTCInfo.Count; - _description.Text = CurrentTCInfo[0]; - for (int index = 1; index < senNum; index++) - { - TextLabel description = new TextLabel(); - description.TextColor = Color.White; - description.ParentOrigin = ParentOrigin.TopLeft; - description.PivotPoint = PivotPoint.TopLeft; - description.Position = new Position(0.0f, 0.0f, 0.0f); - description.Size2D = new Size2D((int)Window.Instance.Size.Width - 100, _detailScrollHeight); - description.HorizontalAlignment = HorizontalAlignment.Begin; - description.VerticalAlignment = VerticalAlignment.Center; - description.PointSize = 3.0f; - description.MultiLine = true; - description.Text = CurrentTCInfo[(int)index]; - - View pageActor = new View(); - pageActor.WidthResizePolicy = ResizePolicyType.FillToParent; - pageActor.HeightResizePolicy = ResizePolicyType.FillToParent; - pageActor.ParentOrigin = ParentOrigin.TopLeft; - pageActor.PivotPoint = PivotPoint.TopLeft; - pageActor.Position = new Position(0, (index - 1) * _detailScrollHeight, 0.0f); - pageActor.Add(description); - _detailList.Add(pageActor); - } - _detailList.SetAxisAutoLock(false); - PropertyMap rulerMapY = new PropertyMap(); - rulerMapY.Add((int)ScrollModeType.XAxisScrollEnabled, new PropertyValue(false)); - rulerMapY.Add((int)ScrollModeType.YAxisScrollEnabled, new PropertyValue(true)); - rulerMapY.Add((int)ScrollModeType.YAxisSnapToInterval, new PropertyValue(_detailScrollHeight)); - rulerMapY.Add((int)ScrollModeType.YAxisScrollBoundary, new PropertyValue(_detailScrollHeight * (senNum - 1))); - _detailList.ScrollMode = rulerMapY; + Tizen.Log.Fatal("ManualTCT", "Print the CreateDetailList::count: " + _currentTCInfo.Count); + _description.Text = _currentTCInfo[0]; + + _detailList = new FlexibleView(); + _detailList.ParentOrigin = ParentOrigin.TopLeft; + _detailList.PivotPoint = PivotPoint.TopLeft; + _detailList.Size = new Size(Window.Instance.Size.Width - 100, _detailScrollHeight); + _detailList.Position = new Position(30, 20); + _detailList.BackgroundColor = Color.Black; + _detailList.ClippingMode = ClippingModeType.ClipChildren; + _adapter_detail = new DetailListBridge(_currentTCInfo); + _detailList.SetAdapter(_adapter_detail); + LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL); + _detailList.SetLayoutManager(layoutManager); + _detailView.Add(_detailList); } //Init all the data, should be offered by Test Framework @@ -651,7 +696,7 @@ namespace Tizen.NUI.Wearable.Tests ResultNumber.Pass = 0; ResultNumber.Fail = 0; ResultNumber.Block = 0; - TCInfoList = new List(); + _tcInfoList = new List(); foreach (KeyValuePair pair in _tRunner.GetTestList()) { List preconditions = new List(); @@ -676,7 +721,7 @@ namespace Tizen.NUI.Wearable.Tests postconditions.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); } } - TCInfoList.Add(new TestcaseInfo + _tcInfoList.Add(new TestcaseInfo { TestcaseName = pair.Key, Preconditions = preconditions, @@ -690,45 +735,45 @@ namespace Tizen.NUI.Wearable.Tests //The data in CurrentTCInfo list will be show in _detailList. void UpdateCurrentTCInfo() { - CurrentTCInfo = new List(); - Tizen.Log.Fatal("NUI", "Print the CurrentTCNum::" + CurrentTCNum); - CurrentTCInfo.Add("DESCRIPTION:#" + (CurrentTCNum + 1)); - string[] str = TCInfoList[CurrentTCNum].TestcaseName.Split('.'); - CurrentTCInfo.Add("CLASS:" + str[str.Length - 2]); - CurrentTCInfo.Add("METHOD:" + str[str.Length - 1]); - for(int index = 0; index < TCInfoList[CurrentTCNum].Preconditions.Count; index++) + _currentTCInfo = new List(); + Tizen.Log.Fatal("ManualTCT", "Print the CurrentTCNum::" + _currentTCNum); + _currentTCInfo.Add("DESCRIPTION:#" + (_currentTCNum + 1)); + string[] str = _tcInfoList[_currentTCNum].TestcaseName.Split('.'); + _currentTCInfo.Add("CLASS:" + str[str.Length - 2]); + _currentTCInfo.Add("METHOD:" + str[str.Length - 1]); + for(int index = 0; index < _tcInfoList[_currentTCNum].Preconditions.Count; index++) { - CurrentTCInfo.Add(TCInfoList[CurrentTCNum].Preconditions[index]); + _currentTCInfo.Add(_tcInfoList[_currentTCNum].Preconditions[index]); } - for(int index = 0; index < TCInfoList[CurrentTCNum].Steps.Count; index++ ) + for(int index = 0; index < _tcInfoList[_currentTCNum].Steps.Count; index++ ) { - CurrentTCInfo.Add(TCInfoList[CurrentTCNum].Steps[index]); + _currentTCInfo.Add(_tcInfoList[_currentTCNum].Steps[index]); } - for(int index = 0; index < TCInfoList[CurrentTCNum].Postconditions.Count; index++ ) + for(int index = 0; index < _tcInfoList[_currentTCNum].Postconditions.Count; index++ ) { - CurrentTCInfo.Add(TCInfoList[CurrentTCNum].Postconditions[index]); + _currentTCInfo.Add(_tcInfoList[_currentTCNum].Postconditions[index]); } - Tizen.Log.Fatal("NUI", "Ppppppppppppppppppppppprint the CurrentTCNum::" + CurrentTCNum); + Tizen.Log.Fatal("ManualTCT", "the CurrentTCNum::" + _currentTCNum); } private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) { //Test when will this event will be triggered - Tizen.Log.Fatal("NUI", "OnSingleTestDone has been triggered!"); + Tizen.Log.Fatal("ManualTCT", "OnSingleTestDone has been triggered!"); // check old result - if (_listItem[CurrentTCNum].Result.Contains(StrResult.FAIL)) + if (_listItem[_currentTCNum].Result.Contains(StrResult.FAIL)) { ResultNumber.Fail = ResultNumber.Fail - 1; } - else if (_listItem[CurrentTCNum].Result.Contains(StrResult.PASS)) + else if (_listItem[_currentTCNum].Result.Contains(StrResult.PASS)) { ResultNumber.Pass = ResultNumber.Pass - 1; } - else if (_listItem[CurrentTCNum].Result.Contains(StrResult.BLOCK)) + else if (_listItem[_currentTCNum].Result.Contains(StrResult.BLOCK)) ResultNumber.Block = ResultNumber.Block - 1; // Update new result - _listItem[CurrentTCNum].Result = e.Result; + _listItem[_currentTCNum].Result = e.Result; if (e.Result.Contains(StrResult.PASS)) { ResultNumber.Pass += 1; @@ -741,22 +786,146 @@ namespace Tizen.NUI.Wearable.Tests { ResultNumber.Block += 1; } - TextLabel label = resultList[CurrentTCNum]; - label.Text = _listItem[(int)CurrentTCNum].Result; + + FlexibleView.ViewHolder holder = _initList?.FindViewHolderForAdapterPosition(_currentTCNum); + if (holder != null) + { + string testcaseName = "#." + (_currentTCNum + 1).ToString() + _tcIDList[_currentTCNum]; + string resultText = "[" + _listItem[(int)_currentTCNum].Result + "]"; + ListItemView item = holder.ItemView as ListItemView; + item.CaseResult = resultText; + _adapter?.UpdateItemData(_listItem); + } SetSummaryResult(); - notRun.Text = _listItem[CurrentTCNum].Result; + _notRun.Text = _listItem[_currentTCNum].Result; } - private PropertyMap CreateTextVisual(string text, Color color) - { - PropertyMap map = new PropertyMap(); - map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)); - map.Add(TextVisualProperty.Text, new PropertyValue(text)); - map.Add(TextVisualProperty.TextColor, new PropertyValue(color)); - map.Add(TextVisualProperty.PointSize, new PropertyValue(6.0f)); - map.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue("CENTER")); - map.Add(TextVisualProperty.VerticalAlignment, new PropertyValue("BOTTOM")); - return map; + private void OnItemClickEvent(object sender, FlexibleView.ItemClickEventArgs e) + { + ListItemView item = e.ClickedView.ItemView as ListItemView; + if (item) + { + Tizen.Log.Fatal("ManualTCT", "Item clicked!!::" + item.Name); + _currentTCNum = int.Parse(item.Name); + _initView.Hide(); + UpdateDetailPage(); + _caseView.Hide(); + _detailView.Show(); + } + } + + private void OnDoneButtonClicked(object sender, Button.ClickEventArgs e) + { + TSettings.GetInstance().SubmitManualResult(); + } + + private void OnRunnerButtonClicked(object sender, Button.ClickEventArgs e) + { + Tizen.Log.Fatal("ManualTCT", "Check all the test case from the first one."); + _currentTCNum = 0; + _initView.Hide(); + _caseView.Hide(); + UpdateDetailPage(); + _detailView.Show(); + } + + private void OnPassButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.PASS; + ManualTest.Confirm(); + } + Tizen.Log.Fatal("TBT", "Pass Button clicked!"); + } + + private void OnFailButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.FAIL; + ManualTest.Confirm(); + } + Tizen.Log.Fatal("TBT", "Fail Button clicked!"); + } + + private void OnBlockButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.BLOCK; + ManualTest.Confirm(); + } + } + + private void OnRunButtonClicked(object sender, Button.ClickEventArgs e) + { + if (_isSelectRunButton == false) + { + _isSelectRunButton = true; + Clear(); + //should update the _caseView by the test case + _pressButton = NavigationButton.NA; + _tsettings.Testcase_ID = _tcIDList[_currentTCNum]; + _tsettings.TCResult = ""; + _tRunner.Execute(); + } + } + + private void OnHomeButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + _pressButton = NavigationButton.Home; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + _detailView.Hide(); + _initView.Show(); + } + } + + private void OnPreButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + if (_currentTCNum != 0) + { + _currentTCNum--; + _notRun.Text = _listItem[_currentTCNum].Result; + ManualTest.Confirm(); + UpdateDetailPage(); + } + } + } + + private void OnNextButtonClicked(object sender, Button.ClickEventArgs e) + { + Clear(); + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + if (_currentTCNum + 1 != ResultNumber.Total) + { + Tizen.Log.Fatal("ManualTCT", "Print the [not run] CurrentTCNum::" + _currentTCNum); + _currentTCNum++; + _notRun.Text = _listItem[_currentTCNum].Result; + UpdateDetailPage(); + } } } } diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/controller_btn_check_on.png b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/controller_btn_check_on.png new file mode 100644 index 000000000..9a3af3a09 Binary files /dev/null and b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/controller_btn_check_on.png differ diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_btn_shadow.png b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_btn_shadow.png new file mode 100644 index 000000000..df385f1ac Binary files /dev/null and b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_btn_shadow.png differ diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_point_btn_normal.png b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_point_btn_normal.png new file mode 100644 index 000000000..677963924 Binary files /dev/null and b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_point_btn_normal.png differ diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_toggle_btn_normal.png b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_toggle_btn_normal.png new file mode 100644 index 000000000..a73694bd6 Binary files /dev/null and b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/rectangle_toggle_btn_normal.png differ diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/tw_bottom_btn_bg.png b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/tw_bottom_btn_bg.png new file mode 100644 index 000000000..55522be92 Binary files /dev/null and b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/res/images/tw_bottom_btn_bg.png differ diff --git a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/testcase/TSNUIWatchApplication.cs b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/testcase/TSNUIWatchApplication.cs index 563dba3c4..0c0a47f52 100755 --- a/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/testcase/TSNUIWatchApplication.cs +++ b/tct-suite-vs/Tizen.NUI.Wearable.Manual.Tests/testcase/TSNUIWatchApplication.cs @@ -21,7 +21,7 @@ using NUnit.Framework.TUnit; using Tizen.Applications; using Tizen.NUI; using Tizen.NUI.BaseComponents; -using Tizen.NUI.UIComponents; +using Tizen.NUI.Components; namespace Tizen.NUI.Wearable.Tests { @@ -32,7 +32,7 @@ namespace Tizen.NUI.Wearable.Tests private bool _isWearable = false; private bool _isEmulator = false; private WearableManualTestNUI _testPage; - private PushButton _infoButton; + private Button _infoButton; [SetUp] public void Init() @@ -51,26 +51,18 @@ namespace Tizen.NUI.Wearable.Tests Log.Info("TCT", "Postconditions for each TEST"); } - private PropertyMap CreateTextMap(float pointSize, string text) + private void CreateButton() { - PropertyMap map = new PropertyMap(); - map.Add(Visual.Property.Type, new PropertyValue((int)Visual.Type.Text)); - map.Add(TextVisualProperty.Text, new PropertyValue(text)); - map.Add(TextVisualProperty.PointSize, new PropertyValue(pointSize)); + _infoButton = new Button(); + _infoButton.Style.Text.Text = "Clicked run, Please refer test step"; + _infoButton.Style.Text.PointSize = 5.0f; if (ManualTest.IsWearable()) { - map.Add(TextVisualProperty.TextColor, new PropertyValue(Color.White)); - map.Add(TextVisualProperty.HorizontalAlignment, new PropertyValue("CENTER")); - map.Add(TextVisualProperty.VerticalAlignment, new PropertyValue("BOTTOM")); + _infoButton.Style.Text.TextColor = Color.White; + _infoButton.Style.Text.HorizontalAlignment = HorizontalAlignment.Center; + _infoButton.Style.Text.VerticalAlignment = VerticalAlignment.Bottom; } - return map; - } - - private void CreateButton() - { - _infoButton = new PushButton(); - _infoButton.Label = CreateTextMap(5.0f, "Clicked run, Please refer test step"); - _infoButton.Size2D = new Size2D(300, 50); + _infoButton.Size = new Size(300, 50); _testPage.ExecuteTC(_infoButton); }