Ben Evans University Second Year Project. Game Called Defender.
Embed:
(wiki syntax)
Show/hide line numbers
Menu_test.h
00001 #ifndef MENU_TEST_H 00002 #define MENU_TEST_H 00003 00004 /** Menu Test 00005 * @brief Test the different Menu functions 00006 * @author Benjamin Evans, University of Leeds 00007 * @date May 2020 00008 * @return true if test are passed 00009 */ 00010 bool menu_select_part_test(MenuParts expected_menu_part, bool pressed) { 00011 // Objects required for test 00012 Menu menu; 00013 00014 // Initialise the menu 00015 menu.init(); 00016 00017 if (pressed) { 00018 printf("Expected menu part play : "); 00019 }else{ 00020 printf("Expected menu part main menu : "); 00021 } 00022 00023 // Calls menu select function with pressed and not pressed 00024 menu.select_part(pressed); 00025 00026 00027 // Gets the current menu part and checks if it is the expected menu part 00028 if ( menu.get_current_menu_part() == expected_menu_part) { 00029 printf ( "Passed!\n"); 00030 return true; 00031 } else { 00032 printf ( "Failed!\n"); 00033 return false; 00034 } 00035 } 00036 00037 bool menu_scroll_test(Direction d_,MenuParts expected_menu_part) { 00038 // Objects required for test 00039 Menu menu; 00040 00041 // Initialise the menu 00042 menu.init(); 00043 00044 printf("Expected menu part %d : ",expected_menu_part); 00045 00046 menu.menu_scroll(d_); 00047 00048 // Calls menu select function to so we can then get the displayed menu part 00049 menu.select_part(true); 00050 00051 MenuParts actual_menu_part = menu.get_current_menu_part(); 00052 00053 // Gets the current menu part and checks if it is the expected menu part 00054 if ( actual_menu_part == expected_menu_part) { 00055 printf ( "Passed!\n"); 00056 return true; 00057 } else { 00058 printf ( "Failed! %d (expecting %d,)\n", actual_menu_part, 00059 expected_menu_part); 00060 return false; 00061 } 00062 } 00063 00064 bool menu_draw_part_test(int expected_pixel_status, 00065 int expected_postion_x, int expected_postion_y) { 00066 // Objects required for test 00067 Menu menu; 00068 N5110 lcd; 00069 00070 // Initialise the Menu 00071 menu.init(); 00072 lcd.init(); 00073 00074 printf("menu_draw_part x,y = %d,%d : ",expected_postion_x, 00075 expected_postion_y ); 00076 00077 menu.draw_part(lcd); 00078 00079 // Reads pixel where hud is expected to be drawn 00080 int actual_pixel_status = lcd.getPixel(expected_postion_x, 00081 expected_postion_y); 00082 00083 // Checks if pixel is drawn and therefor testing it hasn’t gone of screen 00084 if (actual_pixel_status == expected_pixel_status) { 00085 printf ( "Passed!\n"); 00086 return true; 00087 } else { 00088 printf ( "Failed! value = %d (expecting %d)\n", actual_pixel_status, 00089 expected_pixel_status); 00090 return false; 00091 } 00092 } 00093 00094 #endif
Generated on Fri Aug 5 2022 06:55:07 by
1.7.2