[post_and_hardware_tests] Bad pixels limit of 2, not 0

This commit is contained in:
Léa Saviot
2019-07-05 11:41:03 +02:00
parent 0efbdf96b0
commit 7b99f78352
4 changed files with 18 additions and 12 deletions

View File

@@ -29,8 +29,10 @@ bool POSTAndHardwareTests::TextLCDTestOK() {
KDIonContext::sharedContext()->drawString(text, KDPoint(0, i * glyphHeight), font);
}
// Check the drawing
int numberOfFailures = 0;
for (int i = 0; i < Ion::Display::Height / glyphHeight; i++) {
if (!KDIonContext::sharedContext()->checkDrawnString(text, KDPoint(0, i * glyphHeight), font)) {
numberOfFailures += KDIonContext::sharedContext()->checkDrawnString(text, KDPoint(0, i * glyphHeight), font);
if (numberOfFailures > k_acceptableNumberOfFailures) {
return false;
}
}
@@ -49,6 +51,7 @@ bool POSTAndHardwareTests::LCDDataOK() {
bool POSTAndHardwareTests::TilingLCDTestOK() {
Ion::Display::POSTPushMulticolor(k_stampSize);
KDColor stamp[k_stampSize*k_stampSize];
int numberOfFailures = 0;
for (int i = 0; i < Ion::Display::Width / k_stampSize; i++) {
for (int j = 0; j < Ion::Display::Height / k_stampSize; j++) {
Ion::Display::pullRect(KDRect(i * k_stampSize, j * k_stampSize, k_stampSize, k_stampSize), stamp);
@@ -56,7 +59,10 @@ bool POSTAndHardwareTests::TilingLCDTestOK() {
uint16_t color = (uint16_t)(1 << shift);
for (int k = 0; k < k_stampSize*k_stampSize; k++) {
if (stamp[k] != color) {
return false;
numberOfFailures++;
if (numberOfFailures > k_acceptableNumberOfFailures) {
return false;
}
}
color ^= 0xFFFF;
}

View File

@@ -23,6 +23,7 @@ public:
private:
constexpr static int k_stampSize = 8;
constexpr static int k_numberOfLCDIterations = 20;
constexpr static int k_acceptableNumberOfFailures = 2;
static bool TilingLCDTestOK();
static_assert(Ion::Display::Width % k_stampSize == 0, "Stamps must tesselate the display");
static_assert(Ion::Display::Height % k_stampSize == 0, "Stamps must tesselate the display");

View File

@@ -18,7 +18,7 @@ public:
// Text
KDPoint drawString(const char * text, KDPoint p, const KDFont * font = KDFont::LargeFont, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1);
// Check that a string is drawn.
bool checkDrawnString(const char * text, KDPoint p, const KDFont * font = KDFont::LargeFont, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1);
int checkDrawnString(const char * text, KDPoint p, const KDFont * font = KDFont::LargeFont, KDColor textColor = KDColorBlack, KDColor backgroundColor = KDColorWhite, int maxLength = -1);
// Line. Not anti-aliased.
void drawLine(KDPoint p1, KDPoint p2, KDColor c);
@@ -35,7 +35,7 @@ protected:
virtual void pullRect(KDRect rect, KDColor * pixels) = 0;
private:
KDRect absoluteFillRect(KDRect rect);
KDPoint pushOrPullString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxByteLength, bool push, bool * result = nullptr);
KDPoint pushOrPullString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxByteLength, bool push, int * result = nullptr);
KDPoint m_origin;
KDRect m_clippingRect;
};

View File

@@ -10,13 +10,13 @@ KDPoint KDContext::drawString(const char * text, KDPoint p, const KDFont * font,
return pushOrPullString(text, p, font, textColor, backgroundColor, maxByteLength, true);
}
bool KDContext::checkDrawnString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxLength) {
bool result = true;
pushOrPullString(text, p, font, textColor, backgroundColor, maxLength, false, &result);
return result;
int KDContext::checkDrawnString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxLength) {
int numberOfFailedPixels = 0;
pushOrPullString(text, p, font, textColor, backgroundColor, maxLength, false, &numberOfFailedPixels);
return numberOfFailedPixels;
}
KDPoint KDContext::pushOrPullString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxByteLength, bool push, bool * result) {
KDPoint KDContext::pushOrPullString(const char * text, KDPoint p, const KDFont * font, KDColor textColor, KDColor backgroundColor, int maxByteLength, bool push, int * result) {
KDPoint position = p;
KDSize glyphSize = font->glyphSize();
KDFont::RenderPalette palette = font->renderPalette(textColor, backgroundColor);
@@ -53,7 +53,7 @@ KDPoint KDContext::pushOrPullString(const char * text, KDPoint p, const KDFont *
} else {
// Pull and compare the character from the screen
assert(result != nullptr);
*result = true;
*result = 0;
KDFont::GlyphBuffer workingGlyphBuffer;
KDColor * workingColorBuffer = workingGlyphBuffer.colorBuffer();
KDColor * colorBuffer = glyphBuffer.colorBuffer();
@@ -65,8 +65,7 @@ KDPoint KDContext::pushOrPullString(const char * text, KDPoint p, const KDFont *
Ion::Display::pullRect(KDRect(position, glyphSize), workingColorBuffer);
for (int k = 0; k < glyphSize.height() * glyphSize.width(); k++) {
if (colorBuffer[k] != workingColorBuffer[k]) {
*result = false;
return position;
*result = (*result)+1;
}
}
}