--- /dev/null
+/*
+ * 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 System.Threading.Tasks;
+using System.Linq;
+using LibTVRefCommonPortable.DataModels;
+
+namespace HomeUnitTest
+{
+ /// <summary>
+ /// A test cases for AppShortcutController
+ /// </summary>
+ [TestClass]
+ public class AppShortcutTestCases
+ {
+ /// <summary>
+ /// A instance of AppShortcutController
+ /// </summary>
+ private AppShortcutController controller;
+
+ /// <summary>
+ /// All Apps app shortcut name
+ /// </summary>
+ private static readonly string AllApps = "All apps";
+
+ /// <summary>
+ /// MediaHub app shortcut name
+ /// </summary>
+ private static readonly string MediaHub = "Media Hub";
+
+ /// <summary>
+ /// Add pin app shortcut name
+ /// </summary>
+ private static readonly string AddPin = "Add pin";
+
+ /// <summary>
+ /// A constructor that initialize AppShortcutController instance.
+ /// </summary>
+ public AppShortcutTestCases()
+ {
+ controller = new AppShortcutController();
+ }
+
+ #region 추가 테스트 특성
+ //
+ // 테스트를 작성할 때 다음 추가 특성을 사용할 수 있습니다.
+ //
+ // ClassInitialize를 사용하여 클래스의 첫 번째 테스트를 실행하기 전에 코드를 실행합니다.
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // ClassCleanup을 사용하여 클래스의 테스트를 모두 실행한 후에 코드를 실행합니다.
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // TestInitialize를 사용하여 각 테스트를 실행하기 전에 코드를 실행합니다.
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // TestCleanup을 사용하여 각 테스트를 실행한 후에 코드를 실행합니다.
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+ #endregion
+
+
+ [TestMethod]
+ public async Task AppShortcutGetInstalledAppsTest()
+ {
+ var installedApps = await controller.GetInstalledApps();
+
+ foreach (var app in installedApps)
+ {
+ Console.Out.WriteLine("App ID : " + app.AppID);
+ Console.Out.WriteLine("Installed Date : " + app.Installed);
+
+ // Err : CurrentStateDescription should not be null
+ Assert.AreNotEqual(app.CurrentStateDescription, null,
+ "StateDescription CurrentStateDescription is null!!!");
+
+ // Err : removable app property check
+ if (app.CurrentStateDescription.Label.Contains("removable") &&
+ app.IsRemovable == false)
+ {
+ Assert.Fail("Removable is failed");
+ }
+
+ // Err : Invalid state description removing.
+ if (app.CurrentStateDescription.Label.Contains("invalid"))
+ {
+ Assert.Fail("Invalid App Shortcut included!!!");
+ }
+ }
+ }
+
+ [TestMethod]
+ public void AppShortcutGetDefaultShortcutsTest()
+ {
+ var defaultShortcuts = controller.GetDefaultShortcuts();
+
+ // Req : Order of default shortcuts is All apps > Media Hub > Add pin
+ Assert.AreNotEqual(defaultShortcuts.ElementAt(0).CurrentStateDescription,
+ null, "All Apps CurrentStateDescription is invalid!!!");
+ Assert.AreEqual(defaultShortcuts.ElementAt(0).CurrentStateDescription.Label, AllApps);
+
+ Assert.AreNotEqual(defaultShortcuts.ElementAt(1).CurrentStateDescription,
+ null, "Media Hub CurrentStateDescription is invalid!!!");
+ Assert.AreEqual(defaultShortcuts.ElementAt(1).CurrentStateDescription.Label, MediaHub);
+
+ Assert.AreNotEqual(defaultShortcuts.ElementAt(2).CurrentStateDescription,
+ null, "Add pin CurrentStateDescription is invalid!!!");
+ Assert.AreEqual(defaultShortcuts.ElementAt(2).CurrentStateDescription.Label, AddPin);
+ }
+
+ [TestMethod]
+ public async Task AppShortcutGetPinnedAppsWithDefaultShortcutsTest()
+ {
+ var pinnedApps = await controller.GetPinnedAppsWithDefaultShortcuts();
+
+ // Req : A Maximum number of pinned apps is 10. + All apps, Media Hub, Add pin
+ Assert.IsTrue(pinnedApps.Count() <= 13, "A Maximum number of pinned apps is 10!!! NOT " + pinnedApps.Count());
+
+ // Req : Order of default shortcuts is All apps > Media Hub > Add pin
+ Assert.AreNotEqual(pinnedApps.ElementAt(0).CurrentStateDescription,
+ null, "All Apps CurrentStateDescription is invalid!!!");
+ Assert.AreEqual(pinnedApps.ElementAt(0).CurrentStateDescription.Label, AllApps);
+
+ Assert.AreNotEqual(pinnedApps.ElementAt(1).CurrentStateDescription,
+ null, "Media Hub CurrentStateDescription is invalid!!!");
+ Assert.AreEqual(pinnedApps.ElementAt(1).CurrentStateDescription.Label, MediaHub);
+
+ Assert.AreNotEqual(pinnedApps.ElementAt(pinnedApps.Count() - 1).CurrentStateDescription,
+ null, "Add pin CurrentStateDescription is invalid!!!");
+ Assert.AreEqual(pinnedApps.ElementAt(pinnedApps.Count() - 1).CurrentStateDescription.Label, AddPin);
+
+ foreach (var shortcut in pinnedApps)
+ {
+ // Err : shortcut should be AppShortcutInfo
+ if ((shortcut is AppShortcutInfo) == false)
+ {
+ Assert.Fail("Invalid ShortCut type!!!");
+ }
+
+ var app = shortcut as AppShortcutInfo;
+
+ Console.Out.WriteLine("ID : " + app.AppID);
+ Console.Out.WriteLine("Label : " + app.CurrentStateDescription.Label);
+ Console.Out.WriteLine("Installed : " + app.Installed);
+
+ // Err : CurrentStateDescription should not be null
+ Assert.AreNotEqual(app.CurrentStateDescription, null,
+ "StateDescription CurrentStateDescription is null!!!");
+
+ // Err : Both ID and Label should not be null
+ Assert.IsFalse((app.AppID == null || app.AppID.Length < 1) &&
+ (app.CurrentStateDescription.Label == null || app.CurrentStateDescription.Label.Length < 1),
+ "Both ID and Label should not be null!!!");
+
+ // Err : AppID should be exist
+ if (app.AppID == null)
+ {
+ if (app.CurrentStateDescription.Label.CompareTo(AllApps) != 0 &&
+ app.CurrentStateDescription.Label.CompareTo(MediaHub) != 0 &&
+ app.CurrentStateDescription.Label.CompareTo(AddPin) != 0)
+ {
+ Assert.Fail("App ID is missing!!! " + app.CurrentStateDescription.Label);
+ }
+ }
+ else
+ {
+ // Req : TVHome, TVApps, MediaHub, Settings should not be pinned.
+ Assert.IsFalse(app.AppID.Contains("xahome"), "TVHome should not be pinned");
+ Assert.IsFalse(app.AppID.Contains("xaapps"), "TVApps should not be pinned");
+ Assert.IsFalse(app.AppID.Contains("xamediahub"), "MediaHub should not be pinned");
+ Assert.IsFalse(app.AppID.Contains("settings"), "Settings should not be pinned");
+ }
+
+ // Err : removable app property check
+ if (app.CurrentStateDescription.Label.Contains("removable") &&
+ app.IsRemovable == false)
+ {
+ Assert.Fail("Removable is failed");
+ }
+
+ // Err : Invalid state description removing.
+ if (app.CurrentStateDescription.Label.Contains("invalid"))
+ {
+ Assert.Fail("Invalid App Shortcut included!!!");
+ }
+ }
+ }
+
+ [TestMethod]
+ public async Task AppShortcutGetPinnedAppsAppIDsTest()
+ {
+ var pinnedAppsIDs = await controller.GetPinnedAppsAppIDs();
+
+ // Req : A Maximum number of pinned apps is 10.
+ Assert.IsTrue(pinnedAppsIDs.Count() <= 10,
+ "A Maximum number of pinned apps is 10!!! NOT " + pinnedAppsIDs.Count());
+
+ foreach (var appID in pinnedAppsIDs.Keys)
+ {
+ // Err : AppID should not be null or empty.
+ Assert.AreNotEqual(appID, null, "App ID should not be null");
+ Assert.IsFalse(appID.Length < 1, "App ID should not be empty");
+
+ // Req : TVHome, TVApps, MediaHub, Settings should not be pinned.
+ Assert.IsFalse(appID.Contains("xahome"), "TVHome should not be pinned");
+ Assert.IsFalse(appID.Contains("xaapps"), "TVApps should not be pinned");
+ Assert.IsFalse(appID.Contains("xamediahub"), "MediaHub should not be pinned");
+ Assert.IsFalse(appID.Contains("settings"), "Settings should not be pinned");
+ }
+ }
+ }
+}
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>TRACE;DEBUG;_TEST_</DefineConstants>
+ <DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <HintPath>..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Core.dll</HintPath>
- </Reference>
- <Reference Include="Xamarin.Forms.Platform, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <HintPath>..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Platform.dll</HintPath>
- </Reference>
- <Reference Include="Xamarin.Forms.Xaml, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
- <HintPath>..\packages\Xamarin.Forms.2.3.5-r233-008\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.Xaml.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
- <Compile Include="RecentTesting.cs" />
+ <Compile Include="AppShortcutTestCases.cs" />
+ <Compile Include="ManagedAppsTestCases.cs" />
+ <Compile Include="RecentTestCases.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets'))" />
- <Error Condition="!Exists('..\packages\Xamarin.Forms.2.3.5-r233-008\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Xamarin.Forms.2.3.5-r233-008\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" />
- <Import Project="..\packages\Xamarin.Forms.2.3.5-r233-008\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.3.5-r233-008\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20\Xamarin.Forms.targets')" />
</Project>
\ No newline at end of file
--- /dev/null
+/*
+ * 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 Microsoft.VisualStudio.TestTools.UnitTesting;
+using LibTVRefCommonPortable.Models;
+
+namespace HomeUnitTest
+{
+ /// <summary>
+ /// A Test cases for ManagedApps class.
+ /// </summary>
+ [TestClass]
+ public class ManagedAppsTestCases
+ {
+ /// <summary>
+ /// TVHome package ID
+ /// </summary>
+ private static readonly string Home = "org.tizen.xahome";
+
+ /// <summary>
+ /// TVApps package ID
+ /// </summary>
+ private static readonly string Apps = "org.tizen.xaapps";
+
+ /// <summary>
+ /// Mediahub package ID
+ /// </summary>
+ private static readonly string Mediahub = "org.tizen.xamediahub";
+
+ /// <summary>
+ /// Settings package ID
+ /// </summary>
+ private static readonly string Settings = "org.tizen.settings";
+
+ [TestMethod]
+ public void ManagerAppsIsHiddenRecentAppTest()
+ {
+ Assert.IsTrue(ManagedApps.IsHiddenRecentApp(Home), "TVHome should not be hidden in Recents");
+ Assert.IsTrue(ManagedApps.IsHiddenRecentApp(Apps), "Apps should not be hidden in Recents");
+ Assert.IsTrue(ManagedApps.IsHiddenRecentApp(Mediahub), "Mediahub should not be hidden in Recents");
+ Assert.IsTrue(ManagedApps.IsHiddenRecentApp(Settings), "Settings should not be hidden in Recents");
+ }
+
+ [TestMethod]
+ public void ManagerAppsIsNonPinnableAppsTest()
+ {
+ Assert.IsTrue(ManagedApps.IsNonPinnableApps(Home), "TVHome should not be pinned");
+ Assert.IsTrue(ManagedApps.IsNonPinnableApps(Apps), "Apps should not be pinned");
+ Assert.IsTrue(ManagedApps.IsNonPinnableApps(Mediahub), "Mediahub should not be pinned");
+ Assert.IsTrue(ManagedApps.IsNonPinnableApps(Settings), "Settings should not be pinned");
+ }
+ }
+}
namespace HomeUnitTest
{
+ /// <summary>
+ /// A test cases for RecentShortcutController
+ /// </summary>
[TestClass]
- public class RecentTesting
+ public class RecentTestCases
{
- public RecentTesting()
- {
+ /// <summary>
+ /// A instance of RecentShortcutController
+ /// </summary>
+ private RecentShortcutController controller;
+ /// <summary>
+ /// A constructor that initializes RecentShortcutController instance.
+ /// </summary>
+ public RecentTestCases()
+ {
+ controller = new RecentShortcutController();
}
[TestMethod]
- public void GetListTest()
+ public void RecentGetListTest()
{
- RecentShortcutController recentShortcutController = new RecentShortcutController();
-
- var recents = recentShortcutController.GetList();
+ var recents = controller.GetList();
- // MAX number of recent = 10
+ // R : MAX number of recent = 10
if (recents.Count() > 10)
{
Assert.Fail("Too many Recent!!!, Returned = " + recents.Count());
break;
}
- // Invalid Recent(id, label has 'invalid') should not included!!!
+ // R : Invalid Recent(id, label has 'invalid') should not included!!!
if (recent.CurrentStateDescription == null ||
recent.CurrentStateDescription.Label.ToLower().Contains("invalid"))
{
}
}
- // Test Sample Recent is consist of App and Media types.
+ // R : 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);
*/
using System;
-using System.Windows.Input;
-using Xamarin.Forms;
namespace LibTVRefCommonPortable.DataModels
{
namespace LibTVRefCommonPortable.DataModels
{
/// <summary>
- /// A class represnts a state of a Shortcut.
+ /// A class represents a state of a Shortcut.
/// </summary>
public class StateDescription
{
<Compile Include="Models\ManagedApps.cs" />
<Compile Include="Models\RecentShortcutController.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Stubs\ApplicationManagerAPITestStub.cs" />
+ <Compile Include="Stubs\FileSystemAPITestStub.cs" />
+ <Compile Include="Stubs\FileWatcherAPITestStub.cs" />
+ <Compile Include="Stubs\MediaContentAPITestStub.cs" />
<Compile Include="Utils\AppControlUtils.cs" />
<Compile Include="Utils\ApplicationManagerUtils.cs" />
<Compile Include="Utils\AppShortcutStorage.cs" />
using System;
using System.Collections.Generic;
-
using LibTVRefCommonPortable.DataModels;
using LibTVRefCommonPortable.Utils;
using System.Threading.Tasks;
var installedAppList = await ApplicationManagerUtils.Instance.GetAllInstalledApplication();
- foreach (KeyValuePair<string, string[]> item in installedAppList)
+ foreach (var item in installedAppList)
{
- if (ManagedApps.IsNonPinnableApps(item.Key))
+ if (ManagedApps.IsNonPinnableApps(item.AppID))
{
continue;
}
var defaultStateDescription = new StateDescription()
{
- Label = item.Value[0],
- IconPath = item.Value[2],
+ Label = item.Applabel,
+ IconPath = item.IconPath,
Action = new AppControlAction()
{
- AppID = item.Key,
+ AppID = item.AppID,
}
};
- long longDate;
- if (long.TryParse(item.Value[3], out longDate) == false)
- {
- longDate = long.MinValue;
- }
-
var appShortcutInfo = new AppShortcutInfo()
{
- IsRemovable = ApplicationManagerUtils.Instance.GetAppInfoRemovable(item.Key),
- Installed = new DateTime(longDate),
+ IsRemovable = ApplicationManagerUtils.Instance.GetAppInfoRemovable(item.AppID),
+ Installed = item.InstalledTime,
};
appShortcutInfo.StateDescriptions.Add("default", defaultStateDescription);
appShortcutInfo.CurrentStateDescription = defaultStateDescription;
- appShortcutInfo.AppID = item.Key;
+ appShortcutInfo.AppID = item.AppID;
appShortcutInfoList.Add(appShortcutInfo);
}
List<ShortcutInfo> returnPinnedAppsInfo = new List<ShortcutInfo>();
+ int numberOfPinnedApp = 0;
foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
{
- if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
+ if (numberOfPinnedApp >= 10)
{
- continue;
+ break;
}
- Dictionary<string, string> appInfo = ApplicationManagerUtils.Instance.GetInstalledApplication(appShortcutInfo.AppID);
-
- if (appInfo == null)
+ if (appShortcutInfo.AppID == null ||
+ appShortcutInfo.AppID.Length < 1)
{
continue;
}
- string appLabel;
- string appIconPath;
+ if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
+ {
+ continue;
+ }
- if (appInfo.TryGetValue("Label", out appLabel) == false)
+ InstalledApp appInfo = ApplicationManagerUtils.Instance.GetInstalledApplication(appShortcutInfo.AppID);
+ if (appInfo == null)
{
- appLabel = "No Name";
+ continue;
}
- appInfo.TryGetValue("IconPath", out appIconPath);
+ string appLabel = appInfo.Applabel ?? "No Name";
+ string appIconPath = appInfo.IconPath ?? DefaultAppIcon;
var defaultStateDescription = new StateDescription()
{
Label = appLabel,
- IconPath = appIconPath ?? DefaultAppIcon,
+ IconPath = appIconPath,
Action = new AppControlAction
{
AppID = appShortcutInfo.AppID,
appShortcutInfo.CurrentStateDescription = defaultStateDescription;
appShortcutInfo.IsPinned = true;
returnPinnedAppsInfo.Add(appShortcutInfo);
+
+ numberOfPinnedApp += 1;
}
return returnPinnedAppsInfo;
IEnumerable<AppShortcutInfo> pinned_apps_info = await AppShortcutStorage.Read();
Dictionary<string, string> pinnedAppsDictionary = new Dictionary<string, string>();
+ int numberOfPinnedApp = 0;
foreach (AppShortcutInfo appShortcutInfo in pinned_apps_info)
{
+ if (numberOfPinnedApp >= 10)
+ {
+ break;
+ }
+
if (ManagedApps.IsNonPinnableApps(appShortcutInfo.AppID))
{
continue;
}
pinnedAppsDictionary.Add(appShortcutInfo.AppID, appShortcutInfo.AppID);
+ numberOfPinnedApp += 1;
}
return pinnedAppsDictionary;
--- /dev/null
+/*
+ * 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 LibTVRefCommonPortable.Utils;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace LibTVRefCommonPortable.Stubs
+{
+ /// <summary>
+ /// A unit testing stub of IApplicationManagerAPIs.
+ /// </summary>
+ public class ApplicationManagerAPITestStub : IApplicationManagerAPIs
+ {
+ /// <summary>
+ /// A method for removing all recent applications
+ /// </summary>
+ public void DeleteAllRecentApplication()
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// A method for removing the specified recent application
+ /// </summary>
+ /// <param name="appId">An application ID</param>
+ public void DeleteRecentApplication(string appId)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// A method provides installed application list.
+ /// </summary>
+ /// <returns>An installed application list</returns>
+ public Task<IEnumerable<InstalledApp>> GetAllInstalledApplication()
+ {
+ return Task.Run(() =>
+ {
+ List<InstalledApp> installedApps = new List<InstalledApp>();
+
+ installedApps.Add(new InstalledApp
+ {
+ Applabel = "app1",
+ AppID = "app1",
+ IconPath = "path/app1",
+ InstalledTime = new DateTime(2017, 05, 02),
+ });
+
+ installedApps.Add(new InstalledApp
+ {
+ Applabel = "app2.removable",
+ AppID = "app2.removable",
+ IconPath = "path/app2",
+ InstalledTime = new DateTime(2017, 05, 02),
+ });
+
+ installedApps.Add(new InstalledApp
+ {
+ Applabel = "invalid.org.tizen.xahome",
+ AppID = "org.tizen.xahome",
+ IconPath = "path/app3",
+ InstalledTime = new DateTime(2017, 05, 02),
+ });
+
+ installedApps.Add(new InstalledApp
+ {
+ Applabel = "invalid.org.tizen.xaapps",
+ AppID = "org.tizen.xaapps",
+ IconPath = "path/app4",
+ InstalledTime = new DateTime(2017, 05, 02),
+ });
+
+ installedApps.Add(new InstalledApp
+ {
+ Applabel = "invalid.org.tizen.xamediahub",
+ AppID = "org.tizen.xamediahub",
+ IconPath = "path/app5",
+ InstalledTime = new DateTime(2017, 05, 02),
+ });
+
+ installedApps.Add(new InstalledApp
+ {
+ Applabel = "invalid.org.tizen.settings",
+ AppID = "org.tizen.settings",
+ IconPath = "path/app6",
+ InstalledTime = new DateTime(2017, 05, 02),
+ });
+
+ return (IEnumerable<InstalledApp>)installedApps;
+ });
+ }
+
+ /// <summary>
+ /// Gets the app ID by the app label
+ /// </summary>
+ /// <param name="appLabel">the app label to get</param>
+ /// <returns>the app ID of the app label</returns>
+ public Task<string> GetAppIDbyAppLabel(string appLabel)
+ {
+ throw new NotImplementedException();
+ }
+
+ /// <summary>
+ /// Checks whether application is removable
+ /// </summary>
+ /// <param name="appID">The app ID to get</param>
+ /// <returns>If the application is removable, true; otherwise, false</returns>
+ public bool GetAppInfoRemovable(string appID)
+ {
+ return appID.Contains("removable");
+ }
+
+ /// <summary>
+ /// A method provides application information which is matched with the given app ID.
+ /// </summary>
+ /// <param name="applicationId">An application ID</param>
+ /// <returns>An installed application information</returns>
+ public InstalledApp GetInstalledApplication(string applicationId)
+ {
+ return new InstalledApp
+ {
+ AppID = applicationId,
+ Applabel = applicationId,
+ IconPath = "path/" + applicationId,
+ InstalledTime = DateUtils.GetRandomDate(),
+ };
+ }
+
+ /// <summary>
+ /// A method provides a recent application list.
+ /// </summary>
+ /// <returns>A Recent application list.</returns>
+ public IEnumerable<RecentApp> GetRecentApplications()
+ {
+ IList<RecentApp> testData = new List<RecentApp>();
+
+ testData.Add(new RecentApp
+ {
+ InstanceID = "recentapp1",
+ InstanceLabel = "recentapp1",
+ AppID = "org.tizen.recentapp1",
+ Applabel = "recentapp1",
+ IconPath = "/test/recentapp1",
+ LaunchedTime = new DateTime(2014, 11, 12),
+ Uri = "uri/recentapp1",
+ ScreenShot = "screenshot/recentapp1",
+ });
+ testData.Add(new RecentApp
+ {
+ InstanceID = "recentapp2.noscreenshot",
+ InstanceLabel = "recentapp2.noscreenshot",
+ AppID = "org.tizen.recentapp2.noscreenshot",
+ Applabel = "recentapp2.noscreenshot",
+ IconPath = "/test/recentapp2",
+ LaunchedTime = new DateTime(2014, 11, 12),
+ Uri = "uri/recentapp2",
+ });
+ testData.Add(new RecentApp
+ {
+ InstanceID = "invalid.recentapp3.nolabel",
+ AppID = "invalid.org.tizen.recentapp3.nolabel",
+ IconPath = "/test/recentapp3",
+ LaunchedTime = new DateTime(2014, 11, 12),
+ Uri = "uri/recentapp3",
+ ScreenShot = "screenshot/recentapp3",
+ });
+ testData.Add(new RecentApp
+ {
+ InstanceID = "invalid.recentapp4.notime",
+ AppID = "invalid.org.tizen.recentapp4.notime",
+ Applabel = "recentapp4.notime",
+ IconPath = "/test/recentapp4",
+ Uri = "uri/recentapp4",
+ ScreenShot = "screenshot/recentapp4",
+ });
+ testData.Add(new RecentApp
+ {
+ InstanceID = "recentapp5",
+ InstanceLabel = "recentapp5",
+ AppID = "org.tizen.recentapp5",
+ Applabel = "recentapp5",
+ IconPath = "/test/recentapp5",
+ LaunchedTime = new DateTime(2017, 05, 02),
+ Uri = "uri/recentapp5",
+ ScreenShot = "screenshot/recentapp5",
+ });
+ testData.Add(new RecentApp
+ {
+ InstanceID = "recentapp6",
+ InstanceLabel = "recentapp6",
+ AppID = "org.tizen.recentapp6",
+ Applabel = "recentapp6",
+ IconPath = "/test/recentapp6",
+ LaunchedTime = new DateTime(2017, 02, 26),
+ Uri = "uri/recentapp6",
+ ScreenShot = "screenshot/recentapp6",
+ });
+ testData.Add(new RecentApp
+ {
+ InstanceID = "recentapp7",
+ InstanceLabel = "recentapp7",
+ AppID = "org.tizen.recentapp7",
+ Applabel = "recentapp7",
+ IconPath = "/test/recentapp7",
+ LaunchedTime = new DateTime(2016, 04, 25),
+ Uri = "uri/recentapp7",
+ ScreenShot = "screenshot/recentapp7",
+ });
+
+ return testData;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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 LibTVRefCommonPortable.Utils;
+using System;
+using System.IO;
+using System.Text;
+
+namespace LibTVRefCommonPortable.Stubs
+{
+ /// <summary>
+ /// A unit test stub for FileSystemUtils
+ /// </summary>
+ public class FileSystemAPITestStub : IFileSystemAPIs
+ {
+ /// <summary>
+ /// A directory path which should be used for app data storing.
+ /// </summary>
+ public string AppDataStorage
+ {
+ get
+ {
+ return "test_app_data_path/";
+ }
+ }
+
+ /// <summary>
+ /// A directory path which should be used for app resource storing.
+ /// </summary>
+ public string AppResourceStorage
+ {
+ get
+ {
+ return "test_app_resource_path/";
+ }
+ }
+
+ /// <summary>
+ /// A directory path which should be used for sharing between apps.
+ /// </summary>
+ public string PlatformShareStorage
+ {
+ get
+ {
+ return "test_platform_share_path/";
+ }
+ }
+
+ /// <summary>
+ /// A method closes the file.
+ /// </summary>
+ /// <param name="stream">A file descriptor</param>
+ public void CloseFile(Stream stream)
+ {
+ }
+
+ /// <summary>
+ /// A method flushing the stream to write remains.
+ /// </summary>
+ /// <param name="stream">A file descriptor</param>
+ public void Flush(Stream stream)
+ {
+ }
+
+ /// <summary>
+ /// A method checks if a file existence in the file system.
+ /// </summary>
+ /// <param name="filePath">A file path</param>
+ /// <returns>An existence of the file</returns>
+ public bool IsFileExist(string filePath)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// A method checks if file is read to use.
+ /// </summary>
+ /// <param name="filePath">A file path</param>
+ /// <returns>A status of ready</returns>
+ public bool IsFileReady(string filePath)
+ {
+ return true;
+ }
+
+ /// <summary>
+ /// A method opens a file on the given mode.
+ /// </summary>
+ /// <param name="filePath">A file path</param>
+ /// <param name="mode">An opening mode</param>
+ /// <returns>A file descriptor</returns>
+ public Stream OpenFile(string filePath, UtilFileMode mode)
+ {
+ if (mode != UtilFileMode.Open)
+ {
+ throw new NotImplementedException();
+ }
+
+ if (filePath.Contains("pinned_apps_info"))
+ {
+ StringBuilder pinnedApps = new StringBuilder();
+
+ pinnedApps.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
+ pinnedApps.Append("<ArrayOfAppShortcutInfo");
+ pinnedApps.Append(" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
+ pinnedApps.Append(" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.xahome</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.xaapps</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.xamediahub</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.settings</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.TocToc.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.YouTube.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Toda.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly4.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly5.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly6.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly7.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly8.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly9.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly10.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID>org.tizen.example.Butterfly11.Tizen</AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append(" <AppShortcutInfo>");
+ pinnedApps.Append(" <AppID></AppID>");
+ pinnedApps.Append(" </AppShortcutInfo>");
+ pinnedApps.Append("</ArrayOfAppShortcutInfo>");
+
+ MemoryStream stream = new MemoryStream();
+ StreamWriter writer = new StreamWriter(stream);
+ writer.Write(pinnedApps.ToString());
+ writer.Flush();
+ stream.Position = 0;
+ return stream;
+ }
+
+ throw new NotImplementedException();
+ }
+ }
+}
--- /dev/null
+/*
+ * 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 LibTVRefCommonPortable.Utils;
+using System;
+
+namespace LibTVRefCommonPortable.Stubs
+{
+ /// <summary>
+ /// A unit test stub for FileSystemUtils
+ /// </summary>
+ public class FileWatcherAPITestStub : IFileSystemWatcherAPIs
+ {
+ /// <summary>
+ /// A EventHandler for the file system watcher.
+ /// </summary>
+ public event EventHandler<EventArgs> CustomChanged;
+
+ /// <summary>
+ /// A method starts the file system watcher.
+ /// </summary>
+ public void Run()
+ {
+ CustomChanged?.Invoke(this, EventArgs.Empty);
+
+ }
+ }
+}
--- /dev/null
+/*
+ * 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 LibTVRefCommonPortable.Utils;
+using System;
+using System.Collections.Generic;
+
+namespace LibTVRefCommonPortable.Stubs
+{
+ /// <summary>
+ /// A unit testing stub for MediaContentUtils
+ /// </summary>
+ public class MediaContentAPITestStub : IMediaContentAPIs
+ {
+ /// <summary>
+ /// A method for getting recently played media content list
+ /// </summary>
+ /// <param name="limitation">Maximum count of list</param>
+ /// <returns>The recently played media content list</returns>
+ public IEnumerable<RecentlyPlayedMedia> GetRecentlyPlayedMedia(int limitation)
+ {
+ IList<RecentlyPlayedMedia> recentlyPlayed = new List<RecentlyPlayedMedia>();
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "id/recent_media1",
+ ThumbnailPath = "thumbnail/recent_media1",
+ FilePath = "filepath/recent_media1",
+ DisplayName = "recent_media1",
+ PlayedAt = new DateTime(2017, 05, 22),
+ });
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "invalid.recent_media2.nofilepath",
+ ThumbnailPath = "invalid.recent_media2.nofilepath",
+ DisplayName = "invalid.recent_media2.nofilepath",
+ PlayedAt = new DateTime(2017, 2, 26),
+ });
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "id/recent_media3.nothumbnail",
+ FilePath = "filepath/recent_media3.nothumbnail",
+ DisplayName = "recent_media3.nothumbnail",
+ PlayedAt = new DateTime(2016, 4, 25),
+ });
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "id/recent_media4",
+ ThumbnailPath = "thumbnail/recent_media4",
+ FilePath = "filepath/recent_media4",
+ DisplayName = "recent_media4",
+ PlayedAt = new DateTime(2015, 12, 7),
+ });
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "id/recent_media5",
+ ThumbnailPath = "thumbnail/recent_media5",
+ FilePath = "filepath/recent_media5",
+ DisplayName = "recent_media5",
+ PlayedAt = new DateTime(2015, 10, 1),
+ });
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "id/recent_media6",
+ ThumbnailPath = "thumbnail/recent_media6",
+ FilePath = "filepath/recent_media6",
+ DisplayName = "recent_media6",
+ PlayedAt = new DateTime(2015, 3, 3),
+ });
+
+ recentlyPlayed.Add(new RecentlyPlayedMedia
+ {
+ MediaId = "id/recent_media7",
+ ThumbnailPath = "thumbnail/recent_media7",
+ FilePath = "filepath/recent_media7",
+ DisplayName = "recent_media8",
+ PlayedAt = new DateTime(2014, 11, 17),
+ });
+
+ return recentlyPlayed;
+ }
+ }
+}
using System.Collections.Generic;
using System.Xml.Serialization;
using System.IO;
-
using LibTVRefCommonPortable.DataModels;
-
-using Xamarin.Forms;
using System.Threading.Tasks;
using System.Diagnostics;
/// <summary>
/// A file system watcher which checks if the targeted storage is changed.
/// </summary>
- private static IFileSystemWatcherAPIs fileSystemWatcher = DependencyService.Get<IFileSystemWatcherAPIs>();
+ private static IFileSystemWatcherAPIs fileSystemWatcher = FileSystemUtils.Instance.FileSysteamWatcherInstance;
/// <summary>
/// An instance of AppShortcutStorage.
/// </summary>
private AppShortcutStorage()
{
- StoragePath = DependencyService.Get<IFileSystemAPIs>()?.PlatformShareStorage + "pinned_apps_info.xml";
+ StoragePath = FileSystemUtils.Instance.PlatformShareStorage + "pinned_apps_info.xml";
fileSystemWatcher.Run();
}
/// <returns>An app Shortcut list.</returns>
public static async Task<IEnumerable<AppShortcutInfo>> Read()
{
- IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
-
- if (fileSystem.IsFileExist(StoragePath) == false)
+ if (FileSystemUtils.Instance.IsFileExist(StoragePath) == false)
{
DebuggingUtils.Err("Set Default Pinned Apps" + StoragePath);
List<AppShortcutInfo> result = new List<AppShortcutInfo>();
for (int i = 0; i < 5; i++)
{
- if (fileSystem.IsFileReady(StoragePath))
+ if (FileSystemUtils.Instance.IsFileReady(StoragePath))
{
break;
}
DebuggingUtils.Dbg("[" + i + "/5] Waiting for Writing" + StoragePath);
}
- using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Open))
+ using (Stream fileStream = FileSystemUtils.Instance.OpenFile(StoragePath, UtilFileMode.Open))
{
Debug.Assert(fileStream != null);
/// <returns>A status of storage update.</returns>
public static bool Write(IEnumerable<AppShortcutInfo> pinnedAppInfo)
{
- IFileSystemAPIs fileSystem = DependencyService.Get<IFileSystemAPIs>();
-
- using (Stream fileStream = fileSystem.OpenFile(StoragePath, UtilFileMode.Create))
+ using (Stream fileStream = FileSystemUtils.Instance.OpenFile(StoragePath, UtilFileMode.Create))
{
Debug.Assert(fileStream != null);
-
+/*
+ * 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 LibTVRefCommonPortable.Stubs;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
}
/// <summary>
- /// A unit testing stub of IApplicationManagerAPIs.
- /// </summary>
- private class TestingStub : IApplicationManagerAPIs
- {
- public void DeleteAllRecentApplication()
- {
- throw new NotImplementedException();
- }
-
- public void DeleteRecentApplication(string appId)
- {
- throw new NotImplementedException();
- }
-
- public Task<Dictionary<string, string[]>> GetAllInstalledApplication()
- {
- throw new NotImplementedException();
- }
-
- public Task<string> GetAppIDbyAppLabel(string appLabel)
- {
- throw new NotImplementedException();
- }
-
- public bool GetAppInfoRemovable(string appID)
- {
- throw new NotImplementedException();
- }
-
- public Dictionary<string, string> GetInstalledApplication(string applicationId)
- {
- throw new NotImplementedException();
- }
-
- public IEnumerable<RecentApp> GetRecentApplications()
- {
- IList<RecentApp> testData = new List<RecentApp>();
-
- testData.Add(new RecentApp
- {
- InstanceID = "recentapp1",
- InstanceLabel = "recentapp1",
- AppID = "org.tizen.recentapp1",
- Applabel = "recentapp1",
- IconPath = "/test/recentapp1",
- LaunchedTime = new DateTime(2014, 11, 12),
- Uri = "uri/recentapp1",
- ScreenShot = "screenshot/recentapp1",
- });
- testData.Add(new RecentApp
- {
- InstanceID = "recentapp2.noscreenshot",
- InstanceLabel = "recentapp2.noscreenshot",
- AppID = "org.tizen.recentapp2.noscreenshot",
- Applabel = "recentapp2.noscreenshot",
- IconPath = "/test/recentapp2",
- LaunchedTime = new DateTime(2014, 11, 12),
- Uri = "uri/recentapp2",
- });
- testData.Add(new RecentApp
- {
- InstanceID = "invalid.recentapp3.nolabel",
- AppID = "invalid.org.tizen.recentapp3.nolabel",
- IconPath = "/test/recentapp3",
- LaunchedTime = new DateTime(2014, 11, 12),
- Uri = "uri/recentapp3",
- ScreenShot = "screenshot/recentapp3",
- });
- testData.Add(new RecentApp
- {
- InstanceID = "invalid.recentapp4.notime",
- AppID = "invalid.org.tizen.recentapp4.notime",
- Applabel = "recentapp4.notime",
- IconPath = "/test/recentapp4",
- Uri = "uri/recentapp4",
- ScreenShot = "screenshot/recentapp4",
- });
- testData.Add(new RecentApp
- {
- InstanceID = "recentapp5",
- InstanceLabel = "recentapp5",
- AppID = "org.tizen.recentapp5",
- Applabel = "recentapp5",
- IconPath = "/test/recentapp5",
- LaunchedTime = new DateTime(2017, 05, 02),
- Uri = "uri/recentapp5",
- ScreenShot = "screenshot/recentapp5",
- });
- testData.Add(new RecentApp
- {
- InstanceID = "recentapp6",
- InstanceLabel = "recentapp6",
- AppID = "org.tizen.recentapp6",
- Applabel = "recentapp6",
- IconPath = "/test/recentapp6",
- LaunchedTime = new DateTime(2017, 02, 26),
- Uri = "uri/recentapp6",
- ScreenShot = "screenshot/recentapp6",
- });
- testData.Add(new RecentApp
- {
- InstanceID = "recentapp7",
- InstanceLabel = "recentapp7",
- AppID = "org.tizen.recentapp7",
- Applabel = "recentapp7",
- IconPath = "/test/recentapp7",
- LaunchedTime = new DateTime(2016, 04, 25),
- Uri = "uri/recentapp7",
- ScreenShot = "screenshot/recentapp7",
- });
-
- return testData;
- }
- }
-
- /// <summary>
/// A constructor
/// </summary>
private ApplicationManagerUtils()
{
- applicationManagerAPIs = new TestingStub();
+ applicationManagerAPIs = new ApplicationManagerAPITestStub();
try
{
/// </summary>
/// <param name="appID">The app Id to get</param>
/// <returns>The information of the installed application</returns>
- public Dictionary<string, string> GetInstalledApplication(string appID)
+ public InstalledApp GetInstalledApplication(string appID)
{
return applicationManagerAPIs.GetInstalledApplication(appID);
}
/// Gets the information of the installed applications asynchronously
/// </summary>
/// <returns>The list of the installed applications</returns>
- public Task<Dictionary<string, string[]>> GetAllInstalledApplication()
+ public Task<IEnumerable<InstalledApp>> GetAllInstalledApplication()
{
return applicationManagerAPIs.GetAllInstalledApplication();
}
* limitations under the License.
*/
+using LibTVRefCommonPortable.Stubs;
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using Xamarin.Forms;
namespace LibTVRefCommonPortable.Utils
private static IFileSystemAPIs fileSystemAPIs;
/// <summary>
+ /// A instance of file system watcher port layer
+ /// </summary>
+ private static IFileSystemWatcherAPIs fileSystemWatcherAPIs;
+
+ /// <summary>
/// A instance of FileSystemUtils
/// </summary>
private static readonly FileSystemUtils instance = new FileSystemUtils();
}
/// <summary>
- /// A unit test stub for FileSystemUtils
+ /// A property of file system watcher instance
/// </summary>
- private class TestStub : IFileSystemAPIs
+ public IFileSystemWatcherAPIs FileSysteamWatcherInstance
{
- /// <summary>
- /// A directory path which should be used for app data storing.
- /// </summary>
- public string AppDataStorage
- {
- get
- {
- return "test_app_data_path/";
- }
- }
-
- /// <summary>
- /// A directory path which should be used for app resource storing.
- /// </summary>
- public string AppResourceStorage
- {
- get
- {
- return "test_app_resource_path/";
- }
- }
-
- /// <summary>
- /// A directory path which should be used for sharing between apps.
- /// </summary>
- public string PlatformShareStorage
- {
- get
- {
- return "test_platform_share_path/";
- }
- }
-
- /// <summary>
- /// A method closes the file.
- /// </summary>
- /// <param name="stream">A file descriptor</param>
- public void CloseFile(Stream stream)
- {
- }
-
- /// <summary>
- /// A method flushing the stream to write remains.
- /// </summary>
- /// <param name="stream">A file descriptor</param>
- public void Flush(Stream stream)
- {
- }
-
- /// <summary>
- /// A method checks if a file existence in the file system.
- /// </summary>
- /// <param name="filePath">A file path</param>
- /// <returns>An existence of the file</returns>
- public bool IsFileExist(string filePath)
- {
- return true;
- }
-
- /// <summary>
- /// A method checks if file is read to use.
- /// </summary>
- /// <param name="filePath">A file path</param>
- /// <returns>A status of ready</returns>
- public bool IsFileReady(string filePath)
- {
- return true;
- }
-
- /// <summary>
- /// A method opens a file on the given mode.
- /// </summary>
- /// <param name="filePath">A file path</param>
- /// <param name="mode">An opening mode</param>
- /// <returns>A file descriptor</returns>
- public Stream OpenFile(string filePath, UtilFileMode mode)
+ get
{
- throw new NotImplementedException();
+ return fileSystemWatcherAPIs;
}
}
/// </summary>
private FileSystemUtils()
{
- fileSystemAPIs = new TestStub();
+ fileSystemAPIs = new FileSystemAPITestStub();
+ fileSystemWatcherAPIs = new FileWatcherAPITestStub();
try
{
{
fileSystemAPIs = DependencyService.Get<IFileSystemAPIs>();
}
+
+ if (DependencyService.Get<IFileSystemWatcherAPIs>() != null)
+ {
+ fileSystemWatcherAPIs = DependencyService.Get<IFileSystemWatcherAPIs>();
+ }
}
catch (InvalidOperationException e)
{
public String IconPath;
/// <summary>
- /// A last launched data
+ /// A last launched date
/// </summary>
public DateTime LaunchedTime;
}
/// <summary>
+ /// A class to store installed app information.
+ /// </summary>
+ public class InstalledApp
+ {
+ /// <summary>
+ /// An app ID
+ /// </summary>
+ public String AppID;
+
+ /// <summary>
+ /// An app label
+ /// </summary>
+ public String Applabel;
+
+ /// <summary>
+ /// An app icon path
+ /// </summary>
+ public String IconPath;
+
+ /// <summary>
+ /// A installed date
+ /// </summary>
+ public DateTime InstalledTime;
+ }
+
+ /// <summary>
/// An interface for Application Manager feature
/// </summary>
public interface IApplicationManagerAPIs
/// A method provides installed application list.
/// </summary>
/// <returns>An installed application list</returns>
- Task<Dictionary<string, string[]>> GetAllInstalledApplication();
+ Task<IEnumerable<InstalledApp>> GetAllInstalledApplication();
/// <summary>
/// A method provides a recent application list.
/// </summary>
/// <param name="applicationId">An application ID</param>
/// <returns>An installed application information</returns>
- Dictionary<string, string> GetInstalledApplication(string applicationId);
+ InstalledApp GetInstalledApplication(string applicationId);
/// <summary>
/// A method for removing all recent applications
*/
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using System.IO;
namespace LibTVRefCommonPortable.Utils
-using System;
+/*
+ * 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 LibTVRefCommonPortable.Stubs;
+using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using Xamarin.Forms;
namespace LibTVRefCommonPortable.Utils
}
/// <summary>
- /// A unit testing stub for MediaContentUtils
- /// </summary>
- private class TestStub : IMediaContentAPIs
- {
- public IEnumerable<RecentlyPlayedMedia> GetRecentlyPlayedMedia(int limitation)
- {
- IList<RecentlyPlayedMedia> recentlyPlayed = new List<RecentlyPlayedMedia>();
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "id/recent_media1",
- ThumbnailPath = "thumbnail/recent_media1",
- FilePath = "filepath/recent_media1",
- DisplayName = "recent_media1",
- PlayedAt = new DateTime(2017, 05, 22),
- });
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "invalid.recent_media2.nofilepath",
- ThumbnailPath = "invalid.recent_media2.nofilepath",
- DisplayName = "invalid.recent_media2.nofilepath",
- PlayedAt = new DateTime(2017, 2, 26),
- });
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "id/recent_media3.nothumbnail",
- FilePath = "filepath/recent_media3.nothumbnail",
- DisplayName = "recent_media3.nothumbnail",
- PlayedAt = new DateTime(2016, 4, 25),
- });
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "id/recent_media4",
- ThumbnailPath = "thumbnail/recent_media4",
- FilePath = "filepath/recent_media4",
- DisplayName = "recent_media4",
- PlayedAt = new DateTime(2015, 12, 7),
- });
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "id/recent_media5",
- ThumbnailPath = "thumbnail/recent_media5",
- FilePath = "filepath/recent_media5",
- DisplayName = "recent_media5",
- PlayedAt = new DateTime(2015, 10, 1),
- });
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "id/recent_media6",
- ThumbnailPath = "thumbnail/recent_media6",
- FilePath = "filepath/recent_media6",
- DisplayName = "recent_media6",
- PlayedAt = new DateTime(2015, 3, 3),
- });
-
- recentlyPlayed.Add(new RecentlyPlayedMedia
- {
- MediaId = "id/recent_media7",
- ThumbnailPath = "thumbnail/recent_media7",
- FilePath = "filepath/recent_media7",
- DisplayName = "recent_media8",
- PlayedAt = new DateTime(2014, 11, 17),
- });
-
- return recentlyPlayed;
- }
- }
-
- /// <summary>
/// A Constructor
/// </summary>
private MediaContentUtils()
{
- mediaContentAPIs = new TestStub();
+ mediaContentAPIs = new MediaContentAPITestStub();
try
{
/// </summary>
/// <param name="appID">The app Id to get</param>
/// <returns>The information of the installed application</returns>
- public Dictionary<string, string> GetInstalledApplication(string appID)
+ public InstalledApp GetInstalledApplication(string appID)
{
- Dictionary<string, string> result = null;
+ InstalledApp result = null;
ApplicationInfo appInfo = null;
try
return null;
}
- result = new Dictionary<string, string>();
- result.Add("Label", appInfo.Label);
- result.Add("ApplicationId", appInfo.ApplicationId);
- result.Add("IconPath", (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : DefaultAppIcon);
+ result = new InstalledApp()
+ {
+ AppID = appInfo.ApplicationId,
+ Applabel = appInfo.Label,
+ IconPath = (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : DefaultAppIcon,
+ };
}
catch (Exception exception)
{
/// Gets the information of the installed applications asynchronously
/// </summary>
/// <returns>The list of the installed applications</returns>
- public async Task<Dictionary<string, string[]>> GetAllInstalledApplication()
+ public async Task<IEnumerable<InstalledApp>> GetAllInstalledApplication()
{
try
{
- Dictionary<string, string[]> resultList = new Dictionary<string, string[]>();
+ IList<InstalledApp> resultList = new List<InstalledApp>();
Task<IEnumerable<ApplicationInfo>> task = ApplicationManager.GetInstalledApplicationsAsync();
- string[] result;
IEnumerable<ApplicationInfo> installedList = await task;
continue;
}
- result = new string[4];
-
- result[0] = appInfo.Label;
- result[1] = appInfo.ApplicationId;
- result[2] = (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : DefaultAppIcon;
- result[3] = "" + pkgInfo.InstalledTime;
- resultList.Add(appInfo.ApplicationId, result);
+ resultList.Add(new InstalledApp
+ {
+ AppID = appInfo.ApplicationId,
+ Applabel = appInfo.Label,
+ IconPath = (System.IO.File.Exists(appInfo.IconPath)) ? appInfo.IconPath : DefaultAppIcon,
+ InstalledTime = new DateTime(pkgInfo.InstalledTime),
+ });
}
return resultList;
}
else
{
+ if (PinnedApps.Count >= 10)
+ {
+ IsSelectedExceeds = true;
+ ViewModel.OnPropertyChanged("IsSelectedExceeds");
+ return;
+ }
+
DebuggingUtils.Dbg("Pin : " + appID);
SelectedApp.IsPinned = true;
PinnedApps.Add(appID, appID);
/// <summary>
/// A method for checking the application is removable
- /// If the application is removable, show Delete Popup
+ /// If the application is removable, show Delete Pop-up
/// </summary>
/// <param name="appID">The ID of application for checking</param>
public void CheckDeleteApp(string appID)
return;
}
- string appLabel = null;
- if (ApplicationManagerUtils.Instance.GetInstalledApplication(appID).TryGetValue("Label", out appLabel))
- {
- ViewModel.ShowDeletePopup(appLabel);
- }
+ string appLabel = ApplicationManagerUtils.Instance.GetInstalledApplication(appID).Applabel;
+ ViewModel.ShowDeletePopup(appLabel);
}
/// <summary>