aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikita <102851041+HyperNiki@users.noreply.github.com>2022-05-17 22:29:07 +0300
committerGitHub <noreply@github.com>2022-05-17 19:29:07 +0000
commit817de39e6095f46d4d4d4e46a73ac848c0347433 (patch)
tree20b633f168bd282f9b34e3785e9dbb22c94f0197
parent17946fbe9c340cc8fcfc7e11303bddba0cdfbc36 (diff)
downloadumt-817de39e6095f46d4d4d4e46a73ac848c0347433.tar.gz
umt-817de39e6095f46d4d4d4e46a73ac848c0347433.tar.bz2
umt-817de39e6095f46d4d4d4e46a73ac848c0347433.zip
implement the chess board test
-rw-r--r--UefiMonitorTest/UefiMonitorTestStrings.uni10
-rw-r--r--UefiMonitorTest/tests/ChessBoard.c92
2 files changed, 102 insertions, 0 deletions
diff --git a/UefiMonitorTest/UefiMonitorTestStrings.uni b/UefiMonitorTest/UefiMonitorTestStrings.uni
index 60c519c..c99a949 100644
--- a/UefiMonitorTest/UefiMonitorTestStrings.uni
+++ b/UefiMonitorTest/UefiMonitorTestStrings.uni
@@ -106,3 +106,13 @@
"shouldn't have any colorful areas.\n"
"\n"
"Gray tone: %d\n"
+
+// Test "Chess Board"
+
+#string STR_CHESSBOARD_TITLE #language en-US "CHESS BOARD"
+
+#string STR_CHESSBOARD_MSG #language en-US "Assess the effectiveness of the monitor to display\n"
+ "objects with minimum and maximum brightness at the\n"
+ "same time.\n"
+ "\n"
+ "Side length of a square: %d\n"
diff --git a/UefiMonitorTest/tests/ChessBoard.c b/UefiMonitorTest/tests/ChessBoard.c
index 6b90067..7b3b976 100644
--- a/UefiMonitorTest/tests/ChessBoard.c
+++ b/UefiMonitorTest/tests/ChessBoard.c
@@ -1,11 +1,48 @@
+#include <Library/DebugLib.h>
+#include <Library/HiiLib.h>
+#include <Library/MemoryAllocationLib.h>
+
#include "tests/ChessBoard.h"
+STATIC UINT32 CurrentSideLength = 1;
+
VOID
ChessBoardTestInit (
IN UMT_CONTEXT *Ctx
)
{
+ UINT32 I;
+ UINT32 J;
+ enum UMT_COLORS ColorSquare;
+ enum UMT_COLORS FirstColorSquare;
+ enum UMT_COLORS TempColor;
+ GRAPHICS_CONTEXT *Graphics = Ctx->Graphics;
+
+ FirstColorSquare = UMT_COLOR_WHITE;
+ ColorSquare = UMT_COLOR_BLACK;
+
+ for (J = 0; J < Graphics->Height; J += CurrentSideLength)
+ {
+ TempColor = FirstColorSquare;
+ FirstColorSquare = ColorSquare;
+ ColorSquare = TempColor;
+ for (I = 0; I < Graphics->Width; I += CurrentSideLength)
+ {
+ PutRect (Graphics,
+ I,
+ J,
+ I + CurrentSideLength,
+ J + CurrentSideLength,
+ &gUmtColors[ColorSquare].Color);
+
+ ColorSquare = ((ColorSquare == UMT_COLOR_WHITE) ? UMT_COLOR_BLACK : UMT_COLOR_WHITE);
+ }
+ }
+
+ if (Ctx->ShowTip) {
+ ChessBoardTestTip (Ctx);
+ }
}
VOID
@@ -21,7 +58,36 @@ ChessBoardTestTip (
IN UMT_CONTEXT *Ctx
)
{
+ GRAPHICS_CONTEXT *Graphics;
+
+ Graphics = Ctx->Graphics;
+ if (Ctx->ShowTip == FALSE) {
+ // Restore
+ ChessBoardTestInit (Ctx);
+ return;
+ }
+
+ DrawRectWithBorder (Graphics,
+ 15,
+ Graphics->Height - 15 - 124,
+ 430, Graphics->Height - 15,
+ 3,
+ &gUmtColors[UMT_COLOR_WHITE].Color,
+ &gUmtColors[UMT_COLOR_NAVY].Color);
+
+ DrawHiiStringF (Graphics,
+ 25,
+ Graphics->Height - 15 - 114,
+ &gUmtColors[UMT_COLOR_NAVY].Color,
+ STRING_TOKEN (STR_CHESSBOARD_TITLE), gUmtHiiHandle);
+
+ DrawHiiStringF (Graphics,
+ 25,
+ Graphics->Height - 15 - 94,
+ &gUmtColors[UMT_COLOR_BLACK].Color,
+ STRING_TOKEN (STR_CHESSBOARD_MSG), gUmtHiiHandle,
+ CurrentSideLength);
}
VOID
@@ -39,5 +105,31 @@ ChessBoardTestChangeValue (
IN INT8 ValueStep
)
{
+ UINT32 ValueOut;
+ UINT32 Height;
+ UINT32 Width;
+
+ Height = Ctx->Graphics->Height;
+ Width = Ctx->Graphics->Width;
+ ValueOut = CurrentSideLength + ValueStep;
+
+ if (ValueOut == 0) {
+ return;
+ }
+
+ while ((((Width / ValueOut) * ValueOut != Width) ||
+ ((Height / ValueOut) * ValueOut != Height)) &&
+ ((ValueOut < Height) && (ValueOut < Width)) &&
+ (ValueOut > 1))
+ {
+ ValueOut += ValueStep;
+ }
+
+ if ((ValueOut >= Height) || (ValueOut >= Width))
+ {
+ return;
+ }
+ CurrentSideLength = ValueOut;
+ ChessBoardTestInit (Ctx);
}