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 <[email protected]> Reviewed-by: John Scipione <[email protected]> Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
nephele nephele
parent
aa68f6603f
commit
6ab7170720
@@ -15,18 +15,21 @@
|
|||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_CHANGE_LABEL_TEXT = 'chlt',
|
MSG_CHANGE_LABEL_TEXT = 'chlt',
|
||||||
MSG_CHANGE_LABEL_FONT = 'chlf'
|
MSG_CHANGE_LABEL_FONT = 'chlf',
|
||||||
|
MSG_CHANGE_INVALID = 'chiv'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
TextControlTest::TextControlTest()
|
TextControlTest::TextControlTest()
|
||||||
: ControlTest("TextControl"),
|
:
|
||||||
fLongTextCheckBox(NULL),
|
ControlTest("TextControl"),
|
||||||
fBigFontCheckBox(NULL),
|
fLongTextCheckBox(NULL),
|
||||||
fDefaultFont(NULL),
|
fBigFontCheckBox(NULL),
|
||||||
fBigFont(NULL)
|
fInvalidCheckBox(NULL),
|
||||||
|
fDefaultFont(NULL),
|
||||||
|
fBigFont(NULL)
|
||||||
{
|
{
|
||||||
fTextControl = new BTextControl("Label", "Some Text", 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
|
// BMenuField sets its background color to that of its parent in
|
||||||
// AttachedToWindow(). Override.
|
// AttachedToWindow(). Override.
|
||||||
rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
|
fTextControl->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
fTextControl->SetViewColor(background);
|
fTextControl->SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||||
fTextControl->SetLowColor(background);
|
|
||||||
|
|
||||||
// long text
|
// long text
|
||||||
fLongTextCheckBox = new LabeledCheckBox("Long label text",
|
fLongTextCheckBox = new LabeledCheckBox("Long label text",
|
||||||
@@ -75,6 +77,9 @@ TextControlTest::ActivateTest(View* controls)
|
|||||||
new BMessage(MSG_CHANGE_LABEL_FONT), this);
|
new BMessage(MSG_CHANGE_LABEL_FONT), this);
|
||||||
group->AddChild(fBigFontCheckBox);
|
group->AddChild(fBigFontCheckBox);
|
||||||
|
|
||||||
|
fInvalidCheckBox = new LabeledCheckBox("Invalid Input", new BMessage(MSG_CHANGE_INVALID), this);
|
||||||
|
group->AddChild(fInvalidCheckBox);
|
||||||
|
|
||||||
_UpdateLabelText();
|
_UpdateLabelText();
|
||||||
_UpdateLabelFont();
|
_UpdateLabelFont();
|
||||||
|
|
||||||
@@ -100,6 +105,9 @@ TextControlTest::MessageReceived(BMessage* message)
|
|||||||
case MSG_CHANGE_LABEL_FONT:
|
case MSG_CHANGE_LABEL_FONT:
|
||||||
_UpdateLabelFont();
|
_UpdateLabelFont();
|
||||||
break;
|
break;
|
||||||
|
case MSG_CHANGE_INVALID:
|
||||||
|
_UpdateInvalid();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Test::MessageReceived(message);
|
Test::MessageReceived(message);
|
||||||
break;
|
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
|
// _UpdateLabelText
|
||||||
void
|
void
|
||||||
TextControlTest::_UpdateLabelText()
|
TextControlTest::_UpdateLabelText()
|
||||||
|
|||||||
@@ -30,11 +30,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
void _UpdateLabelText();
|
void _UpdateLabelText();
|
||||||
void _UpdateLabelFont();
|
void _UpdateLabelFont();
|
||||||
|
void _UpdateInvalid();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BTextControl* fTextControl;
|
BTextControl* fTextControl;
|
||||||
LabeledCheckBox* fLongTextCheckBox;
|
LabeledCheckBox* fLongTextCheckBox;
|
||||||
LabeledCheckBox* fBigFontCheckBox;
|
LabeledCheckBox* fBigFontCheckBox;
|
||||||
|
LabeledCheckBox* fInvalidCheckBox;
|
||||||
BFont* fDefaultFont;
|
BFont* fDefaultFont;
|
||||||
BFont* fBigFont;
|
BFont* fBigFont;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user