summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-07-05 10:12:45 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-07-05 10:12:45 (GMT)
commit349cda4b8e178dc4a6694c47a3eb45e5a1368fb8 (patch)
treeb0576f3c60bf13a8f62396cac332edc2a421e4bd /Swiften/Whiteboard/UnitTest/WhiteboardServerTest.cpp
parentfadd51fbed5111aba266a3b8b22be2c57ea11262 (diff)
downloadswift-contrib-349cda4b8e178dc4a6694c47a3eb45e5a1368fb8.zip
swift-contrib-349cda4b8e178dc4a6694c47a3eb45e5a1368fb8.tar.bz2
Created simple WhiteboardServer with unit tests
Purpose of WhiteboardServer is to handle server side Operational Transformation operations
Diffstat (limited to 'Swiften/Whiteboard/UnitTest/WhiteboardServerTest.cpp')
-rw-r--r--Swiften/Whiteboard/UnitTest/WhiteboardServerTest.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/Swiften/Whiteboard/UnitTest/WhiteboardServerTest.cpp b/Swiften/Whiteboard/UnitTest/WhiteboardServerTest.cpp
new file mode 100644
index 0000000..3d17064
--- /dev/null
+++ b/Swiften/Whiteboard/UnitTest/WhiteboardServerTest.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2012 Mateusz Piękos
+ * Licensed under the simplified BSD license.
+ * See Documentation/Licenses/BSD-simplified.txt for more information.
+ */
+
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+
+#include <boost/smart_ptr/make_shared.hpp>
+#include <Swiften/Whiteboard/WhiteboardServer.h>
+#include <Swiften/Whiteboard/Operations/WhiteboardInsertOperation.h>
+#include <Swiften/Whiteboard/Elements/WhiteboardEllipseElement.h>
+
+using namespace Swift;
+
+class WhiteboardServerTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(WhiteboardServerTest);
+ CPPUNIT_TEST(testSimpleOp);
+ CPPUNIT_TEST_SUITE_END();
+public:
+ void testSimpleOp() {
+ WhiteboardServer server;
+ WhiteboardInsertOperation::ref firstOp = boost::make_shared<WhiteboardInsertOperation>();
+ firstOp->setID("0");
+ server.handleLocalOperationReceived(firstOp);
+ WhiteboardInsertOperation::ref serverOp = boost::make_shared<WhiteboardInsertOperation>();
+ serverOp->setID("b");
+ serverOp->setParentID("0");
+ serverOp->setPos(1);
+ server.handleLocalOperationReceived(serverOp);
+ WhiteboardInsertOperation::ref clientOp = boost::make_shared<WhiteboardInsertOperation>();
+ WhiteboardEllipseElement::ref clientElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
+ clientOp->setID("a");
+ clientOp->setParentID("0");
+ clientOp->setPos(1);
+ clientOp->setElement(clientElement);
+ WhiteboardInsertOperation::ref op = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(server.handleClientOperationReceived(clientOp));
+ CPPUNIT_ASSERT_EQUAL(std::string("b"), op->getParentID());
+ CPPUNIT_ASSERT_EQUAL(std::string("a"), op->getID());
+ CPPUNIT_ASSERT_EQUAL(1, op->getPos());
+ CPPUNIT_ASSERT_EQUAL(clientElement, boost::dynamic_pointer_cast<WhiteboardEllipseElement>(op->getElement()));
+ }
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(WhiteboardServerTest);