[NUI] Add TCs for NUI.Components.Devel.
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Tests / Tizen.NUI.Components.Devel.Tests / testcase / Controls / RecyclerView / TSCollectionView.cs
1 using NUnit.Framework;
2 using System;
3 using System.Collections;
4 using System.Collections.Generic;
5 using System.Collections.ObjectModel;
6 using System.Collections.Specialized;
7 using System.Text;
8 using System.Threading.Tasks;
9 using Tizen.NUI.BaseComponents;
10 using Tizen.NUI.Binding;
11
12 namespace Tizen.NUI.Components.Devel.Tests
13 {
14     using tlog = Tizen.Log;
15
16     [TestFixture]
17     [Description("Controls/RecyclerView/ItemSource/CollectionView")]
18     class TSCollectionView
19     {
20         private const string tag = "NUITEST";
21
22         private class TestModel : ObservableCollection<string>
23         {
24             private string[] namePool = {
25                 "Cat",
26                 "Boy",
27                 "Arm muscle",
28                 "Girl",
29                 "House",
30                 "Cafe",
31                 "Statue",
32                 "Sea",
33                 "hosepipe",
34                 "Police",
35                 "Rainbow",
36                 "Icicle",
37                 "Tower with the Moon",
38                 "Giraffe",
39                 "Camel",
40                 "Zebra",
41                 "Red Light",
42                 "Banana",
43                 "Lion",
44                 "Espresso",
45             };
46
47             public TestModel()
48             {
49                 CreateData(this, 20);
50             }
51
52             private ObservableCollection<string> CreateData(ObservableCollection<string> result, int count)
53             {
54                 for (int i = 0; i < count; i++)
55                 {
56                     result.Add(namePool[i % 20]);
57                 }
58                 return result;
59             }
60         }
61
62         private DataTemplate testDataTemplate;
63
64         [SetUp]
65         public void Init()
66         {
67             tlog.Info(tag, "Init() is called!");
68
69             testDataTemplate = new DataTemplate(() =>
70             {
71                 var rand = new Random();
72                 DefaultLinearItem item = new DefaultLinearItem();
73                 //Set Width Specification as MatchParent to fit the Item width with parent View.
74                 item.WidthSpecification = LayoutParamPolicies.MatchParent;
75
76                 //Decorate Label
77                 item.Label.SetBinding(TextLabel.TextProperty, "ViewLabel");
78                 item.Label.HorizontalAlignment = HorizontalAlignment.Begin;
79
80                 //Decorate SubLabel
81                 if ((rand.Next() % 2) == 0)
82                 {
83                     item.SubLabel.SetBinding(TextLabel.TextProperty, "Name");
84                     item.SubLabel.HorizontalAlignment = HorizontalAlignment.Begin;
85                 }
86
87                 return item;
88             });
89         }
90
91         [TearDown]
92         public void Destroy()
93         {
94             tlog.Info(tag, "Destroy() is called!");
95         }
96
97         [Test]
98         [Category("P1")]
99         [Description("CollectionView constructor.")]
100         [Property("SPEC", "Tizen.NUI.Components.CollectionView C")]
101         [Property("SPEC_URL", "-")]
102         [Property("CRITERIA", "CONSTR")]
103         [Property("COVPARAM", "")]
104         [Property("AUTHOR", "huayong.xu@samsung.com")]
105         public void CollectionViewConstructor()
106         {
107             tlog.Debug(tag, $"CollectionViewConstructor START");
108
109             var testingTarget = new CollectionView();
110
111             Assert.IsNotNull(testingTarget, "should be not null");
112             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
113
114             testingTarget.Dispose();
115             tlog.Debug(tag, $"CollectionViewConstructor END (OK)");
116         }
117
118         [Test]
119         [Category("P1")]
120         [Description("CollectionView constructor.")]
121         [Property("SPEC", "Tizen.NUI.Components.CollectionView C")]
122         [Property("SPEC_URL", "-")]
123         [Property("CRITERIA", "CONSTR")]
124         [Property("COVPARAM", "")]
125         [Property("AUTHOR", "huayong.xu@samsung.com")]
126         public void CollectionViewConstructorWithItemsSource()
127         {
128             tlog.Debug(tag, $"CollectionViewConstructorWithItemsSource START");
129
130             var model = new TestModel();
131             var testingTarget = new CollectionView(model);
132
133             Assert.IsNotNull(testingTarget, "should be not null");
134             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
135
136             testingTarget.Dispose();
137             tlog.Debug(tag, $"CollectionViewConstructorWithItemsSource END (OK)");
138         }
139
140         [Test]
141         [Category("P1")]
142         [Description("CollectionView constructor.")]
143         [Property("SPEC", "Tizen.NUI.Components.CollectionView C")]
144         [Property("SPEC_URL", "-")]
145         [Property("CRITERIA", "CONSTR")]
146         [Property("COVPARAM", "")]
147         [Property("AUTHOR", "huayong.xu@samsung.com")]
148         public void CollectionViewConstructorWithItemsSourceLayouterTemplate()
149         {
150             tlog.Debug(tag, $"CollectionViewConstructorWithItemsSourceLayouterTemplate START");
151
152             var model = new TestModel();
153             var testingTarget = new CollectionView(model, new LinearLayouter(), testDataTemplate);
154
155             Assert.IsNotNull(testingTarget, "should be not null");
156             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
157
158             testingTarget.Dispose();
159             tlog.Debug(tag, $"CollectionViewConstructorWithItemsSourceLayouterTemplate END (OK)");
160         }
161
162         [Test]
163         [Category("P1")]
164         [Description("CollectionView ItemsSource.")]
165         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ItemsSource A")]
166         [Property("SPEC_URL", "-")]
167         [Property("CRITERIA", "PRW")]
168         [Property("COVPARAM", "")]
169         [Property("AUTHOR", "huayong.xu@samsung.com")]
170         public void CollectionViewItemsSource()
171         {
172             tlog.Debug(tag, $"CollectionViewItemsSource START");
173
174             var testingTarget = new CollectionView();
175
176             Assert.IsNotNull(testingTarget, "should be not null");
177             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
178
179             testingTarget.ItemsSource = new TestModel();
180             Assert.IsNotNull(testingTarget.ItemsSource, "should be not null");
181
182             testingTarget.Dispose();
183             tlog.Debug(tag, $"CollectionViewItemsSource END (OK)");
184         }
185
186         [Test]
187         [Category("P1")]
188         [Description("CollectionView ItemTemplate.")]
189         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ItemTemplate A")]
190         [Property("SPEC_URL", "-")]
191         [Property("CRITERIA", "PRW")]
192         [Property("COVPARAM", "")]
193         [Property("AUTHOR", "huayong.xu@samsung.com")]
194         public void CollectionViewItemTemplate()
195         {
196             tlog.Debug(tag, $"CollectionViewItemTemplate START");
197
198             var testingTarget = new CollectionView();
199
200             Assert.IsNotNull(testingTarget, "should be not null");
201             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
202
203             testingTarget.ItemTemplate = testDataTemplate;
204             Assert.IsNotNull(testingTarget.ItemTemplate, "should be not null");
205
206             testingTarget.Dispose();
207             tlog.Debug(tag, $"CollectionViewItemTemplate END (OK)");
208         }
209
210         [Test]
211         [Category("P2")]
212         [Description("CollectionView ItemTemplate.")]
213         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ItemTemplate A")]
214         [Property("SPEC_URL", "-")]
215         [Property("CRITERIA", "PRW")]
216         [Property("COVPARAM", "")]
217         [Property("AUTHOR", "huayong.xu@samsung.com")]
218         public void CollectionViewItemTemplateNull()
219         {
220             tlog.Debug(tag, $"CollectionViewItemTemplateNull START");
221
222             var testingTarget = new CollectionView();
223
224             Assert.IsNotNull(testingTarget, "should be not null");
225             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
226
227             testingTarget.ItemTemplate = null;
228             Assert.IsNull(testingTarget.ItemTemplate, "should be null");
229
230             testingTarget.Dispose();
231             tlog.Debug(tag, $"CollectionViewItemTemplateNull END (OK)");
232         }
233
234         [Test]
235         [Category("P1")]
236         [Description("CollectionView ItemsLayouter.")]
237         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ItemsLayouter A")]
238         [Property("SPEC_URL", "-")]
239         [Property("CRITERIA", "PRW")]
240         [Property("COVPARAM", "")]
241         [Property("AUTHOR", "huayong.xu@samsung.com")]
242         public void CollectionViewItemsLayouter()
243         {
244             tlog.Debug(tag, $"CollectionViewItemsLayouter START");
245
246             var testingTarget = new CollectionView();
247
248             Assert.IsNotNull(testingTarget, "should be not null");
249             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
250
251             testingTarget.ItemsLayouter = new LinearLayouter();
252             Assert.IsNotNull(testingTarget.ItemsLayouter, "should not be null");
253
254             testingTarget.Dispose();
255             tlog.Debug(tag, $"CollectionViewItemsLayouter END (OK)");
256         }
257
258         [Test]
259         [Category("P2")]
260         [Description("CollectionView ItemsLayouter.")]
261         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ItemsLayouter A")]
262         [Property("SPEC_URL", "-")]
263         [Property("CRITERIA", "PRW")]
264         [Property("COVPARAM", "")]
265         [Property("AUTHOR", "huayong.xu@samsung.com")]
266         public void CollectionViewItemsLayouterNull()
267         {
268             tlog.Debug(tag, $"CollectionViewItemsLayouterNull START");
269
270             var testingTarget = new CollectionView();
271
272             Assert.IsNotNull(testingTarget, "should be not null");
273             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
274
275             testingTarget.ItemsLayouter = null;
276             Assert.IsNull(testingTarget.ItemsLayouter, "should be null");
277
278             testingTarget.Dispose();
279             tlog.Debug(tag, $"CollectionViewItemsLayouterNull END (OK)");
280         }
281
282         [Test]
283         [Category("P1")]
284         [Description("CollectionView ScrollingDirection.")]
285         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ScrollingDirection A")]
286         [Property("SPEC_URL", "-")]
287         [Property("CRITERIA", "PRW")]
288         [Property("COVPARAM", "")]
289         [Property("AUTHOR", "huayong.xu@samsung.com")]
290         public void CollectionViewScrollingDirection()
291         {
292             tlog.Debug(tag, $"CollectionViewScrollingDirection START");
293
294             var testingTarget = new CollectionView();
295
296             Assert.IsNotNull(testingTarget, "should be not null");
297             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
298
299             testingTarget.ScrollingDirection = ScrollableBase.Direction.Horizontal;
300             Assert.AreEqual(testingTarget.ScrollingDirection, ScrollableBase.Direction.Horizontal, "should be horizontal");
301
302             testingTarget.Dispose();
303             tlog.Debug(tag, $"CollectionViewScrollingDirection END (OK)");
304         }
305
306         [Test]
307         [Category("P1")]
308         [Description("CollectionView SelectedItem.")]
309         [Property("SPEC", "Tizen.NUI.Components.CollectionView.SelectedItem A")]
310         [Property("SPEC_URL", "-")]
311         [Property("CRITERIA", "PRW")]
312         [Property("COVPARAM", "")]
313         [Property("AUTHOR", "huayong.xu@samsung.com")]
314         public void CollectionViewSelectedItem()
315         {
316             tlog.Debug(tag, $"CollectionViewSelectedItem START");
317
318             var model = new TestModel();
319             var testingTarget = new CollectionView(model);
320
321             Assert.IsNotNull(testingTarget, "should be not null");
322             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
323
324             testingTarget.SelectedItem = "Cat";
325             Assert.AreEqual(testingTarget.SelectedItem, "Cat", "Some items should be selected");
326
327             testingTarget.Dispose();
328             tlog.Debug(tag, $"CollectionViewSelectedItem END (OK)");
329         }
330
331         [Test]
332         [Category("P1")]
333         [Description("CollectionView SelectedItems.")]
334         [Property("SPEC", "Tizen.NUI.Components.CollectionView.SelectedItems A")]
335         [Property("SPEC_URL", "-")]
336         [Property("CRITERIA", "PRW")]
337         [Property("COVPARAM", "")]
338         [Property("AUTHOR", "huayong.xu@samsung.com")]
339         public void CollectionViewSelectedItems()
340         {
341             tlog.Debug(tag, $"CollectionViewSelectedItems START");
342
343             var model = new TestModel();
344             var testingTarget = new CollectionView(model);
345
346             Assert.IsNotNull(testingTarget, "should be not null");
347             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
348
349             tlog.Debug(tag, "SelectedItems : " + testingTarget.SelectedItems);
350
351             testingTarget.Dispose();
352             tlog.Debug(tag, $"CollectionViewSelectedItems END (OK)");
353         }
354
355         [Test]
356         [Category("P1")]
357         [Description("CollectionView SelectionMode.")]
358         [Property("SPEC", "Tizen.NUI.Components.CollectionView.SelectionMode A")]
359         [Property("SPEC_URL", "-")]
360         [Property("CRITERIA", "PRW")]
361         [Property("COVPARAM", "")]
362         [Property("AUTHOR", "huayong.xu@samsung.com")]
363         public void CollectionViewSelectionMode()
364         {
365             tlog.Debug(tag, $"CollectionViewSelectionMode START");
366
367             var model = new TestModel();
368             var testingTarget = new CollectionView(model);
369
370             Assert.IsNotNull(testingTarget, "should be not null");
371             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
372
373             testingTarget.SelectionMode = ItemSelectionMode.None;
374             Assert.AreEqual(testingTarget.SelectionMode, ItemSelectionMode.None, "Selection mode is none.");
375
376             testingTarget.Dispose();
377             tlog.Debug(tag, $"CollectionViewSelectionMode END (OK)");
378         }
379
380         [Test]
381         [Category("P1")]
382         [Description("CollectionView SelectionChangedCommand.")]
383         [Property("SPEC", "Tizen.NUI.Components.CollectionView.SelectionChangedCommand A")]
384         [Property("SPEC_URL", "-")]
385         [Property("CRITERIA", "PRW")]
386         [Property("COVPARAM", "")]
387         [Property("AUTHOR", "huayong.xu@samsung.com")]
388         public void CollectionViewSelectionChangedCommand()
389         {
390             tlog.Debug(tag, $"CollectionViewSelectionChangedCommand START");
391
392             var model = new TestModel();
393             var testingTarget = new CollectionView(model);
394
395             Assert.IsNotNull(testingTarget, "should be not null");
396             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
397
398             testingTarget.SelectionChangedCommand = null;
399             Assert.IsNull(testingTarget.SelectionChangedCommand, "Selection change command is null.");
400
401             testingTarget.Dispose();
402             tlog.Debug(tag, $"CollectionViewSelectionChangedCommand END (OK)");
403         }
404
405         [Test]
406         [Category("P1")]
407         [Description("CollectionView SelectionChangedCommandParameter.")]
408         [Property("SPEC", "Tizen.NUI.Components.CollectionView.SelectionChangedCommandParameter A")]
409         [Property("SPEC_URL", "-")]
410         [Property("CRITERIA", "PRW")]
411         [Property("COVPARAM", "")]
412         [Property("AUTHOR", "huayong.xu@samsung.com")]
413         public void CollectionViewSelectionChangedCommandParameter()
414         {
415             tlog.Debug(tag, $"CollectionViewSelectionChangedCommandParameter START");
416
417             var model = new TestModel();
418             var testingTarget = new CollectionView(model);
419
420             Assert.IsNotNull(testingTarget, "should be not null");
421             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
422
423             testingTarget.SelectionChangedCommandParameter = null;
424             Assert.IsNull(testingTarget.SelectionChangedCommandParameter, "Selection change command parameter is null.");
425
426             testingTarget.Dispose();
427             tlog.Debug(tag, $"CollectionViewSelectionChangedCommandParameter END (OK)");
428         }
429
430         [Test]
431         [Category("P1")]
432         [Description("CollectionView Header.")]
433         [Property("SPEC", "Tizen.NUI.Components.CollectionView.Header A")]
434         [Property("SPEC_URL", "-")]
435         [Property("CRITERIA", "PRW")]
436         [Property("COVPARAM", "")]
437         [Property("AUTHOR", "huayong.xu@samsung.com")]
438         public void CollectionViewHeader()
439         {
440             tlog.Debug(tag, $"CollectionViewHeader START");
441
442             var model = new TestModel();
443             var testingTarget = new CollectionView(model);
444
445             Assert.IsNotNull(testingTarget, "should be not null");
446             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
447
448             DefaultTitleItem myTitle = new DefaultTitleItem();
449             myTitle.Text = "test";
450             testingTarget.Header = myTitle;
451             Assert.IsNotNull(testingTarget.Header, "should be header.");
452
453             testingTarget.Dispose();
454             tlog.Debug(tag, $"CollectionViewHeader END (OK)");
455         }
456
457         [Test]
458         [Category("P1")]
459         [Description("CollectionView Footer.")]
460         [Property("SPEC", "Tizen.NUI.Components.CollectionView.Footer A")]
461         [Property("SPEC_URL", "-")]
462         [Property("CRITERIA", "PRW")]
463         [Property("COVPARAM", "")]
464         [Property("AUTHOR", "huayong.xu@samsung.com")]
465         public void CollectionViewFooter()
466         {
467             tlog.Debug(tag, $"CollectionViewFooter START");
468
469             var model = new TestModel();
470             var testingTarget = new CollectionView(model);
471
472             Assert.IsNotNull(testingTarget, "should be not null");
473             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
474
475             DefaultTitleItem myTitle = new DefaultTitleItem();
476             myTitle.Text = "test";
477             testingTarget.Footer = myTitle;
478             Assert.IsNotNull(testingTarget.Footer, "should be footer.");
479
480             testingTarget.Dispose();
481             tlog.Debug(tag, $"CollectionViewFooter END (OK)");
482         }
483
484         [Test]
485         [Category("P1")]
486         [Description("CollectionView IsGrouped.")]
487         [Property("SPEC", "Tizen.NUI.Components.CollectionView.IsGrouped A")]
488         [Property("SPEC_URL", "-")]
489         [Property("CRITERIA", "PRW")]
490         [Property("COVPARAM", "")]
491         [Property("AUTHOR", "huayong.xu@samsung.com")]
492         public void CollectionViewIsGrouped()
493         {
494             tlog.Debug(tag, $"CollectionViewIsGrouped START");
495
496             var model = new TestModel();
497             var testingTarget = new CollectionView(model);
498
499             Assert.IsNotNull(testingTarget, "should be not null");
500             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
501
502             testingTarget.IsGrouped = true;
503             Assert.IsTrue(testingTarget.IsGrouped, "should be grouped.");
504
505             testingTarget.Dispose();
506             tlog.Debug(tag, $"CollectionViewIsGrouped END (OK)");
507         }
508
509         [Test]
510         [Category("P1")]
511         [Description("CollectionView GroupHeaderTemplate.")]
512         [Property("SPEC", "Tizen.NUI.Components.CollectionView.GroupHeaderTemplate A")]
513         [Property("SPEC_URL", "-")]
514         [Property("CRITERIA", "PRW")]
515         [Property("COVPARAM", "")]
516         [Property("AUTHOR", "huayong.xu@samsung.com")]
517         public void CollectionViewGroupHeaderTemplate()
518         {
519             tlog.Debug(tag, $"CollectionViewGroupHeaderTemplate START");
520
521             var model = new TestModel();
522             var testingTarget = new CollectionView(model);
523
524             Assert.IsNotNull(testingTarget, "should be not null");
525             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
526
527             testingTarget.GroupHeaderTemplate = testDataTemplate;
528             Assert.IsNotNull(testingTarget.GroupHeaderTemplate, "should not be null.");
529
530             testingTarget.Dispose();
531             tlog.Debug(tag, $"CollectionViewGroupHeaderTemplate END (OK)");
532         }
533
534         [Test]
535         [Category("P1")]
536         [Description("CollectionView GroupFooterTemplate.")]
537         [Property("SPEC", "Tizen.NUI.Components.CollectionView.GroupFooterTemplate A")]
538         [Property("SPEC_URL", "-")]
539         [Property("CRITERIA", "PRW")]
540         [Property("COVPARAM", "")]
541         [Property("AUTHOR", "huayong.xu@samsung.com")]
542         public void CollectionViewGroupFooterTemplate()
543         {
544             tlog.Debug(tag, $"CollectionViewGroupFooterTemplate START");
545
546             var model = new TestModel();
547             var testingTarget = new CollectionView(model);
548
549             Assert.IsNotNull(testingTarget, "should be not null");
550             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
551
552             testingTarget.GroupFooterTemplate = testDataTemplate;
553             Assert.IsNotNull(testingTarget.GroupFooterTemplate, "should not be null.");
554
555             testingTarget.Dispose();
556             tlog.Debug(tag, $"CollectionViewGroupFooterTemplate END (OK)");
557         }
558
559         [Test]
560         [Category("P1")]
561         [Description("CollectionView InternalItemSource.")]
562         [Property("SPEC", "Tizen.NUI.Components.CollectionView.InternalItemSource A")]
563         [Property("SPEC_URL", "-")]
564         [Property("CRITERIA", "PRW")]
565         [Property("COVPARAM", "")]
566         [Property("AUTHOR", "huayong.xu@samsung.com")]
567         public void CollectionViewInternalItemSource()
568         {
569             tlog.Debug(tag, $"CollectionViewInternalItemSource START");
570
571             var model = new TestModel();
572             var testingTarget = new CollectionView(model);
573
574             Assert.IsNotNull(testingTarget, "should be not null");
575             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
576
577             testingTarget.InternalItemSource = null;
578             Assert.IsNull(testingTarget.InternalItemSource, "should be null.");
579
580             testingTarget.Dispose();
581             tlog.Debug(tag, $"CollectionViewInternalItemSource END (OK)");
582         }
583
584         [Test]
585         [Category("P1")]
586         [Description("CollectionView SizingStrategy.")]
587         [Property("SPEC", "Tizen.NUI.Components.CollectionView.SizingStrategy A")]
588         [Property("SPEC_URL", "-")]
589         [Property("CRITERIA", "PRW")]
590         [Property("COVPARAM", "")]
591         [Property("AUTHOR", "huayong.xu@samsung.com")]
592         public void CollectionViewSizingStrategy()
593         {
594             tlog.Debug(tag, $"CollectionViewSizingStrategy START");
595
596             var model = new TestModel();
597             var testingTarget = new CollectionView(model);
598
599             Assert.IsNotNull(testingTarget, "should be not null");
600             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
601
602             testingTarget.SizingStrategy = ItemSizingStrategy.MeasureFirst;
603             Assert.AreEqual(testingTarget.SizingStrategy, ItemSizingStrategy.MeasureFirst, "should be equal.");
604
605             testingTarget.Dispose();
606             tlog.Debug(tag, $"CollectionViewSizingStrategy END (OK)");
607         }
608
609         [Test]
610         [Category("P1")]
611         [Description("CollectionView UpdateSelectedItems.")]
612         [Property("SPEC", "Tizen.NUI.Components.CollectionView.UpdateSelectedItems M")]
613         [Property("SPEC_URL", "-")]
614         [Property("CRITERIA", "MR")]
615         [Property("COVPARAM", "")]
616         [Property("AUTHOR", "huayong.xu@samsung.com")]
617         public void CollectionViewUpdateSelectedItems()
618         {
619             tlog.Debug(tag, $"CollectionViewUpdateSelectedItems START");
620
621             var model = new TestModel();
622             var testingTarget = new CollectionView(model);
623
624             Assert.IsNotNull(testingTarget, "should be not null");
625             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
626
627             try
628             {
629                 testingTarget.UpdateSelectedItems(null);
630             }
631             catch (ArgumentNullException)
632             {
633                 testingTarget.Dispose();
634                 tlog.Debug(tag, $"CollectionViewUpdateSelectedItems END (OK)");
635                 Assert.Pass("Caught ArgumentNullException :  Passed!");
636             }
637         }
638
639         [Test]
640         [Category("P1")]
641         [Description("CollectionView ScrollTo.")]
642         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ScrollTo M")]
643         [Property("SPEC_URL", "-")]
644         [Property("CRITERIA", "MR")]
645         [Property("COVPARAM", "")]
646         [Property("AUTHOR", "huayong.xu@samsung.com")]
647         public void CollectionViewUpdateScrollTo()
648         {
649             tlog.Debug(tag, $"CollectionViewUpdateScrollTo START");
650
651             var model = new TestModel();
652             var testingTarget = new CollectionView(model, new LinearLayouter(), testDataTemplate);
653             Assert.IsNotNull(testingTarget, "should be not null");
654             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
655
656             testingTarget.ScrollTo(123.0f, false);
657             tlog.Debug(tag, "SelectedItems : " + testingTarget.SelectedItems);
658
659             testingTarget.Dispose();
660             tlog.Debug(tag, $"CollectionViewUpdateScrollTo END (OK)");
661         }
662
663         [Test]
664         [Category("P1")]
665         [Description("CollectionView ScrollToIndex.")]
666         [Property("SPEC", "Tizen.NUI.Components.CollectionView.ScrollToIndex M")]
667         [Property("SPEC_URL", "-")]
668         [Property("CRITERIA", "MR")]
669         [Property("COVPARAM", "")]
670         [Property("AUTHOR", "huayong.xu@samsung.com")]
671         public void CollectionViewScrollToIndex()
672         {
673             tlog.Debug(tag, $"CollectionViewScrollToIndex START");
674
675             var model = new TestModel();
676             var testingTarget = new CollectionView(model, new LinearLayouter(), testDataTemplate);
677
678             Assert.IsNotNull(testingTarget, "should be not null");
679             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
680
681             testingTarget.ScrollToIndex(5);
682             tlog.Debug(tag, "SelectedItems : " + testingTarget.SelectedItems);
683
684             testingTarget.Dispose();
685             tlog.Debug(tag, $"CollectionViewScrollToIndex END (OK)");
686         }
687
688         [Test]
689         [Category("P1")]
690         [Description("CollectionView GetNextFocusableView.")]
691         [Property("SPEC", "Tizen.NUI.Components.CollectionView.GetNextFocusableView M")]
692         [Property("SPEC_URL", "-")]
693         [Property("CRITERIA", "MR")]
694         [Property("COVPARAM", "")]
695         [Property("AUTHOR", "huayong.xu@samsung.com")]
696         public async Task CollectionViewGetNextFocusableView()
697         {
698             tlog.Debug(tag, $"CollectionViewGetNextFocusableView START");
699
700             TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>(false);
701             EventHandler onAddedToWindow = (s, e) => { tcs.TrySetResult(true); };
702
703             var model = new TestModel();
704             var testingTarget = new CollectionView(model, new LinearLayouter(), testDataTemplate);
705             testingTarget.AddedToWindow += onAddedToWindow;
706             testingTarget.Size = new Size(100, 100);
707
708             Assert.IsNotNull(testingTarget, "should be not null");
709             Assert.IsInstanceOf<CollectionView>(testingTarget, "should be an instance of testing target class!");
710
711             Window.Instance.Add(testingTarget);
712             var result = await tcs.Task;
713             Assert.IsTrue(result, "Relayout event should be invoked");
714
715             testingTarget.GetNextFocusableView(null, View.FocusDirection.Down, false);
716             tlog.Debug(tag, "SelectedItems : " + testingTarget.SelectedItems);
717
718             if (testingTarget != null)
719             {
720                 Window.Instance.Remove(testingTarget);
721                 testingTarget.Dispose();
722                 testingTarget = null;
723             }
724             tlog.Debug(tag, $"CollectionViewGetNextFocusableView END (OK)");
725         }
726     }
727 }