Microchip® Advanced Software Framework

unit_tests.c File Reference

Unit tests for gfx_mono menu system.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <board.h>
#include <compiler.h>
#include <gfx_mono.h>
#include <gfx_mono_menu.h>
#include <sysclk.h>
#include <sysfont.h>
#include <stdio_serial.h>
#include <unit_test/suite.h>
#include <conf_test.h>

Functions

int main (void)
 Run test suite. More...
 
static void run_menu_init_test (const struct test_case *test)
 Test menu initialization. More...
 
static void run_menu_navigation_test (const struct test_case *test)
 Test menu navigation interface using fake keyboard input. More...
 
static void run_menu_page_change_test (const struct test_case *test)
 Test menu page changing. More...
 
static void run_menu_wrap_first_test (const struct test_case *test)
 Test menu edge wrapping upward from first element. More...
 
static void run_menu_wrap_last_test (const struct test_case *test)
 Test menu edge wrapping downward from last element. More...
 
Menu string declarations
 PROGMEM_DECLARE (char const, main_menu_title[])
 
 PROGMEM_DECLARE (char const, main_menu_1[])
 
 PROGMEM_DECLARE (char const, main_menu_2[])
 
 PROGMEM_DECLARE (char const, main_menu_3[])
 
 PROGMEM_DECLARE (char const, main_menu_4[])
 
 PROGMEM_DECLARE (char const, main_menu_5[])
 
 PROGMEM_DECLARE (char const, main_menu_6[])
 

Variables

PROGMEM_STRING_T main_menu_strings []
 

PROGMEM_DECLARE ( char  const,
main_menu_title  [] 
)
PROGMEM_DECLARE ( char  const,
main_menu_1  [] 
)
PROGMEM_DECLARE ( char  const,
main_menu_2  [] 
)
PROGMEM_DECLARE ( char  const,
main_menu_3  [] 
)
PROGMEM_DECLARE ( char  const,
main_menu_4  [] 
)
PROGMEM_DECLARE ( char  const,
main_menu_5  [] 
)
PROGMEM_DECLARE ( char  const,
main_menu_6  [] 
)
static void run_menu_init_test ( const struct test_case test)
static

Test menu initialization.

This function runs the menu initialization, and check to see that is has been set up correctly. Test assumes that there are more menu items than can fit on one page.

Parameters
testCurrent test case

References gfx_mono_menu::current_page, gfx_mono_menu::current_selection, FIRST_PAGE, GFX_MONO_MENU_ELEMENTS_PER_SCREEN, gfx_mono_menu_init(), LAST_ELEMENT, main_menu_strings, NUM_OF_ELEMENTS, test_assert_true, and gfx_mono_menu::title.

Referenced by main().

static void run_menu_navigation_test ( const struct test_case test)
static

Test menu navigation interface using fake keyboard input.

This test runs the menu system, goes to a menu item, selects it, and verifies that it has been selected. The test assumes that at least three menu items are available on each page.

Parameters
testCurrent test case

References gfx_mono_menu::current_page, gfx_mono_menu::current_selection, FIRST_ELEMENT, FIRST_PAGE, GFX_MONO_MENU_EVENT_EXIT, GFX_MONO_MENU_EVENT_IDLE, gfx_mono_menu_init(), GFX_MONO_MENU_KEYCODE_BACK, GFX_MONO_MENU_KEYCODE_DOWN, GFX_MONO_MENU_KEYCODE_ENTER, GFX_MONO_MENU_KEYCODE_UP, gfx_mono_menu_process_key(), main_menu_strings, NUM_OF_ELEMENTS, test_assert_true, and gfx_mono_menu::title.

Referenced by main().

static void run_menu_page_change_test ( const struct test_case test)
static

Test menu page changing.

This test scrolls down in a menu, until it reaches the next page. This test relies on there being more elements than can fit in a page.

Parameters
testCurrent test case

References gfx_mono_menu::current_page, gfx_mono_menu::current_selection, FIRST_ELEMENT, FIRST_PAGE, GFX_MONO_MENU_ELEMENTS_PER_SCREEN, gfx_mono_menu_init(), GFX_MONO_MENU_KEYCODE_DOWN, gfx_mono_menu_process_key(), main_menu_strings, NUM_OF_ELEMENTS, test_assert_true, and gfx_mono_menu::title.

Referenced by main().

static void run_menu_wrap_first_test ( const struct test_case test)
static

Test menu edge wrapping upward from first element.

This test navigates upward from the first element, expecting to come to the last element in the last page on such an event.

Parameters
testCurrent test case

References gfx_mono_menu::current_page, gfx_mono_menu::current_selection, FIRST_ELEMENT, gfx_mono_menu_init(), GFX_MONO_MENU_KEYCODE_UP, gfx_mono_menu_process_key(), LAST_ELEMENT, LAST_PAGE, main_menu_strings, NUM_OF_ELEMENTS, test_assert_true, and gfx_mono_menu::title.

Referenced by main().

static void run_menu_wrap_last_test ( const struct test_case test)
static

Test menu edge wrapping downward from last element.

This test starts from the last element, and navigates downward, expecting to come to the first element in the first page on such and event.

Parameters
testCurrent test case

References gfx_mono_menu::current_page, gfx_mono_menu::current_selection, FIRST_ELEMENT, FIRST_PAGE, gfx_mono_menu_init(), GFX_MONO_MENU_KEYCODE_DOWN, gfx_mono_menu_process_key(), LAST_ELEMENT, main_menu_strings, NUM_OF_ELEMENTS, test_assert_true, and gfx_mono_menu::title.

Referenced by main().

PROGMEM_STRING_T main_menu_strings[]
Initial value:
= {
main_menu_1,
main_menu_2,
main_menu_3,
main_menu_4,
main_menu_5,
main_menu_6,
}

Referenced by run_menu_init_test(), run_menu_navigation_test(), run_menu_page_change_test(), run_menu_wrap_first_test(), and run_menu_wrap_last_test().