public void TestRestoreDefaultValueButtonVisibility() { SettingsTextBox textBox = null; RestoreDefaultValueButton <string> restoreDefaultValueButton = null; AddStep("create settings item", () => { Child = textBox = new SettingsTextBox { Current = new Bindable <string> { Default = "test", Value = "test" } }; }); AddUntilStep("wait for loaded", () => textBox.IsLoaded); AddStep("retrieve restore default button", () => restoreDefaultValueButton = textBox.ChildrenOfType <RestoreDefaultValueButton <string> >().Single()); AddAssert("restore button hidden", () => restoreDefaultValueButton.Alpha == 0); AddStep("change value from default", () => textBox.Current.Value = "non-default"); AddUntilStep("restore button shown", () => restoreDefaultValueButton.Alpha > 0); AddStep("restore default", () => textBox.Current.SetDefault()); AddUntilStep("restore button hidden", () => restoreDefaultValueButton.Alpha == 0); }
private void PopulateSettingsBox() { SettingsLayoutPanel.Controls.Clear(); SettingsLayoutPanel.FlowDirection = FlowDirection.TopDown; foreach (var Setting in SettingsData.GetType().GetProperties()) { SettingsTextBox Box = new SettingsTextBox(); var Tooltip = Setting.GetValue(SettingsData); Box.SettingsLabel.Text = Tooltip.GetType().GetProperty("Description").GetValue(Tooltip).ToString(); Box.SettingsBox.Name = Setting.Name; Box.SettingsBox.Text = Tooltip.GetType().GetProperty("Value").GetValue(Tooltip).ToString(); SettingsLayoutPanel.Controls.Add(Box); } }
public void TestSetAndClearLabelText() { SettingsTextBox textBox = null; RestoreDefaultValueButton <string> restoreDefaultValueButton = null; OsuTextBox control = null; AddStep("create settings item", () => { Child = textBox = new SettingsTextBox { Current = new Bindable <string> { Default = "test", Value = "test" } }; }); AddUntilStep("wait for loaded", () => textBox.IsLoaded); AddStep("retrieve components", () => { restoreDefaultValueButton = textBox.ChildrenOfType <RestoreDefaultValueButton <string> >().Single(); control = textBox.ChildrenOfType <OsuTextBox>().Single(); }); AddStep("set non-default value", () => restoreDefaultValueButton.Current.Value = "non-default"); AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1)); AddStep("set label", () => textBox.LabelText = "label text"); AddAssert("default value button centre aligned to label size", () => { var label = textBox.ChildrenOfType <OsuSpriteText>().Single(spriteText => spriteText.Text == "label text"); return(Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, label.DrawHeight, 1)); }); AddStep("clear label", () => textBox.LabelText = default); AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1)); AddStep("set warning text", () => textBox.WarningText = "This is some very important warning text! Hopefully it doesn't break the alignment of the default value indicator..."); AddAssert("default value button centre aligned to control size", () => Precision.AlmostEquals(restoreDefaultValueButton.Parent.DrawHeight, control.DrawHeight, 1)); }