|
20 | 20 | #include "Misc/Dispatch.hpp" |
21 | 21 | #include "Misc/Platform.hpp" |
22 | 22 | #include "Misc/Telemetry.hpp" |
23 | | -#include "Models/Json.hpp" |
24 | 23 | #include "Models/KindleBook.hpp" |
25 | | -#include "Models/KindleChaptersResponse.hpp" |
26 | 24 | #include "Models/KindlePageFlipper.hpp" |
27 | 25 | #include "Sensors/LightingController.hpp" |
28 | 26 | #include "Storage/LocalStore.hpp" |
@@ -706,31 +704,31 @@ TEST_CASE("Kindle table of contents highlights current chapter", "[.][no-kindle] |
706 | 704 |
|
707 | 705 | const std::string midChapter = |
708 | 706 | R"({"success":true,"progress":{"current_page":35,"total_pages":1000},"chapters":[{"title":"Intro","uuid":"c1","page":1},{"title":"Middle","uuid":"c2","page":20},{"title":"Later","uuid":"c3","page":40}]})"; |
709 | | - auto midChapterResponse = std::make_shared<KindleChaptersResponse>(); |
710 | | - JsonDocument doc; |
711 | | - deserializeJson(doc, midChapter); |
712 | | - midChapterResponse->fromJson(doc.as<JsonObject>()); |
713 | | - tocScreen.handleTableOfContentsResponse(midChapterResponse); |
| 707 | + auto midResp = std::make_shared<KindleChaptersResponse>(); |
| 708 | + SpiRamJsonDocument doc1(2048); |
| 709 | + deserializeJson(doc1, midChapter); |
| 710 | + midResp->fromJson(doc1.as<JsonObject>()); |
| 711 | + tocScreen.handleTableOfContentsResponse(midResp); |
714 | 712 | REQUIRE(tocScreen.menuView_.getSelectedIndex() == 1); |
715 | 713 | REQUIRE(book->progressPercent == 4); |
716 | 714 |
|
717 | 715 | const std::string earlyChapter = |
718 | 716 | R"({"success":true,"progress":{"current_page":0,"total_pages":1000},"chapters":[{"title":"Intro","uuid":"c1","page":5},{"title":"Next","uuid":"c2","page":15}]})"; |
719 | | - auto earlyChapterResponse = std::make_shared<KindleChaptersResponse>(); |
720 | | - JsonDocument doc2; |
| 717 | + auto earlyResp = std::make_shared<KindleChaptersResponse>(); |
| 718 | + SpiRamJsonDocument doc2(2048); |
721 | 719 | deserializeJson(doc2, earlyChapter); |
722 | | - earlyChapterResponse->fromJson(doc2.as<JsonObject>()); |
723 | | - tocScreen.handleTableOfContentsResponse(earlyChapterResponse); |
| 720 | + earlyResp->fromJson(doc2.as<JsonObject>()); |
| 721 | + tocScreen.handleTableOfContentsResponse(earlyResp); |
724 | 722 | REQUIRE(tocScreen.menuView_.getSelectedIndex() == 0); |
725 | 723 | REQUIRE(book->progressPercent == 0); |
726 | 724 |
|
727 | 725 | const std::string lateChapter = |
728 | 726 | R"({"success":true,"progress":{"current_page":200,"total_pages":1000},"chapters":[{"title":"Intro","uuid":"c1","page":5},{"title":"Next","uuid":"c2","page":115},{"title":"Last","uuid":"c3","page":190}]})"; |
729 | | - auto lateChapterResponse = std::make_shared<KindleChaptersResponse>(); |
730 | | - JsonDocument doc3; |
| 727 | + auto lateResp = std::make_shared<KindleChaptersResponse>(); |
| 728 | + SpiRamJsonDocument doc3(2048); |
731 | 729 | deserializeJson(doc3, lateChapter); |
732 | | - lateChapterResponse->fromJson(doc3.as<JsonObject>()); |
733 | | - tocScreen.handleTableOfContentsResponse(lateChapterResponse); |
| 730 | + lateResp->fromJson(doc3.as<JsonObject>()); |
| 731 | + tocScreen.handleTableOfContentsResponse(lateResp); |
734 | 732 | REQUIRE(tocScreen.menuView_.getSelectedIndex() == 2); |
735 | 733 | REQUIRE(book->progressPercent == 20); |
736 | 734 | } |
|
0 commit comments