mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 10:45:02 +00:00
Add more display tests
BUG=chromium-os:38139 BRANCH=none TEST=make runtests && FEATURES=test emerge-daisy vboot_reference Change-Id: I28cd31f995f078d1715acaeaccce6e864930a986 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/42846 Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
committed by
ChromeBot
parent
7f43669630
commit
fe510c0620
@@ -8,6 +8,7 @@
|
||||
#ifndef VBOOT_REFERENCE_VBOOT_DISPLAY_H_
|
||||
#define VBOOT_REFERENCE_VBOOT_DISPLAY_H_
|
||||
|
||||
#include "bmpblk_font.h"
|
||||
#include "vboot_api.h"
|
||||
#include "vboot_nvstorage.h"
|
||||
|
||||
@@ -21,6 +22,21 @@ VbError_t VbCheckDisplayKey(VbCommonParams *cparams, uint32_t key,
|
||||
|
||||
/* Internal functions, for unit testing */
|
||||
|
||||
typedef FontArrayHeader VbFont_t;
|
||||
|
||||
VbFont_t *VbInternalizeFontData(FontArrayHeader *fonthdr);
|
||||
|
||||
void VbDoneWithFontForNow(VbFont_t *ptr);
|
||||
|
||||
ImageInfo *VbFindFontGlyph(VbFont_t *font, uint32_t ascii,
|
||||
void **bufferptr, uint32_t *buffersize);
|
||||
|
||||
/**
|
||||
* Try to display the specified text at a particular position.
|
||||
*/
|
||||
void VbRenderTextAtPos(char *text, int right_to_left,
|
||||
uint32_t x, uint32_t y, VbFont_t *font);
|
||||
|
||||
/**
|
||||
* Return a description of the recovery reason code.
|
||||
*/
|
||||
|
||||
@@ -68,18 +68,18 @@ char *VbHWID(VbCommonParams *cparams)
|
||||
*/
|
||||
typedef FontArrayHeader VbFont_t;
|
||||
|
||||
static VbFont_t *VbInternalizeFontData(FontArrayHeader *fonthdr)
|
||||
VbFont_t *VbInternalizeFontData(FontArrayHeader *fonthdr)
|
||||
{
|
||||
/* Just return the raw data pointer for now. */
|
||||
return (VbFont_t *)fonthdr;
|
||||
}
|
||||
|
||||
static void VbDoneWithFontForNow(VbFont_t *ptr)
|
||||
void VbDoneWithFontForNow(VbFont_t *ptr)
|
||||
{
|
||||
/* Nothing. */
|
||||
}
|
||||
|
||||
static ImageInfo *VbFindFontGlyph(VbFont_t *font, uint32_t ascii,
|
||||
ImageInfo *VbFindFontGlyph(VbFont_t *font, uint32_t ascii,
|
||||
void **bufferptr, uint32_t *buffersize)
|
||||
{
|
||||
uint8_t *ptr, *firstptr;
|
||||
@@ -120,10 +120,7 @@ static ImageInfo *VbFindFontGlyph(VbFont_t *font, uint32_t ascii,
|
||||
return &(entry->info);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to display the specified text at a particular position.
|
||||
*/
|
||||
static void VbRenderTextAtPos(char *text, int right_to_left,
|
||||
void VbRenderTextAtPos(char *text, int right_to_left,
|
||||
uint32_t x, uint32_t y, VbFont_t *font)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "bmpblk_font.h"
|
||||
#include "gbb_header.h"
|
||||
#include "host_common.h"
|
||||
#include "test_common.h"
|
||||
@@ -148,6 +149,7 @@ static void DisplayKeyTest(void)
|
||||
TEST_NEQ(*debug_info, '\0', "DisplayKey tab = display");
|
||||
|
||||
/* Toggle localization */
|
||||
ResetMocks();
|
||||
VbNvSet(&vnc, VBNV_LOCALIZATION_INDEX, 0);
|
||||
VbNvTeardown(&vnc);
|
||||
VbCheckDisplayKey(&cparams, VB_KEY_DOWN, &vnc);
|
||||
@@ -164,6 +166,7 @@ static void DisplayKeyTest(void)
|
||||
TEST_EQ(u, 0, "DisplayKey up");
|
||||
|
||||
/* Reset localization if localization count is invalid */
|
||||
ResetMocks();
|
||||
VbNvSet(&vnc, VBNV_LOCALIZATION_INDEX, 1);
|
||||
VbNvTeardown(&vnc);
|
||||
bhdr->signature[0] ^= 0x5a;
|
||||
@@ -173,14 +176,59 @@ static void DisplayKeyTest(void)
|
||||
|
||||
}
|
||||
|
||||
/* disable MSVC warnings on unused arguments */
|
||||
__pragma(warning (disable: 4100))
|
||||
static void FontTest(void)
|
||||
{
|
||||
FontArrayHeader h;
|
||||
FontArrayEntryHeader eh[3] = {
|
||||
{
|
||||
.ascii = 'A',
|
||||
.info.original_size = 10,
|
||||
},
|
||||
{
|
||||
.ascii = 'B',
|
||||
.info.original_size = 20,
|
||||
},
|
||||
{
|
||||
.ascii = 'C',
|
||||
.info.original_size = 30,
|
||||
},
|
||||
};
|
||||
FontArrayEntryHeader *eptr;
|
||||
uint8_t buf[sizeof(h) + sizeof(eh)];
|
||||
VbFont_t *fptr;
|
||||
void *bufferptr;
|
||||
uint32_t buffersize;
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
/* Create font data */
|
||||
h.num_entries = ARRAY_SIZE(eh);
|
||||
Memcpy(buf, &h, sizeof(h));
|
||||
eptr = (FontArrayEntryHeader *)(buf + sizeof(h));
|
||||
Memcpy(eptr, eh, sizeof(eh));
|
||||
|
||||
fptr = VbInternalizeFontData((FontArrayHeader *)buf);
|
||||
TEST_PTR_EQ(fptr, buf, "Internalize");
|
||||
|
||||
TEST_PTR_EQ(VbFindFontGlyph(fptr, 'B', &bufferptr, &buffersize),
|
||||
&eptr[1].info, "Glyph found");
|
||||
TEST_EQ(buffersize, eptr[1].info.original_size, " size");
|
||||
TEST_PTR_EQ(VbFindFontGlyph(fptr, 'X', &bufferptr, &buffersize),
|
||||
&eptr[0].info, "Glyph not found");
|
||||
TEST_EQ(buffersize, eptr[0].info.original_size, " size");
|
||||
|
||||
/* Test invalid rendering params */
|
||||
VbRenderTextAtPos(NULL, 0, 0, 0, fptr);
|
||||
VbRenderTextAtPos("ABC", 0, 0, 0, NULL);
|
||||
|
||||
VbDoneWithFontForNow(fptr);
|
||||
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
DebugInfoTest();
|
||||
LocalizationTest();
|
||||
DisplayKeyTest();
|
||||
FontTest();
|
||||
|
||||
return gTestSuccess ? 0 : 255;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user