Add Test cases for app shortcut, managedapps
[profile/tv/apps/dotnet/home.git] / LibTVRefCommonPortable / Stubs / ApplicationManagerAPITestStub.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 LibTVRefCommonPortable.Utils;
18 using System;
19 using System.Collections.Generic;
20 using System.Threading.Tasks;
21
22 namespace LibTVRefCommonPortable.Stubs
23 {
24     /// <summary>
25     /// A unit testing stub of IApplicationManagerAPIs.
26     /// </summary>
27     public class ApplicationManagerAPITestStub : IApplicationManagerAPIs
28     {
29         /// <summary>
30         /// A method for removing all recent applications
31         /// </summary>
32         public void DeleteAllRecentApplication()
33         {
34             throw new NotImplementedException();
35         }
36
37         /// <summary>
38         /// A method for removing the specified recent application
39         /// </summary>
40         /// <param name="appId">An application ID</param>
41         public void DeleteRecentApplication(string appId)
42         {
43             throw new NotImplementedException();
44         }
45
46         /// <summary>
47         /// A method provides installed application list.
48         /// </summary>
49         /// <returns>An installed application list</returns>
50         public Task<IEnumerable<InstalledApp>> GetAllInstalledApplication()
51         {
52             return Task.Run(() =>
53             {
54                 List<InstalledApp> installedApps = new List<InstalledApp>();
55
56                 installedApps.Add(new InstalledApp
57                 {
58                     Applabel = "app1",
59                     AppID = "app1",
60                     IconPath = "path/app1",
61                     InstalledTime = new DateTime(2017, 05, 02),
62                 });
63
64                 installedApps.Add(new InstalledApp
65                 {
66                     Applabel = "app2.removable",
67                     AppID = "app2.removable",
68                     IconPath = "path/app2",
69                     InstalledTime = new DateTime(2017, 05, 02),
70                 });
71
72                 installedApps.Add(new InstalledApp
73                 {
74                     Applabel = "invalid.org.tizen.xahome",
75                     AppID = "org.tizen.xahome",
76                     IconPath = "path/app3",
77                     InstalledTime = new DateTime(2017, 05, 02),
78                 });
79
80                 installedApps.Add(new InstalledApp
81                 {
82                     Applabel = "invalid.org.tizen.xaapps",
83                     AppID = "org.tizen.xaapps",
84                     IconPath = "path/app4",
85                     InstalledTime = new DateTime(2017, 05, 02),
86                 });
87
88                 installedApps.Add(new InstalledApp
89                 {
90                     Applabel = "invalid.org.tizen.xamediahub",
91                     AppID = "org.tizen.xamediahub",
92                     IconPath = "path/app5",
93                     InstalledTime = new DateTime(2017, 05, 02),
94                 });
95
96                 installedApps.Add(new InstalledApp
97                 {
98                     Applabel = "invalid.org.tizen.settings",
99                     AppID = "org.tizen.settings",
100                     IconPath = "path/app6",
101                     InstalledTime = new DateTime(2017, 05, 02),
102                 });
103
104                 return (IEnumerable<InstalledApp>)installedApps;
105             });
106         }
107
108         /// <summary>
109         /// Gets the app ID by the app label
110         /// </summary>
111         /// <param name="appLabel">the app label to get</param>
112         /// <returns>the app ID of the app label</returns>
113         public Task<string> GetAppIDbyAppLabel(string appLabel)
114         {
115             throw new NotImplementedException();
116         }
117
118         /// <summary>
119         /// Checks whether application is removable
120         /// </summary>
121         /// <param name="appID">The app ID to get</param>
122         /// <returns>If the application is removable, true; otherwise, false</returns>
123         public bool GetAppInfoRemovable(string appID)
124         {
125             return appID.Contains("removable");
126         }
127
128         /// <summary>
129         /// A method provides application information which is matched with the given app ID.
130         /// </summary>
131         /// <param name="applicationId">An application ID</param>
132         /// <returns>An installed application information</returns>
133         public InstalledApp GetInstalledApplication(string applicationId)
134         {
135             return new InstalledApp
136             {
137                 AppID = applicationId,
138                 Applabel = applicationId,
139                 IconPath = "path/" + applicationId,
140                 InstalledTime = DateUtils.GetRandomDate(),
141             };
142         }
143
144         /// <summary>
145         /// A method provides a recent application list.
146         /// </summary>
147         /// <returns>A Recent application list.</returns>
148         public IEnumerable<RecentApp> GetRecentApplications()
149         {
150             IList<RecentApp> testData = new List<RecentApp>();
151
152             testData.Add(new RecentApp
153             {
154                 InstanceID = "recentapp1",
155                 InstanceLabel = "recentapp1",
156                 AppID = "org.tizen.recentapp1",
157                 Applabel = "recentapp1",
158                 IconPath = "/test/recentapp1",
159                 LaunchedTime = new DateTime(2014, 11, 12),
160                 Uri = "uri/recentapp1",
161                 ScreenShot = "screenshot/recentapp1",
162             });
163             testData.Add(new RecentApp
164             {
165                 InstanceID = "recentapp2.noscreenshot",
166                 InstanceLabel = "recentapp2.noscreenshot",
167                 AppID = "org.tizen.recentapp2.noscreenshot",
168                 Applabel = "recentapp2.noscreenshot",
169                 IconPath = "/test/recentapp2",
170                 LaunchedTime = new DateTime(2014, 11, 12),
171                 Uri = "uri/recentapp2",
172             });
173             testData.Add(new RecentApp
174             {
175                 InstanceID = "invalid.recentapp3.nolabel",
176                 AppID = "invalid.org.tizen.recentapp3.nolabel",
177                 IconPath = "/test/recentapp3",
178                 LaunchedTime = new DateTime(2014, 11, 12),
179                 Uri = "uri/recentapp3",
180                 ScreenShot = "screenshot/recentapp3",
181             });
182             testData.Add(new RecentApp
183             {
184                 InstanceID = "invalid.recentapp4.notime",
185                 AppID = "invalid.org.tizen.recentapp4.notime",
186                 Applabel = "recentapp4.notime",
187                 IconPath = "/test/recentapp4",
188                 Uri = "uri/recentapp4",
189                 ScreenShot = "screenshot/recentapp4",
190             });
191             testData.Add(new RecentApp
192             {
193                 InstanceID = "recentapp5",
194                 InstanceLabel = "recentapp5",
195                 AppID = "org.tizen.recentapp5",
196                 Applabel = "recentapp5",
197                 IconPath = "/test/recentapp5",
198                 LaunchedTime = new DateTime(2017, 05, 02),
199                 Uri = "uri/recentapp5",
200                 ScreenShot = "screenshot/recentapp5",
201             });
202             testData.Add(new RecentApp
203             {
204                 InstanceID = "recentapp6",
205                 InstanceLabel = "recentapp6",
206                 AppID = "org.tizen.recentapp6",
207                 Applabel = "recentapp6",
208                 IconPath = "/test/recentapp6",
209                 LaunchedTime = new DateTime(2017, 02, 26),
210                 Uri = "uri/recentapp6",
211                 ScreenShot = "screenshot/recentapp6",
212             });
213             testData.Add(new RecentApp
214             {
215                 InstanceID = "recentapp7",
216                 InstanceLabel = "recentapp7",
217                 AppID = "org.tizen.recentapp7",
218                 Applabel = "recentapp7",
219                 IconPath = "/test/recentapp7",
220                 LaunchedTime = new DateTime(2016, 04, 25),
221                 Uri = "uri/recentapp7",
222                 ScreenShot = "screenshot/recentapp7",
223             });
224
225             return testData;
226         }
227     }
228 }