Beispiel #1
0
        public void TestDisabledBindable()
        {
            Bindable <TestEnum?> bindable;

            AddStep("add tabcontrol", () =>
            {
                bindable = new Bindable <TestEnum?> {
                    Value = TestEnum.Test2
                };

                simpleTabcontrol = new StyledTabControl
                {
                    Size = new Vector2(200, 30)
                };

                foreach (var item in items)
                {
                    simpleTabcontrol.AddItem(item);
                }

                bindable.Disabled        = true;
                simpleTabcontrol.Current = bindable;

                Child = simpleTabcontrol;
            });

            AddAssert("test2 selected", () => simpleTabcontrol.SelectedTab.Value == TestEnum.Test2);

            // Todo: Should not fail
            // AddStep("click a tab", () => simpleTabcontrol.TabMap[TestEnum.Test0].Click());
        }
        public void TestTabSelectedWhenDisabledBindableIsBound()
        {
            Bindable <TestEnum?> bindable;

            AddStep("add tabcontrol", () =>
            {
                bindable = new Bindable <TestEnum?> {
                    Value = TestEnum.Test2
                };

                simpleTabcontrol = new StyledTabControl
                {
                    Size = new Vector2(200, 30)
                };

                foreach (var item in items)
                {
                    simpleTabcontrol.AddItem(item);
                }

                bindable.Disabled        = true;
                simpleTabcontrol.Current = bindable;

                Child = simpleTabcontrol;
            });

            AddAssert("test2 selected", () => simpleTabcontrol.SelectedTab.Value == TestEnum.Test2);
        }
Beispiel #3
0
        public void Setup() => Schedule(() =>
        {
            Clear();

            Add(new FillFlowContainer
            {
                RelativeSizeAxes = Axes.Both,
                Direction        = FillDirection.Full,
                Spacing          = new Vector2(50),
                Children         = new Drawable[]
                {
                    simpleTabcontrol = new StyledTabControl
                    {
                        Size = new Vector2(200, 30),
                    },
                    multilineTabControl = new StyledMultilineTabControl
                    {
                        Size = new Vector2(200, 60),
                    },
                    pinnedAndAutoSort = new StyledTabControl
                    {
                        Size     = new Vector2(200, 30),
                        AutoSort = true
                    },
                    platformActionContainer = new PlatformActionContainer
                    {
                        RelativeSizeAxes = Axes.None,
                        Size             = new Vector2(200, 30),
                        Child            = switchingTabControl = new StyledTabControl
                        {
                            RelativeSizeAxes = Axes.Both,
                            IsSwitchable     = true,
                        }
                    },
                    removeAllTabControl = new StyledTabControl
                    {
                        Size = new Vector2(200, 30)
                    },
                    withoutDropdownTabControl = new StyledTabControlWithoutDropdown
                    {
                        Size = new Vector2(200, 30)
                    },
                }
            });

            foreach (var item in items)
            {
                simpleTabcontrol.AddItem(item);
                multilineTabControl.AddItem(item);
                switchingTabControl.AddItem(item);
                withoutDropdownTabControl.AddItem(item);
            }

            items.Take(7).ForEach(item => pinnedAndAutoSort.AddItem(item));
            pinnedAndAutoSort.PinItem(TestEnum.Test5);
        });
Beispiel #4
0
        public TestSceneTabControl()
        {
            items = ((TestEnum[])Enum.GetValues(typeof(TestEnum))).AsEnumerable();

            Add(new FillFlowContainer
            {
                RelativeSizeAxes = Axes.Both,
                Direction = FillDirection.Full,
                Spacing = new Vector2(50),
                Children = new Drawable[]
                {
                    simpleTabcontrol = new StyledTabControl
                    {
                        Size = new Vector2(200, 30),
                    },
                    multilineTabControl = new StyledMultilineTabControl
                    {
                        Size = new Vector2(200, 60),
                    },
                    pinnedAndAutoSort = new StyledTabControl
                    {
                        Size = new Vector2(200, 30),
                        AutoSort = true
                    },
                    platformActionContainer = new PlatformActionContainer
                    {
                        RelativeSizeAxes = Axes.None,
                        Size = new Vector2(200, 30),
                        Child = switchingTabControl = new StyledTabControl
                        {
                            RelativeSizeAxes = Axes.Both
                        }
                    },
                    removeAllTabControl = new StyledTabControl
                    {
                        Size = new Vector2(200, 30)
                    },
                    withoutDropdownTabControl = new StyledTabControlWithoutDropdown
                    {
                        Size = new Vector2(200, 30)
                    },
                }
            });

            foreach (var item in items)
            {
                simpleTabcontrol.AddItem(item);
                multilineTabControl.AddItem(item);
                switchingTabControl.AddItem(item);
                withoutDropdownTabControl.AddItem(item);
            }

            items.Take(7).ForEach(item => pinnedAndAutoSort.AddItem(item));
            pinnedAndAutoSort.PinItem(TestEnum.Test5);
        }
        public void TestInitialSelection(bool selectFirstByDefault, TestEnum?expectedInitialSelection)
        {
            StyledTabControl tabControl = null;

            AddStep("create tab control", () =>
            {
                tabControlContainer.Add(tabControl = new StyledTabControl
                {
                    Size  = new Vector2(200, 30),
                    Items = items.Cast <TestEnum?>().ToList(),
                    SelectFirstTabByDefault = selectFirstByDefault
                });
            });

            AddUntilStep("wait for loaded", () => tabControl.IsLoaded);
            AddAssert("initial selection is correct", () => tabControl.Current.Value == expectedInitialSelection);
        }
Beispiel #6
0
        public override void Reset()
        {
            base.Reset();

            List <KeyValuePair <string, TestEnum> > items = new List <KeyValuePair <string, TestEnum> >();

            foreach (var val in (TestEnum[])Enum.GetValues(typeof(TestEnum)))
            {
                items.Add(new KeyValuePair <string, TestEnum>(val.GetDescription(), val));
            }

            StyledTabControl simpleTabcontrol = new StyledTabControl
            {
                Position = new Vector2(200, 50),
                Size     = new Vector2(200, 30),
            };

            items.AsEnumerable().ForEach(item => simpleTabcontrol.AddItem(item.Value));

            StyledTabControl pinnedAndAutoSort = new StyledTabControl
            {
                Position = new Vector2(500, 50),
                Size     = new Vector2(200, 30),
                AutoSort = true
            };

            items.GetRange(0, 7).AsEnumerable().ForEach(item => pinnedAndAutoSort.AddItem(item.Value));
            pinnedAndAutoSort.PinItem(TestEnum.Test5);

            Add(simpleTabcontrol);
            Add(pinnedAndAutoSort);

            var nextTest = new Func <TestEnum>(() => items.AsEnumerable()
                                               .Select(item => item.Value)
                                               .FirstOrDefault(test => !pinnedAndAutoSort.Items.Contains(test)));

            AddStep("AddItem", () => pinnedAndAutoSort.AddItem(nextTest.Invoke()));
            AddStep("PinItem", () =>
            {
                var test = nextTest.Invoke();
                pinnedAndAutoSort.AddItem(test);
                pinnedAndAutoSort.PinItem(test);
            });
            AddStep("UnpinItem", () => pinnedAndAutoSort.UnpinItem(pinnedAndAutoSort.Items.First()));
        }
Beispiel #7
0
        public void TestInitialSort(bool autoSort, TestEnum?initialItem, bool expected)
        {
            StyledTabControl     tabControlWithBindable = null;
            Bindable <TestEnum?> testBindable           = new Bindable <TestEnum?> {
                Value = initialItem
            };

            AddStep("create tab control", () =>
            {
                tabControlContainer.Add(tabControlWithBindable = new StyledTabControl
                {
                    Size     = new Vector2(200, 20),
                    Items    = items.Cast <TestEnum?>().ToList(),
                    AutoSort = autoSort,
                    Current  = { BindTarget = testBindable }
                });
            });

            AddUntilStep("wait for loaded", () => tabControlWithBindable.IsLoaded);
            AddAssert($"Current selection {(expected ? "visible" : "not visible")}", () => tabControlWithBindable.SelectedTab.IsPresent == expected);
        }
        public void TestClicksBlockedWhenBindableDisabled()
        {
            AddStep("add tabcontrol", () =>
            {
                Child = simpleTabcontrol = new StyledTabControl {
                    Size = new Vector2(200, 30)
                };

                foreach (var item in items)
                {
                    simpleTabcontrol.AddItem(item);
                }

                simpleTabcontrol.Current = new Bindable <TestEnum?>
                {
                    Value    = TestEnum.Test0,
                    Disabled = true
                };
            });

            AddStep("click a tab", () => simpleTabcontrol.TabMap[TestEnum.Test2].Click());
            AddAssert("test0 still selected", () => simpleTabcontrol.SelectedTab.Value == TestEnum.Test0);
        }
        public TestCaseTabControl()
        {
            List <KeyValuePair <string, TestEnum> > items = new List <KeyValuePair <string, TestEnum> >();

            foreach (var val in (TestEnum[])Enum.GetValues(typeof(TestEnum)))
            {
                items.Add(new KeyValuePair <string, TestEnum>(val.GetDescription(), val));
            }

            StyledTabControl simpleTabcontrol = new StyledTabControl
            {
                Position = new Vector2(200, 50),
                Size     = new Vector2(200, 30),
            };

            items.AsEnumerable().ForEach(item => simpleTabcontrol.AddItem(item.Value));

            StyledTabControl pinnedAndAutoSort = new StyledTabControl
            {
                Position = new Vector2(200, 150),
                Size     = new Vector2(200, 30),
                AutoSort = true
            };

            items.GetRange(0, 7).AsEnumerable().ForEach(item => pinnedAndAutoSort.AddItem(item.Value));
            pinnedAndAutoSort.PinItem(TestEnum.Test5);

            StyledTabControl        switchingTabControl;
            PlatformActionContainer platformActionContainer = new PlatformActionContainer
            {
                Child = switchingTabControl = new StyledTabControl
                {
                    Position = new Vector2(200, 250),
                    Size     = new Vector2(200, 30),
                }
            };

            items.AsEnumerable().ForEach(item => switchingTabControl.AddItem(item.Value));

            StyledTabControl removeAllTabControl = new StyledTabControl
            {
                Position = new Vector2(200, 350),
                Size     = new Vector2(200, 30)
            };

            var withoutDropdownTabControl = new StyledTabControlWithoutDropdown
            {
                Position = new Vector2(200, 450),
                Size     = new Vector2(200, 30)
            };

            items.AsEnumerable().ForEach(item => withoutDropdownTabControl.AddItem(item.Value));

            Add(simpleTabcontrol);
            Add(pinnedAndAutoSort);
            Add(platformActionContainer);
            Add(removeAllTabControl);
            Add(withoutDropdownTabControl);

            var nextTest = new Func <TestEnum>(() => items.AsEnumerable()
                                               .Select(item => item.Value)
                                               .FirstOrDefault(test => !pinnedAndAutoSort.Items.Contains(test)));

            Stack <TestEnum> pinned = new Stack <TestEnum>();

            AddStep("AddItem", () =>
            {
                var item = nextTest.Invoke();
                if (!pinnedAndAutoSort.Items.Contains(item))
                {
                    pinnedAndAutoSort.AddItem(item);
                }
            });

            AddStep("RemoveItem", () =>
            {
                if (pinnedAndAutoSort.Items.Any())
                {
                    pinnedAndAutoSort.RemoveItem(pinnedAndAutoSort.Items.First());
                }
            });

            AddStep("PinItem", () =>
            {
                var item = nextTest.Invoke();

                if (!pinnedAndAutoSort.Items.Contains(item))
                {
                    pinned.Push(item);
                    pinnedAndAutoSort.AddItem(item);
                    pinnedAndAutoSort.PinItem(item);
                }
            });

            AddStep("UnpinItem", () =>
            {
                if (pinned.Count > 0)
                {
                    pinnedAndAutoSort.UnpinItem(pinned.Pop());
                }
            });

            AddStep("Set first tab", () => switchingTabControl.Current.Value = switchingTabControl.VisibleItems.First());
            AddStep("Switch forward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentNext)));
            AddAssert("Ensure second tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.ElementAt(1));

            AddStep("Switch backward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentPrevious)));
            AddAssert("Ensure first Tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.First());

            AddStep("Switch backward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentPrevious)));
            AddAssert("Ensure last tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.Last());

            AddStep("Switch forward", () => platformActionContainer.TriggerPressed(new PlatformAction(PlatformActionType.DocumentNext)));
            AddAssert("Ensure first tab", () => switchingTabControl.Current.Value == switchingTabControl.VisibleItems.First());

            AddStep("Add all items", () => items.AsEnumerable().ForEach(item => removeAllTabControl.AddItem(item.Value)));
            AddAssert("Ensure all items", () => removeAllTabControl.Items.Count() == items.Count);

            AddStep("Remove all items", () => removeAllTabControl.Clear());
            AddAssert("Ensure no items", () => !removeAllTabControl.Items.Any());

            AddAssert("Ensure any items", () => withoutDropdownTabControl.Items.Any());
            AddStep("Remove all items", () => withoutDropdownTabControl.Clear());
            AddAssert("Ensure no items", () => !withoutDropdownTabControl.Items.Any());
        }