ShallowHistoryWithDeepEntryTest.cc 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * Copyright (c) 2015 committers of YAKINDU and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * committers of YAKINDU - initial API and implementation
  10. */
  11. #include <string>
  12. #include "gtest/gtest.h"
  13. #include "ShallowHistoryWithDeepEntry.h"
  14. TEST(StatemachineTest, noDeepEntryWithinHistory) {
  15. ShallowHistoryWithDeepEntry* statechart = new ShallowHistoryWithDeepEntry();
  16. statechart->init();
  17. statechart->enter();
  18. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Y));
  19. statechart->raise_toZ();
  20. statechart->runCycle();
  21. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  22. statechart->raise_toY();
  23. statechart->runCycle();
  24. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Y));
  25. statechart->raise_toZ();
  26. statechart->runCycle();
  27. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  28. delete statechart;
  29. }
  30. TEST(StatemachineTest, deepEntryWithinHistory) {
  31. ShallowHistoryWithDeepEntry* statechart = new ShallowHistoryWithDeepEntry();
  32. statechart->init();
  33. statechart->enter();
  34. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Y));
  35. statechart->raise_toZ();
  36. statechart->runCycle();
  37. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_A));
  38. statechart->raise_toC();
  39. statechart->runCycle();
  40. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  41. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  42. statechart->raise_toY();
  43. statechart->runCycle();
  44. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Y));
  45. statechart->raise_toZ();
  46. statechart->runCycle();
  47. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  48. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  49. delete statechart;
  50. }
  51. TEST(StatemachineTest, directDeepEntryIntoHistory) {
  52. ShallowHistoryWithDeepEntry* statechart = new ShallowHistoryWithDeepEntry();
  53. statechart->init();
  54. statechart->enter();
  55. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Y));
  56. statechart->raise_toC();
  57. statechart->runCycle();
  58. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  59. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  60. statechart->raise_toY();
  61. statechart->runCycle();
  62. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Y));
  63. statechart->raise_toZ();
  64. statechart->runCycle();
  65. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B__region0_C));
  66. EXPECT_TRUE(statechart->isActive(ShallowHistoryWithDeepEntry::main_region_Z__region0_B));
  67. delete statechart;
  68. }