InternalEventLifeCycleTest.cc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Generated by YAKINDU Statechart Tools code generator. */
  2. #include <string>
  3. #include "gtest/gtest.h"
  4. #include "InternalEventLifeCycle.h"
  5. #include "sc_runner.h"
  6. #include "sc_types.h"
  7. namespace {
  8. //! The timers are managed by a timer service. */
  9. static SctUnitRunner * runner;
  10. class InternalEventLifeCycleTest : public ::testing::Test{
  11. protected:
  12. InternalEventLifeCycle* statechart;
  13. virtual void SetUp() {
  14. statechart = new InternalEventLifeCycle();
  15. statechart->init();
  16. runner = new SctUnitRunner(
  17. statechart,
  18. false,
  19. 200
  20. );
  21. }
  22. virtual void TearDown() {
  23. delete statechart;
  24. delete runner;
  25. }
  26. };
  27. TEST_F(InternalEventLifeCycleTest, InternalEventLifeCycleTest) {
  28. statechart->enter();
  29. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r1_A));
  30. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r2_C));
  31. statechart->getDefaultSCI()->raise_e();
  32. runner->proceed_cycles(1);
  33. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r1_A));
  34. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r2_D));
  35. runner->proceed_cycles(1);
  36. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r1_A));
  37. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r2_D));
  38. statechart->getDefaultSCI()->raise_f();
  39. runner->proceed_cycles(1);
  40. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r1_A));
  41. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r2_C));
  42. runner->proceed_cycles(1);
  43. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r1_A));
  44. EXPECT_TRUE(statechart->isStateActive(InternalEventLifeCycle::r2_C));
  45. }
  46. }