Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 39 additions & 21 deletions test/CatchTests/KindleShortPagesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<KindleReadableScreen>(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));
Expand All @@ -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));
Expand All @@ -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));
}
}

Expand Down
63 changes: 42 additions & 21 deletions test/CatchTests/KindleTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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:
Expand All @@ -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());
Expand Down
25 changes: 12 additions & 13 deletions test/CatchTests/TestEPub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadableScreen>(screen);
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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");

Expand All @@ -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<ReadableScreen>(screen);
Expand Down Expand Up @@ -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 {
Expand All @@ -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");

Expand All @@ -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<ReadableScreen>(screen);
Expand Down Expand Up @@ -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.");
Expand Down
Loading
Loading