Add Test cases for app shortcut, managedapps
[profile/tv/apps/dotnet/home.git] / HomeUnitTest / RecentTestCases.cs
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using Microsoft.VisualStudio.TestTools.UnitTesting;
19 using LibTVRefCommonPortable.Models;
20 using LibTVRefCommonPortable.DataModels;
21 using System.Linq;
22
23 namespace HomeUnitTest
24 {
25     /// <summary>
26     /// A test cases for RecentShortcutController
27     /// </summary>
28     [TestClass]
29     public class RecentTestCases
30     {
31         /// <summary>
32         /// A instance of RecentShortcutController
33         /// </summary>
34         private RecentShortcutController controller;
35
36         /// <summary>
37         /// A constructor that initializes RecentShortcutController instance.
38         /// </summary>
39         public RecentTestCases()
40         {
41             controller = new RecentShortcutController();
42         }
43
44         [TestMethod]
45         public void RecentGetListTest()
46         {
47             var recents = controller.GetList();
48
49             // R : MAX number of recent = 10
50             if (recents.Count() > 10)
51             {
52                 Assert.Fail("Too many Recent!!!, Returned = " + recents.Count());
53             }
54
55             bool isAllMedias = true;
56             bool isAllApps = true;
57
58             foreach (var recent in recents)
59             {
60                 Console.Out.WriteLine("-----------------------------");
61                 Console.Out.WriteLine("Type : " + recent.Type);
62                 Console.Out.WriteLine("ID : " + recent.Id);
63                 Console.Out.WriteLine("Date : " + recent.Date);
64                 Console.Out.WriteLine("ScreenShot : " + recent.ScreenshotPath);
65
66                 switch (recent.Type)
67                 {
68                     case RecentShortcutType.Application:
69                         isAllMedias = false;
70                         break;
71                     case RecentShortcutType.Media:
72                         isAllApps = false;
73                         break;
74                 }
75
76                 // R : Invalid Recent(id, label has 'invalid') should not included!!!
77                 if (recent.CurrentStateDescription == null ||
78                     recent.CurrentStateDescription.Label.ToLower().Contains("invalid"))
79                 {
80                     Assert.Fail("Recent including invalid items!!!, " + recent.Id);
81                 }
82             }
83
84             // R : Test Sample Recent is consist of App and Media types.
85             if (isAllMedias || isAllApps)
86             {
87                 Assert.Fail("Invalid Recent list, All Media({0}), All Apps({1})", isAllMedias, isAllApps);
88             }
89         }
90     }
91 }