mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
test: add Invalid for TextControlText in WidgetLayoutTest
Change-Id: I1f010fa752251bae7fc94f6d3e8321e57efdc041 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8429 Haiku-Format: Haiku-format Bot <no-reply+haikuformatbot@haiku-os.org> Reviewed-by: John Scipione <jscipione@gmail.com> Reviewed-by: waddlesplash <waddlesplash@gmail.com> Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
This commit is contained in:
parent
aa68f6603f
commit
6ab7170720
@ -15,18 +15,21 @@
|
||||
|
||||
|
||||
enum {
|
||||
MSG_CHANGE_LABEL_TEXT = 'chlt',
|
||||
MSG_CHANGE_LABEL_FONT = 'chlf'
|
||||
MSG_CHANGE_LABEL_TEXT = 'chlt',
|
||||
MSG_CHANGE_LABEL_FONT = 'chlf',
|
||||
MSG_CHANGE_INVALID = 'chiv'
|
||||
};
|
||||
|
||||
|
||||
// constructor
|
||||
TextControlTest::TextControlTest()
|
||||
: ControlTest("TextControl"),
|
||||
fLongTextCheckBox(NULL),
|
||||
fBigFontCheckBox(NULL),
|
||||
fDefaultFont(NULL),
|
||||
fBigFont(NULL)
|
||||
:
|
||||
ControlTest("TextControl"),
|
||||
fLongTextCheckBox(NULL),
|
||||
fBigFontCheckBox(NULL),
|
||||
fInvalidCheckBox(NULL),
|
||||
fDefaultFont(NULL),
|
||||
fBigFont(NULL)
|
||||
{
|
||||
fTextControl = new BTextControl("Label", "Some Text", NULL);
|
||||
|
||||
@ -61,9 +64,8 @@ TextControlTest::ActivateTest(View* controls)
|
||||
|
||||
// BMenuField sets its background color to that of its parent in
|
||||
// AttachedToWindow(). Override.
|
||||
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||
fTextControl->SetViewColor(background);
|
||||
fTextControl->SetLowColor(background);
|
||||
fTextControl->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
fTextControl->SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
|
||||
// long text
|
||||
fLongTextCheckBox = new LabeledCheckBox("Long label text",
|
||||
@ -75,6 +77,9 @@ TextControlTest::ActivateTest(View* controls)
|
||||
new BMessage(MSG_CHANGE_LABEL_FONT), this);
|
||||
group->AddChild(fBigFontCheckBox);
|
||||
|
||||
fInvalidCheckBox = new LabeledCheckBox("Invalid Input", new BMessage(MSG_CHANGE_INVALID), this);
|
||||
group->AddChild(fInvalidCheckBox);
|
||||
|
||||
_UpdateLabelText();
|
||||
_UpdateLabelFont();
|
||||
|
||||
@ -100,6 +105,9 @@ TextControlTest::MessageReceived(BMessage* message)
|
||||
case MSG_CHANGE_LABEL_FONT:
|
||||
_UpdateLabelFont();
|
||||
break;
|
||||
case MSG_CHANGE_INVALID:
|
||||
_UpdateInvalid();
|
||||
break;
|
||||
default:
|
||||
Test::MessageReceived(message);
|
||||
break;
|
||||
@ -107,6 +115,19 @@ TextControlTest::MessageReceived(BMessage* message)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TextControlTest::_UpdateInvalid()
|
||||
{
|
||||
if (!fInvalidCheckBox)
|
||||
return;
|
||||
|
||||
if (fInvalidCheckBox->IsSelected())
|
||||
fTextControl->MarkAsInvalid(true);
|
||||
else
|
||||
fTextControl->MarkAsInvalid(false);
|
||||
}
|
||||
|
||||
|
||||
// _UpdateLabelText
|
||||
void
|
||||
TextControlTest::_UpdateLabelText()
|
||||
|
@ -30,11 +30,13 @@ public:
|
||||
private:
|
||||
void _UpdateLabelText();
|
||||
void _UpdateLabelFont();
|
||||
void _UpdateInvalid();
|
||||
|
||||
private:
|
||||
BTextControl* fTextControl;
|
||||
LabeledCheckBox* fLongTextCheckBox;
|
||||
LabeledCheckBox* fBigFontCheckBox;
|
||||
LabeledCheckBox* fInvalidCheckBox;
|
||||
BFont* fDefaultFont;
|
||||
BFont* fBigFont;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user