From edeab9429a996aa5641cfb9c4b3fc1386b49d81f Mon Sep 17 00:00:00 2001 From: Mateusz Piekos Date: Fri, 20 Jul 2012 12:12:26 +0200 Subject: Removed unnecessary origin field from WhiteboardOperation diff --git a/Swiften/Whiteboard/Operations/WhiteboardOperation.h b/Swiften/Whiteboard/Operations/WhiteboardOperation.h index 73a8b74..02c6438 100644 --- a/Swiften/Whiteboard/Operations/WhiteboardOperation.h +++ b/Swiften/Whiteboard/Operations/WhiteboardOperation.h @@ -14,9 +14,6 @@ namespace Swift { public: typedef boost::shared_ptr ref; public: - - enum OperationOrigin { Local, Other }; - virtual ~WhiteboardOperation(){}; std::string getID() const { @@ -43,18 +40,9 @@ namespace Swift { pos_ = pos; } - OperationOrigin getOrigin() const { - return origin_; - } - - void setOrigin(OperationOrigin origin) { - origin_ = origin; - } - private: std::string id_; std::string parentID_; int pos_; - OperationOrigin origin_; }; } diff --git a/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp b/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp index 7526fdd..9fef701 100644 --- a/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp +++ b/Swiften/Whiteboard/UnitTest/WhiteboardClientTest.cpp @@ -47,7 +47,6 @@ public: //so this operation could be send WhiteboardInsertOperation::ref clientOp; clientOp = createInsertOperation("a", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref aElement = boost::make_shared(0,0,0,0); clientOp->setElement(aElement); WhiteboardInsertOperation::ref result; @@ -57,7 +56,6 @@ public: //so it have to be transformed against local operations and then transformed value can //be returned to draw serverOp = createInsertOperation("b", "0", 1); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref bElement = boost::make_shared(0,0,0,0); serverOp->setElement(bElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -69,7 +67,6 @@ public: //There aren't any waiting operations to send to server, this operation should return //nothing serverOp = createInsertOperation("a", "b", 1); - serverOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server); @@ -78,7 +75,6 @@ public: //but operation returned to send to the server should be parented off last server //operation, which is "b" clientOp = createInsertOperation("c", "b", 3); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref cElement = boost::make_shared(0,0,0,0); clientOp->setElement(cElement); checkOperation(client.handleLocalOperationReceived(clientOp), "c", "a", 3, cElement); @@ -87,7 +83,6 @@ public: //should be the same operation as it was sent because server didn't have to //transform it clientOp = createInsertOperation("c", "a", 3); - clientOp->setOrigin(WhiteboardOperation::Local); clientOp->setElement(cElement); pairResult = client.handleServerOperationReceived(clientOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); @@ -128,7 +123,6 @@ public: //in server history and client doesn't wait for any operation ack from server, //so this operation could be send WhiteboardInsertOperation::ref clientOp = createInsertOperation("c", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref cElement = boost::make_shared(0,0,0,0); clientOp->setElement(cElement); checkOperation(client.handleLocalOperationReceived(clientOp), "c", "0", 1, cElement); @@ -136,7 +130,6 @@ public: //Client receives second local operation, client didn't receive ack about previous //operation from the server so it can't be send. clientOp = createInsertOperation("d", "c", 2); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref dElement = boost::make_shared(0,0,0,0); clientOp->setElement(dElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), client.handleLocalOperationReceived(clientOp)); @@ -145,7 +138,6 @@ public: //same as sent operation because it wasn't transformed, client could send now //operation "d" clientOp = createInsertOperation("c", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); clientOp->setElement(cElement); pairResult = client.handleServerOperationReceived(clientOp); checkOperation(pairResult.server, "d", "c", 2, dElement); @@ -154,7 +146,6 @@ public: //Client receives confirmation about processing "d", it should be the same as //sent operation. There aren't any operations in queue to send. clientOp = createInsertOperation("d", "c", 2); - clientOp->setOrigin(WhiteboardOperation::Local); clientOp->setElement(dElement); pairResult = client.handleServerOperationReceived(clientOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); @@ -206,7 +197,6 @@ public: //so this operation could be send WhiteboardInsertOperation::ref clientOp; clientOp = createInsertOperation("a", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref aElement = boost::make_shared(0,0,0,0); clientOp->setElement(aElement); checkOperation(client.handleLocalOperationReceived(clientOp), "a", "0", 1, aElement); @@ -214,7 +204,6 @@ public: //Client receives second local operation, client didn't receive ack about previous //operation from the server so it can't be send. clientOp = createInsertOperation("b", "a", 2); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref bElement = boost::make_shared(0,0,0,0); clientOp->setElement(bElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), client.handleLocalOperationReceived(clientOp)); @@ -223,7 +212,6 @@ public: //"a" and "b" before adding to local operations history because it's parented off "0". //Because client is waiting for ack of "a", there is no operation to send to server serverOp = createInsertOperation("c", "0", 1); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref cElement = boost::make_shared(0,0,0,0); serverOp->setElement(cElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -235,7 +223,6 @@ public: //"c" existing in local history. //Because client is waiting for ack of "a", there is no operation to send to server serverOp = createInsertOperation("d", "c", 2); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref dElement = boost::make_shared(0,0,0,0); serverOp->setElement(dElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -245,7 +232,6 @@ public: //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.server, "b", "a", 2, bElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); @@ -254,7 +240,6 @@ public: //Client receives confirmation about processing "b", there aren't any operations //waiting so it should return nothing. serverOp = createInsertOperation("b", "a", 2); - serverOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server); @@ -298,7 +283,6 @@ public: //so this operation could be send WhiteboardInsertOperation::ref clientOp; clientOp = createInsertOperation("a", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref aElement = boost::make_shared(0,0,0,0); clientOp->setElement(aElement); checkOperation(client.handleLocalOperationReceived(clientOp), "a", "0", 1, aElement); @@ -306,7 +290,6 @@ public: //Client receives second local operation, client didn't receive ack about previous //operation from the server so it can't be send. clientOp = createInsertOperation("b", "a", 2); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref bElement = boost::make_shared(0,0,0,0); clientOp->setElement(bElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), client.handleLocalOperationReceived(clientOp)); @@ -315,7 +298,6 @@ public: //"a" and "b" before adding to local operations history because it's parented off "0". //Because client is waiting for ack of "a", there is no operation to send to server serverOp = createInsertOperation("c", "0", 1); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref cElement = boost::make_shared(0,0,0,0); serverOp->setElement(cElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -325,7 +307,6 @@ public: //Client receives new local operation, client is still waiting for ack so, it //should return nothing clientOp = createInsertOperation("e", "a", 4); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref eElement = boost::make_shared(0,0,0,0); clientOp->setElement(eElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), client.handleLocalOperationReceived(clientOp)); @@ -334,7 +315,6 @@ public: //against result of previous transformations and operation "e", returned operation should //be parented off "e", which was last local operation serverOp = createInsertOperation("d", "c", 2); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref dElement = boost::make_shared(0,0,0,0); serverOp->setElement(dElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -345,27 +325,22 @@ public: //"c" and "d" and it is now parented off "d", returned value should be next operation //which have to be send to server("b" parented off server version of "a"). serverOp = createInsertOperation("a", "d", 1); - serverOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); checkOperation(pairResult.server, "b", "a", 2, bElement); -// CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::Other, result->getOrigin()); 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 //which have to be send to server("e" parented off server version of "b"). serverOp = createInsertOperation("b", "a", 2); - serverOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); checkOperation(pairResult.server, "e", "b", 4, eElement); -// CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::Other, result->getOrigin()); 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 //nothing serverOp = createInsertOperation("e", "b", 4); - serverOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server); @@ -409,7 +384,6 @@ public: //so this operation could be send WhiteboardInsertOperation::ref clientOp; clientOp = createInsertOperation("a", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref aElement = boost::make_shared(0,0,0,0); clientOp->setElement(aElement); checkOperation(client.handleLocalOperationReceived(clientOp), "a", "0", 1, aElement); @@ -417,7 +391,6 @@ public: //Client receives second local operation, client didn't receive ack about previous //operation from the server so it can't be send. clientOp = createInsertOperation("b", "a", 2); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref bElement = boost::make_shared(0,0,0,0); clientOp->setElement(bElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), client.handleLocalOperationReceived(clientOp)); @@ -426,7 +399,6 @@ public: //"a" and "b" before adding to local operations history because it's parented off "0". //Because client is waiting for ack of "a", there is no operation to send to server serverOp = createInsertOperation("c", "0", 1); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref cElement = boost::make_shared(0,0,0,0); serverOp->setElement(cElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -437,18 +409,15 @@ public: //"c" and it is now parented off "c", returned value should be next operation //which have to be send to server("b" parented off server version of "a"). serverOp = createInsertOperation("a", "c", 1); - serverOp->setOrigin(WhiteboardOperation::Other); serverOp->setElement(aElement); pairResult = client.handleServerOperationReceived(serverOp); checkOperation(pairResult.server, "b", "a", 2, bElement); -// CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::Other, result->getOrigin()); 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 //operation should be parented off "c", which was last local operation serverOp = createInsertOperation("d", "a", 3); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref dElement = boost::make_shared(0,0,0,0); serverOp->setElement(dElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -460,7 +429,6 @@ public: //there aren't any operations to send so this function returns nothing. serverOp = createInsertOperation("b", "d", 2); serverOp->setElement(bElement); - serverOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server); @@ -504,7 +472,6 @@ public: //so this operation could be send WhiteboardInsertOperation::ref clientOp; clientOp = createInsertOperation("a", "0", 1); - clientOp->setOrigin(WhiteboardOperation::Local); WhiteboardEllipseElement::ref aElement = boost::make_shared(0,0,0,0); clientOp->setElement(aElement); checkOperation(client.handleLocalOperationReceived(clientOp), "a", "0", 1, aElement); @@ -531,7 +498,6 @@ public: //"c" existing in local history. //Because client is waiting for ack of "a", there is no operation to send to server serverOp = createInsertOperation("d", "c", 1); - serverOp->setOrigin(WhiteboardOperation::Other); WhiteboardEllipseElement::ref dElement = boost::make_shared(0,0,0,0); serverOp->setElement(dElement); pairResult = client.handleServerOperationReceived(serverOp); @@ -541,7 +507,6 @@ public: //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.server, "b", "a", 0, cElement); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); @@ -550,7 +515,6 @@ public: //Client receives confirmation about processing "b", there aren't any operations //waiting so it should return nothing. serverUpdateOp = createUpdateOperation("b", "a", 0); - serverUpdateOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server); @@ -640,7 +604,6 @@ public: //Client receives confirmation about processing "b", there aren't any operations //waiting so it should return nothing. WhiteboardDeleteOperation::ref serverDeleteOp = createDeleteOperation("b", "a", 0); - serverDeleteOp->setOrigin(WhiteboardOperation::Other); pairResult = client.handleServerOperationReceived(serverDeleteOp); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.client); CPPUNIT_ASSERT_EQUAL(WhiteboardOperation::ref(), pairResult.server); -- cgit v0.10.2-6-g49f6