diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-05-06 20:02:52 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-05-10 17:37:50 +0100 |
commit | 47a0f836dd0e2ec49cd9f40c78a05f5c281dbdd6 (patch) | |
tree | 0c19b3b6fd75116c1054f7ebc0e726a3215bd2cb /test | |
parent | eb376d122f318ba02780b25a03bfd861281ed848 (diff) |
tests: re-factor PNG save to allow easy re-use elsewhere.
Change-Id: Ic24f67d9a078ae49fa4ac187cc924fe36f482879
Diffstat (limited to 'test')
-rw-r--r-- | test/helpers.hpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/test/helpers.hpp b/test/helpers.hpp index 0bbd3c686..c0f9d112c 100644 --- a/test/helpers.hpp +++ b/test/helpers.hpp @@ -586,6 +586,20 @@ inline void sendText(std::shared_ptr<LOOLWebSocket>& socket, const std::string& } } +inline void saveTileAs(const std::vector<char> &tileResponse, + const std::string &filename, + const std::string &testname) +{ + const std::string firstLine = LOOLProtocol::getFirstLine(tileResponse); + std::vector<char> res(tileResponse.begin() + firstLine.size() + 1, tileResponse.end()); + std::stringstream streamRes; + std::copy(res.begin(), res.end(), std::ostream_iterator<char>(streamRes)); + std::fstream outStream(filename, std::ios::out); + outStream.write(res.data(), res.size()); + outStream.close(); + TST_LOG("Saved [" << firstLine << "] to [" << filename << "]"); +} + inline std::vector<char> getTileAndSave(std::shared_ptr<LOOLWebSocket>& socket, const std::string& req, const std::string& filename, @@ -603,12 +617,7 @@ inline std::vector<char> getTileAndSave(std::shared_ptr<LOOLWebSocket>& socket, std::copy(res.begin(), res.end(), std::ostream_iterator<char>(streamRes)); if (!filename.empty()) - { - std::fstream outStream(filename, std::ios::out); - outStream.write(res.data(), res.size()); - outStream.close(); - TST_LOG("Saved [" << firstLine << "] to [" << filename << "]"); - } + saveTileAs(tile, filename, testname); return res; } |