@@ -89,6 +89,42 @@ TEST_F(VehicleTest, InfotainmentPollWithForceWakeSendsData) {
8989 EXPECT_GE (writes.size (), 1 ) << " Infotainment poll with force_wake should send data" ;
9090}
9191
92+ // ============================================================================
93+ // Vehicle Sleep State Tests - Regression test for charging vehicle polling bug
94+ // Issue: Infotainment polls were skipped when vehicle was charging because
95+ // VCSEC reports UNKNOWN status (not AWAKE) for charging vehicles.
96+ // Fix: Inverted logic to treat vehicle as awake unless explicitly ASLEEP.
97+ // ============================================================================
98+
99+ TEST_F (VehicleTest, InfotainmentPollSkippedWhenAsleepByDefault) {
100+ // Verify default behavior: vehicle starts in asleep state (no VCSEC status received)
101+ // and infotainment polls without force_wake should be skipped
102+
103+ bool poll_callback_called = false ;
104+ bool poll_success = false ;
105+
106+ vehicle_->send_command (
107+ UniversalMessage_Domain_DOMAIN_INFOTAINMENT,
108+ " Optional Poll" ,
109+ [](Client* client, uint8_t * buff, size_t * len) {
110+ return client->buildCarServerGetVehicleDataMessage (buff, len, CarServer_GetVehicleData_getChargeState_tag);
111+ },
112+ [&](bool success) {
113+ poll_callback_called = true ;
114+ poll_success = success;
115+ },
116+ false // requires_wake = false (optional poll)
117+ );
118+ vehicle_->loop ();
119+
120+ // Poll should be skipped (no BLE writes) but callback invoked with success
121+ EXPECT_TRUE (poll_callback_called) << " Callback should be invoked for skipped poll" ;
122+ EXPECT_TRUE (poll_success) << " Skipped poll should report success (no-op)" ;
123+
124+ auto writes = mock_ble_->get_written_data ();
125+ EXPECT_EQ (writes.size (), 0 ) << " Poll should be skipped when vehicle is asleep" ;
126+ }
127+
92128TEST_F (VehicleTest, SetChargingAmpsSendsData) {
93129 vehicle_->set_charging_amps (16 );
94130 vehicle_->loop ();
0 commit comments