Commit a630f6b 1 parent b8d47e6 commit a630f6b Copy full SHA for a630f6b
File tree 2 files changed +41
-0
lines changed
2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1609,6 +1609,15 @@ def finalize_event(event, timestamp = nil)
1609
1609
event . finalized! ( timestamp )
1610
1610
end
1611
1611
1612
+ # Apply to +to+ the marks (permanent, mission) of +from+
1613
+ #
1614
+ # It does not remove any marks from +from+
1615
+ def copy_task_marks ( to :, from :)
1616
+ add_permanent_task ( to ) if permanent_task? ( from )
1617
+
1618
+ add_mission_task ( to ) if mission_task? ( from )
1619
+ end
1620
+
1612
1621
def remove_task ( task , timestamp = Time . now )
1613
1622
verify_plan_object_finalization_sanity ( task )
1614
1623
remove_task! ( task , timestamp )
Original file line number Diff line number Diff line change @@ -885,6 +885,38 @@ def prepare_mappings(mappings)
885
885
end
886
886
end
887
887
888
+ describe "#copy_task_marks" do
889
+ attr_reader :task_1 , :task_2
890
+
891
+ before do
892
+ plan . add ( @task_1 = Roby ::Task . new )
893
+ plan . add ( @task_2 = Roby ::Task . new )
894
+ end
895
+
896
+ it "copies mission mark from one task to the other" do
897
+ plan . add_mission_task ( task_1 )
898
+
899
+ plan . copy_task_marks ( from : task_1 , to : task_2 )
900
+ assert_equal plan . mission_task? ( task_1 ) , plan . mission_task? ( task_2 )
901
+ end
902
+
903
+ it "copies permanent mark from one task to the other" do
904
+ plan . add_permanent_task ( task_1 )
905
+
906
+ plan . copy_task_marks ( from : task_1 , to : task_2 )
907
+ assert_equal plan . permanent_task? ( task_1 ) , plan . permanent_task? ( task_2 )
908
+ end
909
+
910
+ it "does not unmark +to+ task" do
911
+ plan . add_mission_task ( task_2 )
912
+
913
+ plan . copy_task_marks ( from : task_1 , to : task_2 )
914
+
915
+ refute plan . permanent_task? ( task_2 )
916
+ assert plan . mission_task? ( task_2 )
917
+ end
918
+ end
919
+
888
920
describe "#remove_task" do
889
921
before do
890
922
plan . add ( @task = Roby ::Task . new )
You can’t perform that action at this time.
0 commit comments