Esempio n. 1
0
        public void ValidateClear()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = new ObservableCollection <int>(Enumerable.Range(0, 10));
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(3);
                selectionModel.Select(4);
                selectionModel.Select(5);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4),
                    Path(5),
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                data.Clear();
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Esempio n. 2
0
        public void ValidateGroupRemoves()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                selectionModel.Select(1, 2);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1),
                    Path(1, 2)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1),
                });

                Log.Comment("Remove before selected range: Removing item at group index 0");
                data.RemoveAt(0);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(0, 1),
                    Path(0, 2)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(0),
                });

                Log.Comment("Remove after selected range: Removing item at group index 1");
                data.RemoveAt(1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(0, 1),
                    Path(0, 2)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(0),
                });

                Log.Comment("Remove group containing selected items");
                data.RemoveAt(0);
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Esempio n. 3
0
 private void Select(SelectionModel manager, int groupIndex, int itemIndex, bool select)
 {
     Log.Comment((select ? "Selecting " : "DeSelecting ") + groupIndex + "." + itemIndex);
     if (select)
     {
         manager.Select(groupIndex, itemIndex);
     }
     else
     {
         manager.Deselect(groupIndex, itemIndex);
     }
 }
Esempio n. 4
0
        //[TestMethod]
        //public void CanReadSelectedItemViaICustomPropertyProvider()
        //{
        //    RunOnUIThread.Execute(() =>
        //    {
        //        var selectionModel = new SelectionModel();
        //        Log.Comment("Set the source to 10 items");
        //        selectionModel.Source = Enumerable.Range(0, 10).ToList();

        //        selectionModel.Select(3);

        //        var icpp = (ICustomPropertyProvider)selectionModel;
        //        var selectedItemProperty = icpp.GetCustomProperty("SelectedItem");
        //        Verify.IsTrue(selectedItemProperty.CanRead);
        //        Verify.AreEqual(3, selectedItemProperty.GetValue(selectionModel));
        //    });
        //}

        private void Select(SelectionModel manager, int index, bool select)
        {
            Log.Comment((select ? "Selecting " : "DeSelecting ") + index);
            if (select)
            {
                manager.Select(index);
            }
            else
            {
                manager.Deselect(index);
            }
        }
Esempio n. 5
0
        public void ValidateGroupInserts()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1),
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1),
                });

                Log.Comment("Insert before selected range: Inserting item at group index 0");
                data.Insert(0, 100);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(2, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(2),
                });

                Log.Comment("Insert after selected range: Inserting item at group index 3");
                data.Insert(3, 1000);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(2, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(2),
                });
            });
        }
Esempio n. 6
0
        public void ValidateGroupClear()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1)
                });

                (data[1] as IList).Clear();
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Esempio n. 7
0
        public void ValidateGroupReplaceLosesSelection()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(1, 1);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1)
                });

                data[1] = new ObservableCollection <int>(Enumerable.Range(0, 5));
                ValidateSelection(selectionModel, new List <IndexPath>());
            });
        }
Esempio n. 8
0
        public void ValidateEventWhenInnerNodeChangesSelectionState()
        {
            RunOnUIThread.Execute(() =>
            {
                bool selectionChangedRaised = false;
                var data                         = CreateNestedData(1 /* levels */, 3 /* groupsAtLevel */, 3 /* countAtLeaf */);
                var selectionModel               = new SelectionModel();
                selectionModel.Source            = data;
                selectionModel.SelectionChanged += (sender, args) => { selectionChangedRaised = true; };

                selectionModel.Select(1, 0);
                selectionModel.Select(1, 1);
                selectionModel.Select(1, 2);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 0),
                    Path(1, 1),
                    Path(1, 2),
                    Path(1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                },
                                  1 /* selectedInnerNodes */);

                Log.Comment("Inserting 1.0");
                selectionChangedRaised = false;
                (data[1] as ObservableCollection <object>).Insert(0, 100);
                Verify.IsTrue(selectionChangedRaised, "SelectionChanged event was not raised");
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 1),
                    Path(1, 2),
                    Path(1, 3),
                },
                                  new List <IndexPath>()
                {
                    Path(),
                    Path(1),
                });

                Log.Comment("Removing 1.0");
                selectionChangedRaised = false;
                (data[1] as ObservableCollection <object>).RemoveAt(0);
                Verify.IsTrue(selectionChangedRaised, "SelectionChanged event was not raised");
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(1, 0),
                    Path(1, 1),
                    Path(1, 2),
                    Path(1)
                },
                                  new List <IndexPath>()
                {
                    Path(),
                },
                                  1 /* selectedInnerNodes */);
            });
        }
Esempio n. 9
0
        public void ValidateRemoves()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = new ObservableCollection <int>(Enumerable.Range(0, 10));
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(6);
                selectionModel.Select(7);
                selectionModel.Select(8);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(6),
                    Path(7),
                    Path(8)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Remove before selected range: Removing item at index 0");
                data.RemoveAt(0);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(5),
                    Path(6),
                    Path(7)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Remove from before to middle of selected range: Removing items at index 3, 4, 5");
                data.RemoveAt(3);
                data.RemoveAt(3);
                data.RemoveAt(3);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Remove after selected range: Removing item at index 5");
                data.RemoveAt(5);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4)
                },
                                  new List <IndexPath>()
                {
                    Path()
                });
            });
        }
Esempio n. 10
0
        public void ValidateInserts()
        {
            RunOnUIThread.Execute(() =>
            {
                var data              = new ObservableCollection <int>(Enumerable.Range(0, 10));
                var selectionModel    = new SelectionModel();
                selectionModel.Source = data;

                selectionModel.Select(3);
                selectionModel.Select(4);
                selectionModel.Select(5);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(4),
                    Path(5),
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Insert in selected range: Inserting 3 items at index 4");
                data.Insert(4, 41);
                data.Insert(4, 42);
                data.Insert(4, 43);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(3),
                    Path(7),
                    Path(8),
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Insert before selected range: Inserting 3 items at index 0");
                data.Insert(0, 100);
                data.Insert(0, 101);
                data.Insert(0, 102);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(6),
                    Path(10),
                    Path(11),
                },
                                  new List <IndexPath>()
                {
                    Path()
                });

                Log.Comment("Insert after selected range: Inserting 3 items at index 12");
                data.Insert(12, 1000);
                data.Insert(12, 1001);
                data.Insert(12, 1002);
                ValidateSelection(selectionModel,
                                  new List <IndexPath>()
                {
                    Path(6),
                    Path(10),
                    Path(11),
                },
                                  new List <IndexPath>()
                {
                    Path()
                });
            });
        }