summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2025-02-11 00:39:24 +0100
committerCarl Hetherington <cth@carlh.net>2025-02-11 00:39:24 +0100
commit96163c06f9b4e964d6f831f1274b147c7c20fcb8 (patch)
tree8be02ae0d8063485387dadcc3ff249743e4b38b0
parentf5c60a80f3b79c8dfa918fbbcdc4b865b0d8344a (diff)
Add a test for the "analytics" code.
-rw-r--r--test/analytics_test.cc74
-rw-r--r--test/wscript1
2 files changed, 75 insertions, 0 deletions
diff --git a/test/analytics_test.cc b/test/analytics_test.cc
new file mode 100644
index 000000000..bc7db7f3d
--- /dev/null
+++ b/test/analytics_test.cc
@@ -0,0 +1,74 @@
+/*
+ Copyright (C) 2025 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#include "lib/analytics.h"
+#include <dcp/filesystem.h>
+#include <boost/test/unit_test.hpp>
+
+
+using std::string;
+
+
+BOOST_AUTO_TEST_CASE(many_successful_encodes_test)
+{
+ dcp::filesystem::remove_all(*State::override_path);
+
+ Analytics analytics;
+
+ string last_title;
+ string last_body;
+ analytics.Message.connect([&](string title, string body) {
+ last_title = title;
+ last_body = body;
+ });
+
+ for (int i = 0; i < 19; ++i) {
+ analytics.successful_dcp_encode();
+ BOOST_CHECK(last_title.empty());
+ BOOST_CHECK(last_body.empty());
+ }
+
+ analytics.successful_dcp_encode();
+ BOOST_CHECK_EQUAL(last_title, "Congratulations!");
+ BOOST_CHECK_EQUAL(last_body,
+ "<h2>You have made 20 DCPs with DCP-o-matic!</h2>"
+ "<img width=\"20%%\" src=\"memory:me.jpg\" align=\"center\">"
+ "<font size=\"+1\">"
+ "<p>Hello. I'm Carl and I'm the "
+ "developer of DCP-o-matic. I work on it in my spare time (with the help "
+ "of a volunteer team of testers and translators) and I release it "
+ "as free software."
+
+ "<p>If you find DCP-o-matic useful, please consider a donation to the "
+ "project. Financial support will help me to spend more "
+ "time developing DCP-o-matic and making it better!"
+
+ "<p><ul>"
+ "<li><a href=\"https://dcpomatic.com/donate_amount?amount=40\">Go to Paypal to donate €40</a>"
+ "<li><a href=\"https://dcpomatic.com/donate_amount?amount=20\">Go to Paypal to donate €20</a>"
+ "<li><a href=\"https://dcpomatic.com/donate_amount?amount=10\">Go to Paypal to donate €10</a>"
+ "</ul>"
+
+ "<p>Thank you!"
+ "</font>"
+ );
+}
+
diff --git a/test/wscript b/test/wscript
index 44f4d9c63..b04e244be 100644
--- a/test/wscript
+++ b/test/wscript
@@ -46,6 +46,7 @@ def build(bld):
obj.source = """
2536_regression_test.cc
4k_test.cc
+ analytics_test.cc
atmos_test.cc
audio_analysis_test.cc
audio_buffers_test.cc