From cab6585b010860c91c015a85edad59beee4f3d80 Mon Sep 17 00:00:00 2001 From: Alexey Fedoseev Date: Thu, 25 Apr 2024 10:54:23 +0300 Subject: [PATCH] add geometry tests --- tests/06-output.graphml | 3 +++ tests/06-output.txt | 2 +- tests/06-two-statemachines.cpp | 2 +- tests/07-output.graphml | 3 +++ tests/07-output.txt | 2 +- tests/07-single-state.cpp | 2 +- tests/09-initial.cpp | 2 +- tests/09-output.graphml | 3 +++ tests/09-output.txt | 2 +- tests/10-final.cpp | 2 +- tests/10-output.graphml | 3 +++ tests/10-output.txt | 2 +- tests/11-choice.cpp | 2 +- tests/11-output.graphml | 3 +++ tests/11-output.txt | 2 +- tests/13-output.graphml | 26 ++++++++++++++++++++++++++ tests/13-output.txt | 2 +- tests/13-transitions.cpp | 12 ++++++++---- tests/14-comments.cpp | 10 +++++++--- tests/14-output.graphml | 14 ++++++++++++++ tests/14-output.txt | 2 +- tests/15-output.graphml | 3 +++ tests/15-output.txt | 2 +- tests/15-terminate.cpp | 2 +- 24 files changed, 87 insertions(+), 21 deletions(-) diff --git a/tests/06-output.graphml b/tests/06-output.graphml index 344fb58..73756da 100644 --- a/tests/06-output.graphml +++ b/tests/06-output.graphml @@ -37,5 +37,8 @@ eventPropagation/ block SM2 + + + diff --git a/tests/06-output.txt b/tests/06-output.txt index bb597c2..ae3b905 100644 --- a/tests/06-output.txt +++ b/tests/06-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM1'}, State Machine: {id: 'G1', name: 'SM2'}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM1'}, State Machine: {id: 'G1', name: 'SM2', geometry: (1; 2; 300; 40)}} diff --git a/tests/06-two-statemachines.cpp b/tests/06-two-statemachines.cpp index 9c85ad3..7d27aa0 100644 --- a/tests/06-two-statemachines.cpp +++ b/tests/06-two-statemachines.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) d.new_state_machine("G0", "SM2"); } catch (const Cyberiada::ParametersException&){ } - d.new_state_machine("SM2"); + d.new_state_machine("SM2", Rect(1, 2, 300, 40)); try { cout << d << endl; d.save(string(argv[0]) + ".graphml", formatCyberiada10); diff --git a/tests/07-output.graphml b/tests/07-output.graphml index 5bab763..9040be5 100644 --- a/tests/07-output.graphml +++ b/tests/07-output.graphml @@ -36,6 +36,9 @@ eventPropagation/ block First state + + + diff --git a/tests/07-output.txt b/tests/07-output.txt index 6f3fbff..b2267ca 100644 --- a/tests/07-output.txt +++ b/tests/07-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Simple State: {id: 'n0', name: 'First state'}}}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Simple State: {id: 'n0', name: 'First state', geometry: (0; 50; 100; 25)}}}} diff --git a/tests/07-single-state.cpp b/tests/07-single-state.cpp index 7ef9ac7..5e302fe 100644 --- a/tests/07-single-state.cpp +++ b/tests/07-single-state.cpp @@ -30,7 +30,7 @@ int main(int argc, char** argv) { Document d; StateMachine* sm = d.new_state_machine("SM"); - d.new_state(sm, "First state"); + d.new_state(sm, "First state", Action(), Rect(0, 50, 100, 25)); try { cout << d << endl; d.save(string(argv[0]) + ".graphml", formatCyberiada10); diff --git a/tests/09-initial.cpp b/tests/09-initial.cpp index 5f35091..dec65d7 100644 --- a/tests/09-initial.cpp +++ b/tests/09-initial.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) d.new_initial(sm, ""); } catch (const Cyberiada::ParametersException&){ } - d.new_initial(parent, "Local init"); + d.new_initial(parent, "Local init", Point(30, 40)); try { // check double initial d.new_initial(parent); diff --git a/tests/09-output.graphml b/tests/09-output.graphml index ae4a518..22089bc 100644 --- a/tests/09-output.graphml +++ b/tests/09-output.graphml @@ -40,6 +40,9 @@ eventPropagation/ block initial Local init + + + diff --git a/tests/09-output.txt b/tests/09-output.txt index ee5979b..9f5bbf2 100644 --- a/tests/09-output.txt +++ b/tests/09-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Composite State: {id: 'n0', name: 'State', elements: {Initial: {id: 'n0::n0', name: 'Local init'}}}, Initial: {id: 'n1'}}}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Composite State: {id: 'n0', name: 'State', elements: {Initial: {id: 'n0::n0', name: 'Local init', geometry: (30; 40)}}}, Initial: {id: 'n1'}}}} diff --git a/tests/10-final.cpp b/tests/10-final.cpp index cc7c618..c075461 100644 --- a/tests/10-final.cpp +++ b/tests/10-final.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) } State* parent = d.new_state(sm, "State"); - d.new_final(parent, "Local exit"); + d.new_final(parent, "Local exit", Point(30, 40)); try { cout << d << endl; diff --git a/tests/10-output.graphml b/tests/10-output.graphml index a458dab..e3bf8d8 100644 --- a/tests/10-output.graphml +++ b/tests/10-output.graphml @@ -43,6 +43,9 @@ eventPropagation/ block final Local exit + + + diff --git a/tests/10-output.txt b/tests/10-output.txt index 2585e1f..5d9cd72 100644 --- a/tests/10-output.txt +++ b/tests/10-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Final: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Final: {id: 'n1::n0', name: 'Local exit'}}}}}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Final: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Final: {id: 'n1::n0', name: 'Local exit', geometry: (30; 40)}}}}}} diff --git a/tests/11-choice.cpp b/tests/11-choice.cpp index a6573f2..243adbd 100644 --- a/tests/11-choice.cpp +++ b/tests/11-choice.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) } State* parent = d.new_state(sm, "State"); - d.new_choice(parent, "Local choice"); + d.new_choice(parent, "Local choice", Rect(0, 5, 100, 50)); try { cout << d << endl; diff --git a/tests/11-output.graphml b/tests/11-output.graphml index 309d758..cd422a7 100644 --- a/tests/11-output.graphml +++ b/tests/11-output.graphml @@ -43,6 +43,9 @@ eventPropagation/ block choice Local choice + + + diff --git a/tests/11-output.txt b/tests/11-output.txt index d0d04eb..ac1c027 100644 --- a/tests/11-output.txt +++ b/tests/11-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Choice: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Choice: {id: 'n1::n0', name: 'Local choice'}}}}}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Choice: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Choice: {id: 'n1::n0', name: 'Local choice', geometry: (0; 5; 100; 50)}}}}}} diff --git a/tests/13-output.graphml b/tests/13-output.graphml index b09df62..02cf9e1 100644 --- a/tests/13-output.graphml +++ b/tests/13-output.graphml @@ -55,12 +55,38 @@ eventPropagation/ block IDLE/ + + + + + + + + + + + INSIDE/ + + + + + + OUTSIDE/ + + + + + + + + + EVENT [guard()]/ diff --git a/tests/13-output.txt b/tests/13-output.txt index 1c502f7..ed3bc9d 100644 --- a/tests/13-output.txt +++ b/tests/13-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Composite State: {id: 'n0', name: 'Parent 0', elements: {Simple State: {id: 'n0::n0', name: 'State 0'}, Simple State: {id: 'n0::n1', name: 'State 1'}}}, Simple State: {id: 'n1', name: 'Parent 1'}, Transition: {id: 'n0::n0-n0::n1', source: 'n0::n0', target: 'n0::n1'}, Transition: {id: 'n0::n0-n0::n1#0', source: 'n0::n0', target: 'n0::n1', action: {trigger: 'A'}}, Transition: {id: 'n0::n0-n0::n0', source: 'n0::n0', target: 'n0::n0', action: {trigger: 'IDLE'}}, Transition: {id: 'n0-n0::n0', source: 'n0', target: 'n0::n0', action: {trigger: 'INSIDE'}}, Transition: {id: 'n0::n1-n0', source: 'n0::n1', target: 'n0', action: {trigger: 'OUTSIDE'}}, Transition: {id: 'n0::n1-n1', source: 'n0::n1', target: 'n1', action: {trigger: 'EVENT', guard: 'guard()', behavior: 'action();'}}}}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Composite State: {id: 'n0', name: 'Parent 0', elements: {Simple State: {id: 'n0::n0', name: 'State 0'}, Simple State: {id: 'n0::n1', name: 'State 1'}}}, Simple State: {id: 'n1', name: 'Parent 1'}, Transition: {id: 'n0::n0-n0::n1', source: 'n0::n0', target: 'n0::n1'}, Transition: {id: 'n0::n0-n0::n1#0', source: 'n0::n0', target: 'n0::n1', action: {trigger: 'A'}}, Transition: {id: 'n0::n0-n0::n0', source: 'n0::n0', target: 'n0::n0', action: {trigger: 'IDLE'}, sp: (-1; -2), tp: (3; 4), polyline: [ (0; 0), (5; 10), (15; 20) ]}, Transition: {id: 'n0-n0::n0', source: 'n0', target: 'n0::n0', action: {trigger: 'INSIDE'}, sp: (-1; -2), tp: (3; 4)}, Transition: {id: 'n0::n1-n0', source: 'n0::n1', target: 'n0', action: {trigger: 'OUTSIDE'}, sp: (-1; -2), tp: (3; 4), label: (5; 6)}, Transition: {id: 'n0::n1-n1', source: 'n0::n1', target: 'n1', action: {trigger: 'EVENT', guard: 'guard()', behavior: 'action();'}}}}} diff --git a/tests/13-transitions.cpp b/tests/13-transitions.cpp index 56a6860..6daf862 100644 --- a/tests/13-transitions.cpp +++ b/tests/13-transitions.cpp @@ -45,10 +45,14 @@ int main(int argc, char** argv) d.new_transition(sm, sm, s1, Action()); } catch (const Cyberiada::ParametersException&){ } - - d.new_transition(sm, s1, s1, Action("IDLE")); - d.new_transition(sm, parent1, s1, Action("INSIDE")); - d.new_transition(sm, s2, parent1, Action("OUTSIDE")); + + Polyline pl; + pl.push_back(Point(0, 0)); + pl.push_back(Point(5, 10)); + pl.push_back(Point(15, 20)); + d.new_transition(sm, s1, s1, Action("IDLE"), pl, Point(-1, -2), Point(3, 4)); + d.new_transition(sm, parent1, s1, Action("INSIDE"), Polyline(), Point(-1, -2), Point(3, 4)); + d.new_transition(sm, s2, parent1, Action("OUTSIDE"), Polyline(), Point(-1, -2), Point(3, 4), Point(5, 6)); try { // check transition action diff --git a/tests/14-comments.cpp b/tests/14-comments.cpp index ec0f299..b06458d 100644 --- a/tests/14-comments.cpp +++ b/tests/14-comments.cpp @@ -39,11 +39,15 @@ int main(int argc, char** argv) } State* state = d.new_state(sm, "State", Action(actionEntry, "action();")); Comment* comm2 = d.new_comment(state, "Comment inside a state\nwith two lines"); - d.new_formal_comment(sm, "Name", "Named formal comment"); + d.new_formal_comment(sm, "Name", "Named formal comment", Rect(0, 5, 100, 50)); d.add_comment_to_element(comm, state); - d.add_comment_to_element_name(comm2, state, "S"); - d.add_comment_to_element_body(comm2, state, "action"); + d.add_comment_to_element_name(comm2, state, "S", Point(-1, -2), Point(3, 4)); + Polyline pl; + pl.push_back(Point(0, 0)); + pl.push_back(Point(5, 10)); + pl.push_back(Point(15, 20)); + d.add_comment_to_element_body(comm2, state, "action", Point(), Point(), pl); try { cout << d << endl; diff --git a/tests/14-output.graphml b/tests/14-output.graphml index 0e82ff3..fc76aff 100644 --- a/tests/14-output.graphml +++ b/tests/14-output.graphml @@ -55,6 +55,9 @@ with two lines formal Name Named formal comment + + + @@ -62,10 +65,21 @@ with two lines dName S + + + + + + dData action + + + + + diff --git a/tests/14-output.txt b/tests/14-output.txt index c63320f..aaa092c 100644 --- a/tests/14-output.txt +++ b/tests/14-output.txt @@ -1,2 +1,2 @@ Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Comment: {id: 'n0', body: 'Top level', subjects: {{id: 'n0-n1', type: element, to: 'n1'}}}, Composite State: {id: 'n1', name: 'State', actions: {a {entry, behavior: 'action();'}}, elements: {Comment: {id: 'n1::n0', body: 'Comment inside a state -with two lines', subjects: {{id: 'n1::n0-n1', type: name, to: 'n1', fragment: 'S'}, {id: 'n1::n0-n1', type: data, to: 'n1', fragment: 'action'}}}}}, Formal Comment: {id: 'n2', name: 'Name', body: 'Named formal comment'}}}} +with two lines', subjects: {{id: 'n1::n0-n1', type: name, to: 'n1', fragment: 'S', source point: (-1; -2), target point: (3; 4)}, {id: 'n1::n0-n1', type: data, to: 'n1', fragment: 'action', polyline: [ (0; 0), (5; 10), (15; 20) ]}}}}}, Formal Comment: {id: 'n2', name: 'Name', body: 'Named formal comment', geometry: (0; 5; 100; 50)}}}} diff --git a/tests/15-output.graphml b/tests/15-output.graphml index 77c79a0..cd59ea0 100644 --- a/tests/15-output.graphml +++ b/tests/15-output.graphml @@ -43,6 +43,9 @@ eventPropagation/ block terminate Local term + + + diff --git a/tests/15-output.txt b/tests/15-output.txt index 796926d..384d540 100644 --- a/tests/15-output.txt +++ b/tests/15-output.txt @@ -1 +1 @@ -Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Terminate: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Terminate: {id: 'n1::n0', name: 'Local term'}}}}}} +Document: {id: '', name: '', format: 'Cyberiada-GraphML-1.0', meta: {standard version: '1.0', transition order: transition first, event propagation: block events}, elements: {State Machine: {id: 'G0', name: 'SM', elements: {Terminate: {id: 'n0'}, Composite State: {id: 'n1', name: 'State', elements: {Terminate: {id: 'n1::n0', name: 'Local term', geometry: (30; 40)}}}}}} diff --git a/tests/15-terminate.cpp b/tests/15-terminate.cpp index b0e2da4..2ef9f1f 100644 --- a/tests/15-terminate.cpp +++ b/tests/15-terminate.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) } State* parent = d.new_state(sm, "State"); - d.new_terminate(parent, "Local term"); + d.new_terminate(parent, "Local term", Point(30, 40)); try { cout << d << endl;