Revert "Add Test cases for app shortcut, managedapps"
[profile/tv/apps/dotnet/home.git] / HomeUnitTest / RecentTesting.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     [TestClass]
26     public class RecentTesting
27     {
28         public RecentTesting()
29         {
30
31         }
32
33         [TestMethod]
34         public void GetListTest()
35         {
36             RecentShortcutController recentShortcutController = new RecentShortcutController();
37
38             var recents = recentShortcutController.GetList();
39
40             // MAX number of recent = 10
41             if (recents.Count() > 10)
42             {
43                 Assert.Fail("Too many Recent!!!, Returned = " + recents.Count());
44             }
45
46             bool isAllMedias = true;
47             bool isAllApps = true;
48
49             foreach (var recent in recents)
50             {
51                 Console.Out.WriteLine("-----------------------------");
52                 Console.Out.WriteLine("Type : " + recent.Type);
53                 Console.Out.WriteLine("ID : " + recent.Id);
54                 Console.Out.WriteLine("Date : " + recent.Date);
55                 Console.Out.WriteLine("ScreenShot : " + recent.ScreenshotPath);
56
57                 switch (recent.Type)
58                 {
59                     case RecentShortcutType.Application:
60                         isAllMedias = false;
61                         break;
62                     case RecentShortcutType.Media:
63                         isAllApps = false;
64                         break;
65                 }
66
67                 // Invalid Recent(id, label has 'invalid') should not included!!!
68                 if (recent.CurrentStateDescription == null ||
69                     recent.CurrentStateDescription.Label.ToLower().Contains("invalid"))
70                 {
71                     Assert.Fail("Recent including invalid items!!!, " + recent.Id);
72                 }
73             }
74
75             // Test Sample Recent is consist of App and Media types.
76             if (isAllMedias || isAllApps)
77             {
78                 Assert.Fail("Invalid Recent list, All Media({0}), All Apps({1})", isAllMedias, isAllApps);
79             }
80         }
81     }
82 }