2 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 using Tizen.Content.MediaContent;
9 namespace TizenTest.PlayListT
13 [Description("Tizen.Content.MediaContent.PlayList Tests")]
16 private static ContentFilter audioFilter;
17 private static PlayList playList = null;
18 private static MediaInformation[] audioArray = new MediaInformation[1000];
19 private static IEnumerable<MediaInformation> audioList;
20 static async Task PlayListSetup()
22 //Get files from the media folder
23 await ContentManager.ScanFolderAsync("/home/owner/content", true);
24 audioFilter = new ContentFilter();
25 audioFilter.Condition = "MEDIA_TYPE = 3";
26 Task<IEnumerable<MediaInformation>> getAudioListTask = ContentManager.Database.SelectAsync<MediaInformation>(audioFilter);
27 audioList = await getAudioListTask;
29 foreach (MediaInformation audio in audioList)
31 audioArray[i++] = audio;
33 Task<IEnumerable<PlayList>> getPlayListsTask = ContentManager.Database.SelectAsync<PlayList>(null);
34 IEnumerable<PlayList> allPlayLists = await getPlayListsTask;
35 foreach (PlayList p in allPlayLists)
37 ContentManager.Database.Delete(p);
42 public static void Init()
44 //get a mediainformation object
46 //LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for each TEST");
50 public static void Destroy()
53 //LogUtils.write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for each TEST");
58 [Description("Test PlayList constructor")]
59 [Property("SPEC", " Tizen.Content.MediaContent.PlayList.PlayList C")]
60 [Property("SPEC_URL", "-")]
61 [Property("CRITERIA", "CONSTR")]
62 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
63 public static async Task PlayList_CONSTRUCTOR()
65 await PlayListSetup();
66 string playListName = "playlist_work";
67 playList = new PlayList(playListName);
68 Assert.IsInstanceOf<PlayList>(playList);
69 Assert.IsTrue(playListName.CompareTo(playList.Name) == 0);
70 Assert.IsTrue(playList.Id == 0);
71 ContentManager.Database.Insert(playList);
72 Assert.IsFalse(playList.Id == 0);
77 [Description("Test if get for PlayList:Id is working properly")]
78 [Property("SPEC", " Tizen.Content.MediaContent.PlayList.Id A")]
79 [Property("SPEC_URL", "-")]
80 [Property("CRITERIA", "PRO")]
81 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
82 public static void Id_READ_ONLY()
84 Assert.IsFalse(playList.Id == 0);
89 [Description("Test if get/set for PlayList:Name is working properly")]
90 [Property("SPEC", "Tizen.Content.MediaContent.PlayList.Name A")]
91 [Property("SPEC_URL", "-")]
92 [Property("CRITERIA", "PRW")]
93 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
94 public static void Name_READ_WRITE()
98 string name = playList.Name;
99 string setValue = name + "_Modified";
100 playList.Name = setValue;
101 ContentManager.Database.Update(playList);
102 Assert.IsTrue(setValue.CompareTo(playList.Name) == 0, "Set value and get value of the property should be same");
107 Tizen.Log.Info("TCT", "Name_READ_WRITE Exception: " + e.Message);
113 [Description("Test if get/set for PlayList:ThumbnailPath is working properly")]
114 [Property("SPEC", "Tizen.Content.MediaContent.PlayList.ThumbnailPath A")]
115 [Property("SPEC_URL", "-")]
116 [Property("CRITERIA", "PRW")]
117 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
118 public static void ThumbnailPath_READ_WRITE()
120 Assert.IsFalse(playList.Id == 0);
121 // TODO dummy thumbnail path value. instead push a jpg in test case preperation
122 string setValue = "/home/owner/content/Camera/20150103-101850.jpg";
123 playList.ThumbnailPath = setValue;
124 ContentManager.Database.Update(playList);
125 string getValue = playList.ThumbnailPath;
126 Assert.IsTrue(setValue.CompareTo(playList.ThumbnailPath) == 0, "Set value and get value of the property should be same");
131 [Description("Test if PlayList:AddItem & PlayList:GetMediaInformationCount APIs are working properly")]
132 [Property("SPEC", "Tizen.Content.MediaContent.PlayList.AddItem Tizen.Content.MediaContent.PlayList.GetMediaInformationCount M")]
133 [Property("SPEC_URL", "-")]
134 [Property("CRITERIA", "MR MCST")]
135 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
136 public static void AddItem_CHECK_LENGTH()
138 Assert.IsFalse(playList.Id == 0 && audioArray.Length == 0);
139 playList.AddItem(audioArray[0]);
140 ContentManager.Database.Update(playList);
141 Assert.IsTrue(1 == playList.GetMediaInformationCount(null));
142 playList.AddItem(audioArray[1]);
143 ContentManager.Database.Update(playList);
144 Assert.IsTrue(2 == playList.GetMediaInformationCount(null));
145 playList.AddItem(audioArray[2]);
146 ContentManager.Database.Update(playList);
147 Assert.IsTrue(3 == playList.GetMediaInformationCount(null));
153 [Description("Test if PlayList:RemoveItem & PlayList:GetMediaInformationCount APIs are working properly")]
154 [Property("SPEC", "Tizen.Content.MediaContent.PlayList.RemoveItem Tizen.Content.MediaContent.PlayList.GetMediaInformationCount M")]
155 [Property("SPEC_URL", "-")]
156 [Property("CRITERIA", "MCST")]
157 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
158 public static void RemoveItem_CHECK_LENGTH()
162 Assert.IsFalse(playList.Id == 0 && playList.GetMediaInformationCount(null) == 0);
163 playList.RemoveItem(audioArray[2]);
164 ContentManager.Database.Update(playList);
165 Assert.IsTrue(2 == playList.GetMediaInformationCount(null));
166 playList.RemoveItem(audioArray[1]);
167 ContentManager.Database.Update(playList);
168 Assert.IsTrue(1 == playList.GetMediaInformationCount(null));
169 playList.RemoveItem(audioArray[0]);
170 ContentManager.Database.Update(playList);
171 Assert.IsTrue(0 == playList.GetMediaInformationCount(null));
176 Tizen.Log.Info("TCT", "RemoveItem_CHECK_LENGTH Exception: " + e.Message);
182 //[Description("Test if PlayList:SetPlayOrder & PlayList:GetPlayOrder APIs are working properly")]
183 //[Property("SPEC", "Tizen.Content.MediaContent.PlayList.SetPlayOrder Tizen.Content.MediaContent.PlayList.GetPlayOrder M")]
184 //[Property("SPEC_URL", "-")]
185 //[Property("CRITERIA", "MR MCST")]
186 //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
187 //public static void PlayOrder_READ_WRITE()
189 // Assert.IsFalse(playList.Id == 0);
190 // playList.AddItem(audioArray[0]);
191 // ContentManager.Database.Update(playList);
192 // playList.AddItem(audioArray[1]);
193 // ContentManager.Database.Update(playList);
194 // playList.AddItem(audioArray[2]);
195 // ContentManager.Database.Update(playList);
196 // Tizen.Log.Info("TCT", "PlayList member count: " + playList.GetMediaInformationCount(null));
197 // Tizen.Log.Info("TCT", "******Setting play order*****");
198 // playList.SetPlayOrder(audioArray[0], 2);
199 // Tizen.Log.Info("TCT", "******play order set*****");
200 // ContentManager.Database.Update(playList);
201 // Tizen.Log.Info("TCT", "******play order updated to database*****");
202 // int p = playList.GetPlayOrder(audioArray[0]);
203 // Tizen.Log.Info("TCT", "Got play order as " + p);
204 // Assert.IsTrue(2 == p);
209 //[Description("Test if PlayList:Import & PlayList:Export APIs are working properly")]
210 //[Property("SPEC", "Tizen.Content.MediaContent.PlayList.Import Tizen.Content.MediaContent.PlayList.Export M")]
211 //[Property("SPEC_URL", "-")]
212 //[Property("CRITERIA", "MR MCST")]
213 //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
214 //public static void PlayList_READ_WRITE()
216 // Assert.IsFalse(playList.Id == 0);
217 // Tizen.Log.Info("TCT", "#########Export#####");
218 // string path = "/home/owner/content/Music/playlist_work_imported.m3u";
219 // PlayList.Export(playList, path);
220 // Tizen.Log.Info("TCT", "#########Import#####");
221 // PlayList importedPlayList = PlayList.Import("playlist_work_imported", path);
222 // Assert.IsTrue(playList.GetMediaInformationCount(null) == importedPlayList.GetMediaInformationCount(null));
223 // Assert.IsTrue(playList.Name.CompareTo(importedPlayList.Name) == 0);
224 // Assert.IsTrue(playList.ThumbnailPath.CompareTo(importedPlayList.ThumbnailPath) == 0);
229 [Description("Test if PlayList:GetMediaInformationsAsync is working properly")]
230 [Property("SPEC", "Tizen.Content.MediaContent.PlayList.GetMediaInformationsAsync M")]
231 [Property("SPEC_URL", "-")]
232 [Property("CRITERIA", "MR")]
233 [Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")]
234 public static async Task GetMediaInformationsAsync_MEDIA_INFORMATION()
236 playList.AddItem(audioArray[0]);
237 playList.AddItem(audioArray[1]);
238 playList.AddItem(audioArray[2]);
239 ContentManager.Database.Update(playList);
240 Assert.IsFalse(playList.Id == 0 && playList.GetMediaInformationCount(null) == 0);
241 IEnumerable<MediaInformation> extract = null;
242 Task<IEnumerable<MediaInformation>> getMembersTask = playList.GetMediaInformationsAsync(null);
243 extract = await getMembersTask;
244 Assert.IsTrue(3 == extract.Count<MediaInformation>());