Exemplo n.º 1
0
        public void WhenConfirmed_ShouldClearTheList([ValueSource(nameof(WorkingOptionSet))]
                                                     ListOptions options, [Values(TestHelpers.CmdType.Click, TestHelpers.CmdType.Program)]
                                                     TestHelpers.CmdType cmdType)
        {
            listElement = new ListElement(Property, options);

            WindowFixture.RootElement.AddAndRemove(listElement, () =>
            {
                if (cmdType == TestHelpers.CmdType.Click)
                {
                    ClearButton.SendEvent(new ClickEvent {
                        target = ClearButton
                    });
                    Yes.SendEvent(new ClickEvent {
                        target = Yes
                    });
                }
                else
                {
                    listElement.ClearListItems();
                }

                listElement.SendEvent(new ListResetEvent {
                    target = listElement
                });
                Assert.AreEqual(0, listElement.Count);
                Assert.AreEqual(0, listElement.Controls.ItemsSection.childCount);
            });
        }
Exemplo n.º 2
0
        public void WhenDisabled_ShouldNotWork()
        {
            SerializedProperty property = Property;

            listElement = new ListElement(property, new ListOptions {
                EnableAdditions = false
            });
            WindowFixture.RootElement.AddAndRemove(listElement, () =>
            {
                int initialSize = property.arraySize;
                listElement.AddNewItemToList();
                listElement.SendEvent(new ListResetEvent {
                    target = listElement
                });
                Assert.AreEqual(initialSize, listElement.Controls.ItemsSection.childCount);
            });
        }
Exemplo n.º 3
0
        public void ShouldNotClearListWhenDisabled()
        {
            SerializedProperty property = Property;

            listElement = new ListElement(Property, new ListOptions {
                EnableDeletions = false
            });
            WindowFixture.RootElement.AddAndRemove(listElement, () =>
            {
                int initialSize = property.arraySize;
                listElement.ClearListItems();
                listElement.SendEvent(new ListResetEvent {
                    target = listElement
                });
                Assert.AreEqual(initialSize, property.arraySize);
            });
        }
Exemplo n.º 4
0
        public void WhenListEmpty_ShouldDisableButton([ValueSource(nameof(WorkingOptionSet))]
                                                      ListOptions options)
        {
            listElement = new ListElement(Property, options);
            WindowFixture.RootElement.AddAndRemove(listElement, () =>
            {
                if (!ClearButton.enabledSelf)
                {
                    Assert.Fail("ClearList button should initially be enabled with items on list");
                }

                listElement.ClearListItems();
                listElement.SendEvent(new ListResetEvent {
                    target = listElement
                });
                Assert.IsFalse(ClearButton.enabledSelf);
            });
        }
Exemplo n.º 5
0
        public void ShouldAddItemToList([ValueSource(nameof(WorkingOptionSet))]
                                        ListOptions options, [Values(TestHelpers.CmdType.Click, TestHelpers.CmdType.Program)]
                                        TestHelpers.CmdType cmdType)
        {
            SerializedProperty property = Property;

            listElement = new ListElement(property, options);
            WindowFixture.RootElement.AddAndRemove(listElement, () =>
            {
                int initialSize = property.arraySize;
                Add.SendEvent(new ClickEvent {
                    target = Add
                });
                listElement.SendEvent(new ListResetEvent {
                    target = listElement
                });
                Assert.AreEqual(initialSize + 1, listElement.Controls.ItemsSection.childCount);
            });
        }
Exemplo n.º 6
0
 public void WhenCancelled_ShouldNotClearList([ValueSource(nameof(WorkingOptionSet))]
                                              ListOptions options)
 {
     listElement = new ListElement(Property, options);
     WindowFixture.RootElement.AddAndRemove(listElement, () =>
     {
         int initialSize = listElement.Count;
         ClearButton.SendEvent(new ClickEvent {
             target = ClearButton
         });
         No.SendEvent(new ClickEvent {
             target = No
         });
         listElement.SendEvent(new ListResetEvent {
             target = listElement
         });
         Assert.AreEqual(initialSize, listElement.Count);
         Assert.AreEqual(initialSize, listElement.Controls.ItemsSection.childCount);
     });
 }
        public static void PopulateList(ListElement listElement)
        {
            Controls           controls     = listElement.Controls;
            SerializedProperty property     = listElement.SerializedProperty;
            IRowGenerator      rowGenerator = listElement.RowGenerator;

            controls.ItemsSection.Clear();

            for (int i = 0; i < property.arraySize; i++)
            {
                controls.ItemsSection.Add(rowGenerator.NewRow(i, property));
                listElement.SendEvent(new RowInsertedEvent
                {
                    target        = listElement,
                    Buttons       = controls.Row[i],
                    PropertyField = controls.Row[i].PropertyField,
                    Index         = i,
                    ListLength    = property.arraySize
                });
            }
        }
Exemplo n.º 8
0
        public IEnumerator ShouldRegisterAllCallbacks()
        {
            ListElement element = new ListElement(true);

            WindowFixture.Window.rootVisualElement.Add(element);

            TestEventHandler handler = new TestEventHandler();

            ListElementEventHandler.RegisterCallbacks(element, handler);

            element.SendEvent(new ClearListRequestedEvent {
                target = element
            });
            element.SendEvent(new ClearListEvent {
                target = element
            });
            element.SendEvent(new ClearListCancelledEvent {
                target = element
            });
            element.SendEvent(new MoveItemEvent {
                target = element
            });
            element.SendEvent(new RemoveItemEvent {
                target = element
            });
            element.SendEvent(new AddItemEvent {
                target = element
            });
            element.SendEvent(new ClickEvent {
                target = element
            });
            element.SendEvent(new ChangeEvent <Object> {
                target = element
            });
            element.SendEvent(new ChangeEvent <int> {
                target = element
            });
            element.SendEvent(new RowInsertedEvent {
                target = element
            });
            element.SendEvent(new ListResetEvent {
                target = element
            });
            element.SendEvent(new AttachToPanelEvent {
                target = element
            });

            yield return(null);

            WindowFixture.Window.rootVisualElement.Remove(element);

            Assert.IsEmpty(handler.EventNames);
        }