From f979707f1edfc6196119061e733ff1a7c143c795 Mon Sep 17 00:00:00 2001 From: Joursoir Date: Wed, 4 May 2022 20:40:17 +0300 Subject: add solid colors test --- UefiMonitorTest/tests/SolidColors.c | 120 ++++++++++++++++++++++++++++++++++++ UefiMonitorTest/tests/SolidColors.h | 33 ++++++++++ 2 files changed, 153 insertions(+) create mode 100644 UefiMonitorTest/tests/SolidColors.c create mode 100644 UefiMonitorTest/tests/SolidColors.h (limited to 'UefiMonitorTest/tests') diff --git a/UefiMonitorTest/tests/SolidColors.c b/UefiMonitorTest/tests/SolidColors.c new file mode 100644 index 0000000..14fe23b --- /dev/null +++ b/UefiMonitorTest/tests/SolidColors.c @@ -0,0 +1,120 @@ +#include +#include +#include + +#include "SolidColors.h" + +STATIC enum UMT_COLORS CurrentColor = 0; + +VOID +SolidColorsTestInit ( + IN UMT_CONTEXT *Ctx + ) +{ + GRAPHICS_CONTEXT *Graphics = Ctx->Graphics; + + PutRect (Graphics, 0, 0, Graphics->Width, Graphics->Height, &gUmtColors[CurrentColor]); + if (Ctx->ShowTip) + SolidColorsTestTip (Ctx); +} + +VOID +SolidColorsTestDoit ( + IN UMT_CONTEXT *Ctx + ) +{ + +} + +VOID +SolidColorsTestTip ( + IN UMT_CONTEXT *Ctx + ) +{ + GRAPHICS_CONTEXT *Graphics; + EFI_STRING_ID TitleToken; + EFI_STRING_ID MsgToken; + CHAR16 *Title; + CHAR16 *Msg; + + Graphics = Ctx->Graphics; + + if (Ctx->ShowTip == FALSE) { + // Restore + PutRect (Graphics, 15, Graphics->Height - 15 - 104, 470, Graphics->Height - 15, &gUmtColors[CurrentColor]); + return; + } + + // TODO: or use CatSPrint()? + switch (CurrentColor) { + case UMT_COLOR_BLACK: + TitleToken = STRING_TOKEN (STR_SOLID_COLORS_BLACK_TITLE); + MsgToken = STRING_TOKEN (STR_SOLID_COLORS_BLACK_MSG); + break; + case UMT_COLOR_WHITE: + TitleToken = STRING_TOKEN (STR_SOLID_COLORS_WHITE_TITLE); + MsgToken = STRING_TOKEN (STR_SOLID_COLORS_WHITE_MSG); + break; + case UMT_COLOR_RED: + TitleToken = STRING_TOKEN (STR_SOLID_COLORS_RED_TITLE); + MsgToken = STRING_TOKEN (STR_SOLID_COLORS_RED_MSG); + break; + case UMT_COLOR_LIME: + TitleToken = STRING_TOKEN (STR_SOLID_COLORS_GREEN_TITLE); + MsgToken = STRING_TOKEN (STR_SOLID_COLORS_GREEN_MSG); + break; + case UMT_COLOR_BLUE: + TitleToken = STRING_TOKEN (STR_SOLID_COLORS_BLUE_TITLE); + MsgToken = STRING_TOKEN (STR_SOLID_COLORS_BLUE_MSG); + break; + default: + ASSERT (FALSE); + break; + } + + Title = HiiGetString (gUmtHiiHandle, TitleToken, NULL); + Msg = HiiGetString (gUmtHiiHandle, MsgToken, NULL); + + DrawRectWithBorder (Graphics, 15, Graphics->Height - 15 - 104, 470, Graphics->Height - 15, + 3, &gUmtColors[UMT_COLOR_WHITE], &gUmtColors[UMT_COLOR_NAVY]); + DrawStringF (Graphics, 25, Graphics->Height - 15 - 94, &gUmtColors[UMT_COLOR_NAVY], Title); + DrawStringF (Graphics, 25, Graphics->Height - 15 - 74, &gUmtColors[UMT_COLOR_BLACK], Msg); + + FreePool (Title); + FreePool (Msg); +} + +VOID +SolidColorsTestChangeValue ( + IN UMT_CONTEXT *Ctx, + IN INT8 ValueStep + ) +{ + if (CurrentColor == 0 && ValueStep < 0) + CurrentColor = UMT_COLOR_BLUE; + else { + CurrentColor += ValueStep; + if (CurrentColor >= UMT_COLOR_BLUE) + CurrentColor = 0; + } + + SolidColorsTestInit (Ctx); +} + +VOID +SolidColorsTestChangeParam ( + IN UMT_CONTEXT *Ctx, + IN INT8 ParamStep + ) +{ + +} + +VOID +SolidColorsTestChangeVar ( + IN UMT_CONTEXT *Ctx, + IN INT8 VariableStep // -1, +1 + ) +{ + +} diff --git a/UefiMonitorTest/tests/SolidColors.h b/UefiMonitorTest/tests/SolidColors.h new file mode 100644 index 0000000..a4d7f72 --- /dev/null +++ b/UefiMonitorTest/tests/SolidColors.h @@ -0,0 +1,33 @@ +#ifndef UMT_SOLID_COLORS_TEST_H +#define UMT_SOLID_COLORS_TEST_H + +#include "UefiMonitorTest.h" + +VOID +SolidColorsTestInit ( + IN UMT_CONTEXT *Ctx + ); + +VOID +SolidColorsTestDoit ( + IN UMT_CONTEXT *Ctx + ); + +VOID +SolidColorsTestTip ( + IN UMT_CONTEXT *Ctx + ); + +VOID +SolidColorsTestChangeParam ( + IN UMT_CONTEXT *Ctx, + IN INT8 ParamStep + ); + +VOID +SolidColorsTestChangeValue ( + IN UMT_CONTEXT *Ctx, + IN INT8 ValueStep + ); + +#endif /* UMT_SOLID_COLORS_TEST_H */ -- cgit v1.2.3-18-g5258