Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SilKit/source/services/lin/LinController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@ void LinController::SetControllerStatusInternal(LinControllerStatus status)

LinControllerStatusUpdate msg;
msg.status = status;
msg.timestamp = _timeProvider->Now();

SendMsg(msg);
}
Expand Down
8 changes: 8 additions & 0 deletions SilKit/source/services/lin/LinTestUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const LinControllerStatusUpdate&>
{
using namespace testing;
return AllOf(Field(&LinControllerStatusUpdate::status, status),
Field(&LinControllerStatusUpdate::timestamp, timestamp));
}

struct Callbacks
{
MOCK_METHOD3(FrameStatusHandler, void(ILinController*, const LinFrame&, LinFrameStatus));
Expand Down
14 changes: 10 additions & 4 deletions SilKit/source/services/lin/Test_LinControllerDetailedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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();
}
Expand All @@ -210,7 +213,8 @@ TEST_F(Test_LinControllerDetailedSim, go_to_sleep_internal)
master.Init(config);

EXPECT_CALL(participant, SendMsg(&master, netsimName, A<const LinSendFrameRequest&>())).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();
}
Expand Down Expand Up @@ -262,7 +266,8 @@ TEST_F(Test_LinControllerDetailedSim, wake_up)
master.Init(config);

EXPECT_CALL(participant, SendMsg(&master, netsimName, A<const LinWakeupPulse&>())).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();
}
Expand All @@ -275,7 +280,8 @@ TEST_F(Test_LinControllerDetailedSim, wake_up_internal)
master.Init(config);

EXPECT_CALL(participant, SendMsg(&master, netsimName, A<const LinWakeupPulse&>())).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();
}
Expand Down
18 changes: 10 additions & 8 deletions SilKit/source/services/lin/Test_LinControllerTrivialSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,18 +617,19 @@ 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();
}

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();
}
Expand Down Expand Up @@ -668,8 +669,8 @@ TEST_F(Test_LinControllerTrivialSim, wake_up)
master.Init(MakeControllerConfig(LinControllerMode::Master));

EXPECT_CALL(participant, SendMsg(&master, A<const LinWakeupPulse&>())).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();
}
Expand All @@ -680,7 +681,8 @@ TEST_F(Test_LinControllerTrivialSim, wake_up_internal)
master.Init(config);

EXPECT_CALL(participant, SendMsg(&master, A<const LinWakeupPulse&>())).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();
}
Expand Down
Loading