-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Add initial test for checkbox #2551
Conversation
I've read the article you have linked and I like the long descriptive names. If the test fails anyone sees from the log what could go wrong. With
The The rest is rather some rendering tests. It's hard to test with
@cmumford replaced Unity with
Good question. The test are organized and built by |
It would probably be cleanest to have a common assertion function for the tests that can be used to check whether the memory usage grew by more than an expected amount. |
E.g. |
no, we're still using Unity. I'm only using ctest to execute the Unity based tests and to report their results. I did question the use of Unity, as there are other more widely used testing systems (like googletest), but Unity is designed to run on the MCU. We don't currently do this, but I'm guessing the goal is to do so at some point. The generated executables are inside the |
OK. The tests are all built in I think that adding an option to |
Thanks for the tip, I'm using WSL Ubuntu 20, will try to find those files later today. I think using Unity is better than nothing, I personally have been using CPPUTest and their mocks, it's quite easy to use, we can continue using Unity until we hit a huge blocker.
At the beginning I was a bit confused by parallel builds 😄
Did you tried using the |
I had to apply the following patch to allow me build the tests with symbols and debug the individual test (test_checkbox in my case), @cmumford could we enable building with debug information? Maybe disabled as default, I didn't knew where in the diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index c7cd3e8a7..3933c239e 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -235,6 +235,7 @@ set(COMPILE_OPTIONS
-Wundef
-Wuninitialized
-Wunreachable-code
+ -g
${BUILD_OPTIONS}
) The following test fails, I was expecting the event handler not being called because the checkbox is disabled: static volatile bool event_called = false;
static void event_handler(lv_event_t *e)
{
lv_event_code_t code = lv_event_get_code(e);
if (LV_EVENT_VALUE_CHANGED == code) {
event_called = true;
}
}
void test_checkbox_should_not_call_event_handler_on_click_when_disabled(void)
{
active_screen = lv_scr_act();
checkbox = lv_checkbox_create(active_screen);
lv_obj_add_state(checkbox, LV_STATE_DISABLED);
lv_obj_add_event_cb(checkbox, event_handler, LV_EVENT_ALL, NULL);
lv_test_mouse_click_at(checkbox->coords.x1, checkbox->coords.y1);
TEST_ASSERT_FALSE(event_called);
event_called = false;
}
I've placed a brakpoint in the |
@kisvegabor I've accidentally pushed a test for a bugfix (in a separated file), what should I do? I think I don't fully understand the static text capability, I was expecting a chunk of memory being allocated to hold the static text, so the available memory would be reduced. I guess I could simulate the checkbox being dissapeared by placing it inside an smaller scope, when the scope is exited, then the statically allocated memory for the static text should be released? Or simply by calling |
Sure. You can do that in build_type = 'Debug' IMO we're better off running these tests in debug mode. Maybe when we start doing performance tests or running on device (and need the RAM) we can run a release build. |
OK, I will send a PR with your suggestion. I also agree running test with debug info enabled is very useful. |
Also adds reference to issue in a comment
I'm not sure about both static text tests, let me know if you want me to improve them. |
I did so but didn't got the symbol information when loading the executables into gdb. |
NULL shouldn't be passed as text Related to #2551
|
Test removed |
…freshed NULL isn't a valid parameter in lv_checkbox_set_text_static
Do we need more tests for now? |
Looks god to me. Thank you, Carlos! Merging. |
* test(checkbox): Add initial test for checkbox * test(checkbox): Add test_checkbox_should_have_default_text_when_created * test(checkbox): Add test_checkbox_should_return_dinamically_allocated_text * test(checkbox): Add initial tests for static text Tests are failing tho * test(arc): Rename bugfix test to arc Also adds reference to issue in a comment * test(checkbox): Tests for static text passes * test(checkbox): Remove test for memory freeing when static text is refreshed NULL isn't a valid parameter in lv_checkbox_set_text_static
Description of the feature or fix
Add initial set of tests for checkbox widget, I choose this widget because it's one of the simplest (?)
@kisvegabor What else should we test? If the checkbox state is
LV_STATE_DISABLED
and we click on it, should it call theevent_handler
?Also, I wasn't able to use the Unity
setup
andtearDown
functions, and is it possible to debug thetest_checkbox
object file? I was trying to debug using gdb but couldn't find the generated executables.Checkpoints