From: anh.vn Date: Tue, 5 Sep 2023 03:32:14 +0000 (+0700) Subject: [Non-ACR][Template] Update auto and manual template base on NUI X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F89%2F298289%2F22;p=test%2Ftct%2Fcsharp%2Fapi.git [Non-ACR][Template] Update auto and manual template base on NUI Change-Id: Id9942d97480eedf562dc6cda2990a590a6e1f998 --- diff --git a/tct-suite-vs/CSharpTCT.sln b/tct-suite-vs/CSharpTCT.sln index 6609177..b72b1e3 100644 --- a/tct-suite-vs/CSharpTCT.sln +++ b/tct-suite-vs/CSharpTCT.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29519.181 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Tests", "Tizen.Applications.Tests\Tizen.Applications.Tests.csproj", "{F0D122C4-48E1-4037-A97D-F7BC75365C81}" EndProject @@ -216,8 +216,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplate", "Template\ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoTemplate", "Template\AutoTemplate\AutoTemplate.csproj", "{B11ABB0C-C3C1-4B5C-8251-A15628A775F3}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplateForWearable", "Template\ManualTemplateForWearable\ManualTemplateForWearable.csproj", "{D36CED01-29BD-4EB3-8903-62E0BF2A822D}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Usb.Tests", "Tizen.Usb.Tests\Tizen.Usb.Tests.csproj", "{E62E2556-106D-4559-9F81-7E60F2A575BA}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Usb.Manual.Tests", "Tizen.Usb.Manual.Tests\Tizen.Usb.Manual.Tests.csproj", "{840C727C-876C-477F-92ED-5AA8473AB3FF}" @@ -316,6 +314,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Cion.Tes EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.MediaVision.ImageClassifier.Tests", "Tizen.MediaVision.ImageClassifier.Tests\Tizen.MediaVision.ImageClassifier.Tests.csproj", "{9B315B92-8187-41D3-A909-EC9C88C55BBE}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ManualTemplateForWearable", "Template\ManualTemplateForWearable\ManualTemplateForWearable.csproj", "{9578A8A4-0500-44FB-BB71-D56A93E5B514}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewAutoTemplate", "NewTemplate\NewAutoTemplate\NewAutoTemplate.csproj", "{6261B915-0F97-424C-91FA-B494EA9A2033}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewManualTemplate", "NewTemplate\NewManualTemplate\NewManualTemplate.csproj", "{FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -912,12 +916,6 @@ Global {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.NUI|Any CPU.Build.0 = Debug|Any CPU {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.ActiveCfg = Release|Any CPU {B11ABB0C-C3C1-4B5C-8251-A15628A775F3}.Release|Any CPU.Build.0 = Release|Any CPU - {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.NUI|Any CPU.ActiveCfg = Debug|Any CPU - {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.NUI|Any CPU.Build.0 = Debug|Any CPU - {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D36CED01-29BD-4EB3-8903-62E0BF2A822D}.Release|Any CPU.Build.0 = Release|Any CPU {E62E2556-106D-4559-9F81-7E60F2A575BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E62E2556-106D-4559-9F81-7E60F2A575BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {E62E2556-106D-4559-9F81-7E60F2A575BA}.NUI|Any CPU.ActiveCfg = Debug|Any CPU @@ -1215,6 +1213,24 @@ Global {9B315B92-8187-41D3-A909-EC9C88C55BBE}.NUI|Any CPU.Build.0 = Debug|Any CPU {9B315B92-8187-41D3-A909-EC9C88C55BBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {9B315B92-8187-41D3-A909-EC9C88C55BBE}.Release|Any CPU.Build.0 = Release|Any CPU + {9578A8A4-0500-44FB-BB71-D56A93E5B514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9578A8A4-0500-44FB-BB71-D56A93E5B514}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9578A8A4-0500-44FB-BB71-D56A93E5B514}.NUI|Any CPU.ActiveCfg = Debug|Any CPU + {9578A8A4-0500-44FB-BB71-D56A93E5B514}.NUI|Any CPU.Build.0 = Debug|Any CPU + {9578A8A4-0500-44FB-BB71-D56A93E5B514}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9578A8A4-0500-44FB-BB71-D56A93E5B514}.Release|Any CPU.Build.0 = Release|Any CPU + {6261B915-0F97-424C-91FA-B494EA9A2033}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6261B915-0F97-424C-91FA-B494EA9A2033}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6261B915-0F97-424C-91FA-B494EA9A2033}.NUI|Any CPU.ActiveCfg = Debug|Any CPU + {6261B915-0F97-424C-91FA-B494EA9A2033}.NUI|Any CPU.Build.0 = Debug|Any CPU + {6261B915-0F97-424C-91FA-B494EA9A2033}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6261B915-0F97-424C-91FA-B494EA9A2033}.Release|Any CPU.Build.0 = Release|Any CPU + {FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}.NUI|Any CPU.ActiveCfg = Debug|Any CPU + {FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}.NUI|Any CPU.Build.0 = Debug|Any CPU + {FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FE12333F-1B32-4F2F-9F4C-2F1B1AFCDA43}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tct-suite-vs/NewTemplate/NewAutoTemplate/NewAutoTemplate.cs b/tct-suite-vs/NewTemplate/NewAutoTemplate/NewAutoTemplate.cs new file mode 100644 index 0000000..a358668 --- /dev/null +++ b/tct-suite-vs/NewTemplate/NewAutoTemplate/NewAutoTemplate.cs @@ -0,0 +1,80 @@ + + +using NUnitLite.TUnit; +using System.Diagnostics; +using System.Threading; +using Tizen.NUI; +using Tizen.NUI.BaseComponents; + +namespace Tizen.Auto.NewTemplate +{ + public class App : NUIApplication + { + + private View _view; + private Window _window; + private Layer _layer; + private const string TextTitle = "Tizen Template Auto TCT \n\n"; + private const float TextSize = 30.0f; + private const string TAG = "Tizen Auto Tests"; + + + public App() : base() + { + Tizen.Log.Debug(TAG, "Call App()"); + } + + protected override void OnCreate() + { + base.OnCreate(); + + _window = GetDefaultWindow(); + _window.BackgroundColor = Color.Green; + + _view = new View() + { + Size = new Size(100, 100), + BackgroundColor = Color.White, + PositionUsesPivotPoint = true, + ParentOrigin = ParentOrigin.Center, + PivotPoint = PivotPoint.Center, + }; + + _layer = _window.GetDefaultLayer(); + _layer.Add(_view); + + var mainTitle = new TextLabel() + { + MultiLine = true, + Text = TextTitle + $"Process ID: {Process.GetCurrentProcess().Id}\nThread ID: {Thread.CurrentThread.ManagedThreadId}\n", + PixelSize = TextSize, + BackgroundColor = Color.Cyan, + Size2D = new Size2D(_window.WindowSize.Width / 2, _window.WindowSize.Height / 2), + PositionUsesPivotPoint = true, + ParentOrigin = ParentOrigin.Center, + PivotPoint = PivotPoint.Center, + }; + _view.Add(mainTitle); + } + + protected override void OnResume() + { + base.OnResume(); + var tRunner = new TRunner(); + tRunner.LoadTestsuite(); + tRunner.Execute(); + } + + protected override void OnPause() + { + base.OnPause(); + } + + protected override void OnTerminate() + { + base.OnTerminate(); + Exit(); + } + + } +} diff --git a/tct-suite-vs/NewTemplate/NewAutoTemplate/NewAutoTemplate.csproj b/tct-suite-vs/NewTemplate/NewAutoTemplate/NewAutoTemplate.csproj new file mode 100644 index 0000000..7f1dfdb --- /dev/null +++ b/tct-suite-vs/NewTemplate/NewAutoTemplate/NewAutoTemplate.csproj @@ -0,0 +1,23 @@ + + + + Library + net6.0-tizen8.0 + True + Tizen + + + + + + + + + + + + + + + + diff --git a/tct-suite-vs/NewTemplate/NewManualTemplate/NewManualTemplate.cs b/tct-suite-vs/NewTemplate/NewManualTemplate/NewManualTemplate.cs new file mode 100644 index 0000000..6cfc709 --- /dev/null +++ b/tct-suite-vs/NewTemplate/NewManualTemplate/NewManualTemplate.cs @@ -0,0 +1,929 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd. +* +* 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.Runtime.InteropServices; +using System.Collections.Generic; +using NUnitLite.TUnit; +using NUnit.Framework.Interfaces; +using NUnit.Framework.TUnit; +using System.Reflection; +using Tizen.NUI.Components; +using Tizen.Applications; +using Tizen.NUI; +using System.Threading.Tasks; +using NUnit.Framework.Internal; +using Tizen.NUI.BaseComponents; + +namespace Tizen.Manual.NewTemplate +{ + public class ManualTemplate + { + private List _listTcsName; + private List _listItem; + private TSettings _tSettings; + private TRunner _tRunner; + private List _listNotPass; + private ToastMessage _toastMessage; + private float _pointSize = 20.0f; + + private List _listTcsInfo; + private List _currentTCInfo; + + private static ManualTemplate _instance; + private static Object _lockObject = new object(); + + private View _viewInit, _viewDetail, _viewCase, _viewPageMainTest; + private FlexibleView _flvInit; + private ViewAdapter _viewAdapter; + private ScrollableBase _scrollableBase; + private TableView _tableViewInit, _tableViewDetail; + private View _viewContainerButton1, _viewContainerButton2, _viewContentTest; + private View _viewSummary, _viewInitButton; + private Button _btnInitRun, _btnDone, _btnBackViewTest; + private Button _btnPass, _btnFail, _btnBlock, _btnDetailRun; + private Button _btnHome, _btnPrevious, _btnNext; + private TextLabel _txtNotRun; + private TextLabel _txtSummary; + + private int _currentTCNum = 0; + + 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"; + + + public static ManualTemplate GetInstance() + { + lock (_lockObject) + { + if (_instance == null) + { + _instance = new ManualTemplate(); + } + } + return _instance; + } + + private ManualTemplate() + { + InitializeView(); + } + public void InitializeView() + { + FocusManager.Instance.FocusIndicator = new View() + { + PositionUsesPivotPoint = true, + PivotPoint = new Position(0, 0, 0), + WidthResizePolicy = ResizePolicyType.FillToParent, + HeightResizePolicy = ResizePolicyType.FillToParent, + BorderlineColor = Color.Orange, + BorderlineWidth = 4.0f, + BorderlineOffset = -1f, + BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.2f), + }; + + Window.Instance.BackgroundColor = Color.White; + + _toastMessage = new ToastMessage(); + _pointSize = ManualTest.GetPointSize(); + RunType.Value = RunType.MANUAL; + _tRunner = new TRunner(); + _tRunner.LoadTestsuite(); + _tRunner.SingleTestDone += OnSingleTestDone; + _listTcsName = new List(); + _listItem = new List(); + _listNotPass = TSettings.GetInstance().GetNotPassListManual(); + int count = 0; + if (_listNotPass.Count == 0) + { + foreach (KeyValuePair pair in _tRunner.GetTestList()) + { + count++; + _listItem.Add(new ItemData { No = count, TCName = pair.Key, Result = StrResult.NOTRUN }); + _listTcsName.Add(pair.Key); + } + } + else + { + foreach (var tc in _listNotPass) + { + count++; + _listItem.Add(new ItemData { No = count, TCName = tc, Result = StrResult.NOTRUN }); + _listTcsName.Add(tc); + } + } + + _tSettings = TSettings.GetInstance(); + _tSettings.IsManual = true; + + InitData(); + _viewCase = new View(); + _viewSummary = new View { + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.05f), + BorderlineWidth = 2, + BackgroundColor = Color.White, + BorderlineColor = new Color("#D1D1D1"), + BoxShadow = new Shadow(5f, Color.DarkGray, new Vector2(2, 2), null), + }; + + Window.Instance.GetDefaultLayer().Add(_viewSummary); + + _txtSummary = new TextLabel(); + _txtSummary.PointSize = 15.0f; + _txtSummary.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.05f); + _txtSummary.ParentOrigin = Position.ParentOriginTopLeft; + _txtSummary.PivotPoint = PivotPoint.TopLeft; + _txtSummary.HorizontalAlignment = HorizontalAlignment.Center; + _txtSummary.VerticalAlignment = VerticalAlignment.Center; + _txtSummary.TextColor = Color.Black; + _viewSummary.Add(_txtSummary); + SetSummaryResult(); + + _viewInit = new View(); + _viewInit.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.9f); + _viewInit.Position = new Position(0.0f, (int)(Window.Instance.Size.Height * 0.05f), 0.0f); + _viewInit.ParentOrigin = Position.ParentOriginTopLeft; + _viewInit.PivotPoint = PivotPoint.TopLeft; + InitializeFirstPage(); + _viewInit.Show(); + Window.Instance.GetDefaultLayer().Add(_viewInit); + + _viewDetail = new View(); + _viewDetail.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height*0.9f); + _viewDetail.Position = new Position(0.0f, (int)(Window.Instance.Size.Height * 0.05f), 0.0f); + _viewDetail.ParentOrigin = Position.ParentOriginTopLeft; + _viewDetail.PivotPoint = PivotPoint.TopLeft; + DetailView(); + _viewDetail.Hide(); + Window.Instance.GetDefaultLayer().Add(_viewDetail); + // Set viewPageMainTest + _viewPageMainTest = new View(); + CreateTestPageView(); + _viewPageMainTest.Hide(); + Window.Instance.GetDefaultLayer().Add(_viewPageMainTest); + //FocusManager.Instance.SetCurrentFocusView(_btnInitRun); + } + + public void LockUIButton() + { + _btnDetailRun.IsEnabled = false; + } + + public void UnlockUIButton() + { + _btnDetailRun.IsEnabled = true; + } + + void SetCommonButtonStyle(Button button, string text) + { + if (!button) return; + button.Text = text; + button.Feedback = false; + button.PointSize = _pointSize+1; + float buttonWidth = ManualTest.IsMobile() ? Window.Instance.Size.Width * 0.18f : Window.Instance.Size.Width * 0.06f; + if (ManualTest.IsEmulator()) + { + buttonWidth = Window.Instance.Size.Width * 0.16f; + } + button.Size = new Size(buttonWidth, Window.Instance.Size.Height * 0.046f); + + button.TextColorSelector = new ColorSelector + { + Normal = Color.White, + Pressed = Color.White, + Selected = Color.White, + Disabled = Color.White, + }; + + } + + void InitializeFirstPage() + { + _btnDone = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnDone, "Done"); + _btnDone.Clicked += (obj, ee) => + { + TSettings.GetInstance().SubmitManualResult(); + }; + + _btnInitRun = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnInitRun, "Run"); + _btnInitRun.Clicked += (obj, ee) => + { + _currentTCNum = 0; + _viewInit.Hide(); + _viewCase.Hide(); + UpdateDetailPage(); + _viewDetail.Show(); + //FocusManager.Instance.SetCurrentFocusView(_btnDetailRun); + }; + //_btnDone.RightFocusableView = _btnInitRun; + //_btnInitRun.LeftFocusableView = _btnDone; + + _flvInit = new FlexibleView { + + }; + _flvInit.Position = new Position(0, Window.Instance.Size.Height * 0.1f); + _flvInit.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.75f); + _viewAdapter = new ViewAdapter(_listTcsName, _listItem); + _flvInit.SetAdapter(_viewAdapter); + LinearLayoutManager layoutManager = new LinearLayoutManager(LinearLayoutManager.VERTICAL); + _flvInit.SetLayoutManager(layoutManager); + _flvInit.FocusedItemIndex = 0; + _flvInit.Focusable = true; + _flvInit.ItemClicked += (obj, e) => + { + Button button = e.ClickedView.ItemView as Button; + if (button) + { + _currentTCNum = int.Parse(button.Name); + _viewInit.Hide(); + UpdateDetailPage(); + _viewCase.Hide(); + _viewDetail.Show(); + //FocusManager.Instance.SetCurrentFocusView(_btnDetailRun); + } + }; + _flvInit.FocusGained += (obj, e) => + { + FlexibleViewViewHolder holder = _flvInit?.FindViewHolderForAdapterPosition(0); + if (holder != null && holder.ItemView != null) + { + FocusManager.Instance.SetCurrentFocusView(holder.ItemView); + _currentTCNum = 0; + } + }; + _flvInit.FocusLost += (obj, e) => + { + _currentTCNum = 0; + }; + _flvInit.KeyEvent += (obj, e) => + { + if (e.Key.State == Key.StateType.Down) + { + if (e.Key.KeyPressedName == "Up") + { + if (_currentTCNum == 0) + { + //FocusManager.Instance.SetCurrentFocusView(_btnInitRun); + } + else + { + FlexibleViewViewHolder holder = _flvInit?.FindViewHolderForAdapterPosition(_currentTCNum - 1); + if (holder != null && holder.ItemView != null) + { + FocusManager.Instance.SetCurrentFocusView(holder.ItemView); + _currentTCNum--; + } + } + } + else if (e.Key.KeyPressedName == "Down") + { + if (_currentTCNum == _flvInit.ChildCount - 1) + { + _currentTCNum = 0; + } + else + { + _currentTCNum++; + } + FlexibleViewViewHolder holder = _flvInit?.FindViewHolderForAdapterPosition(_currentTCNum); + if (holder != null && holder.ItemView != null) + { + FocusManager.Instance.SetCurrentFocusView(holder.ItemView); + } + } + else if (e.Key.KeyPressedName == "Return") + { + _viewInit.Hide(); + UpdateDetailPage(); + _viewCase.Hide(); + _viewDetail.Show(); + //FocusManager.Instance.SetCurrentFocusView(_btnDetailRun); + } + } + return true; + }; + + _tableViewInit = new TableView + { + Rows = 2, + Columns = 5, + ParentOrigin = new Position(0, _viewSummary.Size.Height) + + }; + _viewInitButton = new View(); + var layoutViewInitButton = new FlexLayout() + { + Direction = FlexLayout.FlexDirection.Row, + Justification = FlexLayout.FlexJustification.SpaceBetween, + WrapType = FlexLayout.FlexWrapType.Wrap, + }; + _viewInitButton.Layout = layoutViewInitButton; + _viewInitButton.PivotPoint = PivotPoint.Center; + _viewInitButton.Position = new Position(Window.Instance.Size.Width * 0.25f, Window.Instance.Size.Height * 0.015f, 0); + _viewInitButton.Size = new Size(Window.Instance.Size.Width*0.5f, Window.Instance.Size.Height * 0.05f); + _viewInitButton.Focusable = true; + + _viewInitButton.Add(_btnInitRun); + _viewInitButton.Add(_btnDone); + _btnInitRun.DownFocusableView = _flvInit; + _btnDone.DownFocusableView = _flvInit; + _viewInit.Add(_viewInitButton); + _viewInit.Add(_flvInit); + } + + void UpdateDetailPage() + { + UpdateCurrentTCInfo(); + CreateTestCase(); + } + + void DetailView() + { + _scrollableBase = new ScrollableBase + { + Size = new Size(Window.Instance.Size.Width * 0.9739f, Window.Instance.Size.Height * 0.6629f), + ScrollingDirection = ScrollableBase.Direction.Vertical, + BorderlineWidth = 2, + }; + _tableViewDetail = new TableView(23, 1); + _tableViewDetail.Focusable = true; + _tableViewDetail.Size = new Size(Window.Instance.Size.Width * 0.9739f, Window.Instance.Size.Height * 0.9f); + _tableViewDetail.ParentOrigin = Position.ParentOriginTopLeft; + _tableViewDetail.PivotPoint = PivotPoint.TopLeft; + _tableViewDetail.Position = new Position(0.0f, 0.0f, 0.0f); + CreateDetailList(); + _scrollableBase.Add(_tableViewDetail); + _scrollableBase.BorderlineWidth = 1; + _scrollableBase.BorderlineColor = new Color("#edeff0"); + _scrollableBase.ParentOrigin = new Position(0f,0f); + _viewDetail.Add(_scrollableBase); + + + _viewContainerButton1 = new View { + BorderlineWidth = 2, + BorderlineColor = new Color("#edeff0"), + }; + _viewContainerButton1.PivotPoint = PivotPoint.TopLeft; + _viewContainerButton1.ParentOrigin = Position.ParentOriginTopLeft; + _viewContainerButton1.Position = new Position(0, Window.Instance.Size.Height * 0.76f, 0); + _viewContainerButton1.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.2f); + _viewContainerButton1.Focusable = true; + + _viewContainerButton2 = new View(); + _viewContainerButton2.PivotPoint = PivotPoint.TopLeft; + _viewContainerButton2.ParentOrigin = Position.ParentOriginTopLeft; + _viewContainerButton2.Position = new Position(0, Window.Instance.Size.Height * 0.84f, 0); + _viewContainerButton2.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.1f); + _viewContainerButton2.Focusable = true; + + var flexlayout = new FlexLayout() { + Direction = FlexLayout.FlexDirection.Row, + Justification = FlexLayout.FlexJustification.SpaceBetween, + WrapType = FlexLayout.FlexWrapType.Wrap, + }; + _viewContainerButton1.Layout = flexlayout; + var flexlayout2 = new FlexLayout(); + flexlayout2.Direction = FlexLayout.FlexDirection.Row; + flexlayout2.Justification = FlexLayout.FlexJustification.SpaceBetween; + _viewContainerButton2.Layout = flexlayout2; + CreateButtons(); + _viewDetail.Add(_viewCase); + _viewDetail.Add(_viewContainerButton1); + _viewDetail.Add(_viewContainerButton2); + } + + void CreateTestCase() + { + if (_tableViewDetail != null && _scrollableBase != null) + { + _viewDetail.Remove(_scrollableBase); + _scrollableBase.Remove(_tableViewDetail); + _tableViewDetail.Dispose(); + _tableViewDetail = null; + _scrollableBase.Dispose(); + _scrollableBase = null; + } + _scrollableBase = new ScrollableBase + { + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.6629f), + ScrollingDirection = ScrollableBase.Direction.Vertical, + BorderlineWidth = 5, + BorderlineColor = new Color("#edeff0"), + BackgroundColor = new Color("#F4F5F7"), + }; + _tableViewDetail = new TableView(10, 1); + _tableViewDetail.Focusable = true; + _tableViewDetail.Size = new Size(Window.Instance.Size.Width * 0.9739f, Window.Instance.Size.Height * 0.9f); + _tableViewDetail.ParentOrigin = Position.ParentOriginTopLeft; + _tableViewDetail.PivotPoint = PivotPoint.TopLeft; + _tableViewDetail.Position = new Position(0.0f, 0.0f, 0.0f); + CreateDetailList(); + _scrollableBase.Add(_tableViewDetail); + _scrollableBase.ParentOrigin = new Position(0f, 0f); + _viewDetail.Add(_scrollableBase); + if (_txtNotRun) + { + _txtNotRun.Text = _listItem[_currentTCNum].Result; + } + } + + void CreateButtons() + { + _txtNotRun = new TextLabel + { + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + PointSize = _pointSize, + Text = "Not Run", + Margin = new Extents((ushort)Math.Round(Window.Instance.Size.Width * 0.05), + (ushort)Math.Round(Window.Instance.Size.Width * 0.05), 10, 10), + }; + //_txtNotRun.ParentOrigin = new Position(0.12f, 0); + + float txtWidth = ManualTest.IsMobile() ? Window.Instance.Size.Width * 0.18f : Window.Instance.Size.Width * 0.06f; + if (ManualTest.IsEmulator()) + { + txtWidth = Window.Instance.Size.Width * 0.16f; + } + _txtNotRun.Size = new Size(txtWidth, Window.Instance.Size.Height * 0.046f); + + _btnPass = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnPass, "Pass"); + _btnPass.Clicked += (obj, ee) => + { + ClearView(); + if (!ManualTest.IsConfirmed()) + { + _tSettings.TCResult = StrResult.PASS; + ManualTest.Confirm(); + } + Tizen.Log.Fatal("TBT", "Pass Button clicked!"); + }; + + _btnFail = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnFail, "Fail"); + _btnFail.Clicked += (obj, ee) => + { + ClearView(); + if (!ManualTest.IsConfirmed()) + { + _tSettings.TCResult = StrResult.FAIL; + ManualTest.Confirm(); + } + Tizen.Log.Fatal("TBT", "Fail Button clicked!"); + }; + + _btnBlock = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnBlock, "Block"); + _btnBlock.Clicked += (obj, ee) => + { + ClearView(); + if (!ManualTest.IsConfirmed()) + { + _tSettings.TCResult = StrResult.BLOCK; + ManualTest.Confirm(); + } + }; + + _btnDetailRun = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnDetailRun, "Run"); + _btnDetailRun.Clicked += (obj, ee) => + { + LockUIButton(); + ClearView(); + _tSettings.Testcase_ID = _listTcsName[_currentTCNum]; + _tSettings.TCResult = ""; + _tRunner.Execute(); + }; + + _btnHome = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnHome, "Home"); + _btnHome.Clicked += (obj, ee) => + { + ClearView(); + if (!ManualTest.IsConfirmed()) + { + _tSettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + _viewDetail.Hide(); + _viewInit.Show(); + //FocusManager.Instance.SetCurrentFocusView(_btnInitRun); + } + }; + + _btnPrevious = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnPrevious, "<<"); + _btnPrevious.Clicked += (obj, ee) => + { + ClearView(); + if (!ManualTest.IsConfirmed()) + { + _tSettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + if (_currentTCNum != 0) + { + _currentTCNum--; + _txtNotRun.Text = _listItem[_currentTCNum].Result; + ManualTest.Confirm(); + UpdateDetailPage(); + } + else if (_currentTCNum == 0) + { + _toastMessage.Message = "This is first testcase"; + _toastMessage.Post(); + } + } + }; + + _btnNext = new Button(ButtonStyleStandard); + SetCommonButtonStyle(_btnNext, ">>"); + _btnNext.Clicked += (obj, ee) => + { + ClearView(); + 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++; + _txtNotRun.Text = _listItem[_currentTCNum].Result; + _txtNotRun.TextColor = _listItem[_currentTCNum].ResultColor; + UpdateDetailPage(); + } + else if (_currentTCNum + 1 == ResultNumber.Total) + { + _toastMessage.Message = "This is last testcase"; + _toastMessage.Post(); + } + }; + + _btnPass.RightFocusableView = _btnFail; + _btnPass.DownFocusableView = _btnHome; + _btnFail.LeftFocusableView = _btnPass; + _btnFail.RightFocusableView = _btnBlock; + _btnBlock.LeftFocusableView = _btnFail; + _btnBlock.RightFocusableView = _btnDetailRun; + _btnBlock.DownFocusableView = _btnPrevious; + _btnDetailRun.LeftFocusableView = _btnBlock; + _btnDetailRun.DownFocusableView = _btnNext; + _btnHome.UpFocusableView = _btnPass; + _btnHome.RightFocusableView = _btnPrevious; + _btnPrevious.UpFocusableView = _btnBlock; + _btnPrevious.LeftFocusableView = _btnHome; + _btnPrevious.RightFocusableView = _btnNext; + _btnNext.UpFocusableView = _btnDetailRun; + _btnNext.LeftFocusableView = _btnPrevious; + + _viewContainerButton1.Add(_btnPass); + _viewContainerButton1.Add(_btnFail); + _viewContainerButton1.Add(_btnBlock); + _viewContainerButton1.Add(_btnDetailRun); + _viewContainerButton2.Add(_btnHome); + _viewContainerButton2.Add(_txtNotRun); + _viewContainerButton2.Add(_btnPrevious); + _viewContainerButton2.Add(_btnNext); + + } + + private bool OnKeyPressed(object source, View.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + if (e.Key.KeyPressedName == "Down") + { + FocusManager.Instance.SetCurrentFocusView(_btnPass); + } + } + return false; + } + + private bool OnRunnerKeyPressed(object source, View.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + if (e.Key.KeyPressedName == "Up") + { + FocusManager.Instance.SetCurrentFocusView(_btnDone); + } + } + return false; + } + + private bool OnDownButtonKeyPressed(object source, View.KeyEventArgs e) + { + if (e.Key.State == Key.StateType.Down) + { + if (e.Key.KeyPressedName == "Down") + { + FocusManager.Instance.SetCurrentFocusView(_btnInitRun); + } + } + return false; + } + + private void ClearView() + { + if (_viewCase.IsOnWindow == true) + { + _viewDetail.Remove(_viewCase); + } + } + + public void ClearTestCase(View view) + { + //FocusManager.Instance.SetCurrentFocusView(_btnDetailRun); + _viewDetail.Remove(view); + } + + private void SetSummaryResult() + { + ResultNumber.NotRun = ResultNumber.Total - ResultNumber.Pass - ResultNumber.Fail - ResultNumber.Block; + _txtSummary.Text = "Total : " + ResultNumber.Total + ", Pass : " + ResultNumber.Pass + ", Fail : " + ResultNumber.Fail + ", Block : " + ResultNumber.Block + ", Not Run : " + ResultNumber.NotRun; + } + + private void CreateDetailList() + { + int senNum = _currentTCInfo.Count; + for (int index = 0; index < senNum; index++) + { + TextLabel description = new TextLabel(); + description.Size2D = new Size2D((int)(Window.Instance.Size.Width * 0.9895), (int)(Window.Instance.Size.Height * 0.0462)); + description.PointSize = _pointSize; + description.Text = _currentTCInfo[(int)index]; + description.MultiLine = true; + _tableViewDetail.AddChild(description, new TableView.CellPosition((uint)index, 0)); + _tableViewDetail.SetCellAlignment(new TableView.CellPosition((uint)index, 0), (HorizontalAlignmentType) HorizontalAlignment.Begin, (VerticalAlignmentType) VerticalAlignment.Center); + _tableViewDetail.SetFixedHeight((uint)index, Window.Instance.Size.Height * 0.0462f); + _tableViewDetail.ParentOrigin = new Position(0.02f, 0.01f); + + + } + } + + void InitData() + { + ResultNumber.Total = _listTcsName.Count; + ResultNumber.Pass = 0; + ResultNumber.Fail = 0; + ResultNumber.Block = 0; + _listTcsInfo = new List(); + foreach (var testcaseItem in _listItem) + { + foreach (KeyValuePair pair in _tRunner.GetTestList()) + { + if (testcaseItem.TCName.Equals(pair.Key)) + { + IEnumerator customAttributes = pair.Value.Method.MethodInfo.CustomAttributes.GetEnumerator(); + List preconditions = new List(); + preconditions.Add("Preconditions:"); + List steps = new List(); + steps.Add("Steps:"); + List postconditions = new List(); + postconditions.Add("Postconditions:\n"); + + while (customAttributes.MoveNext()) + { + if (customAttributes.Current.AttributeType.FullName.Equals(STEP_ATTRIBUTE_NAME)) + { + steps.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + else if (customAttributes.Current.AttributeType.FullName.Equals(PRECONDITION_ATTRIBUTE_NAME)) + { + preconditions.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + else if (customAttributes.Current.AttributeType.FullName.Equals(POSTCONDITION_ATTRIBUTE_NAME)) + { + postconditions.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + } + + _listTcsInfo.Add(new TestcaseInfo + { + TestcaseName = pair.Key, + Preconditions = preconditions, + Steps = steps, + Postconditions = postconditions, + }); + break; + } + } + } + UpdateCurrentTCInfo(); + } + + void UpdateCurrentTCInfo() + { + _currentTCInfo = new List(); + _currentTCInfo.Add("DESCRIPTION:#" + (_currentTCNum + 1)); + string[] str = _listTcsInfo[_currentTCNum].TestcaseName.Split('.'); + _currentTCInfo.Add("CLASS:" + str[str.Length - 2]); + _currentTCInfo.Add("METHOD:" + str[str.Length - 1]); + for (int index = 0; index < _listTcsInfo[_currentTCNum].Preconditions.Count; index++) + { + _currentTCInfo.Add(_listTcsInfo[_currentTCNum].Preconditions[index]); + } + for (int index = 0; index < _listTcsInfo[_currentTCNum].Steps.Count; index++) + { + _currentTCInfo.Add(_listTcsInfo[_currentTCNum].Steps[index]); + } + for (int index = 0; index < _listTcsInfo[_currentTCNum].Postconditions.Count; index++) + { + _currentTCInfo.Add(_listTcsInfo[_currentTCNum].Postconditions[index]); + } + } + + private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) + { + if (_listItem[_currentTCNum].Result.Contains(StrResult.FAIL)) + { + ResultNumber.Fail = ResultNumber.Fail - 1; + } + else if (_listItem[_currentTCNum].Result.Contains(StrResult.PASS)) + { + ResultNumber.Pass = ResultNumber.Pass - 1; + } + else if (_listItem[_currentTCNum].Result.Contains(StrResult.BLOCK)) + ResultNumber.Block = ResultNumber.Block - 1; + + _listItem[_currentTCNum].Result = e.Result; + if (e.Result.Contains(StrResult.PASS)) + { + ResultNumber.Pass += 1; + } + else if (e.Result.Contains(StrResult.FAIL)) + { + ResultNumber.Fail += 1; + } + else if (e.Result.Contains(StrResult.BLOCK)) + { + ResultNumber.Block += 1; + } + + FlexibleViewViewHolder holder = _flvInit?.FindViewHolderForAdapterPosition(_currentTCNum); + if (holder != null) + { + string testcaseName = "#" + (_currentTCNum + 1).ToString() + ". " + _listTcsName[_currentTCNum]; + string resultText = " " + "[" + _listItem[(int)_currentTCNum].Result + "]"; + string text = testcaseName + resultText; + Button btn = holder.ItemView as Button; + btn.Text = text; + _viewAdapter?.UpdateItemData(_currentTCNum, _listItem); + } + SetSummaryResult(); + _txtNotRun.Text = _listItem[_currentTCNum].Result; + _txtNotRun.TextColor = _listItem[_currentTCNum].ResultColor; + } + private void CreateTestPageView() + { + _viewPageMainTest = new View() + { + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height), + ParentOrigin = NUI.Position.ParentOriginTopLeft, + PivotPoint = PivotPoint.TopLeft, + BackgroundColor = new Color("#eeeee4") + }; + // + _btnBackViewTest = new Button(); + SetCommonButtonStyle(_btnBackViewTest, "Back"); + _btnBackViewTest.Clicked += (obj, e) => + { + _viewDetail.Show(); + _viewPageMainTest.Hide(); + }; + // + _btnBackViewTest.Position = new Position(_btnBackViewTest.SizeHeight * 0.1f, _btnBackViewTest.SizeHeight * 0.1f, 0.0f); + _btnBackViewTest.PointSize = _btnBackViewTest.PointSize * 1.4f; + _viewPageMainTest.Add(_btnBackViewTest); + // + _viewContentTest = new View() + { + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height), + Position = new Position(0.0f, _btnBackViewTest.SizeHeight * 1.2f, 0.0f), + ParentOrigin = Position.ParentOriginTopLeft, + PivotPoint = PivotPoint.TopLeft + }; + _viewPageMainTest.Add(_viewContentTest); + } + private void addViewContent(View subView) + { + _viewPageMainTest.Remove(_viewContentTest); + _viewContentTest = new View() + { + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height), + Position = new Position(0.0f, _btnBackViewTest.SizeHeight * 1.2f, 0.0f), + ParentOrigin = Position.ParentOriginTopLeft, + PivotPoint = PivotPoint.TopLeft + }; + _viewContentTest.Add(subView); + _viewPageMainTest.Add(_viewContentTest); + } + public static void DisplayLabel(String msg) + { + var manualTemplate = GetInstance(); + var mLabel = new TextLabel() + { + Text = msg + " is not support on this profile. So, you can not test this TC. please mark as PASS", + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Center, + PointSize = ManualTest.GetPointSize(), + TextColor = new Color("#0000b3"), + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.09f), + Focusable = true + }; + mLabel.MultiLine = true; + mLabel.ParentOrigin = ParentOrigin.TopLeft; + mLabel.BorderlineColor = Color.DodgerBlue; + mLabel.BorderlineWidth = 1; + mLabel.BackgroundColor = Color.LightGray; + View view = new View(); + view.Add(mLabel); + view.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal }; + manualTemplate.ExecuteTC(view); + } + public static void DisplayCustomLabel(String msg) + { + var manualTemplate = GetInstance(); + var mLabel = new TextLabel() + { + Text = msg, + VerticalAlignment = VerticalAlignment.Center, + HorizontalAlignment = HorizontalAlignment.Center, + PointSize = ManualTest.GetPointSize(), + TextColor = new Color("#0000b3"), + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.09f), + Focusable = true + }; + mLabel.MultiLine = true; + mLabel.ParentOrigin = ParentOrigin.TopLeft; + View view = new View(); + view.Add(mLabel); + view.Layout = new LinearLayout() { LinearOrientation = LinearLayout.Orientation.Horizontal }; + manualTemplate.ExecuteTC(view); + } + public void ExecuteTC(View view) + { + _viewCase = new View + { + PivotPoint = PivotPoint.TopLeft, + ParentOrigin = Position.ParentOriginTopLeft, + Position = new Position(0, Window.Instance.Size.Height * 0.68f, 0), + Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.09f), + Focusable = true + }; + _viewCase.Add(view); + _viewDetail.Add(_viewCase); + _viewCase.Show(); + FocusManager.Instance.SetCurrentFocusView(_viewCase); + } + + public void ExecuteTCView(View view) + { + addViewContent(view); + _viewPageMainTest.Show(); + FocusManager.Instance.SetCurrentFocusView(view); + _viewDetail.Hide(); + } + private ButtonStyle ButtonStyleStandard = new ButtonStyle + { + BackgroundColor = new ColorSelector + { + Normal = new Color("#02bcfa"), + Pressed = new Color("#029dd1"), + Selected = new Color("#029dd1"), + Disabled = new Color("#029dd1"), + }, + Focusable = true, + CornerRadius = 8, + PivotPoint = PivotPoint.TopLeft, + Margin = new Extents((ushort)Math.Round(Window.Instance.Size.Width*0.05), + (ushort)Math.Round(Window.Instance.Size.Width * 0.05), 12, 12), + }; + } +} + diff --git a/tct-suite-vs/NewTemplate/NewManualTemplate/NewManualTemplate.csproj b/tct-suite-vs/NewTemplate/NewManualTemplate/NewManualTemplate.csproj new file mode 100644 index 0000000..c9ce39a --- /dev/null +++ b/tct-suite-vs/NewTemplate/NewManualTemplate/NewManualTemplate.csproj @@ -0,0 +1,22 @@ + + + + Library + net6.0-tizen8.0 + True + Tizen + + + + + + + + + + + + + + + diff --git a/tct-suite-vs/NewTemplate/NewManualTemplate/NewUtils.cs b/tct-suite-vs/NewTemplate/NewManualTemplate/NewUtils.cs new file mode 100644 index 0000000..963bca6 --- /dev/null +++ b/tct-suite-vs/NewTemplate/NewManualTemplate/NewUtils.cs @@ -0,0 +1,271 @@ +/* + * 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.Tasks; +using System.Runtime.InteropServices; +using System.Collections.Generic; +using System.ComponentModel; +using Tizen.NUI.BaseComponents; +using Tizen.NUI; +using Tizen.NUI.Components; + +namespace Tizen.Manual.NewTemplate +{ + public class ResultNumber + { + public static int Total { get; set; } + public static int Pass { get; set; } + public static int Fail { get; set; } + public static int NotRun { get; set; } + public static int Block { get; set; } + } + + public class TestcaseInfo + { + private string _tescaseName; + public string TestcaseName + { + get + { + return _tescaseName; + } + set + { + _tescaseName = value; + } + } + + private List _preconditions; + public List Preconditions + { + get + { + return _preconditions; + } + set + { + _preconditions = value; + } + } + + private List _steps; + public List Steps + { + get + { + return _steps; + } + set + { + _steps = value; + } + } + + private List _postconditions; + public List Postconditions + { + get + { + return _postconditions; + } + set + { + _postconditions = value; + } + } + } + public class ItemData : INotifyPropertyChanged + { + public event PropertyChangedEventHandler PropertyChanged; + private void OnPropertyChanged(object sender, string propertyName) + { + if (this.PropertyChanged != null) + { + PropertyChanged(sender, new PropertyChangedEventArgs(propertyName)); + } + } + public int No { get; set; } + + public string TCName { get; set; } + + private string _result; + public string Result + { + get + { + return _result; + } + set + { + _result = value; + if (_result.Equals(StrResult.PASS)) + { + ResultColor = Color.DarkGreen; + } + else if (_result.Equals(StrResult.FAIL)) + { + ResultColor = Color.Red; + } + else if (_result.Equals(StrResult.BLOCK)) + { + ResultColor = Color.Orange; + } + else + { + ResultColor = Color.Black; + } + OnPropertyChanged(this, "Result"); + } + } + + private Color _resultColor; + public Color ResultColor + { + get { return _resultColor; } + set + { + _resultColor = value; + OnPropertyChanged(this, "ResultColor"); + } + } + + } + + public class StrResult + { + public static string PASS = "PASS"; + public static string FAIL = "FAIL"; + public static string NOTRUN = "NOT RUN"; + public static string BLOCK = "BLOCK"; + } + + public class RunType + { + public static string AUTO = "AUTO"; + public static string MANUAL = "MANUAL"; + + public static string Value { get; set; } + } + + public class ManualTest + { + private static bool Confirmed = true; + + public static async Task WaitForConfirm() + { + Confirmed = false; + while (true) + { + await Task.Delay(200); + if (Confirmed) + break; + } + ManualTemplate.GetInstance().UnlockUIButton(); + } + + public static bool IsConfirmed() + { + return Confirmed; + } + + public static void Confirm() + { + Confirmed = true; + } + + public static bool IsMobile() + { + string value; + var result = Tizen.System.Information.TryGetValue("tizen.org/feature/profile", out value); + if (result && value.Equals("mobile")) + { + return true; + } + + return false; + } + + public static bool IsWearable() + { + string value; + var result = Tizen.System.Information.TryGetValue("tizen.org/feature/profile", out value); + if (result && value.Equals("wearable")) + { + return true; + } + + return false; + } + + public static bool IsEmulator() + { + string value; + var result = Tizen.System.Information.TryGetValue("tizen.org/system/model_name", out value); + if (result && value.Equals("Emulator")) + { + return true; + } + + return false; + } + + public static float GetPointSize() + { + float retValue = 10.0f; //default + string value; + Tizen.System.Information.TryGetValue("tizen.org/feature/profile", out value); + switch (value) + { + case "wearable": + retValue = 4.0f; + break; + case "mobile": + retValue = 5.0f; + break; + case "tv": + retValue = 20.0f; + break; + } + if (ManualTest.IsEmulator()) + { + retValue = 4.5f; + } + return retValue; + } + + public static TextLabel CreateLabel(string information) + { + TextLabel mLabel = new TextLabel(); + mLabel.TextColor = Color.White; + mLabel.PointSize = 4.0f; + mLabel.VerticalAlignment = VerticalAlignment.Center; + mLabel.HorizontalAlignment = HorizontalAlignment.Begin; + mLabel.MultiLine = true; + mLabel.Text = information; + mLabel.Size2D = new Size2D(300, 50); + return mLabel; + } + } + + enum NavigationButton + { + Next, + Previous, + Home, + NA + } +} diff --git a/tct-suite-vs/NewTemplate/NewManualTemplate/NewViewAdapter.cs b/tct-suite-vs/NewTemplate/NewManualTemplate/NewViewAdapter.cs new file mode 100644 index 0000000..d4b0f64 --- /dev/null +++ b/tct-suite-vs/NewTemplate/NewManualTemplate/NewViewAdapter.cs @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2017 Samsung Electronics Co., Ltd. +* +* 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.Collections.Generic; +using Tizen.NUI.Components; +using Tizen.NUI; +using NUnit.Framework.TUnit; +using Tizen.NUI.BaseComponents; + +namespace Tizen.Manual.NewTemplate +{ + public class ViewAdapter : FlexibleViewAdapter + { + private List _listDatas; + private List _listItems; + private TextLabel _textResult; + public ViewAdapter(List datas, List item) + { + _listDatas = datas; + _listItems = item; + } + public void UpdateItemData(int position, List item) + { + _listItems = item; + } + public override FlexibleViewViewHolder OnCreateViewHolder(int viewType) + { + FlexibleViewViewHolder viewHolder = new FlexibleViewViewHolder(new Button()); + return viewHolder; + } + public override void OnBindViewHolder(FlexibleViewViewHolder holder, int position) + { + string testcaseName = "#" + (position + 1).ToString() + ". " + _listDatas[position]; + string resultText = " " + "[" + _listItems[(int)position].Result + "]"; + string text = testcaseName + resultText; + Button btnItem = holder.ItemView as Button; + if (btnItem) + { + btnItem.Focusable = true; + btnItem.Text = text; + btnItem.Feedback = false; + btnItem.Name = position.ToString(); + btnItem.PointSize = ManualTest.GetPointSize(); + btnItem.Size = new Size(Window.Instance.Size.Width, Window.Instance.Size.Height * 0.046f); + btnItem.TextColor = new Color(0, 0, 0, 1); + btnItem.ItemAlignment = LinearLayout.Alignment.Begin; + btnItem.ParentOrigin = Position.ParentOriginTopLeft; + btnItem.PivotPoint = PivotPoint.TopLeft; + btnItem.TextAlignment = HorizontalAlignment.Begin; + btnItem.CellIndex = new Vector2(position, 0); + btnItem.CornerRadius = 2; + btnItem.BackgroundColor = Color.White; + btnItem.BorderlineColor = Color.LightSkyBlue; + btnItem.BorderlineWidth = 1; + } + } + public override void OnDestroyViewHolder(FlexibleViewViewHolder holder) + { + if (holder.ItemView != null) + { + holder.ItemView.Dispose(); + } + } + + public override int GetItemCount() + { + return _listDatas.Count; + } + } +} + diff --git a/tct-suite-vs/Template/ManualTemplate/TestPage.cs b/tct-suite-vs/Template/ManualTemplate/TestPage.cs old mode 100755 new mode 100644 index b775e4e..e1ea459 --- a/tct-suite-vs/Template/ManualTemplate/TestPage.cs +++ b/tct-suite-vs/Template/ManualTemplate/TestPage.cs @@ -1,662 +1,662 @@ -/* - * 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.Collections.Generic; -using NUnitLite.TUnit; -using NUnit.Framework.TUnit; -using NUnit.Framework.Interfaces; -using System.Reflection; -using ManualTemplate; -using Xamarin.Forms; -using Tizen.Applications; - -namespace NUnit.Framework -{ - public class TestPage - { - private static TestPage instance; - private static Object lockObject = new object(); - - private NavigationPage _navigationPage; - private ContentPage _tcContentPage; - private Page _tcUIPage; - private Label _summaryLabel, _tcResultText, _descriptionTitle; - private ListView _tcDescriptions; - private Button _runBtn, _passBtn, _failBtn, _blockBtn; - private Button _mainBtn, _prevBtn, _nextBtn; - private StackLayout _mainLayout, _tcUILayout; - - private int _tcIndex = 0; - private List _tcIDList; - private List _listItem; - private List _tcInfoList; - private List _currentTCInfo; - private TRunner _tunitRunner; - private TSettings _tsettings; - private NavigationButton _pressButton = NavigationButton.NA; - private ToastMessage _toastMessage; - - 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"; - - public event EventHandler TestcaseDone; - - private void OnTestcaseDone(string e) - { - EventHandler handler = TestcaseDone; - if (handler != null) - { - handler(this, e); - } - } - - public NavigationPage getNavigationPage() - { - return _navigationPage; - } - - public static TestPage GetInstance() - { - lock (lockObject) - { - if (instance == null) - { - instance = new TestPage(); - } - } - return instance; - } - - private TestPage() - { - } - - public void Initialize(TRunner tunitRunner, List testcaseIDList, List listItem) - { - _toastMessage = new ToastMessage(); - RunType.Value = RunType.MANUAL; - _tunitRunner = tunitRunner; - _tunitRunner.SingleTestDone += OnSingleTestDone; - _tcInfoList = new List(); - _tcIDList = testcaseIDList; - _tsettings = TSettings.GetInstance(); - _tsettings.IsManual = true; - _listItem = listItem; - MakeTCInfoList(); - _summaryLabel = new Label() - { - Text = "", - HorizontalOptions = LayoutOptions.CenterAndExpand, - MinimumHeightRequest = 60, - TextColor = Color.White - }; - SetResultNumber(0, 0, 0); - MakeTestPage(); - } - - private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) - { - // check old result - if (_listItem[_tcIndex].Result.Contains(StrResult.FAIL)) - { - ResultNumber.Fail = ResultNumber.Fail - 1; - } - else if (_listItem[_tcIndex].Result.Contains(StrResult.PASS)) - { - ResultNumber.Pass = ResultNumber.Pass - 1; - } - else if (_listItem[_tcIndex].Result.Contains(StrResult.BLOCK)) - ResultNumber.Block = ResultNumber.Block - 1; - - // Update new result - _listItem[_tcIndex].Result = e.Result; - if (e.Result.Contains(StrResult.PASS)) - { - ResultNumber.Pass += 1; - } - else if (e.Result.Contains(StrResult.FAIL)) - { - ResultNumber.Fail += 1; - } - else if (e.Result.Contains(StrResult.BLOCK)) - { - ResultNumber.Block += 1; - } - - UpdateLayout(); - } - - private void UpdateLayout() - { - SetResultNumber(ResultNumber.Pass, ResultNumber.Fail, ResultNumber.Block); - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - if (_tcUILayout != null) - { - _tcUILayout.Children.Clear(); - } - if (_pressButton == NavigationButton.Next) - { - Next(); - } - else if (_pressButton == NavigationButton.Previous) - { - Previous(); - } - else if (_pressButton == NavigationButton.Home) - { - _navigationPage.PopAsync(); - } - OnTestcaseDone(null); - _passBtn.IsEnabled = false; - _failBtn.IsEnabled = false; - _blockBtn.IsEnabled = false; - _runBtn.IsEnabled = true; - _mainBtn.IsEnabled = true; - _prevBtn.IsEnabled = true; - _nextBtn.IsEnabled = true; - } - - private void SetResultNumber(int pass, int fail, int block) - { - ResultNumber.NotRun = ResultNumber.Total - pass - fail - block; - _summaryLabel.Text = "Total : " + ResultNumber.Total + ", Pass : " + pass + ", Fail : " + fail + ", Block : " + block + ", Not Run : " + ResultNumber.NotRun; - } - - private void MakeTestPage() - { - _mainLayout = new StackLayout() - { - Orientation = StackOrientation.Vertical, - IsVisible = true, - HorizontalOptions = LayoutOptions.FillAndExpand, - VerticalOptions = LayoutOptions.FillAndExpand, - Spacing = 10, - Padding = new Thickness(10), - }; - _descriptionTitle = new Label() - { - Text = "DESCRIPTION:", - HorizontalOptions = LayoutOptions.FillAndExpand, - VerticalOptions = LayoutOptions.Start, - HeightRequest = 50, - TextColor = Color.White - }; - // layout - StackLayout functionLayout = new StackLayout() - { - Orientation = StackOrientation.Horizontal, - IsVisible = true, - HorizontalOptions = LayoutOptions.FillAndExpand, - Spacing = 10, - VerticalOptions = LayoutOptions.End, - }; - - _mainBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "Home", - HeightRequest = 80, - }; - - _mainBtn.Clicked += (sender, e) => - { - _pressButton = NavigationButton.Home; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - _navigationPage.PopAsync(); - } - }; - - _prevBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "<<", - HeightRequest = 80, - }; - - _prevBtn.Clicked += (sender, e) => - { - PreviousTestcase(); - }; - - _nextBtn = new Button() - { - Text = ">>", - HorizontalOptions = LayoutOptions.Start, - HeightRequest = 80, - }; - - _nextBtn.Clicked += (sender, e) => - { - NextTestcase(); - }; - - _tcResultText = new Label() - { - HorizontalOptions = LayoutOptions.Start, - VerticalOptions = LayoutOptions.FillAndExpand, - HorizontalTextAlignment = TextAlignment.Center, - VerticalTextAlignment = TextAlignment.Center, - HeightRequest = 80, - }; - functionLayout.Children.Add(_mainBtn); - functionLayout.Children.Add(_tcResultText); - functionLayout.Children.Add(_prevBtn); - functionLayout.Children.Add(_nextBtn); - // Show description - ShowDescription(); - - var navigationLayout = new StackLayout() - { - Orientation = StackOrientation.Horizontal, - IsVisible = true, - HorizontalOptions = LayoutOptions.FillAndExpand, - Spacing = 10, - VerticalOptions = LayoutOptions.End, - }; - - _passBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "Pass", - HeightRequest = 80, - IsEnabled = false, - }; - - _passBtn.Clicked += (sender, e) => - { - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.PASS; - ManualTest.Confirm(); - } - }; - - _failBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "Fail", - HeightRequest = 80, - IsEnabled = false, - }; - - _failBtn.Clicked += (sender, e) => - { - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.FAIL; - ManualTest.Confirm(); - } - }; - - _blockBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "Block", - HeightRequest = 80, - IsEnabled = false, - }; - - _blockBtn.Clicked += (sender, e) => - { - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.BLOCK; - ManualTest.Confirm(); - } - }; - - _runBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "Run", - HeightRequest = 80, - }; - - _runBtn.Clicked += (sender, e) => - { - LockUIButton(); - _pressButton = NavigationButton.NA; - _tsettings.Testcase_ID = _tcIDList[_tcIndex]; - _tsettings.TCResult = ""; - _tunitRunner.Execute(); - }; - - navigationLayout.Children.Add(_passBtn); - navigationLayout.Children.Add(_failBtn); - navigationLayout.Children.Add(_blockBtn); - navigationLayout.Children.Add(_runBtn); - - _tcUILayout = new StackLayout() - { - Orientation = StackOrientation.Vertical, - HorizontalOptions = LayoutOptions.FillAndExpand, - HeightRequest = 200 - }; - - _mainLayout.Children.Add(_summaryLabel); - _mainLayout.Children.Add(_descriptionTitle); - _mainLayout.Children.Add(_tcDescriptions); - _mainLayout.Children.Add(_tcUILayout); - _mainLayout.Children.Add(navigationLayout); - _mainLayout.Children.Add(functionLayout); - _tcContentPage = new ContentPage() - { - Content = _mainLayout - }; - NavigationPage.SetHasNavigationBar(_tcContentPage, false); - } - - public void LockUIButton() - { - if (ManualTest.IsWearable()) - { - WearableTemplate.TestPage.GetInstance().LockUIButton(); - } - else - { - _runBtn.IsEnabled = false; - _passBtn.IsEnabled = false; - _failBtn.IsEnabled = false; - _blockBtn.IsEnabled = false; - _mainBtn.IsEnabled = false; - _prevBtn.IsEnabled = false; - _nextBtn.IsEnabled = false; - } - } - - public void UnlockUIButton() - { - if (ManualTest.IsWearable()) - { - WearableTemplate.TestPage.GetInstance().UnlockUIButton(); - } - else - { - _passBtn.IsEnabled = true; - _failBtn.IsEnabled = true; - _blockBtn.IsEnabled = true; - _mainBtn.IsEnabled = true; - _prevBtn.IsEnabled = true; - _nextBtn.IsEnabled = true; - } - } - - public void Show(NavigationPage navigationPage, int testcaseIndex) - { - _navigationPage = navigationPage; - _tcIndex = testcaseIndex - 1; - _descriptionTitle.Text = "DESCRIPTION : #" + testcaseIndex; - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - UpdateDescriptions(); - navigationPage.PushAsync(_tcContentPage); - _passBtn.IsEnabled = false; - _failBtn.IsEnabled = false; - _blockBtn.IsEnabled = false; - } - - private void NextTestcase() - { - _pressButton = NavigationButton.Next; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - Next(); - } - } - - private void Next() - { - if (_tcIndex < _tcIDList.Count - 1) - { - _tcIndex = _tcIndex + 1; - _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - UpdateDescriptions(); - } - else if (_tcIndex == _tcIDList.Count - 1) - { - _toastMessage.Message = "This is last testcase"; - _toastMessage.Post(); - } - } - - private void PreviousTestcase() - { - _pressButton = NavigationButton.Previous; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - Previous(); - } - } - - private void Previous() - { - if (_tcIndex > 0) - { - _tcIndex = _tcIndex - 1; - _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - UpdateDescriptions(); - } - else if (_tcIndex == 0) - { - _toastMessage.Message = "This is first testcase"; - _toastMessage.Post(); - } - } - - private void SetColor(string result) - { - if (result.Equals(StrResult.PASS)) - { - _tcResultText.TextColor = Color.Green; - } - else if (result.Equals(StrResult.FAIL)) - { - _tcResultText.TextColor = Color.Red; - } - else if (result.Equals(StrResult.BLOCK)) - { - _tcResultText.TextColor = Color.Orange; - } - else - { - _tcResultText.TextColor = Color.White; - } - } - - private int FindMaxLineDescription() - { - int maxLine = 0; - for (int i = 0; i < _tcInfoList.Count; i++) - { - int len = _tcInfoList[i].Steps.Count + _tcInfoList[i].Preconditions.Count + _tcInfoList[i].Postconditions.Count; - maxLine = maxLine < len ? len : maxLine; - } - return maxLine; - } - - private void ShowDescription() - { - int lenght = FindMaxLineDescription() + 3; - var template = new DataTemplate(() => - { - var grid = new Grid(); - - var descriptionLabel = new Label - { - HorizontalOptions = LayoutOptions.FillAndExpand, - LineBreakMode = LineBreakMode.CharacterWrap - }; - - descriptionLabel.SetBinding(Label.TextProperty, new Binding("Description")); - - grid.Children.Add(descriptionLabel); - - return new ViewCell - { - View = grid, - }; - }); - - _tcDescriptions = new ListView() - { - ItemTemplate = template, - HorizontalOptions = LayoutOptions.FillAndExpand, - RowHeight = 150, - Margin = new Thickness(10), - }; - _currentTCInfo = new List(); - - for (int i = 0; i < lenght; i++) - { - _currentTCInfo.Add(new TestcaseDescription("")); - } - UpdateDescriptions(); - _tcDescriptions.ItemsSource = _currentTCInfo; - } - - private void UpdateDescriptions() - { - _prevBtn.IsEnabled = false; - _nextBtn.IsEnabled = false; - int lenght = FindMaxLineDescription() + 3; - for (int i = 0; i < lenght; i++) - { - _currentTCInfo[i].Description = ""; - } - int index = 0; - if (_tcInfoList.Count == 0) - { - _toastMessage.Message = "Some testing class wrong, plz recheck"; - _toastMessage.Post(); - return; - } - +/* + * 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.Collections.Generic; +using NUnitLite.TUnit; +using NUnit.Framework.TUnit; +using NUnit.Framework.Interfaces; +using System.Reflection; +using ManualTemplate; +using Xamarin.Forms; +using Tizen.Applications; + +namespace NUnit.Framework +{ + public class TestPage + { + private static TestPage instance; + private static Object lockObject = new object(); + + private NavigationPage _navigationPage; + private ContentPage _tcContentPage; + private Page _tcUIPage; + private Label _summaryLabel, _tcResultText, _descriptionTitle; + private ListView _tcDescriptions; + private Button _runBtn, _passBtn, _failBtn, _blockBtn; + private Button _mainBtn, _prevBtn, _nextBtn; + private StackLayout _mainLayout, _tcUILayout; + + private int _tcIndex = 0; + private List _tcIDList; + private List _listItem; + private List _tcInfoList; + private List _currentTCInfo; + private TRunner _tunitRunner; + private TSettings _tsettings; + private NavigationButton _pressButton = NavigationButton.NA; + private ToastMessage _toastMessage; + + 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"; + + public event EventHandler TestcaseDone; + + private void OnTestcaseDone(string e) + { + EventHandler handler = TestcaseDone; + if (handler != null) + { + handler(this, e); + } + } + + public NavigationPage getNavigationPage() + { + return _navigationPage; + } + + public static TestPage GetInstance() + { + lock (lockObject) + { + if (instance == null) + { + instance = new TestPage(); + } + } + return instance; + } + + private TestPage() + { + } + + public void Initialize(TRunner tunitRunner, List testcaseIDList, List listItem) + { + _toastMessage = new ToastMessage(); + RunType.Value = RunType.MANUAL; + _tunitRunner = tunitRunner; + _tunitRunner.SingleTestDone += OnSingleTestDone; + _tcInfoList = new List(); + _tcIDList = testcaseIDList; + _tsettings = TSettings.GetInstance(); + _tsettings.IsManual = true; + _listItem = listItem; + MakeTCInfoList(); + _summaryLabel = new Label() + { + Text = "", + HorizontalOptions = LayoutOptions.CenterAndExpand, + MinimumHeightRequest = 60, + TextColor = Color.White + }; + SetResultNumber(0, 0, 0); + MakeTestPage(); + } + + private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) + { + // check old result + if (_listItem[_tcIndex].Result.Contains(StrResult.FAIL)) + { + ResultNumber.Fail = ResultNumber.Fail - 1; + } + else if (_listItem[_tcIndex].Result.Contains(StrResult.PASS)) + { + ResultNumber.Pass = ResultNumber.Pass - 1; + } + else if (_listItem[_tcIndex].Result.Contains(StrResult.BLOCK)) + ResultNumber.Block = ResultNumber.Block - 1; + + // Update new result + _listItem[_tcIndex].Result = e.Result; + if (e.Result.Contains(StrResult.PASS)) + { + ResultNumber.Pass += 1; + } + else if (e.Result.Contains(StrResult.FAIL)) + { + ResultNumber.Fail += 1; + } + else if (e.Result.Contains(StrResult.BLOCK)) + { + ResultNumber.Block += 1; + } + + UpdateLayout(); + } + + private void UpdateLayout() + { + SetResultNumber(ResultNumber.Pass, ResultNumber.Fail, ResultNumber.Block); + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + if (_tcUILayout != null) + { + _tcUILayout.Children.Clear(); + } + if (_pressButton == NavigationButton.Next) + { + Next(); + } + else if (_pressButton == NavigationButton.Previous) + { + Previous(); + } + else if (_pressButton == NavigationButton.Home) + { + _navigationPage.PopAsync(); + } + OnTestcaseDone(null); + _passBtn.IsEnabled = false; + _failBtn.IsEnabled = false; + _blockBtn.IsEnabled = false; + _runBtn.IsEnabled = true; + _mainBtn.IsEnabled = true; + _prevBtn.IsEnabled = true; + _nextBtn.IsEnabled = true; + } + + private void SetResultNumber(int pass, int fail, int block) + { + ResultNumber.NotRun = ResultNumber.Total - pass - fail - block; + _summaryLabel.Text = "Total : " + ResultNumber.Total + ", Pass : " + pass + ", Fail : " + fail + ", Block : " + block + ", Not Run : " + ResultNumber.NotRun; + } + + private void MakeTestPage() + { + _mainLayout = new StackLayout() + { + Orientation = StackOrientation.Vertical, + IsVisible = true, + HorizontalOptions = LayoutOptions.FillAndExpand, + VerticalOptions = LayoutOptions.FillAndExpand, + Spacing = 10, + Padding = new Thickness(10), + }; + _descriptionTitle = new Label() + { + Text = "DESCRIPTION:", + HorizontalOptions = LayoutOptions.FillAndExpand, + VerticalOptions = LayoutOptions.Start, + HeightRequest = 50, + TextColor = Color.White + }; + // layout + StackLayout functionLayout = new StackLayout() + { + Orientation = StackOrientation.Horizontal, + IsVisible = true, + HorizontalOptions = LayoutOptions.FillAndExpand, + Spacing = 10, + VerticalOptions = LayoutOptions.End, + }; + + _mainBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "Home", + HeightRequest = 80, + }; + + _mainBtn.Clicked += (sender, e) => + { + _pressButton = NavigationButton.Home; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + _navigationPage.PopAsync(); + } + }; + + _prevBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "<<", + HeightRequest = 80, + }; + + _prevBtn.Clicked += (sender, e) => + { + PreviousTestcase(); + }; + + _nextBtn = new Button() + { + Text = ">>", + HorizontalOptions = LayoutOptions.Start, + HeightRequest = 80, + }; + + _nextBtn.Clicked += (sender, e) => + { + NextTestcase(); + }; + + _tcResultText = new Label() + { + HorizontalOptions = LayoutOptions.Start, + VerticalOptions = LayoutOptions.FillAndExpand, + HorizontalTextAlignment = TextAlignment.Center, + VerticalTextAlignment = TextAlignment.Center, + HeightRequest = 80, + }; + functionLayout.Children.Add(_mainBtn); + functionLayout.Children.Add(_tcResultText); + functionLayout.Children.Add(_prevBtn); + functionLayout.Children.Add(_nextBtn); + // Show description + ShowDescription(); + + var navigationLayout = new StackLayout() + { + Orientation = StackOrientation.Horizontal, + IsVisible = true, + HorizontalOptions = LayoutOptions.FillAndExpand, + Spacing = 10, + VerticalOptions = LayoutOptions.End, + }; + + _passBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "Pass", + HeightRequest = 80, + IsEnabled = false, + }; + + _passBtn.Clicked += (sender, e) => + { + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.PASS; + ManualTest.Confirm(); + } + }; + + _failBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "Fail", + HeightRequest = 80, + IsEnabled = false, + }; + + _failBtn.Clicked += (sender, e) => + { + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.FAIL; + ManualTest.Confirm(); + } + }; + + _blockBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "Block", + HeightRequest = 80, + IsEnabled = false, + }; + + _blockBtn.Clicked += (sender, e) => + { + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.BLOCK; + ManualTest.Confirm(); + } + }; + + _runBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "Run", + HeightRequest = 80, + }; + + _runBtn.Clicked += (sender, e) => + { + LockUIButton(); + _pressButton = NavigationButton.NA; + _tsettings.Testcase_ID = _tcIDList[_tcIndex]; + _tsettings.TCResult = ""; + _tunitRunner.Execute(); + }; + + navigationLayout.Children.Add(_passBtn); + navigationLayout.Children.Add(_failBtn); + navigationLayout.Children.Add(_blockBtn); + navigationLayout.Children.Add(_runBtn); + + _tcUILayout = new StackLayout() + { + Orientation = StackOrientation.Vertical, + HorizontalOptions = LayoutOptions.FillAndExpand, + HeightRequest = 200 + }; + + _mainLayout.Children.Add(_summaryLabel); + _mainLayout.Children.Add(_descriptionTitle); + _mainLayout.Children.Add(_tcDescriptions); + _mainLayout.Children.Add(_tcUILayout); + _mainLayout.Children.Add(navigationLayout); + _mainLayout.Children.Add(functionLayout); + _tcContentPage = new ContentPage() + { + Content = _mainLayout + }; + NavigationPage.SetHasNavigationBar(_tcContentPage, false); + } + + public void LockUIButton() + { + if (ManualTest.IsWearable()) + { + WearableTemplate.TestPage.GetInstance().LockUIButton(); + } + else + { + _runBtn.IsEnabled = false; + _passBtn.IsEnabled = false; + _failBtn.IsEnabled = false; + _blockBtn.IsEnabled = false; + _mainBtn.IsEnabled = false; + _prevBtn.IsEnabled = false; + _nextBtn.IsEnabled = false; + } + } + + public void UnlockUIButton() + { + if (ManualTest.IsWearable()) + { + WearableTemplate.TestPage.GetInstance().UnlockUIButton(); + } + else + { + _passBtn.IsEnabled = true; + _failBtn.IsEnabled = true; + _blockBtn.IsEnabled = true; + _mainBtn.IsEnabled = true; + _prevBtn.IsEnabled = true; + _nextBtn.IsEnabled = true; + } + } + + public void Show(NavigationPage navigationPage, int testcaseIndex) + { + _navigationPage = navigationPage; + _tcIndex = testcaseIndex - 1; + _descriptionTitle.Text = "DESCRIPTION : #" + testcaseIndex; + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + UpdateDescriptions(); + navigationPage.PushAsync(_tcContentPage); + _passBtn.IsEnabled = false; + _failBtn.IsEnabled = false; + _blockBtn.IsEnabled = false; + } + + private void NextTestcase() + { + _pressButton = NavigationButton.Next; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + Next(); + } + } + + private void Next() + { + if (_tcIndex < _tcIDList.Count - 1) + { + _tcIndex = _tcIndex + 1; + _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + UpdateDescriptions(); + } + else if (_tcIndex == _tcIDList.Count - 1) + { + _toastMessage.Message = "This is last testcase"; + _toastMessage.Post(); + } + } + + private void PreviousTestcase() + { + _pressButton = NavigationButton.Previous; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + Previous(); + } + } + + private void Previous() + { + if (_tcIndex > 0) + { + _tcIndex = _tcIndex - 1; + _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + UpdateDescriptions(); + } + else if (_tcIndex == 0) + { + _toastMessage.Message = "This is first testcase"; + _toastMessage.Post(); + } + } + + private void SetColor(string result) + { + if (result.Equals(StrResult.PASS)) + { + _tcResultText.TextColor = Color.Green; + } + else if (result.Equals(StrResult.FAIL)) + { + _tcResultText.TextColor = Color.Red; + } + else if (result.Equals(StrResult.BLOCK)) + { + _tcResultText.TextColor = Color.Orange; + } + else + { + _tcResultText.TextColor = Color.White; + } + } + + private int FindMaxLineDescription() + { + int maxLine = 0; + for (int i = 0; i < _tcInfoList.Count; i++) + { + int len = _tcInfoList[i].Steps.Count + _tcInfoList[i].Preconditions.Count + _tcInfoList[i].Postconditions.Count; + maxLine = maxLine < len ? len : maxLine; + } + return maxLine; + } + + private void ShowDescription() + { + int lenght = FindMaxLineDescription() + 3; + var template = new DataTemplate(() => + { + var grid = new Grid(); + + var descriptionLabel = new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + LineBreakMode = LineBreakMode.CharacterWrap + }; + + descriptionLabel.SetBinding(Label.TextProperty, new Binding("Description")); + + grid.Children.Add(descriptionLabel); + + return new ViewCell + { + View = grid, + }; + }); + + _tcDescriptions = new ListView() + { + ItemTemplate = template, + HorizontalOptions = LayoutOptions.FillAndExpand, + RowHeight = 150, + Margin = new Thickness(10), + }; + _currentTCInfo = new List(); + + for (int i = 0; i < lenght; i++) + { + _currentTCInfo.Add(new TestcaseDescription("")); + } + UpdateDescriptions(); + _tcDescriptions.ItemsSource = _currentTCInfo; + } + + private void UpdateDescriptions() + { + _prevBtn.IsEnabled = false; + _nextBtn.IsEnabled = false; + int lenght = FindMaxLineDescription() + 3; + for (int i = 0; i < lenght; i++) + { + _currentTCInfo[i].Description = ""; + } + int index = 0; + if (_tcInfoList.Count == 0) + { + _toastMessage.Message = "Some testing class wrong, plz recheck"; + _toastMessage.Post(); + return; + } + _currentTCInfo[index].Description = "TC : " + _tcInfoList[_tcIndex].TestcaseName; - TLogger.Write("############### TC Name:" + _tcInfoList[_tcIndex].TestcaseName); - foreach (string precondition in _tcInfoList[_tcIndex].Preconditions.ToArray()) - { - index++; - _currentTCInfo[index].Description = precondition; - } - foreach (string step in _tcInfoList[_tcIndex].Steps.ToArray()) - { - index++; - _currentTCInfo[index].Description = step; - } - foreach (string postcondition in _tcInfoList[_tcIndex].Postconditions.ToArray()) - { - index++; - _currentTCInfo[index].Description = postcondition; - } - _prevBtn.IsEnabled = true; - _nextBtn.IsEnabled = true; - } - - private void MakeTCInfoList() - { - foreach (var testcaseItem in _listItem) - { - foreach (KeyValuePair pair in _tunitRunner.GetTestList()) - { - if (testcaseItem.TCName.Equals(pair.Key)) - { - IEnumerator customAttributes = pair.Value.Method.MethodInfo.CustomAttributes.GetEnumerator(); - List _preconditonsStr = new List(); _preconditonsStr.Add("Preconditions:"); - List _stepsStr = new List(); _stepsStr.Add("Steps:"); - List _postconditionsStr = new List(); _postconditionsStr.Add("Postconditions:\n"); - - while (customAttributes.MoveNext()) - { - if (customAttributes.Current.AttributeType.FullName.Equals(STEP_ATTRIBUTE_NAME)) - { - _stepsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); - } - else if (customAttributes.Current.AttributeType.FullName.Equals(PRECONDITION_ATTRIBUTE_NAME)) - { - _preconditonsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); - } - else if (customAttributes.Current.AttributeType.FullName.Equals(POSTCONDITION_ATTRIBUTE_NAME)) - { - _postconditionsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); - } - } - - _tcInfoList.Add(new TestcaseInfo - { - TestcaseName = pair.Key, - Preconditions = _preconditonsStr, - Steps = _stepsStr, - Postconditions = _postconditionsStr, - }); - break; - } - } - } - } - - public void ExecuteTC(Layout layout) - { - if (ManualTest.IsWearable()) - { - WearableTemplate.TestPage.GetInstance().ExecuteTC(layout); - } - else - { - _tcUILayout.Children.Add(layout); - } - } - - public void ExecuteTC(Page page) - { - if (ManualTest.IsWearable()) - { - if (String.IsNullOrEmpty(page.Title)) - { - NavigationPage.SetHasNavigationBar(page, false); - } - WearableTemplate.TestPage.GetInstance().ExecuteTC(page); - } - else - { - _tcUIPage = page; - _navigationPage.PushAsync(page); - } - } - } -} + TLogger.Write("############### TC Name:" + _tcInfoList[_tcIndex].TestcaseName); + foreach (string precondition in _tcInfoList[_tcIndex].Preconditions.ToArray()) + { + index++; + _currentTCInfo[index].Description = precondition; + } + foreach (string step in _tcInfoList[_tcIndex].Steps.ToArray()) + { + index++; + _currentTCInfo[index].Description = step; + } + foreach (string postcondition in _tcInfoList[_tcIndex].Postconditions.ToArray()) + { + index++; + _currentTCInfo[index].Description = postcondition; + } + _prevBtn.IsEnabled = true; + _nextBtn.IsEnabled = true; + } + + private void MakeTCInfoList() + { + foreach (var testcaseItem in _listItem) + { + foreach (KeyValuePair pair in _tunitRunner.GetTestList()) + { + if (testcaseItem.TCName.Equals(pair.Key)) + { + IEnumerator customAttributes = pair.Value.Method.MethodInfo.CustomAttributes.GetEnumerator(); + List _preconditonsStr = new List(); _preconditonsStr.Add("Preconditions:"); + List _stepsStr = new List(); _stepsStr.Add("Steps:"); + List _postconditionsStr = new List(); _postconditionsStr.Add("Postconditions:\n"); + + while (customAttributes.MoveNext()) + { + if (customAttributes.Current.AttributeType.FullName.Equals(STEP_ATTRIBUTE_NAME)) + { + _stepsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + else if (customAttributes.Current.AttributeType.FullName.Equals(PRECONDITION_ATTRIBUTE_NAME)) + { + _preconditonsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + else if (customAttributes.Current.AttributeType.FullName.Equals(POSTCONDITION_ATTRIBUTE_NAME)) + { + _postconditionsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + } + + _tcInfoList.Add(new TestcaseInfo + { + TestcaseName = pair.Key, + Preconditions = _preconditonsStr, + Steps = _stepsStr, + Postconditions = _postconditionsStr, + }); + break; + } + } + } + } + + public void ExecuteTC(Layout layout) + { + if (ManualTest.IsWearable()) + { + WearableTemplate.TestPage.GetInstance().ExecuteTC(layout); + } + else + { + _tcUILayout.Children.Add(layout); + } + } + + public void ExecuteTC(Page page) + { + if (ManualTest.IsWearable()) + { + if (String.IsNullOrEmpty(page.Title)) + { + NavigationPage.SetHasNavigationBar(page, false); + } + WearableTemplate.TestPage.GetInstance().ExecuteTC(page); + } + else + { + _tcUIPage = page; + _navigationPage.PushAsync(page); + } + } + } +} diff --git a/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplate.cs b/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplate.cs old mode 100755 new mode 100644 index 320aaa8..8d69afc --- a/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplate.cs +++ b/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplate.cs @@ -49,23 +49,23 @@ namespace WearableTemplate _listNotPass = TSettings.GetInstance().GetNotPassListManual(); int count = 0; - if (_listNotPass.Count == 0) - { - foreach (KeyValuePair pair in _tunitrunner.GetTestList()) - { - count++; - _listItem.Add(new ItemData { No = count, TCName = pair.Key, Result = StrResult.NOTRUN }); - _tcIDList.Add(pair.Key); - } - } - else - { - foreach (var tc in _listNotPass) - { - count++; - _listItem.Add(new ItemData { No = count, TCName = tc, Result = StrResult.NOTRUN }); - _tcIDList.Add(tc); - } + if (_listNotPass.Count == 0) + { + foreach (KeyValuePair pair in _tunitrunner.GetTestList()) + { + count++; + _listItem.Add(new ItemData { No = count, TCName = pair.Key, Result = StrResult.NOTRUN }); + _tcIDList.Add(pair.Key); + } + } + else + { + foreach (var tc in _listNotPass) + { + count++; + _listItem.Add(new ItemData { No = count, TCName = tc, Result = StrResult.NOTRUN }); + _tcIDList.Add(tc); + } } ResultNumber.Total = ResultNumber.NotRun = _tcIDList.Count; diff --git a/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplateForWearable.csproj b/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplateForWearable.csproj old mode 100755 new mode 100644 index bc1001d..c9ce39a --- a/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplateForWearable.csproj +++ b/tct-suite-vs/Template/ManualTemplateForWearable/ManualTemplateForWearable.csproj @@ -1,22 +1,22 @@ - - - - Library - net6.0-tizen8.0 - True - Tizen - - - - - - - - - - - - - - - + + + + Library + net6.0-tizen8.0 + True + Tizen + + + + + + + + + + + + + + + diff --git a/tct-suite-vs/Template/ManualTemplateForWearable/TestPage.cs b/tct-suite-vs/Template/ManualTemplateForWearable/TestPage.cs old mode 100755 new mode 100644 index b5f99fd..9a977e2 --- a/tct-suite-vs/Template/ManualTemplateForWearable/TestPage.cs +++ b/tct-suite-vs/Template/ManualTemplateForWearable/TestPage.cs @@ -1,668 +1,668 @@ -/* - * 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.Collections.Generic; -using NUnitLite.TUnit; -using NUnit.Framework.TUnit; -using NUnit.Framework.Interfaces; -using System.Reflection; -using Xamarin.Forms; -using Tizen.Applications; - -namespace WearableTemplate -{ - public class TestPage - { - private static TestPage instance; - private static Object lockObject = new object(); - - private NavigationPage _navigationPage; - private ContentPage _tcContentPage; - private Page _tcUIPage; - private Label _summaryLabel1, _summaryLabel2, _tcResultText, _descriptionTitle; - private ListView _tcDescriptions; - private Button _runBtn, _passBtn, _failBtn, _blockBtn; - private Button _mainBtn, _prevBtn, _nextBtn; - private StackLayout _mainLayout, _tcUILayout; - - private int _tcIndex = 0; - private List _tcIDList; - private List _listItem; - private List _tcInfoList; - private List _currentTCInfo; - private TRunner _tunitRunner; - private TSettings _tsettings; - private NavigationButton _pressButton = NavigationButton.NA; - private ToastMessage _toastMessage; - - 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"; - - public event EventHandler TestcaseDone; - - private void OnTestcaseDone(string e) - { - EventHandler handler = TestcaseDone; - if (handler != null) - { - handler(this, e); - } - } - - public NavigationPage getNavigationPage() - { - return _navigationPage; - } - - public static TestPage GetInstance() - { - - lock (lockObject) - { - if (instance == null) - { - instance = new TestPage(); - } - } - return instance; - } - - private TestPage() - { - } - - public void Initialize(TRunner tunitRunner, List testcaseIDList, List listItem) - { - _toastMessage = new ToastMessage(); - RunType.Value = RunType.MANUAL; - _tunitRunner = tunitRunner; - _tunitRunner.SingleTestDone += OnSingleTestDone; - _tcInfoList = new List(); - _tcIDList = testcaseIDList; - _tsettings = TSettings.GetInstance(); - _tsettings.IsManual = true; - _listItem = listItem; - MakeTCInfoList(); - - _summaryLabel1 = new Label() - { - Text = "", - HeightRequest = 25, - HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center, - TextColor = Color.White, - FontSize = 5, - }; - _summaryLabel2 = new Label() - { - Text = "", - HeightRequest = 25, - HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center, - TextColor = Color.White, - FontSize = 5, - }; - SetResultNumber(0, 0, 0); - MakeTestPage(); - } - - private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) - { - // check old result - if (_listItem[_tcIndex].Result.Contains(StrResult.FAIL)) - { - ResultNumber.Fail = ResultNumber.Fail - 1; - } - else if (_listItem[_tcIndex].Result.Contains(StrResult.PASS)) - { - ResultNumber.Pass = ResultNumber.Pass - 1; - } - else if (_listItem[_tcIndex].Result.Contains(StrResult.BLOCK)) - ResultNumber.Block = ResultNumber.Block - 1; - - // Update new result - _listItem[_tcIndex].Result = e.Result; - if (e.Result.Contains(StrResult.PASS)) - { - ResultNumber.Pass += 1; - } - else if (e.Result.Contains(StrResult.FAIL)) - { - ResultNumber.Fail += 1; - } - else if (e.Result.Contains(StrResult.BLOCK)) - { - ResultNumber.Block += 1; - } - - UpdateLayout(); - } - - private void UpdateLayout() - { - SetResultNumber(ResultNumber.Pass, ResultNumber.Fail, ResultNumber.Block); - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - if (_tcUILayout != null) - { - _tcUILayout.Children.Clear(); - } - if (_pressButton == NavigationButton.Next) - { - Next(); - } - else if (_pressButton == NavigationButton.Previous) - { - Previous(); - } - else if (_pressButton == NavigationButton.Home) - { - _navigationPage.PopAsync(); - } - OnTestcaseDone(null); - _passBtn.IsEnabled = false; - _failBtn.IsEnabled = false; - _blockBtn.IsEnabled = false; - _runBtn.IsEnabled = true; - _mainBtn.IsEnabled = true; - _prevBtn.IsEnabled = true; - _nextBtn.IsEnabled = true; - } - - private void SetResultNumber(int pass, int fail, int block) - { - ResultNumber.NotRun = ResultNumber.Total - pass - fail - block; - _summaryLabel1.Text = "T : " + ResultNumber.Total + ", P : " + pass; - _summaryLabel2.Text = "F : " + fail + ", B : " + block + ", NR : " + ResultNumber.NotRun; - } - - private void MakeTestPage() - { - _mainLayout = new StackLayout() - { - Orientation = StackOrientation.Vertical, - IsVisible = true, - HorizontalOptions = LayoutOptions.CenterAndExpand, - VerticalOptions = LayoutOptions.CenterAndExpand, - Spacing = 5, - Padding = new Thickness(10), - }; - _descriptionTitle = new Label() - { - Text = "DESCRIPTION:", - HorizontalOptions = LayoutOptions.FillAndExpand, - VerticalOptions = LayoutOptions.Start, - HeightRequest = 23, - Margin = new Thickness(40, 0, 0, 0), - FontSize = 5, - TextColor = Color.White, - }; - - StackLayout functionLayout = new StackLayout() - { - Orientation = StackOrientation.Horizontal, - IsVisible = true, - HeightRequest = 30, - HorizontalOptions = LayoutOptions.CenterAndExpand, - VerticalOptions = LayoutOptions.Start, - Spacing = 2, - Margin = new Thickness(0, 0, 0, 15) - }; - - _mainBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "H", - HeightRequest = 30, - WidthRequest = 55, - FontSize = 5 - }; - - _mainBtn.Clicked += (sender, e) => - { - _pressButton = NavigationButton.Home; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - _navigationPage.PopAsync(); - } - }; - - _prevBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "<<", - HeightRequest = 30, - WidthRequest = 55, - FontSize = 4 - }; - - _prevBtn.Clicked += (sender, e) => - { - PreviousTestcase(); - }; - - _nextBtn = new Button() - { - Text = ">>", - HorizontalOptions = LayoutOptions.Start, - HeightRequest = 30, - WidthRequest = 55, - FontSize = 4 - }; - - _nextBtn.Clicked += (sender, e) => - { - NextTestcase(); - }; - - _tcResultText = new Label() - { - HorizontalOptions = LayoutOptions.Start, - VerticalOptions = LayoutOptions.FillAndExpand, - HorizontalTextAlignment = TextAlignment.Center, - VerticalTextAlignment = TextAlignment.Center, - HeightRequest = 30, - FontSize = 3 - }; - functionLayout.Children.Add(_mainBtn); - functionLayout.Children.Add(_tcResultText); - functionLayout.Children.Add(_prevBtn); - functionLayout.Children.Add(_nextBtn); - // Show description - ShowDescription(); - - var navigationLayout = new StackLayout() - { - Orientation = StackOrientation.Horizontal, - IsVisible = true, - HeightRequest = 30, - HorizontalOptions = LayoutOptions.CenterAndExpand, - VerticalOptions = LayoutOptions.Start, - Spacing = 5, - }; - - _passBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "P", - HeightRequest = 30, - IsEnabled = false, - FontSize = 5, - WidthRequest = 60 - }; - - _passBtn.Clicked += (sender, e) => - { - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.PASS; - ManualTest.Confirm(); - } - }; - - _failBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "F", - HeightRequest = 30, - IsEnabled = false, - FontSize = 5, - WidthRequest = 60 - }; - - _failBtn.Clicked += (sender, e) => - { - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.FAIL; - ManualTest.Confirm(); - } - }; - - _blockBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "B", - HeightRequest = 30, - IsEnabled = false, - FontSize = 5, - WidthRequest = 60 - }; - - _blockBtn.Clicked += (sender, e) => - { - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.BLOCK; - ManualTest.Confirm(); - } - }; - - _runBtn = new Button() - { - HorizontalOptions = LayoutOptions.Start, - Text = "R", - HeightRequest = 30, - FontSize = 5, - WidthRequest = 60 - }; - - _runBtn.Clicked += (sender, e) => - { - LockUIButton(); - _pressButton = NavigationButton.NA; - _tsettings.Testcase_ID = _tcIDList[_tcIndex]; - _tsettings.TCResult = ""; - _tunitRunner.Execute(); - }; - - navigationLayout.Children.Add(_passBtn); - navigationLayout.Children.Add(_failBtn); - navigationLayout.Children.Add(_blockBtn); - navigationLayout.Children.Add(_runBtn); - - _tcUILayout = new StackLayout() - { - Orientation = StackOrientation.Vertical, - HorizontalOptions = LayoutOptions.FillAndExpand, - VerticalOptions = LayoutOptions.Start, - HeightRequest = 40, - WidthRequest = 280, - Margin = new Thickness(10, 0, 10, 0) - }; - - _mainLayout.Children.Add(_summaryLabel1); - _mainLayout.Children.Add(_summaryLabel2); - _mainLayout.Children.Add(_descriptionTitle); - _mainLayout.Children.Add(_tcDescriptions); - _mainLayout.Children.Add(_tcUILayout); - _mainLayout.Children.Add(navigationLayout); - _mainLayout.Children.Add(functionLayout); - _tcContentPage = new ContentPage() - { - Content = _mainLayout - }; - NavigationPage.SetHasNavigationBar(_tcContentPage, false); - } - - public void LockUIButton() - { - _runBtn.IsEnabled = false; - _passBtn.IsEnabled = false; - _failBtn.IsEnabled = false; - _blockBtn.IsEnabled = false; - _mainBtn.IsEnabled = false; - _prevBtn.IsEnabled = false; - _nextBtn.IsEnabled = false; - - } - - public void UnlockUIButton() - { - _passBtn.IsEnabled = true; - _failBtn.IsEnabled = true; - _blockBtn.IsEnabled = true; - _mainBtn.IsEnabled = true; - _prevBtn.IsEnabled = true; - _nextBtn.IsEnabled = true; - } - - public void Show(NavigationPage navigationPage, int testcaseIndex) - { - _navigationPage = navigationPage; - _tcIndex = testcaseIndex - 1; - _descriptionTitle.Text = "DESCRIPTION : #" + testcaseIndex; - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - UpdateDescriptions(); - navigationPage.PushAsync(_tcContentPage); - _passBtn.IsEnabled = false; - _failBtn.IsEnabled = false; - _blockBtn.IsEnabled = false; - } - - private void NextTestcase() - { - _pressButton = NavigationButton.Next; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - Next(); - } - } - - private void Next() - { - if (_tcIndex < _tcIDList.Count - 1) - { - _tcIndex = _tcIndex + 1; - _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - UpdateDescriptions(); - } - else if (_tcIndex == _tcIDList.Count - 1) - { - _toastMessage.Message = "This is last testcase"; - _toastMessage.Post(); - } - } - - private void PreviousTestcase() - { - _pressButton = NavigationButton.Previous; - if (!ManualTest.IsConfirmed()) - { - _tsettings.TCResult = StrResult.NOTRUN; - ManualTest.Confirm(); - } - else - { - Previous(); - } - } - - private void Previous() - { - if (_tcIndex > 0) - { - _tcIndex = _tcIndex - 1; - _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); - _tcResultText.Text = _listItem[_tcIndex].Result; - SetColor(_tcResultText.Text); - UpdateDescriptions(); - } - else if (_tcIndex == 0) - { - _toastMessage.Message = "This is first testcase"; - _toastMessage.Post(); - } - } - - private void SetColor(string result) - { - if (result.Equals(StrResult.PASS)) - { - _tcResultText.TextColor = Color.Green; - } - else if (result.Equals(StrResult.FAIL)) - { - _tcResultText.TextColor = Color.Red; - } - else if (result.Equals(StrResult.BLOCK)) - { - _tcResultText.TextColor = Color.Orange; - } - else - { - _tcResultText.TextColor = Color.White; - } - } - - private int FindMaxLineDescription() - { - int maxLine = 0; - for (int i = 0; i < _tcInfoList.Count; i++) - { - int len = _tcInfoList[i].Steps.Count + _tcInfoList[i].Preconditions.Count + _tcInfoList[i].Postconditions.Count; - maxLine = maxLine < len ? len : maxLine; - } - return maxLine; - } - - private void ShowDescription() - { - int lenght = FindMaxLineDescription() + 3; - var template = new DataTemplate(() => - { - var grid = new Grid(); - - var descriptionLabel = new Label - { - HorizontalOptions = LayoutOptions.FillAndExpand, - LineBreakMode = LineBreakMode.CharacterWrap, - FontSize = 6 - }; - - descriptionLabel.SetBinding(Label.TextProperty, new Binding("Description")); - - grid.Children.Add(descriptionLabel); - - return new ViewCell - { - View = grid, - }; - }); - - _tcDescriptions = new ListView() - { - ItemTemplate = template, - HorizontalOptions = LayoutOptions.FillAndExpand, - RowHeight = 110, - Margin = new Thickness(10, 0, 10, 0), - }; - _currentTCInfo = new List(); - for (int i = 0; i < lenght; i++) - { - _currentTCInfo.Add(new TestcaseDescription("")); - } - UpdateDescriptions(); - _tcDescriptions.ItemsSource = _currentTCInfo; - } - - private void UpdateDescriptions() - { - _prevBtn.IsEnabled = false; - _nextBtn.IsEnabled = false; - int lenght = FindMaxLineDescription() + 3; - for (int i = 0; i < lenght; i++) - { - _currentTCInfo[i].Description = ""; - } - int index = 0; - if (_tcInfoList.Count == 0) - { - _toastMessage.Message = "Some testing class wrong, plz recheck"; - _toastMessage.Post(); - return; - } - +/* + * 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.Collections.Generic; +using NUnitLite.TUnit; +using NUnit.Framework.TUnit; +using NUnit.Framework.Interfaces; +using System.Reflection; +using Xamarin.Forms; +using Tizen.Applications; + +namespace WearableTemplate +{ + public class TestPage + { + private static TestPage instance; + private static Object lockObject = new object(); + + private NavigationPage _navigationPage; + private ContentPage _tcContentPage; + private Page _tcUIPage; + private Label _summaryLabel1, _summaryLabel2, _tcResultText, _descriptionTitle; + private ListView _tcDescriptions; + private Button _runBtn, _passBtn, _failBtn, _blockBtn; + private Button _mainBtn, _prevBtn, _nextBtn; + private StackLayout _mainLayout, _tcUILayout; + + private int _tcIndex = 0; + private List _tcIDList; + private List _listItem; + private List _tcInfoList; + private List _currentTCInfo; + private TRunner _tunitRunner; + private TSettings _tsettings; + private NavigationButton _pressButton = NavigationButton.NA; + private ToastMessage _toastMessage; + + 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"; + + public event EventHandler TestcaseDone; + + private void OnTestcaseDone(string e) + { + EventHandler handler = TestcaseDone; + if (handler != null) + { + handler(this, e); + } + } + + public NavigationPage getNavigationPage() + { + return _navigationPage; + } + + public static TestPage GetInstance() + { + + lock (lockObject) + { + if (instance == null) + { + instance = new TestPage(); + } + } + return instance; + } + + private TestPage() + { + } + + public void Initialize(TRunner tunitRunner, List testcaseIDList, List listItem) + { + _toastMessage = new ToastMessage(); + RunType.Value = RunType.MANUAL; + _tunitRunner = tunitRunner; + _tunitRunner.SingleTestDone += OnSingleTestDone; + _tcInfoList = new List(); + _tcIDList = testcaseIDList; + _tsettings = TSettings.GetInstance(); + _tsettings.IsManual = true; + _listItem = listItem; + MakeTCInfoList(); + + _summaryLabel1 = new Label() + { + Text = "", + HeightRequest = 25, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + TextColor = Color.White, + FontSize = 5, + }; + _summaryLabel2 = new Label() + { + Text = "", + HeightRequest = 25, + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + TextColor = Color.White, + FontSize = 5, + }; + SetResultNumber(0, 0, 0); + MakeTestPage(); + } + + private void OnSingleTestDone(object sender, SingleTestDoneEventArgs e) + { + // check old result + if (_listItem[_tcIndex].Result.Contains(StrResult.FAIL)) + { + ResultNumber.Fail = ResultNumber.Fail - 1; + } + else if (_listItem[_tcIndex].Result.Contains(StrResult.PASS)) + { + ResultNumber.Pass = ResultNumber.Pass - 1; + } + else if (_listItem[_tcIndex].Result.Contains(StrResult.BLOCK)) + ResultNumber.Block = ResultNumber.Block - 1; + + // Update new result + _listItem[_tcIndex].Result = e.Result; + if (e.Result.Contains(StrResult.PASS)) + { + ResultNumber.Pass += 1; + } + else if (e.Result.Contains(StrResult.FAIL)) + { + ResultNumber.Fail += 1; + } + else if (e.Result.Contains(StrResult.BLOCK)) + { + ResultNumber.Block += 1; + } + + UpdateLayout(); + } + + private void UpdateLayout() + { + SetResultNumber(ResultNumber.Pass, ResultNumber.Fail, ResultNumber.Block); + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + if (_tcUILayout != null) + { + _tcUILayout.Children.Clear(); + } + if (_pressButton == NavigationButton.Next) + { + Next(); + } + else if (_pressButton == NavigationButton.Previous) + { + Previous(); + } + else if (_pressButton == NavigationButton.Home) + { + _navigationPage.PopAsync(); + } + OnTestcaseDone(null); + _passBtn.IsEnabled = false; + _failBtn.IsEnabled = false; + _blockBtn.IsEnabled = false; + _runBtn.IsEnabled = true; + _mainBtn.IsEnabled = true; + _prevBtn.IsEnabled = true; + _nextBtn.IsEnabled = true; + } + + private void SetResultNumber(int pass, int fail, int block) + { + ResultNumber.NotRun = ResultNumber.Total - pass - fail - block; + _summaryLabel1.Text = "T : " + ResultNumber.Total + ", P : " + pass; + _summaryLabel2.Text = "F : " + fail + ", B : " + block + ", NR : " + ResultNumber.NotRun; + } + + private void MakeTestPage() + { + _mainLayout = new StackLayout() + { + Orientation = StackOrientation.Vertical, + IsVisible = true, + HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.CenterAndExpand, + Spacing = 5, + Padding = new Thickness(10), + }; + _descriptionTitle = new Label() + { + Text = "DESCRIPTION:", + HorizontalOptions = LayoutOptions.FillAndExpand, + VerticalOptions = LayoutOptions.Start, + HeightRequest = 23, + Margin = new Thickness(40, 0, 0, 0), + FontSize = 5, + TextColor = Color.White, + }; + + StackLayout functionLayout = new StackLayout() + { + Orientation = StackOrientation.Horizontal, + IsVisible = true, + HeightRequest = 30, + HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.Start, + Spacing = 2, + Margin = new Thickness(0, 0, 0, 15) + }; + + _mainBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "H", + HeightRequest = 30, + WidthRequest = 55, + FontSize = 5 + }; + + _mainBtn.Clicked += (sender, e) => + { + _pressButton = NavigationButton.Home; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + _navigationPage.PopAsync(); + } + }; + + _prevBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "<<", + HeightRequest = 30, + WidthRequest = 55, + FontSize = 4 + }; + + _prevBtn.Clicked += (sender, e) => + { + PreviousTestcase(); + }; + + _nextBtn = new Button() + { + Text = ">>", + HorizontalOptions = LayoutOptions.Start, + HeightRequest = 30, + WidthRequest = 55, + FontSize = 4 + }; + + _nextBtn.Clicked += (sender, e) => + { + NextTestcase(); + }; + + _tcResultText = new Label() + { + HorizontalOptions = LayoutOptions.Start, + VerticalOptions = LayoutOptions.FillAndExpand, + HorizontalTextAlignment = TextAlignment.Center, + VerticalTextAlignment = TextAlignment.Center, + HeightRequest = 30, + FontSize = 3 + }; + functionLayout.Children.Add(_mainBtn); + functionLayout.Children.Add(_tcResultText); + functionLayout.Children.Add(_prevBtn); + functionLayout.Children.Add(_nextBtn); + // Show description + ShowDescription(); + + var navigationLayout = new StackLayout() + { + Orientation = StackOrientation.Horizontal, + IsVisible = true, + HeightRequest = 30, + HorizontalOptions = LayoutOptions.CenterAndExpand, + VerticalOptions = LayoutOptions.Start, + Spacing = 5, + }; + + _passBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "P", + HeightRequest = 30, + IsEnabled = false, + FontSize = 5, + WidthRequest = 60 + }; + + _passBtn.Clicked += (sender, e) => + { + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.PASS; + ManualTest.Confirm(); + } + }; + + _failBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "F", + HeightRequest = 30, + IsEnabled = false, + FontSize = 5, + WidthRequest = 60 + }; + + _failBtn.Clicked += (sender, e) => + { + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.FAIL; + ManualTest.Confirm(); + } + }; + + _blockBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "B", + HeightRequest = 30, + IsEnabled = false, + FontSize = 5, + WidthRequest = 60 + }; + + _blockBtn.Clicked += (sender, e) => + { + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.BLOCK; + ManualTest.Confirm(); + } + }; + + _runBtn = new Button() + { + HorizontalOptions = LayoutOptions.Start, + Text = "R", + HeightRequest = 30, + FontSize = 5, + WidthRequest = 60 + }; + + _runBtn.Clicked += (sender, e) => + { + LockUIButton(); + _pressButton = NavigationButton.NA; + _tsettings.Testcase_ID = _tcIDList[_tcIndex]; + _tsettings.TCResult = ""; + _tunitRunner.Execute(); + }; + + navigationLayout.Children.Add(_passBtn); + navigationLayout.Children.Add(_failBtn); + navigationLayout.Children.Add(_blockBtn); + navigationLayout.Children.Add(_runBtn); + + _tcUILayout = new StackLayout() + { + Orientation = StackOrientation.Vertical, + HorizontalOptions = LayoutOptions.FillAndExpand, + VerticalOptions = LayoutOptions.Start, + HeightRequest = 40, + WidthRequest = 280, + Margin = new Thickness(10, 0, 10, 0) + }; + + _mainLayout.Children.Add(_summaryLabel1); + _mainLayout.Children.Add(_summaryLabel2); + _mainLayout.Children.Add(_descriptionTitle); + _mainLayout.Children.Add(_tcDescriptions); + _mainLayout.Children.Add(_tcUILayout); + _mainLayout.Children.Add(navigationLayout); + _mainLayout.Children.Add(functionLayout); + _tcContentPage = new ContentPage() + { + Content = _mainLayout + }; + NavigationPage.SetHasNavigationBar(_tcContentPage, false); + } + + public void LockUIButton() + { + _runBtn.IsEnabled = false; + _passBtn.IsEnabled = false; + _failBtn.IsEnabled = false; + _blockBtn.IsEnabled = false; + _mainBtn.IsEnabled = false; + _prevBtn.IsEnabled = false; + _nextBtn.IsEnabled = false; + + } + + public void UnlockUIButton() + { + _passBtn.IsEnabled = true; + _failBtn.IsEnabled = true; + _blockBtn.IsEnabled = true; + _mainBtn.IsEnabled = true; + _prevBtn.IsEnabled = true; + _nextBtn.IsEnabled = true; + } + + public void Show(NavigationPage navigationPage, int testcaseIndex) + { + _navigationPage = navigationPage; + _tcIndex = testcaseIndex - 1; + _descriptionTitle.Text = "DESCRIPTION : #" + testcaseIndex; + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + UpdateDescriptions(); + navigationPage.PushAsync(_tcContentPage); + _passBtn.IsEnabled = false; + _failBtn.IsEnabled = false; + _blockBtn.IsEnabled = false; + } + + private void NextTestcase() + { + _pressButton = NavigationButton.Next; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + Next(); + } + } + + private void Next() + { + if (_tcIndex < _tcIDList.Count - 1) + { + _tcIndex = _tcIndex + 1; + _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + UpdateDescriptions(); + } + else if (_tcIndex == _tcIDList.Count - 1) + { + _toastMessage.Message = "This is last testcase"; + _toastMessage.Post(); + } + } + + private void PreviousTestcase() + { + _pressButton = NavigationButton.Previous; + if (!ManualTest.IsConfirmed()) + { + _tsettings.TCResult = StrResult.NOTRUN; + ManualTest.Confirm(); + } + else + { + Previous(); + } + } + + private void Previous() + { + if (_tcIndex > 0) + { + _tcIndex = _tcIndex - 1; + _descriptionTitle.Text = "DESCRIPTION : #" + (_tcIndex + 1); + _tcResultText.Text = _listItem[_tcIndex].Result; + SetColor(_tcResultText.Text); + UpdateDescriptions(); + } + else if (_tcIndex == 0) + { + _toastMessage.Message = "This is first testcase"; + _toastMessage.Post(); + } + } + + private void SetColor(string result) + { + if (result.Equals(StrResult.PASS)) + { + _tcResultText.TextColor = Color.Green; + } + else if (result.Equals(StrResult.FAIL)) + { + _tcResultText.TextColor = Color.Red; + } + else if (result.Equals(StrResult.BLOCK)) + { + _tcResultText.TextColor = Color.Orange; + } + else + { + _tcResultText.TextColor = Color.White; + } + } + + private int FindMaxLineDescription() + { + int maxLine = 0; + for (int i = 0; i < _tcInfoList.Count; i++) + { + int len = _tcInfoList[i].Steps.Count + _tcInfoList[i].Preconditions.Count + _tcInfoList[i].Postconditions.Count; + maxLine = maxLine < len ? len : maxLine; + } + return maxLine; + } + + private void ShowDescription() + { + int lenght = FindMaxLineDescription() + 3; + var template = new DataTemplate(() => + { + var grid = new Grid(); + + var descriptionLabel = new Label + { + HorizontalOptions = LayoutOptions.FillAndExpand, + LineBreakMode = LineBreakMode.CharacterWrap, + FontSize = 6 + }; + + descriptionLabel.SetBinding(Label.TextProperty, new Binding("Description")); + + grid.Children.Add(descriptionLabel); + + return new ViewCell + { + View = grid, + }; + }); + + _tcDescriptions = new ListView() + { + ItemTemplate = template, + HorizontalOptions = LayoutOptions.FillAndExpand, + RowHeight = 110, + Margin = new Thickness(10, 0, 10, 0), + }; + _currentTCInfo = new List(); + for (int i = 0; i < lenght; i++) + { + _currentTCInfo.Add(new TestcaseDescription("")); + } + UpdateDescriptions(); + _tcDescriptions.ItemsSource = _currentTCInfo; + } + + private void UpdateDescriptions() + { + _prevBtn.IsEnabled = false; + _nextBtn.IsEnabled = false; + int lenght = FindMaxLineDescription() + 3; + for (int i = 0; i < lenght; i++) + { + _currentTCInfo[i].Description = ""; + } + int index = 0; + if (_tcInfoList.Count == 0) + { + _toastMessage.Message = "Some testing class wrong, plz recheck"; + _toastMessage.Post(); + return; + } + _currentTCInfo[index].Description = "TC : " + _tcInfoList[_tcIndex].TestcaseName; - TLogger.Write("############### TC Name:" + _tcInfoList[_tcIndex].TestcaseName); - foreach (string precondition in _tcInfoList[_tcIndex].Preconditions.ToArray()) - { - index++; - _currentTCInfo[index].Description = precondition; - } - foreach (string step in _tcInfoList[_tcIndex].Steps.ToArray()) - { - index++; - _currentTCInfo[index].Description = step; - } - foreach (string postcondition in _tcInfoList[_tcIndex].Postconditions.ToArray()) - { - index++; - _currentTCInfo[index].Description = postcondition; - } - _prevBtn.IsEnabled = true; - _nextBtn.IsEnabled = true; - } - - private void MakeTCInfoList() - { - foreach (var testcaseItem in _listItem) - { - foreach (KeyValuePair pair in _tunitRunner.GetTestList()) - { - if (testcaseItem.TCName.Equals(pair.Key)) - { - IEnumerator customAttributes = pair.Value.Method.MethodInfo.CustomAttributes.GetEnumerator(); - List _preconditonsStr = new List(); _preconditonsStr.Add("Preconditions:"); - List _stepsStr = new List(); _stepsStr.Add("Steps:"); - List _postconditionsStr = new List(); _postconditionsStr.Add("Postconditions:\n"); - - while (customAttributes.MoveNext()) - { - if (customAttributes.Current.AttributeType.FullName.Equals(STEP_ATTRIBUTE_NAME)) - { - _stepsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); - } - else if (customAttributes.Current.AttributeType.FullName.Equals(PRECONDITION_ATTRIBUTE_NAME)) - { - _preconditonsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); - } - else if (customAttributes.Current.AttributeType.FullName.Equals(POSTCONDITION_ATTRIBUTE_NAME)) - { - _postconditionsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); - } - } - - _tcInfoList.Add(new TestcaseInfo - { - TestcaseName = pair.Key, - Preconditions = _preconditonsStr, - Steps = _stepsStr, - Postconditions = _postconditionsStr, - }); - break; - } - } - } - } - - public void ExecuteTC(Layout layout) - { - _tcUILayout.Children.Add(layout); - } - - public void ExecuteTC(Page page) - { - _tcUIPage = page; - _navigationPage.PushAsync(page); - } - } -} + TLogger.Write("############### TC Name:" + _tcInfoList[_tcIndex].TestcaseName); + foreach (string precondition in _tcInfoList[_tcIndex].Preconditions.ToArray()) + { + index++; + _currentTCInfo[index].Description = precondition; + } + foreach (string step in _tcInfoList[_tcIndex].Steps.ToArray()) + { + index++; + _currentTCInfo[index].Description = step; + } + foreach (string postcondition in _tcInfoList[_tcIndex].Postconditions.ToArray()) + { + index++; + _currentTCInfo[index].Description = postcondition; + } + _prevBtn.IsEnabled = true; + _nextBtn.IsEnabled = true; + } + + private void MakeTCInfoList() + { + foreach (var testcaseItem in _listItem) + { + foreach (KeyValuePair pair in _tunitRunner.GetTestList()) + { + if (testcaseItem.TCName.Equals(pair.Key)) + { + IEnumerator customAttributes = pair.Value.Method.MethodInfo.CustomAttributes.GetEnumerator(); + List _preconditonsStr = new List(); _preconditonsStr.Add("Preconditions:"); + List _stepsStr = new List(); _stepsStr.Add("Steps:"); + List _postconditionsStr = new List(); _postconditionsStr.Add("Postconditions:\n"); + + while (customAttributes.MoveNext()) + { + if (customAttributes.Current.AttributeType.FullName.Equals(STEP_ATTRIBUTE_NAME)) + { + _stepsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + else if (customAttributes.Current.AttributeType.FullName.Equals(PRECONDITION_ATTRIBUTE_NAME)) + { + _preconditonsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + else if (customAttributes.Current.AttributeType.FullName.Equals(POSTCONDITION_ATTRIBUTE_NAME)) + { + _postconditionsStr.Add(customAttributes.Current.ConstructorArguments[0].Value + "." + customAttributes.Current.ConstructorArguments[1].Value); + } + } + + _tcInfoList.Add(new TestcaseInfo + { + TestcaseName = pair.Key, + Preconditions = _preconditonsStr, + Steps = _stepsStr, + Postconditions = _postconditionsStr, + }); + break; + } + } + } + } + + public void ExecuteTC(Layout layout) + { + _tcUILayout.Children.Add(layout); + } + + public void ExecuteTC(Page page) + { + _tcUIPage = page; + _navigationPage.PushAsync(page); + } + } +} diff --git a/tct-suite-vs/Template/ManualTemplateForWearable/Utils.cs b/tct-suite-vs/Template/ManualTemplateForWearable/Utils.cs old mode 100755 new mode 100644 diff --git a/tct-suite-vs/Tizen.Alarm.UI.Tests/Program.cs b/tct-suite-vs/Tizen.Alarm.UI.Tests/Program.cs index 129489a..3010ceb 100755 --- a/tct-suite-vs/Tizen.Alarm.UI.Tests/Program.cs +++ b/tct-suite-vs/Tizen.Alarm.UI.Tests/Program.cs @@ -10,42 +10,22 @@ * 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 + * See the License for the specific language governing permissions and * limitations under the License */ using System; -using NUnitLite.TUnit; -using AutoTemplate; +using Tizen.Auto.Template; -namespace XamarinForTizen.Tizen +namespace Tizen.Applications.Tests { - class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + public class Program { - private static App _app; - protected override void OnCreate() - { - base.OnCreate(); - - Console.WriteLine("TCT : OnCreate()"); - _app = new App(); - LoadApplication(_app); - - TRunner t = new TRunner(); - t.LoadTestsuite(); - t.Execute(); - } - - public static App getApp() - { - return _app; - } static void Main(string[] args) { - Console.WriteLine("TCT : Main()"); - var app = new Program(); - global::Xamarin.Forms.Forms.Init(app); + Console.WriteLine("TCT CSharp: Main()"); + var app = new App(); app.Run(args); } } diff --git a/tct-suite-vs/Tizen.Applications.Manual.Tests/Program.cs b/tct-suite-vs/Tizen.Applications.Manual.Tests/Program.cs index 34d3a91..90f3b76 100755 --- a/tct-suite-vs/Tizen.Applications.Manual.Tests/Program.cs +++ b/tct-suite-vs/Tizen.Applications.Manual.Tests/Program.cs @@ -14,35 +14,29 @@ * limitations under the License */ + + using System; -using NUnit.Framework; -using Xamarin.Forms; +using NUnitLite.TUnit; +using Tizen.NUI; +using Tizen.Manual.Template; -namespace XamarinApplication.Tizen +namespace Tizen.Applications.AttachPanel.Manual.Tests { - class Program : global::Xamarin.Forms.Platform.Tizen.FormsApplication + public class Program : NUIApplication { - private Application _app; + protected override void OnCreate() { Console.WriteLine("TCT : OnCreate()"); base.OnCreate(); - if (ManualTest.IsWearable()) - { - _app = new WearableTemplate.MainPage(); - } - else - { - _app = new ManualTemplate.MainPage(); - } - LoadApplication(_app); + ManualTemplate.GetInstance(); } static void Main(string[] args) { Console.WriteLine("TCT : Main()"); var app = new Program(); - global::Xamarin.Forms.Forms.Init(app); app.Run(args); } }