summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-17 13:52:29 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-17 15:40:55 +0100
commitb00389305af83dfd1e3b41ab3b108cb591f18c5d (patch)
tree3a369aa9607a8cab92236bf22e779a826edecf55 /test
parentc6b2624c1965740fa7b5d2230baf20156ff34151 (diff)
Make a generic base for uploaders and move the SCP code into a subclass of that.
Diffstat (limited to 'test')
-rw-r--r--test/uploader_test.cc83
-rw-r--r--test/wscript1
2 files changed, 84 insertions, 0 deletions
diff --git a/test/uploader_test.cc b/test/uploader_test.cc
new file mode 100644
index 000000000..c583de667
--- /dev/null
+++ b/test/uploader_test.cc
@@ -0,0 +1,83 @@
+/*
+ Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+
+ This program 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.
+
+ This program 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 this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "lib/uploader.h"
+#include <boost/bind.hpp>
+#include <boost/test/unit_test.hpp>
+
+using std::vector;
+using std::make_pair;
+using std::pair;
+using std::string;
+using boost::shared_ptr;
+using boost::bind;
+
+static void
+set_status (string)
+{
+
+}
+
+static void
+set_progress (float)
+{
+
+}
+
+class TestUploader : public Uploader
+{
+public:
+ TestUploader ()
+ : Uploader (bind (&set_status, _1), bind (&set_progress, _1))
+ {
+ _directories.push_back ("uploader");
+ _directories.push_back ("uploader/a");
+ _directories.push_back ("uploader/c");
+ _directories.push_back ("uploader/b");
+ _directories.push_back ("uploader/b/e");
+ _next_directory = _directories.begin ();
+
+ _files.push_back (make_pair ("test/data/uploader/a/d", "uploader/a/d"));
+ _files.push_back (make_pair ("test/data/uploader/b/e/f", "uploader/b/e/f"));
+ _next_file = _files.begin ();
+ }
+
+protected:
+ void create_directory (boost::filesystem::path directory) {
+ BOOST_CHECK (directory == *_next_directory);
+ ++_next_directory;
+ }
+
+ void upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t &, boost::uintmax_t) {
+ BOOST_CHECK (make_pair (from, to) == *_next_file);
+ ++_next_file;
+ }
+
+private:
+ vector<boost::filesystem::path> _directories;
+ vector<boost::filesystem::path>::iterator _next_directory;
+ vector<std::pair<boost::filesystem::path, boost::filesystem::path> > _files;
+ vector<std::pair<boost::filesystem::path, boost::filesystem::path> >::iterator _next_file;
+};
+
+BOOST_AUTO_TEST_CASE (uploader_test)
+{
+ TestUploader uploader;
+ uploader.upload ("test/data/uploader");
+}
diff --git a/test/wscript b/test/wscript
index 931f3e924..bc3750904 100644
--- a/test/wscript
+++ b/test/wscript
@@ -80,6 +80,7 @@ def build(bld):
threed_test.cc
time_calculation_test.cc
update_checker_test.cc
+ uploader_test.cc
upmixer_a_test.cc
util_test.cc
video_content_scale_test.cc