diff options
author | Michael Meeks <michael.meeks@collabora.com> | 2019-06-22 13:00:48 +0100 |
---|---|---|
committer | Michael Meeks <michael.meeks@collabora.com> | 2019-08-05 21:18:31 -0400 |
commit | 4347883c6547b707a330fa38cb0111f2d4c4f7c8 (patch) | |
tree | d25f73c6228a06922a176a47f45ca2c264b23a35 /test/UnitCopyPaste.cpp | |
parent | 149b8619754e4d1af47671aaad05b74cd82deff6 (diff) |
clipboard: add more unit tests.
Change-Id: Id1841935927e451e6aa15489c303dd9f01ac21b4
Diffstat (limited to 'test/UnitCopyPaste.cpp')
-rw-r--r-- | test/UnitCopyPaste.cpp | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/test/UnitCopyPaste.cpp b/test/UnitCopyPaste.cpp index 26da33a99..25c0ccde8 100644 --- a/test/UnitCopyPaste.cpp +++ b/test/UnitCopyPaste.cpp @@ -112,6 +112,24 @@ public: return true; } + bool fetchClipboardAssert(const std::string &clipURI, + const std::string &mimeType, + const std::string &content) + { + std::shared_ptr<ClipboardData> clipboard; + try { + clipboard = getClipboard(clipURI); + } catch (ParseError &err) { + std::cerr << "parse error " << err.toString() << std::endl; + exitTest(TestResult::Failed); + return false; + } + + if (!assertClipboard(clipboard, mimeType, content)) + return false; + return true; + } + void invokeTest() override { std::string testname = "copypaste"; @@ -134,35 +152,30 @@ public: } std::string clipURI = clientSession->getClipboardURI(false); // nominally thread unsafe - std::shared_ptr<ClipboardData> clipboard; - try { - clipboard = getClipboard(clipURI); - } catch (ParseError &err) { - std::cerr << "parse error " << err.toString() << std::endl; - exitTest(TestResult::Failed); + + // In an empty cell + if (!fetchClipboardAssert(clipURI, "text/plain;charset=utf-8", "")) return; - } - // Empty cell so ... - if (!assertClipboard(clipboard, "text/plain;charset=utf-8", "")) + // Check existing content + helpers::sendTextFrame(socket, "uno .uno:SelectAll", testname); + helpers::sendTextFrame(socket, "uno .uno:Copy", testname); + std::string oneColumn = "2\n3\n5\n"; + if (!fetchClipboardAssert(clipURI, "text/plain;charset=utf-8", oneColumn)) return; + // Inject some content std::string text = "This is some content?&*/\\!!"; helpers::sendTextFrame(socket, "paste mimetype=text/plain;charset=utf-8\n" + text, testname); helpers::sendTextFrame(socket, "uno .uno:SelectAll", testname); helpers::sendTextFrame(socket, "uno .uno:Copy", testname); - try { - clipboard = getClipboard(clipURI); - } catch (ParseError &err) { - std::cerr << "parse error " << err.toString() << std::endl; - exitTest(TestResult::Failed); + if (!fetchClipboardAssert(clipURI, "text/plain;charset=utf-8", + text + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t2\n\t\t3\n\t\t5\n")) return; - } - std::string existing = "2\t\n3\t\n5"; - if (!assertClipboard(clipboard, "text/plain;charset=utf-8", existing + "\t" + text + "\n")) - return; + // Now try pushing some new clipboard content ... + std::cerr << "CopyPaste tests succeeded" << std::endl; exitTest(TestResult::Ok); |