Restore the V4 WiFi setup QR with a one-pixel border
This commit is contained in:
1 parent
db143c5ed4
commit
d88b162f28
6 files changed
+94
-17
No files matched your search
@@ -106,6 +106,7 @@ public:
|
||||
int qr_x = -1;
|
||||
int qr_y = -1;
|
||||
int qr_size = -1;
|
||||
int qr_border = -1;
|
||||
|
||||
QrTestDisplay(int width, int height, int glyph_width)
|
||||
: TestDisplay(width, height, glyph_width) {}
|
||||
@@ -116,6 +117,11 @@ public:
|
||||
qr_size = size;
|
||||
return true;
|
||||
}
|
||||
bool drawQrCodeWithBorder(const char* text, int x, int y, int size,
|
||||
int border) override {
|
||||
qr_border = border;
|
||||
return drawQrCode(text, x, y, size);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
@@ -163,6 +169,31 @@ TEST(WiFiSetupQrPayload, EncodesOpenSetupNetwork) {
|
||||
EXPECT_LE(strlen(small_payload), 17U);
|
||||
}
|
||||
|
||||
TEST(DisplayDriver, V4QrUsesOnePixelBorderAndKeepsActionsBesideTheCode) {
|
||||
QrTestDisplay display(128, 64, 6);
|
||||
ASSERT_TRUE(mesh::ui::drawWiFiSetupQr(
|
||||
display, "MC-F7F0", "192.168.4.1", true, "HOLD STOP"));
|
||||
EXPECT_EQ(44, display.qr_size);
|
||||
EXPECT_EQ(1, display.qr_border);
|
||||
EXPECT_EQ(21 * 2 + 2 * display.qr_border, display.qr_size);
|
||||
ASSERT_EQ(5U, display.rows.size());
|
||||
EXPECT_EQ("SCAN JOIN", display.rows[0].text);
|
||||
EXPECT_EQ("HOLD STOP", display.rows[1].text);
|
||||
EXPECT_EQ("192.168.4.1", display.rows.back().text);
|
||||
for (const auto& row : display.rows) {
|
||||
EXPECT_GE(row.x, display.qr_size + 4);
|
||||
EXPECT_LE(row.x + display.getTextWidth(row.text.c_str()), display.width());
|
||||
EXPECT_LE(row.y + 8, display.height());
|
||||
}
|
||||
}
|
||||
|
||||
TEST(DisplayDriver, V4QrKeepsFallbackWhenRendererIsUnavailable) {
|
||||
TestDisplay display(128, 64, 6);
|
||||
EXPECT_FALSE(mesh::ui::drawWiFiSetupQr(
|
||||
display, "MC-F7F0", "192.168.4.1", true, "HOLD STOP"));
|
||||
EXPECT_TRUE(display.rows.empty());
|
||||
}
|
||||
|
||||
TEST(WiFiSetupQrPayload, EscapesProtectedNetworkFields) {
|
||||
char payload[96];
|
||||
EXPECT_TRUE(mesh::ui::buildWiFiSetupQrPayload(
|
||||
|
||||
@@ -41,7 +41,7 @@ class HeltecV4WiFiSetupPageTest(unittest.TestCase):
|
||||
)
|
||||
self.assertNotIn("UI_WIFI_SETUP_HOME_PAGE", R8_PROFILE.read_text())
|
||||
|
||||
def test_compact_page_fits_128_by_64_without_qr_or_cli_copy(self):
|
||||
def test_compact_page_restores_qr_with_a_readable_text_fallback(self):
|
||||
ui = UI.read_text(encoding="utf-8")
|
||||
start = ui.index("static bool drawCompactCompanionWiFiSetupPage")
|
||||
end = ui.index("\nstatic void drawCompanionWiFiSetupPage", start)
|
||||
@@ -53,8 +53,12 @@ class HeltecV4WiFiSetupPageTest(unittest.TestCase):
|
||||
self.assertIn('"HOLD STOP AP" : "HOLD START AP"', compact)
|
||||
self.assertIn('snprintf(open_ip, sizeof(open_ip), "OPEN %s", setup_ip)', compact)
|
||||
self.assertIn("display.drawTextEllipsized", compact)
|
||||
self.assertNotIn("drawQrCode", compact)
|
||||
self.assertNotIn("buildWiFiSetupQrPayload", compact)
|
||||
self.assertIn("mesh::ui::drawWiFiSetupQr(", compact)
|
||||
self.assertIn('display, setup_ssid, setup_ip, true, "HOLD STOP"', compact)
|
||||
self.assertLess(compact.index("display.fillRect(0, 0,"),
|
||||
compact.index("mesh::ui::drawWiFiSetupQr("))
|
||||
self.assertLess(compact.index("mesh::ui::drawWiFiSetupQr("),
|
||||
compact.index('"SETUP AP ACTIVE"'))
|
||||
self.assertNotIn("start webconfig", compact.lower())
|
||||
|
||||
# Default size-one glyphs are six by eight logical pixels.
|
||||
|
||||
Reference in new issue
Block a user