diff --git a/SilKit/source/services/lin/LinController.cpp b/SilKit/source/services/lin/LinController.cpp index 07bd1cafa..a70decbcc 100644 --- a/SilKit/source/services/lin/LinController.cpp +++ b/SilKit/source/services/lin/LinController.cpp @@ -608,6 +608,7 @@ void LinController::SetControllerStatusInternal(LinControllerStatus status) LinControllerStatusUpdate msg; msg.status = status; + msg.timestamp = _timeProvider->Now(); SendMsg(msg); } diff --git a/SilKit/source/services/lin/LinTestUtils.hpp b/SilKit/source/services/lin/LinTestUtils.hpp index 5b53d0478..fafd0b2b0 100644 --- a/SilKit/source/services/lin/LinTestUtils.hpp +++ b/SilKit/source/services/lin/LinTestUtils.hpp @@ -108,6 +108,14 @@ inline auto AControllerStatusUpdateWith(LinControllerStatus status) return Field(&LinControllerStatusUpdate::status, status); } +inline auto AControllerStatusUpdateWith(LinControllerStatus status, std::chrono::nanoseconds timestamp) + -> testing::Matcher +{ + using namespace testing; + return AllOf(Field(&LinControllerStatusUpdate::status, status), + Field(&LinControllerStatusUpdate::timestamp, timestamp)); +} + struct Callbacks { MOCK_METHOD3(FrameStatusHandler, void(ILinController*, const LinFrame&, LinFrameStatus)); diff --git a/SilKit/source/services/lin/Test_LinControllerDetailedSim.cpp b/SilKit/source/services/lin/Test_LinControllerDetailedSim.cpp index 06122ca23..93f915c6f 100644 --- a/SilKit/source/services/lin/Test_LinControllerDetailedSim.cpp +++ b/SilKit/source/services/lin/Test_LinControllerDetailedSim.cpp @@ -56,6 +56,8 @@ class Test_LinControllerDetailedSim : public testing::Test controllerBusSim.SetServiceDescriptor(addr1_netsim); master.SetDetailedBehavior(addr1_netsim); slave1.SetDetailedBehavior(addr1_netsim); + + ON_CALL(participant.mockTimeProvider, Now()).WillByDefault(testing::Return(35s)); } protected: @@ -197,7 +199,8 @@ TEST_F(Test_LinControllerDetailedSim, go_to_sleep) expectedMsg.responseType = LinFrameResponseType::MasterResponse; EXPECT_CALL(participant, SendMsg(&master, netsimName, expectedMsg)).Times(1); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::SleepPending))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::SleepPending, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); master.GoToSleep(); } @@ -210,7 +213,8 @@ TEST_F(Test_LinControllerDetailedSim, go_to_sleep_internal) master.Init(config); EXPECT_CALL(participant, SendMsg(&master, netsimName, A())).Times(0); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Sleep))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Sleep, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); master.GoToSleepInternal(); } @@ -262,7 +266,8 @@ TEST_F(Test_LinControllerDetailedSim, wake_up) master.Init(config); EXPECT_CALL(participant, SendMsg(&master, netsimName, A())).Times(1); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); master.Wakeup(); } @@ -275,7 +280,8 @@ TEST_F(Test_LinControllerDetailedSim, wake_up_internal) master.Init(config); EXPECT_CALL(participant, SendMsg(&master, netsimName, A())).Times(0); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); master.WakeupInternal(); } diff --git a/SilKit/source/services/lin/Test_LinControllerTrivialSim.cpp b/SilKit/source/services/lin/Test_LinControllerTrivialSim.cpp index 47067240d..4a7eb022d 100644 --- a/SilKit/source/services/lin/Test_LinControllerTrivialSim.cpp +++ b/SilKit/source/services/lin/Test_LinControllerTrivialSim.cpp @@ -617,9 +617,9 @@ TEST_F(Test_LinControllerTrivialSim, go_to_sleep) { master.Init(MakeControllerConfig(LinControllerMode::Master)); - EXPECT_CALL(participant, SendMsg(&master, ATransmissionWith(GoToSleepFrame(), LinFrameStatus::LIN_RX_OK))).Times(1); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Sleep))).Times(1); - EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); + EXPECT_CALL(participant, SendMsg(&master, ATransmissionWith(GoToSleepFrame(), LinFrameStatus::LIN_RX_OK, 35s))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Sleep, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(2); master.GoToSleep(); } @@ -627,8 +627,9 @@ TEST_F(Test_LinControllerTrivialSim, go_to_sleep_internal) { master.Init(MakeControllerConfig(LinControllerMode::Master)); - EXPECT_CALL(participant, SendMsg(&master, ATransmissionWith(GoToSleepFrame(), LinFrameStatus::LIN_RX_OK))).Times(0); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Sleep))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, ATransmissionWith(GoToSleepFrame(), LinFrameStatus::LIN_RX_OK, 35s))).Times(0); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Sleep, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); master.GoToSleepInternal(); } @@ -668,8 +669,8 @@ TEST_F(Test_LinControllerTrivialSim, wake_up) master.Init(MakeControllerConfig(LinControllerMode::Master)); EXPECT_CALL(participant, SendMsg(&master, A())).Times(1); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational))).Times(1); - EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(2); master.Wakeup(); } @@ -680,7 +681,8 @@ TEST_F(Test_LinControllerTrivialSim, wake_up_internal) master.Init(config); EXPECT_CALL(participant, SendMsg(&master, A())).Times(0); - EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational))).Times(1); + EXPECT_CALL(participant, SendMsg(&master, AControllerStatusUpdateWith(LinControllerStatus::Operational, 35s))).Times(1); + EXPECT_CALL(participant.mockTimeProvider, Now()).Times(1); master.WakeupInternal(); }