diff --git a/engine/BUILD.bazel b/engine/BUILD.bazel index 1143206ab9845afaf5d2154ccfc29060b36571d5..2c0353c29313977edf20d35f39f82eaa2acfb4d7 100644 --- a/engine/BUILD.bazel +++ b/engine/BUILD.bazel @@ -177,7 +177,7 @@ cc_test( data = [":open_scenario_engine_test_data"], tags = ["test"], deps = [ - "test_utils", + ":test_utils", ":open_scenario_engine", ":open_scenario_engine_test_utils", "@googletest//:gtest_main", @@ -197,6 +197,7 @@ cc_test( deps = [ ":open_scenario_engine", ":open_scenario_engine_test_utils", + ":test_utils", "@googletest//:gtest_main", "@mantle_api//:test_utils", ], diff --git a/engine/src/Node/EventNode.cpp b/engine/src/Node/EventNode.cpp index a20bbe48b9c2bc0473a6397d39addab8d27369e7..532f5765a23e6713115eded5fd38c5910cc64ccf 100644 --- a/engine/src/Node/EventNode.cpp +++ b/engine/src/Node/EventNode.cpp @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (c) 2025 Ansys, Inc. + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -37,7 +38,7 @@ yase::NodeStatus EventNode::tick() auto current_status = TriggerableCompositeNode::tick(); - if (start_trigger_->status() == yase::NodeStatus::kSuccess) + if (start_trigger_ == nullptr || start_trigger_->status() == yase::NodeStatus::kSuccess) { event_prioritizer_->EventStarted(name()); } diff --git a/engine/tests/Node/EventNodeTest.cpp b/engine/tests/Node/EventNodeTest.cpp index 8023ef7842a402635555b6263b0c55e810fedb32..899c66c4800377ef907e605fad3d184951b057a7 100644 --- a/engine/tests/Node/EventNodeTest.cpp +++ b/engine/tests/Node/EventNodeTest.cpp @@ -1,5 +1,6 @@ /******************************************************************************* * Copyright (c) 2025 Ansys, Inc. + * Copyright (c) 2025 Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -57,7 +58,7 @@ class EventNodeTest : public testing::Test { protected: EventNodeTest() - : root{tree.get_root()}, event_prioritizer{tree.get_event_prioritizer()} + : root{tree.get_root()}, event_prioritizer{tree.get_event_prioritizer()} { ON_CALL(event_prioritizer, RegisterEvent).WillByDefault(Return()); ON_CALL(*mock_action_node, tick()).WillByDefault(Return(yase::NodeStatus::kSuccess)); @@ -135,3 +136,15 @@ TEST_F(EventNodeTest, GivenStartedNodeWithNonSkipPriority_WhenShouldStopChildAnd EXPECT_CALL(event_prioritizer, EventStarted).Times(0); ASSERT_THAT(root.executeTick(), yase::NodeStatus::kSuccess); } + +TEST_F(EventNodeTest, GivenEventWithoutStartTrigger_WhenTick_ThenEventStarted) +{ + auto event_under_test = std::make_shared<EventNode>("Event", mock_action_node, nullptr); + root.setChild(event_under_test); + root.distributeData(); + + EXPECT_CALL(event_prioritizer, ShouldStopChild).Times(1).WillOnce(Return(false)); + EXPECT_CALL(event_prioritizer, ShouldSkipChild).Times(1).WillOnce(Return(false)); + EXPECT_CALL(event_prioritizer, EventStarted).Times(1).WillOnce(Return()); + root.executeTick(); +}