summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2020-05-05 10:34:11 +0800
committerCommit Bot <commit-bot@chromium.org>2020-05-07 09:58:54 +0000
commit54ca8c3a2516bde0097d439bd6a85ddb1ce320fa (patch)
treec2b19ae923407dffcd1662f5e77c0ff8700bb2bf /tests
parent8c03950f59c86df17eca8dfe2a8bdc7ea3e075c7 (diff)
downloadvboot-54ca8c3a2516bde0097d439bd6a85ddb1ce320fa.tar.gz
vboot/ui: remove validate_selection function
Given that we are sending the full vb2_ui_context into UI-related functions, it's impossible to fully validate that called functions don't modify UI state in unexpected ways. Assume UI-related functions are mutating vb2_ui_context data correctly. Screen init functions (see CL:2168072) will be used to set selected_item and disabled_mask before displaying a screen for the first time. change_screen() is also changed to return a vb2_error_t value to be more consistent with action functions. BUG=b:146399181 TEST=make clean && make runtests BRANCH=none Change-Id: Icda68f95a835b9143b8dd085d8dbdb7bced04775 Signed-off-by: Joel Kitching <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2182084 Tested-by: Joel Kitching <kitching@chromium.org> Commit-Queue: Yu-Ping Wu <yupingso@chromium.org> Reviewed-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Yu-Ping Wu <yupingso@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/vb2_ui_utility_tests.c63
1 files changed, 6 insertions, 57 deletions
diff --git a/tests/vb2_ui_utility_tests.c b/tests/vb2_ui_utility_tests.c
index da7aaf72..e62f6c05 100644
--- a/tests/vb2_ui_utility_tests.c
+++ b/tests/vb2_ui_utility_tests.c
@@ -614,72 +614,22 @@ static void change_screen_tests(void)
mock_state->screen = &mock_screen_menu;
mock_state->selected_item = 2;
mock_state->disabled_item_mask = 0x10;
- VB2_DEBUG("change_screen will clear screen state\n");
- change_screen(&mock_ui_context, MOCK_SCREEN_BASE);
+ TEST_EQ(change_screen(&mock_ui_context, MOCK_SCREEN_BASE),
+ VB2_REQUEST_UI_CONTINUE,
+ "change_screen will clear screen state");
screen_state_eq(mock_state, MOCK_SCREEN_BASE, 0, 0);
/* Change to screen which does not exist */
reset_common_data();
mock_state->screen = &mock_screen_menu;
- VB2_DEBUG("change to screen which does not exist\n");
- change_screen(&mock_ui_context, MOCK_NO_SCREEN);
+ TEST_EQ(change_screen(&mock_ui_context, MOCK_NO_SCREEN),
+ VB2_REQUEST_UI_CONTINUE,
+ "change to screen which does not exist");
screen_state_eq(mock_state, MOCK_SCREEN_MENU, MOCK_IGNORE, MOCK_IGNORE);
VB2_DEBUG("...done.\n");
}
-static void validate_selection_tests(void)
-{
- VB2_DEBUG("Testing validate_selection...");
-
- /* No item */
- reset_common_data();
- mock_state->screen = &mock_screen_base;
- mock_state->selected_item = 2;
- mock_state->disabled_item_mask = 0x10;
- VB2_DEBUG("no item (fix selected_item)\n");
- validate_selection(mock_state);
- screen_state_eq(mock_state, MOCK_SCREEN_BASE, 0, MOCK_IGNORE);
-
- /* Valid selected_item */
- reset_common_data();
- mock_state->screen = &mock_screen_menu;
- mock_state->selected_item = 2;
- mock_state->disabled_item_mask = 0x13; /* 0b10011 */
- VB2_DEBUG("valid selected_item\n");
- validate_selection(mock_state);
- screen_state_eq(mock_state, MOCK_SCREEN_MENU, 2, MOCK_IGNORE);
-
- /* selected_item too large */
- reset_common_data();
- mock_state->screen = &mock_screen_menu;
- mock_state->selected_item = 5;
- mock_state->disabled_item_mask = 0x15; /* 0b10101 */
- VB2_DEBUG("selected_item too large\n");
- validate_selection(mock_state);
- screen_state_eq(mock_state, MOCK_SCREEN_MENU, 1, MOCK_IGNORE);
-
- /* Select a disabled item */
- reset_common_data();
- mock_state->screen = &mock_screen_menu;
- mock_state->selected_item = 4;
- mock_state->disabled_item_mask = 0x17; /* 0b10111 */
- VB2_DEBUG("select a disabled item\n");
- validate_selection(mock_state);
- screen_state_eq(mock_state, MOCK_SCREEN_MENU, 3, MOCK_IGNORE);
-
- /* No available item */
- reset_common_data();
- mock_state->screen = &mock_screen_menu;
- mock_state->selected_item = 2;
- mock_state->disabled_item_mask = 0x1f; /* 0b11111 */
- VB2_DEBUG("no available item\n");
- validate_selection(mock_state);
- screen_state_eq(mock_state, MOCK_SCREEN_MENU, 0, MOCK_IGNORE);
-
- VB2_DEBUG("...done.\n");
-}
-
static void ui_loop_tests(void)
{
VB2_DEBUG("Testing ui_loop...\n");
@@ -781,7 +731,6 @@ int main(void)
shutdown_required_tests();
menu_action_tests();
change_screen_tests();
- validate_selection_tests();
ui_loop_tests();
return gTestSuccess ? 0 : 255;