コード例 #1
0
        public void RadioButtonTest()
        {
            string value    = null;
            string selected = null;

            var app = new RadioButtonApp(new RadioButtonAppProps
            {
                OnValueSet     = v => value = v,
                OnSelectionSet = v => selected = v,
                Items          = { "Foo", "Bar", "Gra", "Hoh" }
            });

            TestUIDriver driver = new TestUIDriver(app);

            driver.Press(Buttons.DPadRight);
            driver.Press(Buttons.A);

            value.Should().Be("Bar");
            selected.Should().Be("Bar");

            driver.Press(Buttons.DPadRight);

            value.Should().Be("Bar");
            selected.Should().Be("Gra");
        }
コード例 #2
0
ファイル: MenuTest.cs プロジェクト: eylvisaker/BallBusterX
        public void SkipDisabledMenuItems()
        {
            var menu = new Window(new WindowProps
            {
                Children =
                {
                    new Window(new WindowProps
                    {
                        Children =
                        {
                            new Button(new ButtonProps {
                                Text = "Hello"
                            }),
                            new Button(new ButtonProps {
                                Text = "Some"
                            }),
                            new Button(new ButtonProps {
                                Text = "Items", Enabled = false,
                            }),
                            new Button(new ButtonProps {
                                Text = "Are"
                            }),
                            new Button(new ButtonProps {
                                Text = "Disabled", Enabled = false
                            }),
                        }
                    }),
                    new Window(new WindowProps
                    {
                        Children =
                        {
                            new Button(new ButtonProps {
                                Text = "Testing if we"
                            }),
                            new Button(new ButtonProps {
                                Text = "Can navigate out"
                            }),
                            new Button(new ButtonProps {
                                Text = "of a menu who's last"
                            }),
                            new Button(new ButtonProps {
                                Text = "item is disabled."
                            }),
                        }
                    })
                }
            });

            TestUIDriver driver = new TestUIDriver(menu);

            driver.Press(Buttons.DPadDown);
            FocusItemHasText(driver, "Some");

            driver.Press(Buttons.DPadDown);
            FocusItemHasText(driver, "Are");

            driver.Press(Buttons.DPadDown);
            FocusItemHasText(driver, "Testing if we");
        }
コード例 #3
0
ファイル: MenuTest.cs プロジェクト: eylvisaker/BallBusterX
        public void DisabledMenuItemsWontTriggerOnAccept()
        {
            int disabledCount = 0;

            var menu = new Window(new WindowProps
            {
                Children =
                {
                    new MenuEnableToggleComponent(new MenuEnableToggleComponentProps
                    {
                        OnMenuItemDisabled = e =>
                        {
                            if (disabledCount > 0)
                            {
                                throw new InvalidOperationException("OnAccept triggered for disabled menu item.");
                            }

                            disabledCount++;
                        },
                    }),
                    new Window(new WindowProps
                    {
                        Children =
                        {
                            new Button(new ButtonProps {
                                Text = "Testing if we"
                            }),
                            new Button(new ButtonProps {
                                Text = "Can navigate out"
                            }),
                            new Button(new ButtonProps {
                                Text = "of a menu who's last"
                            }),
                            new Button(new ButtonProps {
                                Text = "item is disabled."
                            }),
                        }
                    })
                }
            });

            TestUIDriver driver = new TestUIDriver(menu);

            driver.Press(Buttons.A);
            driver.Press(Buttons.A);

            disabledCount.Should().Be(1, "menu item's onaccept should only be called once.");
        }
コード例 #4
0
        public void DoubleRadiosEnabledAfterSelectingBoth()
        {
            var app = new DoubleRadioMenusApp(new DoubleRadioMenusProps
            {
                LeftItems = new[]
                {
                    new ItemData {
                        Name = "Foo", Description = "Food is good for you."
                    },
                    new ItemData {
                        Name = "Bar", Description = "Bars serve drinks."
                    },
                    new ItemData {
                        Name = "Gra", Description = "Gra is a nonsense word."
                    },
                    new ItemData {
                        Name = "Hoh", Description = "Hoh is one letter short."
                    },
                },
                RightItems = new[]
                {
                    new ItemData {
                        Name = "MegaFoo", Description = "Food is good for you."
                    },
                    new ItemData {
                        Name = "MegaBar", Description = "Bars serve drinks."
                    },
                    new ItemData {
                        Name = "MegaGra", Description = "Gra is a nonsense word."
                    },
                    new ItemData {
                        Name = "MegaHoh", Description = "Hoh is one letter short."
                    },
                },
            });

            TestUIDriver driver = new TestUIDriver(app);

            driver.Press(Buttons.A);
            driver.Press(Buttons.DPadRight);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.A);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);

            app.SelectedLeft.Name.Should().Be("Foo");
            app.SelectedRight.Name.Should().Be("MegaGra");

            driver.Focus.Should().BeOfType(typeof(ButtonElement));
        }
コード例 #5
0
ファイル: MenuTest.cs プロジェクト: eylvisaker/BallBusterX
        public void MenuInputCancel()
        {
            bool canceled = false;

            var menu = new Window(new WindowProps
            {
                OnCancel = e => canceled = true,
                Children = { new Button(new ButtonProps {
                        Text = "Hello"
                    }) }
            });

            TestUIDriver driver = new TestUIDriver(menu);

            driver.Press(Buttons.B);

            canceled.Should().BeTrue("Menu did not exit when cancel was pressed.");
        }
コード例 #6
0
        public void DoubleRadiosAcceptDisabledByDefault()
        {
            var app = new DoubleRadioMenusApp(new DoubleRadioMenusProps
            {
                LeftItems = new[]
                {
                    new ItemData {
                        Name = "Foo", Description = "Food is good for you."
                    },
                    new ItemData {
                        Name = "Bar", Description = "Bars serve drinks."
                    },
                    new ItemData {
                        Name = "Gra", Description = "Gra is a nonsense word."
                    },
                    new ItemData {
                        Name = "Hoh", Description = "Hoh is one letter short."
                    },
                },
                RightItems = new[]
                {
                    new ItemData {
                        Name = "MegaFoo", Description = "Food is good for you."
                    },
                    new ItemData {
                        Name = "MegaBar", Description = "Bars serve drinks."
                    },
                    new ItemData {
                        Name = "MegaGra", Description = "Gra is a nonsense word."
                    },
                    new ItemData {
                        Name = "MegaHoh", Description = "Hoh is one letter short."
                    },
                },
            });

            TestUIDriver driver = new TestUIDriver(app);

            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);

            // This
            driver.Focus.Should().BeOfType(typeof(RadioButtonElement), "we shouldn't have gotten to the accept button.");
        }
コード例 #7
0
        public void DoubleRadiosDownAndBackUp()
        {
            ItemData selectedLeft  = null;
            ItemData selectedRight = null;
            bool     acceptFired   = false;

            var app = new DoubleRadioMenusApp(new DoubleRadioMenusProps
            {
                LeftItems = new[]
                {
                    new ItemData {
                        Name = "Foo", Description = "Food is good for you."
                    },
                    new ItemData {
                        Name = "Bar", Description = "Bars serve drinks."
                    },
                    new ItemData {
                        Name = "Gra", Description = "Gra is a nonsense word."
                    },
                    new ItemData {
                        Name = "Hoh", Description = "Hoh is one letter short."
                    },
                },
                RightItems = new[]
                {
                    new ItemData {
                        Name = "MegaFoo", Description = "Food is good for you."
                    },
                    new ItemData {
                        Name = "MegaBar", Description = "Bars serve drinks."
                    },
                    new ItemData {
                        Name = "MegaGra", Description = "Gra is a nonsense word."
                    },
                    new ItemData {
                        Name = "MegaHoh", Description = "Hoh is one letter short."
                    },
                },
                OnAccept = (left, right) =>
                {
                    acceptFired   = true;
                    selectedLeft  = left;
                    selectedRight = right;
                }
            });

            TestUIDriver driver = new TestUIDriver(app);

            driver.Press(Buttons.DPadRight);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.A);
            driver.Press(Buttons.DPadLeft);
            driver.Press(Buttons.A);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadDown);
            driver.Press(Buttons.DPadUp);
            driver.Press(Buttons.A);

            acceptFired.Should().BeFalse("accept event was not fired.");

            app.SelectedLeft.Name.Should().Be("Hoh");
            app.SelectedRight.Name.Should().Be("MegaGra");
        }