Ignore:
Timestamp:
Apr 8, 2010, 2:00:11 PM (16 years ago)
Author:
Tillmann Crueger <crueger@…>
Children:
91b18cd
Parents:
770138
Message:

Added detailed documentation for the Action class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • molecuilder/src/unittests/ActionSequenceTest.cpp

    r770138 rabd4a1  
    1313#include "Actions/Action.hpp"
    1414#include "Actions/ActionSequence.hpp"
     15#include "Actions/MakroAction.hpp"
     16#include "Actions/ActionHistory.hpp"
     17#include "Actions/ActionRegistry.hpp"
    1518
    1619#ifdef HAVE_TESTRUNNER
     
    2225// Registers the fixture into the 'registry'
    2326CPPUNIT_TEST_SUITE_REGISTRATION( ActionSequenceTest );
    24 
    25 void setUp();
    26 void tearDown();
    27 
    28 void canUndoTest();
    2927
    3028/* some neccessary stubs for tests */
     
    110108
    111109void ActionSequenceTest::setUp(){
     110  ActionHistory::init();
    112111  // create some necessary stubs used in this test
    113112  positive1 = new canUndoActionStub();
     
    134133  delete shouldNotCall2;
    135134
     135  ActionHistory::purgeInstance();
     136  ActionRegistry::purgeInstance();
    136137}
    137138
     
    209210void ActionSequenceTest::doesUndoTest(){
    210211  ActionSequence *sequence = new ActionSequence();
    211   sequence->addAction(shouldNotCall1);
    212   sequence->addAction(shouldNotCall2);
    213   sequence->addAction(shouldCall1);
    214   sequence->addAction(shouldCall2);
    215 
    216   ActionSequence::stateSet states = sequence->callAll();
    217 
    218   sequence->removeLastAction();
    219   sequence->removeLastAction();
    220 
    221   sequence->undoAll(states);
    222 
    223   CPPUNIT_ASSERT_EQUAL(true,shouldCall1->wasCalled());
    224   CPPUNIT_ASSERT_EQUAL(true,shouldCall2->wasCalled());
    225   CPPUNIT_ASSERT_EQUAL(false,shouldNotCall1->wasCalled());
    226   CPPUNIT_ASSERT_EQUAL(false,shouldNotCall2->wasCalled());
    227 
    228   delete sequence;
    229 }
    230 
    231 
     212  wasCalledActionStub *wasCalled1 = new wasCalledActionStub();
     213  wasCalledActionStub *wasCalled2 = new wasCalledActionStub();
     214  sequence->addAction(wasCalled1);
     215  sequence->addAction(wasCalled2);
     216
     217  MakroAction act("Test MakroAction",sequence,false);
     218
     219  act.call();
     220
     221  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
     222  CPPUNIT_ASSERT_EQUAL(true,wasCalled1->wasCalled());
     223
     224  ActionHistory::getInstance().undoLast();
     225
     226  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
     227  CPPUNIT_ASSERT_EQUAL(false,wasCalled1->wasCalled());
     228
     229}
     230
     231
Note: See TracChangeset for help on using the changeset viewer.