From 6ab71707203eebaedfb0ec23812b171a67655ab1 Mon Sep 17 00:00:00 2001 From: Pascal Abresch Date: Wed, 2 Oct 2024 01:06:14 +0200 Subject: [PATCH] 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 Reviewed-by: John Scipione Reviewed-by: waddlesplash Tested-by: Commit checker robot --- .../tests/TextControlTest.cpp | 41 ++++++++++++++----- .../tests/TextControlTest.h | 2 + 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.cpp b/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.cpp index 0463a62876..87a79ef077 100644 --- a/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.cpp +++ b/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.cpp @@ -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() diff --git a/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.h b/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.h index 51854566b4..4fadf4b9e1 100644 --- a/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.h +++ b/src/tests/kits/interface/layout/widget_layout_test/tests/TextControlTest.h @@ -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; };