diff --git a/test/CatchTests/KindleShortPagesTest.cpp b/test/CatchTests/KindleShortPagesTest.cpp index 6713e0be6..fa3667451 100644 --- a/test/CatchTests/KindleShortPagesTest.cpp +++ b/test/CatchTests/KindleShortPagesTest.cpp @@ -349,42 +349,51 @@ TEST_CASE("Test Kindle multi-page fetching with short pages visual", "[.][kindle // Take initial screenshot of main menu // First screen renders twice WAIT_FOR_DRAW(display); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest00-MainMenu", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest00-MainMenu"); // Navigate to Kindle section SendRemoteCommand(RIGHT); WAIT_FOR_DRAW(display); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest01-KindleSection", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest01-KindleSection"); // Go to the last book in the list SendRemoteCommand(UP); WAIT_FOR_DRAW(display); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest02-ShortPagesBookSelected", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest02-ShortPagesBookSelected"); // Open the book - this should load then trigger the first last-read dialog from /open-book SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest03-Connecting", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest03-Connecting"); auto screen = UIGetCurrentScreen(); auto kindleScreen = std::dynamic_pointer_cast(screen); REQUIRE(kindleScreen != nullptr); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest04-Opening", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest04-Opening"); // Wait for the last-read dialog to be shown WAIT_FOR_DRAW(display); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest05-FirstLastReadDialog", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest05-FirstLastReadDialog"); // Accept the first dialog - should go to Chapter 42 SendRemoteCommand(ENTER); // Wait for the "Sync to last read page" message - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest06-SyncingToLastRead", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest06-SyncingToLastRead"); // TODO: Unknown why message page renders twice - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest06.5-SyncingToLastRead", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest06.5-SyncingToLastRead"); // Wait for content to render - this will be Chapter 42 - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest07-Chapter42Initial", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest07-Chapter42Initial"); // Wait for POST to complete via mock server REQUIRE(waitForLastReadPostCount(1)); @@ -393,27 +402,33 @@ TEST_CASE("Test Kindle multi-page fetching with short pages visual", "[.][kindle log_i("TEST: Paging forward through Chapter 42"); for (int i = 0; i < 3; i++) { SendRemoteCommand(RIGHT); - ASSERT_VIEW_UNCHANGED( - display, "ShortPagesTest09-Chapter42Forward" + std::to_string(i + 1), true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, + "ShortPagesTest09-Chapter42Forward" + std::to_string(i + 1)); } // Navigate to page 4 - should trigger second last-read dialog SendRemoteCommand(RIGHT); // Three: one to render the page, then two to render the menu - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest10-BeforeSecondLastReadDialog", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest10-BeforeSecondLastReadDialog"); WAIT_FOR_DRAW(display); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest12-SecondLastReadDialog", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest12-SecondLastReadDialog"); SendRemoteCommand(ENTER); // Wait for the "Sync to last read page" message - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest13-SyncingToPage10", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest13-SyncingToPage10"); // TODO: Unknown why message page renders twice - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest13.5-SyncingToPage10", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest13.5-SyncingToPage10"); // Wait for content to render - this will be Page 10 - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest14-Page10Initial", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest14-Page10Initial"); // Wait for POST to complete via mock server REQUIRE(waitForLastReadPostCount(2)); @@ -426,22 +441,25 @@ TEST_CASE("Test Kindle multi-page fetching with short pages visual", "[.][kindle // First RIGHT press - should move to PAGE 11 SendRemoteCommand(RIGHT); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest16-ForwardFrom10-1", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest16-ForwardFrom10-1"); // Second RIGHT press - should move to PAGE 12 SendRemoteCommand(RIGHT); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest16-ForwardFrom10-2", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest16-ForwardFrom10-2"); // Third RIGHT press - should move to PAGE 13 SendRemoteCommand(RIGHT); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest16-ForwardFrom10-3", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest16-ForwardFrom10-3"); // Page backward to verify backward navigation works log_i("TEST: Paging backward to verify backward navigation"); for (int i = 0; i < 2; i++) { SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest19-Backward" + std::to_string(i + 1), - true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "ShortPagesTest19-Backward" + std::to_string(i + 1)); } } diff --git a/test/CatchTests/KindleTests.cpp b/test/CatchTests/KindleTests.cpp index 8e5e3cd79..e112e86f9 100644 --- a/test/CatchTests/KindleTests.cpp +++ b/test/CatchTests/KindleTests.cpp @@ -887,7 +887,8 @@ TEST_CASE("Test Kindle navigation visual traversal", "[.][kindle]") { // 0. Open Kindle book SendRemoteCommand(RIGHT); WAIT_FOR_DRAW(display); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest00-BookMenu", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest00-BookMenu"); SendRemoteCommand(ENTER); @@ -902,66 +903,85 @@ TEST_CASE("Test Kindle navigation visual traversal", "[.][kindle]") { // Capture the initial page 0 (Lines 1-20) // Note: Initial content is already rendered before we can set up the callback, // so we just wait for the draw - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest01-InitialPage0", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest01-InitialPage0"); // 1. Navigate forward through 6 pages to pages 1-6 (clears buffer) SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest02-ForwardToPage1", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest02-ForwardToPage1"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest03-ForwardToPage2", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest03-ForwardToPage2"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest04-ForwardToPage3", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest04-ForwardToPage3"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest05-ForwardToPage4", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest05-ForwardToPage4"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest06-ForwardToPage5", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest06-ForwardToPage5"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest07-ForwardToPage6", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest07-ForwardToPage6"); // 2. Navigate backward through 6 pages // We're now on page 6, navigate back to page 0 // Navigate back 6 pages: 6 -> 5 -> 4 -> 3 -> 2 -> 1 -> 0 SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest08-BackToPage5", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest08-BackToPage5"); SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest09-BackToPage4", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest09-BackToPage4"); SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest10-BackToPage3", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest10-BackToPage3"); SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest11-BackToPage2", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest11-BackToPage2"); SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest12-BackToPage1", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest12-BackToPage1"); SendRemoteCommand(LEFT); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest13-BackToPage0", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest13-BackToPage0"); // 3. Navigate forward again through 6 pages from page 0 to page 6 SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest14-ForwardAgainToPage1", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest14-ForwardAgainToPage1"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest15-ForwardAgainToPage2", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest15-ForwardAgainToPage2"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest16-ForwardAgainToPage3", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest16-ForwardAgainToPage3"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest17-ForwardAgainToPage4", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest17-ForwardAgainToPage4"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest18-ForwardAgainToPage5", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest18-ForwardAgainToPage5"); SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest19-ForwardAgainToPage6", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest19-ForwardAgainToPage6"); // Verify mock server was called the expected number of times // With the buffer filling logic and 6-page navigation, we expect more calls: @@ -978,7 +998,8 @@ TEST_CASE("Test Kindle navigation visual traversal", "[.][kindle]") { // 4. Navigate to page 7 and beyond to trigger new server request SendRemoteCommand(ENTER); - ASSERT_VIEW_UNCHANGED(display, "KindleNavTest20-ForwardToPage7", true); + WAIT_FOR_DRAW(display, false); + ASSERT_VIEW_UNCHANGED(display, "KindleNavTest20-ForwardToPage7"); // After navigating to page 4, we should have more calls log_i("Mock server: Total navigate calls after page 4: %d", mockNavigateCallCount.load()); diff --git a/test/CatchTests/TestEPub.cpp b/test/CatchTests/TestEPub.cpp index 778d058e5..2f747b0db 100644 --- a/test/CatchTests/TestEPub.cpp +++ b/test/CatchTests/TestEPub.cpp @@ -108,18 +108,17 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { // First screen renders twice once with a full refresh and once with a AU4 WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "FirstScreen"); SECTION("Books") { SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); - // WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "OnePageTutorial"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); auto screen = UIGetCurrentScreen(); auto readableScreen = std::dynamic_pointer_cast(screen); @@ -147,7 +146,7 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { if (readableScreen->checkAtEnd()) break; SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); } } @@ -158,13 +157,13 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { SendRemoteCommand(UP); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastPagePopupMenu"); SendRemoteCommand(ENTER); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "MainMenu"); @@ -178,7 +177,7 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { WAIT_FOR_DRAW(display); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); screen = UIGetCurrentScreen(); readableScreen = std::dynamic_pointer_cast(screen); @@ -208,7 +207,7 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { if (readableScreen->checkAtEnd()) break; SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); } } else { @@ -218,13 +217,13 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { SendRemoteCommand(UP); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "MainMenu"); SendRemoteCommand(ENTER); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "ThirdScreen"); @@ -236,7 +235,7 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { WAIT_FOR_DRAW(display); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); screen = UIGetCurrentScreen(); readableScreen = std::dynamic_pointer_cast(screen); @@ -266,7 +265,7 @@ TEST_CASE("Test EPub Books Rendering", "[.][epub]") { if (readableScreen->checkAtEnd()) break; SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); } } else { UNSCOPED_INFO("Unable to get ReadableScreen instance for Book3."); diff --git a/test/CatchTests/TestViews.cpp b/test/CatchTests/TestViews.cpp index ec74e4eda..c53a547e3 100644 --- a/test/CatchTests/TestViews.cpp +++ b/test/CatchTests/TestViews.cpp @@ -44,7 +44,7 @@ TEST_CASE("First few screens render correctly and handle remote commands") { // First screen renders twice once with a full refresh and once with a AU4 WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "FirstScreen"); @@ -62,7 +62,7 @@ TEST_CASE("First few screens render correctly and handle remote commands") { SendRemoteCommand(ENTER); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "ContentSettings"); @@ -77,12 +77,12 @@ TEST_CASE("First few screens render correctly and handle remote commands") { // Render a bunch of readable pages SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "ReadableIntro"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion1"); // Check to make sure going forward from page 1 and then back @@ -90,7 +90,7 @@ TEST_CASE("First few screens render correctly and handle remote commands") { SendRemoteCommand(ENTER); WAIT_FOR_DRAW(display); SendRemoteCommand(LEFT); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion1"); // This is the new default way to get a bookmark on a page @@ -101,13 +101,13 @@ TEST_CASE("First few screens render correctly and handle remote commands") { WAIT_FOR_DRAW(display); WAIT_FOR_DRAW(display); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion1Bookmarked"); // Render the popup menu to confirm page 1 SendRemoteCommand(UP); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PopupMenu1"); // Return to book on page 1 @@ -118,27 +118,27 @@ TEST_CASE("First few screens render correctly and handle remote commands") { // Start paging through the book SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion2"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion3"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion4"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion5"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion6"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "LastQuestion7"); // Navigate to seek in the popup menu @@ -149,7 +149,7 @@ TEST_CASE("First few screens render correctly and handle remote commands") { WAIT_FOR_DRAW(display); WAIT_FOR_DRAW(display); SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PopupMenu2"); // Seek to the end of the book, then confirm page number @@ -163,14 +163,15 @@ TEST_CASE("First few screens render correctly and handle remote commands") { WAIT_FOR_DRAW(display); for (int i = 0; i < 10; i++) { SendRemoteCommand(RIGHT); - WAIT_FOR_DRAW(display); + // Only wait on the last one + WAIT_FOR_DRAW(display, i != 9); } ASSERT_VIEW_UNCHANGED(display, "SeekingAround"); SendRemoteCommand(UP); WAIT_FOR_DRAW(display); SendRemoteCommand(UP); // Show popup menu and we are on seek item still WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PopupMenu3"); // Go back to the main menu @@ -202,13 +203,13 @@ TEST_CASE("First few screens render correctly and handle remote commands") { for (int i = 0; i < 6; i++) { SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, i != 5); } ASSERT_VIEW_UNCHANGED(display, "PopupTOC"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Dawn"); @@ -220,7 +221,7 @@ TEST_CASE("First few screens render correctly and handle remote commands") { WAIT_FOR_DRAW(display); WAIT_FOR_DRAW(display); SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); // Should show the updated seeked spot from the TOC ASSERT_VIEW_UNCHANGED(display, "PopupMenu4"); @@ -228,7 +229,7 @@ TEST_CASE("First few screens render correctly and handle remote commands") { SendRemoteCommand(UP); WAIT_FOR_DRAW(display); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Dawn1"); // Render the popup menu, navigate to Contents @@ -237,19 +238,19 @@ TEST_CASE("First few screens render correctly and handle remote commands") { WAIT_FOR_DRAW(display); SendRemoteCommand(LEFT); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PopupMenu5"); // Open the next chapter to ensure the dictionary shows something different SendRemoteCommand(ENTER); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "DawnToC"); SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "DawnToC2"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Dawn2"); @@ -263,36 +264,36 @@ TEST_CASE("First few screens render correctly and handle remote commands") { SendRemoteCommand(DOWN); WAIT_FOR_DRAW(display); SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PopupMenu6"); // Open the summary SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary1"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary2"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary3"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary4"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary5"); SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary6"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary7"); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Summary8"); SendRemoteCommand(UP); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Dawn4"); // Render the popup menu and go to placemark history @@ -300,18 +301,18 @@ TEST_CASE("First few screens render correctly and handle remote commands") { WAIT_FOR_DRAW(display); WAIT_FOR_DRAW(display); SendRemoteCommand(DOWN); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PopupMenu7"); // Open the placemark history SendRemoteCommand(ENTER); WAIT_FOR_DRAW(display); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "PlacemarkHistory1"); SendRemoteCommand(DOWN); WAIT_FOR_DRAW(display); SendRemoteCommand(ENTER); - WAIT_FOR_DRAW(display); + WAIT_FOR_DRAW(display, false); ASSERT_VIEW_UNCHANGED(display, "Dawn5"); } } diff --git a/test/CatchTests/ViewTestCommon.cpp b/test/CatchTests/ViewTestCommon.cpp index 3a872e8e5..95cfa8d12 100644 --- a/test/CatchTests/ViewTestCommon.cpp +++ b/test/CatchTests/ViewTestCommon.cpp @@ -154,7 +154,7 @@ void StopFreeRtos() { log_i("Stopped FreeRTOS scheduler"); } -auto WaitForDraw(DisplayEinkET013TT1 &display, long timeoutSeconds, bool continueAfterDraw) +auto WaitForDraw(DisplayEinkET013TT1 &display, bool continueAfterDraw, long timeoutSeconds) -> bool { struct timespec startTime; clock_gettime(CLOCK_MONOTONIC, &startTime); @@ -174,9 +174,11 @@ auto WaitForDraw(DisplayEinkET013TT1 &display, long timeoutSeconds, bool continu clock_gettime(CLOCK_MONOTONIC, &endTime); // get current time elapsedTime = endTime.tv_sec - startTime.tv_sec; } - if (continueAfterDraw) { - xQueueReceiveFromISR(display.renderQueue(), &out, nullptr); + auto result = xQueueReceiveFromISR(display.renderQueue(), &out, nullptr); + if (result == pdFALSE) { + log_w("Warning: Failed to empty render queue after waiting"); + } } return true; @@ -225,8 +227,7 @@ static auto RepoRelative(const std::string &absolutePath) -> std::string { } // TODO: How do we use the test name also for the key -auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key, bool waitForDraw) - -> ViewTestResult { +auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key) -> ViewTestResult { log_i("Checking view unchanged for %s", key.c_str()); auto directory = GetDirectory(); ViewTestResult result = { @@ -240,19 +241,10 @@ auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key, bool wait std::filesystem::create_directories( std::filesystem::path(result.renderedImagePath).parent_path()); - if (waitForDraw) { - auto success = WaitForDraw(display, 10, false); - if (!success) { - UNSCOPED_INFO("CheckViewUnchanged timeout for key " << key); - result.passed = false; - return result; - } - } defer { - if (waitForDraw) { - uint8_t out; - xQueueReceiveFromISR(display.renderQueue(), &out, nullptr); - } + // Before returning, allow the display to continue + uint8_t out; + xQueueReceiveFromISR(display.renderQueue(), &out, nullptr); }; log_i("Saving image to %s (width=%d, height=%d)", @@ -285,7 +277,6 @@ auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key, bool wait std::filesystem::copy(result.renderedImagePath, result.acceptedImagePath, std::filesystem::copy_options::overwrite_existing); result.passed = true; - return result; } return result; }; @@ -336,9 +327,9 @@ auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key, bool wait return result; } -auto CheckViewUnchanged(std::shared_ptr display, std::string key, - bool waitForDraw) -> ViewTestResult { - return CheckViewUnchanged(*display, key, waitForDraw); +auto CheckViewUnchanged(std::shared_ptr display, std::string key) + -> ViewTestResult { + return CheckViewUnchanged(*display, key); } auto GetRootDisplay() -> DisplayEinkET013TT1 & { return myDisplay; } diff --git a/test/CatchTests/ViewTestCommon.hpp b/test/CatchTests/ViewTestCommon.hpp index 09d6a6d81..24bc6ea14 100644 --- a/test/CatchTests/ViewTestCommon.hpp +++ b/test/CatchTests/ViewTestCommon.hpp @@ -24,12 +24,12 @@ void SetImagesFolder(std::string folder); void SendRemoteCommand(RemoteCommand command); -auto WaitForDraw(DisplayEinkET013TT1 &display, long timeoutSeconds = 10, - bool continueAfterDraw = true) -> bool; +auto WaitForDraw(DisplayEinkET013TT1 &display, bool continueAfterDraw = true, + long timeoutSeconds = 10) -> bool; auto HasQueuedDraw(DisplayEinkET013TT1 &display) -> bool; -#define WAIT_FOR_DRAW(display) REQUIRE(WaitForDraw(display)) +#define WAIT_FOR_DRAW(display, ...) REQUIRE(WaitForDraw(display, ##__VA_ARGS__)) // TODO: This struct is probably overkill struct ViewTestResult { @@ -39,14 +39,12 @@ struct ViewTestResult { std::string diffImagePath; }; -auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key, bool waitForDraw = false) - -> ViewTestResult; +auto CheckViewUnchanged(DisplayEinkET013TT1 &display, std::string key) -> ViewTestResult; -auto CheckViewUnchanged(std::shared_ptr display, std::string key, - bool waitForDraw = false) -> ViewTestResult; +auto CheckViewUnchanged(std::shared_ptr display, std::string key) + -> ViewTestResult; -#define ASSERT_VIEW_UNCHANGED(display, key, ...) \ - CHECK(CheckViewUnchanged(display, key, ##__VA_ARGS__).passed) +#define ASSERT_VIEW_UNCHANGED(display, key) CHECK(CheckViewUnchanged(display, key).passed) auto GetRootDisplay() -> DisplayEinkET013TT1 &;