@@ -53,6 +53,15 @@ FAKE_VALUE_FUNC(int, date_time_set, const struct tm *);
5353FAKE_VALUE_FUNC (const char * , location_method_str , enum location_method );
5454FAKE_VALUE_FUNC (int , nrf_cloud_coap_location_send , const struct nrf_cloud_gnss_data * , bool );
5555
56+ /* Helper function to verify location status messages */
57+ static void verify_location_status (enum location_msg_type expected_status )
58+ {
59+ enum location_msg_type received_status ;
60+ int err = zbus_chan_read (& LOCATION_CHAN , & received_status , K_MSEC (100 ));
61+
62+ TEST_ASSERT_EQUAL (0 , err );
63+ TEST_ASSERT_EQUAL (expected_status , received_status );
64+ }
5665
5766/* Define FFF globals */
5867DEFINE_FFF_GLOBALS ;
@@ -128,6 +137,33 @@ void test_location_search_trigger(void)
128137 TEST_ASSERT_NULL (location_request_fake .arg0_val ); /* No config provided */
129138}
130139
140+ /* Test location event handler with basic location event */
141+ void test_location_event_handler_basic (void )
142+ {
143+ /* Wait for module initialization */
144+ k_sleep (K_MSEC (100 ));
145+
146+ /* Set up location_method_str fake to return a dummy string */
147+ location_method_str_fake .return_val = "TEST_METHOD" ;
148+
149+ /* Create a simple location event */
150+ struct location_event_data mock_event = {
151+ .id = LOCATION_EVT_LOCATION ,
152+ .method = LOCATION_METHOD_CELLULAR ,
153+ .location = {
154+ .latitude = 60.123 ,
155+ .longitude = 10.456 ,
156+ .accuracy = 5.0
157+ }
158+ };
159+
160+ /* Call the real handler through our stored reference */
161+ registered_handler (& mock_event );
162+
163+ /* Verify correct status message was published */
164+ verify_location_status (LOCATION_SEARCH_DONE );
165+ }
166+
131167/* Unity requirement */
132168extern int unity_main (void );
133169
0 commit comments