Esempio n. 1
0
        public void OnSelectionChangedOverrideTest()
        {
            TestTabControl tabControl = new TestTabControl();

            Assert.AreEqual(tabControl.TestString, null);
            Assert.AreEqual(tabControl.SelectedIndex, -1);

            CreateAsyncTask(tabControl,
                            () => tabControl.Items.Add(new TabItem()),
                            () => Assert.AreEqual(tabControl.TestString, "SelectionChanged")
                            );

            EnqueueTestComplete();
        }
        public TestSceneChannelTabControl()
        {
            SpriteText currentText;

            Add(new Container
            {
                RelativeSizeAxes = Axes.X,
                Origin           = Anchor.Centre,
                Anchor           = Anchor.Centre,
                Children         = new Drawable[]
                {
                    channelTabControl = new TestTabControl
                    {
                        RelativeSizeAxes = Axes.X,
                        Origin           = Anchor.Centre,
                        Anchor           = Anchor.Centre,
                        Height           = 50
                    },
                    new Box
                    {
                        Colour           = Color4.Black.Opacity(0.1f),
                        RelativeSizeAxes = Axes.X,
                        Height           = 50,
                        Depth            = -1,
                        Origin           = Anchor.Centre,
                        Anchor           = Anchor.Centre,
                    }
                }
            });

            Add(new Container
            {
                Origin   = Anchor.TopLeft,
                Anchor   = Anchor.TopLeft,
                Children = new Drawable[]
                {
                    currentText = new OsuSpriteText
                    {
                        Text = "Currently selected channel:"
                    }
                }
            });

            channelTabControl.OnRequestLeave       += channel => channelTabControl.RemoveChannel(channel);
            channelTabControl.Current.ValueChanged += channel => currentText.Text = "Currently selected channel: " + channel.NewValue;

            AddStep("Add random private channel", addRandomPrivateChannel);
            AddAssert("There is only one channels", () => channelTabControl.Items.Count == 2);
            AddRepeatStep("Add 3 random private channels", addRandomPrivateChannel, 3);
            AddAssert("There are four channels", () => channelTabControl.Items.Count == 5);
            AddStep("Add random public channel", () => addChannel(RNG.Next().ToString()));

            AddRepeatStep("Select a random channel", () =>
            {
                List <Channel> validChannels = channelTabControl.Items.Where(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel)).ToList();
                channelTabControl.SelectChannel(validChannels[RNG.Next(0, validChannels.Count)]);
            }, 20);

            Channel channelBefore = null;

            AddStep("set first channel", () => channelTabControl.SelectChannel(channelBefore = channelTabControl.Items.First(c => !(c is ChannelSelectorTabItem.ChannelSelectorTabChannel))));

            AddStep("select selector tab", () => channelTabControl.SelectChannel(channelTabControl.Items.Single(c => c is ChannelSelectorTabItem.ChannelSelectorTabChannel)));
            AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);

            AddAssert("check channel unchanged", () => channelBefore == channelTabControl.Current.Value);

            AddStep("set second channel", () => channelTabControl.SelectChannel(channelTabControl.Items.GetNext(channelBefore)));
            AddAssert("selector tab is inactive", () => !channelTabControl.ChannelSelectorActive.Value);

            AddUntilStep("remove all channels", () =>
            {
                foreach (var item in channelTabControl.Items.ToList())
                {
                    if (item is ChannelSelectorTabItem.ChannelSelectorTabChannel)
                    {
                        continue;
                    }

                    channelTabControl.RemoveChannel(item);
                    return(false);
                }

                return(true);
            });

            AddAssert("selector tab is active", () => channelTabControl.ChannelSelectorActive.Value);
        }
Esempio n. 3
0
        public void OnSelectionChangedOverrideTest()
        {
            TestTabControl tabControl = new TestTabControl();
            Assert.AreEqual(tabControl.TestString, null);
            Assert.AreEqual(tabControl.SelectedIndex, -1);

            CreateAsyncTask(tabControl,
                () => tabControl.Items.Add(new TabItem()),
                () => Assert.AreEqual(tabControl.TestString, "SelectionChanged")
            );

            EnqueueTestComplete();
        }