summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp')
-rw-r--r--Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp108
1 files changed, 54 insertions, 54 deletions
diff --git a/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp b/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp
index e30bd4e..1b89ae4 100644
--- a/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp
+++ b/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp
@@ -34,9 +34,9 @@ public:
WhiteboardClient client;
WhiteboardInsertOperation::ref serverOp;
serverOp = createInsertOperation("0", "", 0);
- std::pair<WhiteboardOperation::ref, WhiteboardOperation::ref> pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first));
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ WhiteboardClient::Result pairResult = client.handleServerOperationReceived(serverOp);
+ CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client));
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives first local operation, because it's parented off "0" which exists
//in server history and client doesn't wait for any operation ack from server,
@@ -57,8 +57,8 @@ public:
WhiteboardEllipseElement::ref bElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(bElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "b", "a", 2, bElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "b", "a", 2, bElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives confirmation from the server about processed "a" operation, it had to
//be transformed against "b" on the server side to receive operation parented off "b".
@@ -67,8 +67,8 @@ public:
serverOp = createInsertOperation("a", "b", 1);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives local operation, it doesn't have to be transformed against anything
//but operation returned to send to the server should be parented off last server
@@ -86,8 +86,8 @@ public:
clientOp->setOrigin(WhiteboardOperation::Local);
clientOp->setElement(cElement);
pairResult = client.handleServerOperationReceived(clientOp);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Results:
//Client operations:
@@ -116,9 +116,9 @@ public:
WhiteboardClient client;
WhiteboardInsertOperation::ref serverOp;
serverOp = createInsertOperation("0", "", 0);
- std::pair<WhiteboardOperation::ref, WhiteboardOperation::ref> pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first));
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ WhiteboardClient::Result pairResult = client.handleServerOperationReceived(serverOp);
+ CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client));
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives first local operation, because it's parented off "0" which exists
//in server history and client doesn't wait for any operation ack from server,
@@ -144,8 +144,8 @@ public:
clientOp->setOrigin(WhiteboardOperation::Local);
clientOp->setElement(cElement);
pairResult = client.handleServerOperationReceived(clientOp);
- checkOperation(pairResult.second, "d", "c", 2, dElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
+ checkOperation(pairResult.server, "d", "c", 2, dElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
//Client receives confirmation about processing "d", it should be the same as
//sent operation. There aren't any operations in queue to send.
@@ -153,8 +153,8 @@ public:
clientOp->setOrigin(WhiteboardOperation::Local);
clientOp->setElement(dElement);
pairResult = client.handleServerOperationReceived(clientOp);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives new operation from server, it's parented off "d" which is at
//the end of local history so it doesn't have to be transformed, so operation
@@ -163,9 +163,9 @@ public:
WhiteboardEllipseElement::ref eElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(eElement);
pairResult = client.handleServerOperationReceived(serverOp);
- WhiteboardInsertOperation::ref result = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first);
- CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first));
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ WhiteboardInsertOperation::ref result = boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client));
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client operations:
@@ -193,9 +193,9 @@ public:
WhiteboardClient client;
WhiteboardInsertOperation::ref serverOp;
serverOp = createInsertOperation("0", "", 0);
- std::pair<WhiteboardOperation::ref, WhiteboardOperation::ref> pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first));
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ WhiteboardClient::Result pairResult = client.handleServerOperationReceived(serverOp);
+ CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client));
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives first local operation, because it's parented off "0" which exists
//in server history and client doesn't wait for any operation ack from server,
@@ -223,8 +223,8 @@ public:
WhiteboardEllipseElement::ref cElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(cElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "c", "b", 3, cElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "c", "b", 3, cElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives new operation from server, it should be transformed against
//results of previous transformations, returned operation should be parented off
@@ -235,16 +235,16 @@ public:
WhiteboardEllipseElement::ref dElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(dElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "d", "c", 4, dElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "d", "c", 4, dElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives confirmation about processing "a", it should send next operation
//to server which is "b", but it should be version parented of transformed "a"
serverOp = createInsertOperation("a", "d", 1);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.second, "b", "a", 2, bElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
+ checkOperation(pairResult.server, "b", "a", 2, bElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
//Client receives confirmation about processing "b", there aren't any operations
@@ -252,8 +252,8 @@ public:
serverOp = createInsertOperation("b", "a", 2);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client operations:
//ID pos
@@ -285,9 +285,9 @@ public:
WhiteboardClient client;
WhiteboardInsertOperation::ref serverOp;
serverOp = createInsertOperation("0", "", 0);
- std::pair<WhiteboardOperation::ref, WhiteboardOperation::ref> pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first));
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ WhiteboardClient::Result pairResult = client.handleServerOperationReceived(serverOp);
+ CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client));
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives first local operation, because it's parented off "0" which exists
//in server history and client doesn't wait for any operation ack from server,
@@ -315,8 +315,8 @@ public:
WhiteboardEllipseElement::ref cElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(cElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "c", "b", 3, cElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "c", "b", 3, cElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives new local operation, client is still waiting for ack so, it
//should return nothing
@@ -334,8 +334,8 @@ public:
WhiteboardEllipseElement::ref dElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(dElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "d", "e", 5, dElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "d", "e", 5, dElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives confirmation about processing "a", it had to be transformed against
//"c" and "d" and it is now parented off "d", returned value should be next operation
@@ -343,9 +343,9 @@ public:
serverOp = createInsertOperation("a", "d", 1);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.second, "b", "a", 2, bElement);
+ checkOperation(pairResult.server, "b", "a", 2, bElement);
// CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::Other, result->getOrigin());
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
//Client receives confirmation about processing "b", it is the same operation as sent because
//it didn't have to be transformed, returned value should be next operation
@@ -353,9 +353,9 @@ public:
serverOp = createInsertOperation("b", "a", 2);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.second, "e", "b", 4, eElement);
+ checkOperation(pairResult.server, "e", "b", 4, eElement);
// CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::Other, result->getOrigin());
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
//Client receives confirmation about processing "b", it is the same operation as sent because
//it didn't have to be transformed, there aren't any operations to send so this function returns
@@ -363,8 +363,8 @@ public:
serverOp = createInsertOperation("e", "b", 4);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Result:
//Client operations:
@@ -396,9 +396,9 @@ public:
WhiteboardClient client;
WhiteboardInsertOperation::ref serverOp;
serverOp = createInsertOperation("0", "", 0);
- std::pair<WhiteboardOperation::ref, WhiteboardOperation::ref> pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.first));
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ WhiteboardClient::Result pairResult = client.handleServerOperationReceived(serverOp);
+ CPPUNIT_ASSERT_EQUAL(serverOp, boost::dynamic_pointer_cast<WhiteboardInsertOperation>(pairResult.client));
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives first local operation, because it's parented off "0" which exists
//in server history and client doesn't wait for any operation ack from server,
@@ -426,8 +426,8 @@ public:
WhiteboardEllipseElement::ref cElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(cElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "c", "b", 3, cElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "c", "b", 3, cElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives confirmation about processing "a", it had to be transformed against
//"c" and it is now parented off "c", returned value should be next operation
@@ -436,9 +436,9 @@ public:
serverOp->setOrigin(WhiteboardOperation::Other);
serverOp->setElement(aElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.second, "b", "a", 2, bElement);
+ checkOperation(pairResult.server, "b", "a", 2, bElement);
// CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::Other, result->getOrigin());
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
//Client receives new server operation, to add it to local history it should be transformed
//against result of previous transformation(but only with transformation of "b"), returned
@@ -448,8 +448,8 @@ public:
WhiteboardEllipseElement::ref dElement = boost::make_shared<WhiteboardEllipseElement>(0,0,0,0);
serverOp->setElement(dElement);
pairResult = client.handleServerOperationReceived(serverOp);
- checkOperation(pairResult.first, "d", "c", 4, dElement);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ checkOperation(pairResult.client, "d", "c", 4, dElement);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client receives confirmation about processing "b", it had to be transformed against
//"d" because both operations was parented off server version of "a".
@@ -458,8 +458,8 @@ public:
serverOp->setElement(bElement);
serverOp->setOrigin(WhiteboardOperation::Other);
pairResult = client.handleServerOperationReceived(serverOp);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.first);
- CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.second);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client);
+ CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server);
//Client operations:
//ID pos