From 07450e9fe80913d280b80cb6eec11572c015ff1c Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 06:36:47 -0600 Subject: Add tests aopacket --- test/CMakeLists.txt | 6 ++++++ test/test_aopacket.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 test/CMakeLists.txt create mode 100644 test/test_aopacket.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..cc02859 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,6 @@ +find_package(Qt5 COMPONENTS Widgets REQUIRED) +find_package(Catch2 REQUIRED) + +add_executable(test test_aopacket.cpp ../include/aopacket.h ../src/aopacket.cpp) +target_include_directories(test PRIVATE ../include) +target_link_libraries(test PRIVATE Qt5::Widgets Catch2::Catch2) diff --git a/test/test_aopacket.cpp b/test/test_aopacket.cpp new file mode 100644 index 0000000..a5aeb43 --- /dev/null +++ b/test/test_aopacket.cpp @@ -0,0 +1,47 @@ +#define CATCH_CONFIG_MAIN +#include + +#include "aopacket.h" + +TEST_CASE("AOPacket construct", "[aopacket]") { + // Parameters + QString packet_string = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d/123/edit##%"; + QString header = "CT"; + QStringList contents = {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/123/edit#"}; + + // Packet string only + AOPacket p(packet_string); + REQUIRE(p.to_string() == packet_string); + + // Header and Contents Separate + AOPacket p2(header, contents); + REQUIRE(p2.to_string() == packet_string); +} + +TEST_CASE("AOPacket encode/decode", "[aopacket]") { + // Parameters + QString packet_string = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d/%$&/edit##%"; + QString header = "CT"; + QStringList contents = {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/%$&/edit#"}; + + // Encodes that get "sent" to the server + QString bad_send = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d//edit##%"; + QString good_send = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d//edit#%"; + + // Bad encode/decode for docs because the split on '#' after "edit" in the doc url + AOPacket p(packet_string); + p.net_encode(); + REQUIRE(p.to_string() == bad_send); + + p.net_decode(); + REQUIRE(p.to_string() == packet_string); + + // Good encode/decode for docs because header and contents are separate + AOPacket p2(header, contents); + + p2.net_encode(); + REQUIRE(p2.to_string() == good_send); + + p2.net_decode(); + REQUIRE(p2.to_string() == packet_string); +} -- cgit From fd5387caf839ec6074545bce59fec7598faec57e Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 12:09:04 -0600 Subject: Link a more relevant qt lib --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cc02859..ea163c1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ -find_package(Qt5 COMPONENTS Widgets REQUIRED) +find_package(Qt5 COMPONENTS Core REQUIRED) find_package(Catch2 REQUIRED) add_executable(test test_aopacket.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) -target_link_libraries(test PRIVATE Qt5::Widgets Catch2::Catch2) +target_link_libraries(test PRIVATE Qt5::Core Catch2::Catch2) -- cgit From b1090d6e271ae2b04854462c242ef2ce87d74822 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 20:08:27 -0600 Subject: Add test for case loading --- test/CMakeLists.txt | 2 +- test/test_caseloading.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test/test_caseloading.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ea163c1..3dd51c7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ find_package(Qt5 COMPONENTS Core REQUIRED) find_package(Catch2 REQUIRED) -add_executable(test test_aopacket.cpp ../include/aopacket.h ../src/aopacket.cpp) +add_executable(test test_aopacket.cpp test_caseloading.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_libraries(test PRIVATE Qt5::Core Catch2::Catch2) diff --git a/test/test_caseloading.cpp b/test/test_caseloading.cpp new file mode 100644 index 0000000..5df2782 --- /dev/null +++ b/test/test_caseloading.cpp @@ -0,0 +1,18 @@ +#include + +#include + +TEST_CASE("Sort case evidence numerically", "[case]") { + // Parameters + QStringList case_evidence = {"1", "10", "11", "2", "3", "4", "5", "6", "7", "8", "9"}; + QStringList case_evidence_sorted = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"}; + + // Sort + std::sort(case_evidence.begin(), case_evidence.end(), + [] (const QString &a, const QString &b) { + return a.toInt() < b.toInt(); + }); + + // Test + REQUIRE(case_evidence == case_evidence_sorted); +} -- cgit From 337b056400955c9384accf4bb4f3a58a768852cf Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 23:57:43 -0600 Subject: Add test for apng --- test/CMakeLists.txt | 6 +++--- test/test_apng.cpp | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 test/test_apng.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3dd51c7..31aab1e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ -find_package(Qt5 COMPONENTS Core REQUIRED) +find_package(Qt5 COMPONENTS Core Gui REQUIRED) find_package(Catch2 REQUIRED) -add_executable(test test_aopacket.cpp test_caseloading.cpp ../include/aopacket.h ../src/aopacket.cpp) +add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) -target_link_libraries(test PRIVATE Qt5::Core Catch2::Catch2) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2) diff --git a/test/test_apng.cpp b/test/test_apng.cpp new file mode 100644 index 0000000..c1c0481 --- /dev/null +++ b/test/test_apng.cpp @@ -0,0 +1,15 @@ +#include + +#include +#include +#include + +TEST_CASE("Support APNG Plugin (place lib same path)", "[apng]") { + QCoreApplication::addLibraryPath("."); + QPluginLoader apngPlugin("qapng"); + REQUIRE(apngPlugin.load()); + + // Fails for some reason on windows and linux don't know about osx + // apng animation seems to be broken linux qt5-5.15.2 + REQUIRE(QImageReader::supportedImageFormats().contains("APNG")); +} -- cgit From 1fc6c855684ad6ef00f5ff3d646df043363ee100 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:15:19 -0600 Subject: Add test for streaming with BASS --- test/CMakeLists.txt | 5 +++-- test/test_bass.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 test/test_bass.cpp (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 31aab1e..4249f1b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,7 @@ find_package(Qt5 COMPONENTS Core Gui REQUIRED) find_package(Catch2 REQUIRED) -add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp ../include/aopacket.h ../src/aopacket.cpp) +add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) -target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2) +target_link_directories(test PRIVATE ../lib) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass) diff --git a/test/test_bass.cpp b/test/test_bass.cpp new file mode 100644 index 0000000..0709fb9 --- /dev/null +++ b/test/test_bass.cpp @@ -0,0 +1,28 @@ +#include +#include + +#include +#include + +#include "bass.h" + +TEST_CASE("BASS URL streaming", "[bass]") { + // Sample + QString url = "https://raw.githubusercontent.com/skyedeving/aocharedit/master/Attorney%20Online%20Character%20Editor/Resources/about.mp3"; + BASS_Init(-1, 44100, 0, 0, nullptr); +#ifdef _WIN32 + HSTREAM stream = BASS_StreamCreateURL(url.toWStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0); +#else + HSTREAM stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0); +#endif + const char *tags = BASS_ChannelGetTags(stream, BASS_TAG_HTTP); + if (tags) { + while(*tags) { + UNSCOPED_INFO(tags); + tags += strlen(tags) + 1; + } + } + REQUIRE(stream != 0); + REQUIRE(BASS_ChannelPlay(stream, TRUE) == TRUE); + // while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED); +} -- cgit From ba47b5d35e90f0e4a5ea55d00dbe82acba65fb56 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:46:40 -0600 Subject: Update bass streaming test to include opus as well --- test/CMakeLists.txt | 2 +- test/test_bass.cpp | 24 ++++++++++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4249f1b..840eabc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,4 +4,4 @@ find_package(Catch2 REQUIRED) add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_directories(test PRIVATE ../lib) -target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus) diff --git a/test/test_bass.cpp b/test/test_bass.cpp index 0709fb9..2435749 100644 --- a/test/test_bass.cpp +++ b/test/test_bass.cpp @@ -5,16 +5,26 @@ #include #include "bass.h" +#include "bassopus.h" TEST_CASE("BASS URL streaming", "[bass]") { // Sample QString url = "https://raw.githubusercontent.com/skyedeving/aocharedit/master/Attorney%20Online%20Character%20Editor/Resources/about.mp3"; + + // initialize BASS_Init(-1, 44100, 0, 0, nullptr); -#ifdef _WIN32 - HSTREAM stream = BASS_StreamCreateURL(url.toWStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0); -#else - HSTREAM stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, BASS_STREAM_STATUS, nullptr, 0); -#endif + + // create stream from url + HSTREAM stream; + unsigned int flags = BASS_STREAM_AUTOFREE | BASS_STREAM_STATUS; + if (url.endsWith(".opus")) { + stream = BASS_OPUS_StreamCreateURL(url.toStdString().c_str(), 0, flags, nullptr, 0); + } + else { + stream = BASS_StreamCreateURL(url.toStdString().c_str(), 0, flags, nullptr, 0); + } + + // Log http status const char *tags = BASS_ChannelGetTags(stream, BASS_TAG_HTTP); if (tags) { while(*tags) { @@ -22,7 +32,9 @@ TEST_CASE("BASS URL streaming", "[bass]") { tags += strlen(tags) + 1; } } + + // Test REQUIRE(stream != 0); REQUIRE(BASS_ChannelPlay(stream, TRUE) == TRUE); - // while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED); + // while (BASS_ChannelIsActive(stream) != BASS_ACTIVE_STOPPED); // block test to listen } -- cgit From 7a1d6743e1b1c59d7315914f72f523509808ad1f Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 22:51:15 -0600 Subject: Refactor aopacket tests --- test/test_aopacket.cpp | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) (limited to 'test') diff --git a/test/test_aopacket.cpp b/test/test_aopacket.cpp index a5aeb43..b289f85 100644 --- a/test/test_aopacket.cpp +++ b/test/test_aopacket.cpp @@ -6,42 +6,38 @@ TEST_CASE("AOPacket construct", "[aopacket]") { // Parameters QString packet_string = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d/123/edit##%"; - QString header = "CT"; - QStringList contents = {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/123/edit#"}; - // Packet string only - AOPacket p(packet_string); - REQUIRE(p.to_string() == packet_string); - - // Header and Contents Separate - AOPacket p2(header, contents); - REQUIRE(p2.to_string() == packet_string); + SECTION("Packet string") { + AOPacket p(packet_string); + REQUIRE(p.to_string() == packet_string); + } + SECTION("Header and contents") { + AOPacket p("CT", {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/123/edit#"}); + REQUIRE(p.to_string() == packet_string); + } } TEST_CASE("AOPacket encode/decode", "[aopacket]") { // Parameters QString packet_string = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d/%$&/edit##%"; - QString header = "CT"; - QStringList contents = {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/%$&/edit#"}; - - // Encodes that get "sent" to the server - QString bad_send = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d//edit##%"; - QString good_send = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d//edit#%"; + QString good_encode = "CT#MY_OOC_NAME#/doc https://docs.google.com/document/d//edit#%"; - // Bad encode/decode for docs because the split on '#' after "edit" in the doc url - AOPacket p(packet_string); - p.net_encode(); - REQUIRE(p.to_string() == bad_send); + SECTION("Bad encode/decode because packet string constructor splits the '#' after 'edit'") { + AOPacket p(packet_string); + p.net_encode(); + REQUIRE(p.to_string() != good_encode); - p.net_decode(); - REQUIRE(p.to_string() == packet_string); + p.net_decode(); + REQUIRE(p.to_string() == packet_string); + } - // Good encode/decode for docs because header and contents are separate - AOPacket p2(header, contents); + SECTION("Good encode/decode with header and contents constructor") { + AOPacket p("CT", {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/%$&/edit#"}); - p2.net_encode(); - REQUIRE(p2.to_string() == good_send); + p.net_encode(); + REQUIRE(p.to_string() == good_encode); - p2.net_decode(); - REQUIRE(p2.to_string() == packet_string); + p.net_decode(); + REQUIRE(p.to_string() == packet_string); + } } -- cgit From f1d12d17a06ad00f8e092bc47b4ef675ff4303ad Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 23:02:12 -0600 Subject: Fix compile error Forgot about passing rvalues --- test/test_aopacket.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_aopacket.cpp b/test/test_aopacket.cpp index b289f85..0b31821 100644 --- a/test/test_aopacket.cpp +++ b/test/test_aopacket.cpp @@ -12,7 +12,8 @@ TEST_CASE("AOPacket construct", "[aopacket]") { REQUIRE(p.to_string() == packet_string); } SECTION("Header and contents") { - AOPacket p("CT", {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/123/edit#"}); + QStringList contents = {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/123/edit#"}; + AOPacket p("CT", contents); REQUIRE(p.to_string() == packet_string); } } @@ -32,7 +33,8 @@ TEST_CASE("AOPacket encode/decode", "[aopacket]") { } SECTION("Good encode/decode with header and contents constructor") { - AOPacket p("CT", {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/%$&/edit#"}); + QStringList contents = {"MY_OOC_NAME", "/doc https://docs.google.com/document/d/%$&/edit#"}; + AOPacket p("CT", contents); p.net_encode(); REQUIRE(p.to_string() == good_encode); -- cgit From 341c658cde9808eedb789981b51fa89edb71e4cd Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 23:09:46 -0600 Subject: Test for both apng and APNG in supported image formats --- test/test_apng.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index c1c0481..9c15e3c 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -11,5 +11,6 @@ TEST_CASE("Support APNG Plugin (place lib same path)", "[apng]") { // Fails for some reason on windows and linux don't know about osx // apng animation seems to be broken linux qt5-5.15.2 - REQUIRE(QImageReader::supportedImageFormats().contains("APNG")); + REQUIRE((QImageReader::supportedImageFormats().contains("apng") || + QImageReader::supportedImageFormats().contains("APNG"))); } -- cgit From b3dd00270e6d644864ced766a0f1ec2bb3a89a78 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 23:21:37 -0600 Subject: Add info to failing test case --- test/test_apng.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 9c15e3c..026826b 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -11,6 +11,7 @@ TEST_CASE("Support APNG Plugin (place lib same path)", "[apng]") { // Fails for some reason on windows and linux don't know about osx // apng animation seems to be broken linux qt5-5.15.2 + INFO(QImageReader::supportedImageFormats().join(' ').toStdString()); REQUIRE((QImageReader::supportedImageFormats().contains("apng") || QImageReader::supportedImageFormats().contains("APNG"))); } -- cgit From be0fa26e85de1edaa5c7e0e68d62d9f59f854753 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Wed, 6 Jan 2021 00:43:30 -0600 Subject: Test seems to work if linking QtApng installed on system --- test/CMakeLists.txt | 2 +- test/test_apng.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 840eabc..e09e48e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,4 +4,4 @@ find_package(Catch2 REQUIRED) add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_directories(test PRIVATE ../lib) -target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus qapng) diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 026826b..7d7062b 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -4,14 +4,15 @@ #include #include -TEST_CASE("Support APNG Plugin (place lib same path)", "[apng]") { +TEST_CASE("Support APNG Plugin", "[apng]") { + // Check paths for libs QCoreApplication::addLibraryPath("."); + QCoreApplication::addLibraryPath("lib"); + + // Either it's loaded from system or we load local QPluginLoader apngPlugin("qapng"); - REQUIRE(apngPlugin.load()); + apngPlugin.load(); - // Fails for some reason on windows and linux don't know about osx - // apng animation seems to be broken linux qt5-5.15.2 INFO(QImageReader::supportedImageFormats().join(' ').toStdString()); - REQUIRE((QImageReader::supportedImageFormats().contains("apng") || - QImageReader::supportedImageFormats().contains("APNG"))); + REQUIRE(QImageReader::supportedImageFormats().contains("apng")); } -- cgit From 26887eff32640ccb5bcf1d0e042dee31b4e7aa9a Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Wed, 6 Jan 2021 01:35:13 -0600 Subject: Check if the explicit linking is unnecessary --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e09e48e..840eabc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,4 +4,4 @@ find_package(Catch2 REQUIRED) add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_directories(test PRIVATE ../lib) -target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus qapng) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus) -- cgit From bd5ed84c1678877e7500558f0e455bed4d653766 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Wed, 6 Jan 2021 01:46:34 -0600 Subject: Add DISCORD compile definition to tests too --- test/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 840eabc..aa26ae4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,4 +4,5 @@ find_package(Catch2 REQUIRED) add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_directories(test PRIVATE ../lib) -target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus discord-rpc) +target_compile_definitions(Attorney_Online PRIVATE DISCORD) -- cgit From a8fdea09b046a7c9c4fbb00d878fbb693abecdde Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 03:15:45 -0600 Subject: Add test for detecting png animation --- test/CMakeLists.txt | 4 ++-- test/test_apng.cpp | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index aa26ae4..e43b551 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,8 +1,8 @@ -find_package(Qt5 COMPONENTS Core Gui REQUIRED) +find_package(Qt5 COMPONENTS Core Gui Widgets REQUIRED) find_package(Catch2 REQUIRED) add_executable(test test_aopacket.cpp test_caseloading.cpp test_apng.cpp test_bass.cpp ../include/aopacket.h ../src/aopacket.cpp) target_include_directories(test PRIVATE ../include) target_link_directories(test PRIVATE ../lib) -target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Catch2::Catch2 bass bassopus discord-rpc) +target_link_libraries(test PRIVATE Qt5::Core Qt5::Gui Qt5::Widgets Catch2::Catch2 bass bassopus discord-rpc) target_compile_definitions(Attorney_Online PRIVATE DISCORD) diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 7d7062b..cbeb68a 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include TEST_CASE("Support APNG Plugin", "[apng]") { // Check paths for libs @@ -16,3 +18,22 @@ TEST_CASE("Support APNG Plugin", "[apng]") { INFO(QImageReader::supportedImageFormats().join(' ').toStdString()); REQUIRE(QImageReader::supportedImageFormats().contains("apng")); } + +TEST_CASE("Detect png animation", "[apng]") { + // Required for QPixmap methods + int argc = 1; + char bin[] = "test"; + char *argv[] = { bin }; + QApplication app(argc, argv); + + // Detect apng supports animation + QImageReader a("snackoo.png", "apng"); + REQUIRE(a.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(a.read()).isNull()); + + // Detect png frame has no animation + QImageReader p("snackoo-frame.png", "apng"); + REQUIRE(!p.supportsAnimation()); + p.setFormat("png"); + REQUIRE(!QPixmap::fromImage(p.read()).isNull()); +} -- cgit From 608d6dff61ba55fb29e21fde5e1d2b6b63479901 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 03:22:23 -0600 Subject: Try to fix CI --- test/test_apng.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index cbeb68a..c15bebb 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -3,7 +3,7 @@ #include #include #include -#include +#include #include TEST_CASE("Support APNG Plugin", "[apng]") { @@ -24,7 +24,7 @@ TEST_CASE("Detect png animation", "[apng]") { int argc = 1; char bin[] = "test"; char *argv[] = { bin }; - QApplication app(argc, argv); + QGuiApplication app(argc, argv); // Detect apng supports animation QImageReader a("snackoo.png", "apng"); -- cgit From 6e679056b52abc9f48f0cfc9129b2bd708515b69 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 03:39:02 -0600 Subject: Add tag for not running test in ci --- test/test_apng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index c15bebb..fdfb8dd 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -19,7 +19,7 @@ TEST_CASE("Support APNG Plugin", "[apng]") { REQUIRE(QImageReader::supportedImageFormats().contains("apng")); } -TEST_CASE("Detect png animation", "[apng]") { +TEST_CASE("Detect png animation", "[apng][noci]") { // Required for QPixmap methods int argc = 1; char bin[] = "test"; -- cgit From 517ebdf2479647cd7c42166ec0c292d86ec3aace Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 03:57:04 -0600 Subject: Add test case for auto detect of apng from png failing --- test/test_apng.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index fdfb8dd..180465a 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -36,4 +36,11 @@ TEST_CASE("Detect png animation", "[apng][noci]") { REQUIRE(!p.supportsAnimation()); p.setFormat("png"); REQUIRE(!QPixmap::fromImage(p.read()).isNull()); + + // Auto detect fails + QImageReader d; + d.setAutoDetectImageFormat(true); + d.setFileName("snackoo.png"); + REQUIRE(!d.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(d.read()).isNull()); } -- cgit From c7f86707949b654a50bc8e6240e665d53ec2a056 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:03:51 -0600 Subject: Add test case for apng failed to detect from content --- test/test_apng.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 180465a..50965ad 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -37,10 +37,17 @@ TEST_CASE("Detect png animation", "[apng][noci]") { p.setFormat("png"); REQUIRE(!QPixmap::fromImage(p.read()).isNull()); - // Auto detect fails + // Auto detect fails on apng QImageReader d; - d.setAutoDetectImageFormat(true); + d.setDecideFormatFromContent(true); d.setFileName("snackoo.png"); REQUIRE(!d.supportsAnimation()); REQUIRE(!QPixmap::fromImage(d.read()).isNull()); + + // Decide format fom content fails on apng + QImageReader c; + c.setDecideFormatFromContent(true); + c.setFileName("snackoo.png"); + REQUIRE(!c.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(c.read()).isNull()); } -- cgit From 29354d919fad2da8c26054abb796ed7a270f278d Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:05:25 -0600 Subject: Undo accidentally overwrite --- test/test_apng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 50965ad..403034b 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -39,7 +39,7 @@ TEST_CASE("Detect png animation", "[apng][noci]") { // Auto detect fails on apng QImageReader d; - d.setDecideFormatFromContent(true); + d.setAutoDetectImageFormat(true); d.setFileName("snackoo.png"); REQUIRE(!d.supportsAnimation()); REQUIRE(!QPixmap::fromImage(d.read()).isNull()); -- cgit From 760d5861604b63b088943552fb70863952fa060e Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:22:18 -0600 Subject: Refactor the test for detecting apng from png --- test/test_apng.cpp | 56 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 403034b..93550b5 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -26,28 +26,36 @@ TEST_CASE("Detect png animation", "[apng][noci]") { char *argv[] = { bin }; QGuiApplication app(argc, argv); - // Detect apng supports animation - QImageReader a("snackoo.png", "apng"); - REQUIRE(a.supportsAnimation()); - REQUIRE(!QPixmap::fromImage(a.read()).isNull()); - - // Detect png frame has no animation - QImageReader p("snackoo-frame.png", "apng"); - REQUIRE(!p.supportsAnimation()); - p.setFormat("png"); - REQUIRE(!QPixmap::fromImage(p.read()).isNull()); - - // Auto detect fails on apng - QImageReader d; - d.setAutoDetectImageFormat(true); - d.setFileName("snackoo.png"); - REQUIRE(!d.supportsAnimation()); - REQUIRE(!QPixmap::fromImage(d.read()).isNull()); - - // Decide format fom content fails on apng - QImageReader c; - c.setDecideFormatFromContent(true); - c.setFileName("snackoo.png"); - REQUIRE(!c.supportsAnimation()); - REQUIRE(!QPixmap::fromImage(c.read()).isNull()); + // Instantiate reader + QImageReader reader; + + SECTION("Decide format from content fails on apng") { + reader.setFileName("snackoo.png"); + reader.setDecideFormatFromContent(true); + REQUIRE(!reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } + + SECTION("Auto detect fails on apng") { + reader.setFileName("snackoo.png"); + reader.setAutoDetectImageFormat(true); + REQUIRE(!reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } + + SECTION("Detect apng supports animation") { + reader.setFileName("snackoo.png"); + reader.setFormat("apng"); + REQUIRE(reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } + + SECTION("Detect png frame has no animation") { + reader.setFileName("snackoo-frame.png"); + reader.setFormat("apng"); + REQUIRE(!reader.supportsAnimation()); + reader.setFormat("png"); + REQUIRE(!reader.supportsAnimation()); + REQUIRE(!QPixmap::fromImage(reader.read()).isNull()); + } } -- cgit From cbdeea00109fa8b7bd052653938ac106514c1133 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:29:49 -0600 Subject: Add test resources in and enable tests --- test/missle.png | Bin 0 -> 55423 bytes test/snackoo.png | Bin 0 -> 92034 bytes test/test_apng.cpp | 4 ++-- 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 test/missle.png create mode 100644 test/snackoo.png (limited to 'test') diff --git a/test/missle.png b/test/missle.png new file mode 100644 index 0000000..6f373b4 Binary files /dev/null and b/test/missle.png differ diff --git a/test/snackoo.png b/test/snackoo.png new file mode 100644 index 0000000..31577a3 Binary files /dev/null and b/test/snackoo.png differ diff --git a/test/test_apng.cpp b/test/test_apng.cpp index 93550b5..20c7e92 100644 --- a/test/test_apng.cpp +++ b/test/test_apng.cpp @@ -19,7 +19,7 @@ TEST_CASE("Support APNG Plugin", "[apng]") { REQUIRE(QImageReader::supportedImageFormats().contains("apng")); } -TEST_CASE("Detect png animation", "[apng][noci]") { +TEST_CASE("Detect png animation", "[apng]") { // Required for QPixmap methods int argc = 1; char bin[] = "test"; @@ -51,7 +51,7 @@ TEST_CASE("Detect png animation", "[apng][noci]") { } SECTION("Detect png frame has no animation") { - reader.setFileName("snackoo-frame.png"); + reader.setFileName("missle.png"); reader.setFormat("apng"); REQUIRE(!reader.supportsAnimation()); reader.setFormat("png"); -- cgit From d73acf4d0d138efa7e85ed45c2f2df3ef2b99d96 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 04:44:10 -0600 Subject: Use noci tag for disabling bass test --- test/test_bass.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/test_bass.cpp b/test/test_bass.cpp index 2435749..f5f9198 100644 --- a/test/test_bass.cpp +++ b/test/test_bass.cpp @@ -7,7 +7,7 @@ #include "bass.h" #include "bassopus.h" -TEST_CASE("BASS URL streaming", "[bass]") { +TEST_CASE("BASS URL streaming", "[bass][noci]") { // Sample QString url = "https://raw.githubusercontent.com/skyedeving/aocharedit/master/Attorney%20Online%20Character%20Editor/Resources/about.mp3"; -- cgit