Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

observertest_mock.h

00001 
00002 
00003 #include "../../src/domain/animation/animation.h"
00004 #include "../../src/domain/animation/animationmodel.h"
00005 #include "../../src/presentation/observer.h"
00006 #include "../../src/presentation/frontends/frontend.h"
00007           
00008 
00009 
00010 //Crude mock object for testing the observer architecture
00011 class ObserverTestMock : public Observer
00012 {
00013 private:
00014         int recievedUpdate_0;
00015         int recievedUpdate_1;
00016         int lastUpdate;
00017 
00018 public:
00019         ObserverTestMock()
00020         {
00021                 recievedUpdate_0 = 0;
00022                 recievedUpdate_1 = 0;
00023                 lastUpdate = 0;
00024         }
00025 
00026 
00027         //1
00028         void updateAdd(const std::vector<char*>&, unsigned int, Frontend*)
00029         {
00030                 if(++lastUpdate%2 == 0)
00031                         recievedUpdate_0 = 1;
00032                 else
00033                         recievedUpdate_1 = 1;
00034         }
00035         
00036         //2
00037         void updateRemove(unsigned int, unsigned int)
00038         {
00039                 if(++lastUpdate%2 == 0)
00040                         recievedUpdate_0 = 2;
00041                 else
00042                         recievedUpdate_1 = 2;
00043         };
00044         
00045         //3
00046         void updateMove(unsigned int, unsigned int, unsigned int)
00047         {
00048                 if(++lastUpdate%2 == 0)
00049                         recievedUpdate_0 = 3;
00050                 else
00051                         recievedUpdate_1 = 3;
00052         };
00053         
00054         
00055         //4
00056         void updateNewActiveFrame(int)
00057         {
00058                 if(++lastUpdate%2 == 0)
00059                         recievedUpdate_0 = 4;
00060                 else
00061                         recievedUpdate_1 = 4;
00062         }
00063         
00064         //5
00065         void updateClear()
00066         {
00067                 if(++lastUpdate%2 == 0)
00068                         recievedUpdate_0 = 5;
00069                 else
00070                         recievedUpdate_1 = 5;
00071         }
00072         
00073         //6
00074         void updatePlayFrame(int)
00075         {
00076                 if(++lastUpdate%2 == 0)
00077                         recievedUpdate_0 = 6;
00078                 else
00079                         recievedUpdate_1 = 6;
00080         }
00081         
00082         
00083         //The last update
00084         int updatedStatus()
00085         {
00086                 if(lastUpdate%2 == 0)
00087                         return recievedUpdate_0;
00088                 else
00089                         return recievedUpdate_1;
00090         }
00091         
00092         //The second last update
00093         int updatedStatus_2()
00094         {
00095                 if(lastUpdate%2 == 0)
00096                         return recievedUpdate_1;
00097                 else
00098                         return recievedUpdate_0;
00099         }
00100         
00101         void clear()
00102         {
00103                 recievedUpdate_0 = 0;
00104                 recievedUpdate_1 = 0;
00105         }
00106 };

Generated on Thu May 19 01:51:21 2005 for stopmotion.kdevelop by  doxygen 1.4.2