-
Notifications
You must be signed in to change notification settings - Fork 42
reactive styles #666
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Alex2772
wants to merge
11
commits into
develop
Choose a base branch
from
feat/reactive-styles
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
reactive styles #666
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
67feedb
reactive styles
Alex2772 5734608
Merge branch 'develop' into feat/reactive-styles
Alex2772 82db3c8
Merge branch 'develop' into feat/reactive-styles
Alex2772 370dfca
u
Alex2772 0d47a62
Merge branch 'develop' into feat/reactive-styles
Alex2772 b3dc8af
added copy ctor for ASmallVector.h
Alex2772 44d315e
modifier prototype
Alex2772 32f47d6
update ut
Alex2772 28bde02
Merge branch 'develop' into feat/reactive-styles
Alex2772 c102131
ass::prop -> ass::legacy
Alex2772 dad8626
TextColor impl for Modifier
Alex2772 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| #include "AUI/Test/UI/UITestCase.h" | ||
| #include "AUI/Test/UI/Assertion/Color.h" | ||
| #include "AUI/Util/Declarative/Containers.h" | ||
| #include "AUI/View/ACheckBox.h" | ||
|
|
||
| namespace { | ||
|
|
||
|
|
@@ -40,26 +41,64 @@ TEST_F(UIReactiveTest, Label) { | |
| // Test that a reactive label updates its text when the bound property changes. | ||
| // The test creates a simple state object with a reactive string property | ||
| // and binds it to a label using the AUI_REACT macro. It then verifies | ||
| // the initial rendered text and the updated text after changing the | ||
| // the initially rendered text and the updated text after changing the | ||
| // property. | ||
| using namespace ass; | ||
|
|
||
| struct State { | ||
| AProperty<AString> name; | ||
| AProperty<AString> name = "Test"; | ||
| }; | ||
| auto state = _new<State>(); | ||
|
|
||
| mWindow->setContents(Vertical { | ||
| Label { AUI_REACT("{}!"_format(state->name)) } | ||
| }); | ||
|
|
||
| // Initially, the property is empty, so the label should display "!". | ||
| EXPECT_EQ(*_cast<ALabel>(By::type<ALabel>().one())->text(), "!"); | ||
| // Initially, the property equals to "Test", so the label should display "Test!". | ||
| EXPECT_EQ(*_cast<ALabel>(By::type<ALabel>().one())->text(), "Test!"); | ||
| // Update the property; the label should automatically reflect the new value. | ||
| state->name = "Hello"; | ||
| EXPECT_EQ(*_cast<ALabel>(By::type<ALabel>().one())->text(), "Hello!"); | ||
| } | ||
|
|
||
| struct TextColor { | ||
| AColor color; | ||
|
|
||
| void operator()(AView& view) const { | ||
|
|
||
| } | ||
| }; | ||
|
|
||
| TEST_F(UIReactiveTest, Test2) { | ||
| // Test that a reactive label updates its text when the bound property changes. | ||
| // The test creates a simple state object with a reactive bool property | ||
| // and binds it to a label using the AUI_REACT macro. It then verifies | ||
| // the initial rendered text and the updated text after changing the | ||
| // property. | ||
| using namespace ass; | ||
|
|
||
| struct State { | ||
| AProperty<bool> option = false; | ||
| }; | ||
| auto state = _new<State>(); | ||
|
|
||
| mWindow->setContents(Vertical { | ||
| Label { | ||
| .text = "Test", | ||
| .modifier = AUI_REACT(Modifier {} | ::TextColor { state->option ? AColor::GREEN : AColor::RED }), | ||
| }, | ||
| }); | ||
|
|
||
| // Initially, the property equals to `false`, so the label should be red. | ||
| uitest::frame(); | ||
| EXPECT_EQ(_cast<ALabel>(By::type<ALabel>().one())->textColor(), AColor::RED); | ||
|
|
||
| // Update the property; the label should automatically reflect the new value. | ||
| state->option = true; | ||
| uitest::frame(); | ||
| EXPECT_EQ(_cast<ALabel>(By::type<ALabel>().one())->textColor(), AColor::GREEN); | ||
| } | ||
|
Comment on lines
+72
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test case has several issues and appears to be incomplete:
The test should be completed to properly verify the reactive modifier functionality. For example, it could check the |
||
|
|
||
| /* | ||
| TEST_F(UIReactiveTest, MultipleWithStyle) { | ||
| // Test that multiple containers with overridden styles render correctly. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
APimplalias is defined in the global namespace. To avoid polluting the global namespace and for better organization, it should be defined within theauinamespace, consistent with wherefast_pimplis defined.