From b75d1fd65ffa45a63398fe401157504e035d5085 Mon Sep 17 00:00:00 2001 From: ChulSeung Kim Date: Mon, 5 Jun 2017 16:27:18 +0900 Subject: [PATCH] Add unit test case for RecentShortcutController. Remove meaningless TODOs Change-Id: I157ddce45ede7ac4967add7ba95e4c9986917e4f --- HomeUnitTest/HomeUnitTest.csproj | 84 +++ HomeUnitTest/Properties/AssemblyInfo.cs | 21 + HomeUnitTest/RecentTesting.cs | 82 +++ HomeUnitTest/Settings.StyleCop | 722 +++++++++++++++++++++ HomeUnitTest/packages.config | 6 + LibTVRefCommonPortable/DataModels/CommandAction.cs | 8 +- LibTVRefCommonPortable/DataModels/ShortcutInfo.cs | 10 - .../LibTVRefCommonPortable.csproj | 18 +- .../Models/AppShortcutController.cs | 40 +- LibTVRefCommonPortable/Models/ManagedApps.cs | 9 - .../Models/RecentShortcutController.cs | 159 +---- LibTVRefCommonPortable/Utils/AppShortcutStorage.cs | 2 - .../Utils/ApplicationManagerUtils.cs | 219 ++++++- LibTVRefCommonPortable/Utils/DebuggingUtils.cs | 13 +- LibTVRefCommonPortable/Utils/FileSystemUtils.cs | 243 +++++++ LibTVRefCommonPortable/Utils/IPackageManager.cs | 4 +- .../Utils/IPlatformNotification.cs | 4 +- LibTVRefCommonPortable/Utils/MediaContentUtils.cs | 141 ++++ .../Utils/PackageManagerUtils.cs | 2 +- .../Utils/RecentShortcutStorage.cs | 163 ++++- LibTVRefCommonPortable/Utils/SizeUtils.cs | 12 +- LibTVRefCommonPortable/packages.config | 4 +- .../LibTVRefCommonTizen.nuget.targets | 4 +- .../LibTVRefCommonTizen.project.json | 14 +- LibTVRefCommonTizen/Ports/AppControlPort.cs | 11 +- .../Ports/ApplicationManagerPort.cs | 6 +- LibTVRefCommonTizen/Ports/PackageManagerPort.cs | 14 +- TVApps/TVApps.TizenTV/TVApps.TizenTV.nuget.targets | 4 +- TVApps/TVApps.TizenTV/TVApps.TizenTV.project.json | 10 +- TVApps/TVApps/Controls/AppItemCell.xaml.cs | 1 - TVApps/TVApps/Controls/AppListView.xaml.cs | 2 - TVApps/TVApps/TVApps.csproj | 16 +- TVApps/TVApps/ViewModels/AppsHolder.cs | 69 +- TVApps/TVApps/ViewModels/MainPageViewModel.cs | 3 +- TVApps/TVApps/Views/FooterNormalStatus.xaml.cs | 1 - TVApps/TVApps/Views/MainPage.xaml.cs | 1 - TVApps/TVApps/packages.config | 4 +- TVHome/TVHome.TizenTV/Sniper.cs | 600 ++++++++--------- TVHome/TVHome.TizenTV/SniperInterOp.cs | 2 +- TVHome/TVHome.TizenTV/TVHome.TizenTV.csproj | 21 +- TVHome/TVHome.TizenTV/TVHome.TizenTV.nuget.targets | 4 +- TVHome/TVHome.TizenTV/TVHome.TizenTV.project.json | 10 +- .../res/org.tizen.example.Butterfly.Tizen.png | Bin 71615 -> 0 bytes .../res/org.tizen.example.Calculator.Tizen.png | Bin 46254 -> 0 bytes .../res/org.tizen.example.HomeFitness.Tizen.png | Bin 71615 -> 0 bytes .../res/org.tizen.example.Sports.Tizen.png | Bin 46254 -> 0 bytes .../res/org.tizen.example.Toda.Tizen.png | Bin 46254 -> 0 bytes .../res/org.tizen.example.YouTube.Tizen.png | Bin 71615 -> 0 bytes TVHome/TVHome/TVHome.csproj | 16 +- TVHome/TVHome/ViewModels/MainPageViewModel.cs | 5 +- TVHome/TVHome/packages.config | 4 +- TVHomeApps.sln | 10 +- 52 files changed, 2072 insertions(+), 726 deletions(-) create mode 100644 HomeUnitTest/HomeUnitTest.csproj create mode 100644 HomeUnitTest/Properties/AssemblyInfo.cs create mode 100644 HomeUnitTest/RecentTesting.cs create mode 100644 HomeUnitTest/Settings.StyleCop create mode 100644 HomeUnitTest/packages.config create mode 100644 LibTVRefCommonPortable/Utils/FileSystemUtils.cs create mode 100644 LibTVRefCommonPortable/Utils/MediaContentUtils.cs delete mode 100644 TVHome/TVHome.TizenTV/res/org.tizen.example.Butterfly.Tizen.png delete mode 100644 TVHome/TVHome.TizenTV/res/org.tizen.example.Calculator.Tizen.png delete mode 100644 TVHome/TVHome.TizenTV/res/org.tizen.example.HomeFitness.Tizen.png delete mode 100644 TVHome/TVHome.TizenTV/res/org.tizen.example.Sports.Tizen.png delete mode 100644 TVHome/TVHome.TizenTV/res/org.tizen.example.Toda.Tizen.png delete mode 100644 TVHome/TVHome.TizenTV/res/org.tizen.example.YouTube.Tizen.png diff --git a/HomeUnitTest/HomeUnitTest.csproj b/HomeUnitTest/HomeUnitTest.csproj new file mode 100644 index 0000000..7bf1694 --- /dev/null +++ b/HomeUnitTest/HomeUnitTest.csproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + {1F2DB8A0-7D1E-4BA3-BF27-335D033C572C} + Library + Properties + HomeUnitTest + HomeUnitTest + v4.6.1 + 512 + {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 15.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages + False + UnitTest + + + + + true + full + false + bin\Debug\ + TRACE;DEBUG;_TEST_ + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + + + ..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + + + + + ..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll + + + ..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll + + + ..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll + + + + + + + + + {67f9d3a8-f71e-4428-913f-c37ae82cdb24} + LibTVRefCommonPortable + + + + + + + + + + 이 프로젝트는 이 컴퓨터에 없는 NuGet 패키지를 참조합니다. 해당 패키지를 다운로드하려면 NuGet 패키지 복원을 사용하십시오. 자세한 내용은 http://go.microsoft.com/fwlink/?LinkID=322105를 참조하십시오. 누락된 파일은 {0}입니다. + + + + + + + + \ No newline at end of file diff --git a/HomeUnitTest/Properties/AssemblyInfo.cs b/HomeUnitTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..695ffc8 --- /dev/null +++ b/HomeUnitTest/Properties/AssemblyInfo.cs @@ -0,0 +1,21 @@ +// +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("HomeUnitTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("HomeUnitTest")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +[assembly: ComVisible(false)] + +[assembly: Guid("1f2db8a0-7d1e-4ba3-bf27-335d033c572c")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/HomeUnitTest/RecentTesting.cs b/HomeUnitTest/RecentTesting.cs new file mode 100644 index 0000000..50f90b0 --- /dev/null +++ b/HomeUnitTest/RecentTesting.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * 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 Microsoft.VisualStudio.TestTools.UnitTesting; +using LibTVRefCommonPortable.Models; +using LibTVRefCommonPortable.DataModels; +using System.Linq; + +namespace HomeUnitTest +{ + [TestClass] + public class RecentTesting + { + public RecentTesting() + { + + } + + [TestMethod] + public void GetListTest() + { + RecentShortcutController recentShortcutController = new RecentShortcutController(); + + var recents = recentShortcutController.GetList(); + + // MAX number of recent = 10 + if (recents.Count() > 10) + { + Assert.Fail("Too many Recent!!!, Returned = " + recents.Count()); + } + + bool isAllMedias = true; + bool isAllApps = true; + + foreach (var recent in recents) + { + Console.Out.WriteLine("-----------------------------"); + Console.Out.WriteLine("Type : " + recent.Type); + Console.Out.WriteLine("ID : " + recent.Id); + Console.Out.WriteLine("Date : " + recent.Date); + Console.Out.WriteLine("ScreenShot : " + recent.ScreenshotPath); + + switch (recent.Type) + { + case RecentShortcutType.Application: + isAllMedias = false; + break; + case RecentShortcutType.Media: + isAllApps = false; + break; + } + + // Invalid Recent(id, label has 'invalid') should not included!!! + if (recent.CurrentStateDescription == null || + recent.CurrentStateDescription.Label.ToLower().Contains("invalid")) + { + Assert.Fail("Recent including invalid items!!!, " + recent.Id); + } + } + + // Test Sample Recent is consist of App and Media types. + if (isAllMedias || isAllApps) + { + Assert.Fail("Invalid Recent list, All Media({0}), All Apps({1})", isAllMedias, isAllApps); + } + } + } +} diff --git a/HomeUnitTest/Settings.StyleCop b/HomeUnitTest/Settings.StyleCop new file mode 100644 index 0000000..837530c --- /dev/null +++ b/HomeUnitTest/Settings.StyleCop @@ -0,0 +1,722 @@ + + + NoMerge + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + False + + + + + + + \ No newline at end of file diff --git a/HomeUnitTest/packages.config b/HomeUnitTest/packages.config new file mode 100644 index 0000000..dab081a --- /dev/null +++ b/HomeUnitTest/packages.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LibTVRefCommonPortable/DataModels/CommandAction.cs b/LibTVRefCommonPortable/DataModels/CommandAction.cs index 8ad9efa..40585c9 100644 --- a/LibTVRefCommonPortable/DataModels/CommandAction.cs +++ b/LibTVRefCommonPortable/DataModels/CommandAction.cs @@ -14,7 +14,9 @@ * limitations under the License. */ +using System; using System.Windows.Input; +using Xamarin.Forms; namespace LibTVRefCommonPortable.DataModels { @@ -29,9 +31,9 @@ namespace LibTVRefCommonPortable.DataModels public string NextStateDescription { get; set; } /// - /// A Command. + /// A Command to be executed /// - public ICommand Command { get; set; } + public event EventHandler Command; /// /// A Command parameter. @@ -44,7 +46,7 @@ namespace LibTVRefCommonPortable.DataModels /// A next statue of a Shortcut. public string Execute() { - Command.Execute(CommandParameter); + Command?.Invoke(this, CommandParameter); return NextStateDescription; } } diff --git a/LibTVRefCommonPortable/DataModels/ShortcutInfo.cs b/LibTVRefCommonPortable/DataModels/ShortcutInfo.cs index b110f36..00854f6 100644 --- a/LibTVRefCommonPortable/DataModels/ShortcutInfo.cs +++ b/LibTVRefCommonPortable/DataModels/ShortcutInfo.cs @@ -87,16 +87,6 @@ namespace LibTVRefCommonPortable.DataModels return true; } - // TODO : remove, for debugging purpose - foreach (var item in stateDescriptions) - { - if (item.Value.Equals(CurrentStateDescription)) - { - //DebuggingUtils.Dbg("[" + item.Key + "] => [" + state + "]"); - break; - } - } - CurrentStateDescription = stateDescriptions[state]; OnPropertyChanged("CurrentStateDescription"); return true; diff --git a/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj b/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj index 52a8703..f59578f 100755 --- a/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj +++ b/LibTVRefCommonPortable/LibTVRefCommonPortable.csproj @@ -54,8 +54,10 @@ + + @@ -75,32 +77,28 @@ - ..\packages\Tizen.Xamarin.Forms.Extension.2.3.5-r233-002\lib\portable-win+net45+wp80+win81+wpa81\Tizen.Xamarin.Forms.Extension.dll - True + ..\packages\Tizen.Xamarin.Forms.Extension.2.3.5-r233-003\lib\portable-win+net45+wp80+win81+wpa81\Tizen.Xamarin.Forms.Extension.dll - ..\packages\Xamarin.Forms.2.3.5-r233-003\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll - True + ..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll - ..\packages\Xamarin.Forms.2.3.5-r233-003\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll - True + ..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll - ..\packages\Xamarin.Forms.2.3.5-r233-003\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll - True + ..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll - + 이 프로젝트는 이 컴퓨터에 없는 NuGet 패키지를 참조합니다. 해당 패키지를 다운로드하려면 NuGet 패키지 복원을 사용하십시오. 자세한 내용은 http://go.microsoft.com/fwlink/?LinkID=322105를 참조하십시오. 누락된 파일은 {0}입니다. - +