00001 00002 #include <cxxtest/TestSuite.h> 00003 00004 #include <cstring> 00005 00006 00007 #include "../../src/domain/animation/animation.h" 00008 #include "../../src/domain/animation/animationmodel.h" 00009 #include "frontendstub.h" 00010 00011 #include <vector> 00012 00013 class AnimationTest : public CxxTest::TestSuite 00014 { 00015 private: 00016 AnimationModel *animation; 00017 00018 public: 00019 00020 00021 void setUp() 00022 { 00023 /*cout << ".........................................................\n......................AnimationTest......................" << endl; 00024 00025 animation = new Animation(); 00026 animation->newProject(); 00027 FrontendStub *fs = new FrontendStub(); 00028 animation->registerFrontend(fs); 00029 vector<char*> frameNames; 00030 frameNames.push_back("Frame0"); 00031 frameNames.push_back("Frame1"); 00032 frameNames.push_back("Frame2"); 00033 animation->addFrames(frameNames, 0);*/ 00034 } 00035 00036 void tearDown() 00037 { 00038 // delete animation; 00039 } 00040 00041 00042 void test_getFrame() 00043 { 00044 00045 /*TS_ASSERT( strstr(animation->getFrame(0)->getImagePath(), "tmp_0") != NULL ); 00046 TS_ASSERT( strstr(animation->getFrame(2)->getImagePath(), "tmp_2") != NULL ); 00047 TS_ASSERT( animation->getFrame(3) == 0 );*/ 00048 } 00049 00050 void test_getModelSize() 00051 { 00052 // TS_ASSERT_EQUALS( animation->getModelSize(), 3); 00053 } 00054 00055 void test_removeFrames() 00056 { 00057 /*AnimationModel* a = new Animation(); 00058 a->newProject(); 00059 FrontendStub *fs = new FrontendStub(); 00060 a->registerFrontend(fs); 00061 00062 vector<char*> frameNames; 00063 frameNames.push_back("Frame0"); 00064 frameNames.push_back("Frame1"); 00065 frameNames.push_back("Frame2"); 00066 frameNames.push_back("Frame3"); 00067 a->addFrames(frameNames, 0); 00068 a->setActiveFrame(1); 00069 a->removeFrames(a->getActiveFrameNumber(), a->getActiveFrameNumber()); 00070 TS_ASSERT( strstr(a->getFrame(1)->getImagePath(), "tmp_2") != NULL ); 00071 a->removeFrames(a->getActiveFrameNumber(), a->getActiveFrameNumber()); 00072 TS_ASSERT( strstr(a->getFrame(1)->getImagePath(), "tmp_3") != NULL ); 00073 a->removeFrames(a->getActiveFrameNumber(), a->getActiveFrameNumber()); 00074 TS_ASSERT( a->getFrame(1) == 0 ); 00075 TS_ASSERT( strstr(a->getFrame(0)->getImagePath(), "tmp_0") != NULL ); 00076 00077 delete a;*/ 00078 } 00079 00080 void test_moveFrame() 00081 { 00082 /*AnimationModel* a = new Animation(); 00083 a->newProject(); 00084 FrontendStub *fs = new FrontendStub(); 00085 a->registerFrontend(fs); 00086 00087 vector<char*> frameNames; 00088 frameNames.push_back("Frame0"); 00089 frameNames.push_back("Frame1"); 00090 frameNames.push_back("Frame2"); 00091 frameNames.push_back("Frame3"); 00092 a->addFrames(frameNames, 0); 00093 a->moveFrames(0, 0, 3); 00094 TS_ASSERT( strstr(a->getFrame(0)->getImagePath(), "tmp_1") != NULL ); 00095 TS_ASSERT( strstr(a->getFrame(2)->getImagePath(), "tmp_3") != NULL ); 00096 TS_ASSERT( strstr(a->getFrame(3)->getImagePath(), "tmp_0") != NULL ); 00097 a->moveFrames(3, 3, 0); 00098 TS_ASSERT( strstr(a->getFrame(0)->getImagePath(), "tmp_0") != NULL ); 00099 TS_ASSERT( strstr(a->getFrame(1)->getImagePath(), "tmp_1") != NULL ); 00100 TS_ASSERT( strstr(a->getFrame(3)->getImagePath(), "tmp_3") != NULL ); 00101 00102 delete a;*/ 00103 } 00104 00105 void test_addFrame() 00106 { 00107 /*AnimationModel* a = new Animation(); 00108 a->newProject(); 00109 FrontendStub *fs = new FrontendStub(); 00110 a->registerFrontend(fs); 00111 00112 vector<char*> frameNames; 00113 frameNames.push_back("Frame0"); 00114 frameNames.push_back("Frame1"); 00115 a->addFrames(frameNames, 0); 00116 frameNames.clear(); 00117 frameNames.push_back("Frame2"); 00118 a->addFrames(frameNames, 0); 00119 cout << a->getFrame(0)->getImagePath() << endl; 00120 TS_ASSERT( strstr(a->getFrame(0)->getImagePath(), "tmp_2") != NULL ); 00121 00122 delete a;*/ 00123 } 00124 00125 void test_getActiveFrameNumber() 00126 { 00127 /*AnimationModel* a = new Animation(); 00128 FrontendStub *fs = new FrontendStub(); 00129 a->registerFrontend(fs); 00130 00131 vector<char*> frameNames; 00132 frameNames.push_back("Frame0"); 00133 frameNames.push_back("Frame1"); 00134 a->addFrames(frameNames, 0); 00135 TS_ASSERT_EQUALS(a->getActiveFrameNumber(), 1); 00136 a->setActiveFrame(0); 00137 TS_ASSERT_EQUALS(a->getActiveFrameNumber(), 0); 00138 00139 delete a;*/ 00140 } 00141 };