@@ -341,26 +341,32 @@ TEST_F(FirebaseAnalyticsTest, TestSetConsent) {
341
341
did_test_setconsent_ = true ;
342
342
}
343
343
344
- // Test that it compiles and runs on all platforms.
345
344
TEST_F (FirebaseAnalyticsTest, TestSetDefaultEventParameters) {
346
345
LogInfo (" Testing SetDefaultEventParameters()." );
347
346
348
- // Set some default parameters.
347
+ // Set some default parameters with various types .
349
348
std::map<std::string, firebase::Variant> defaults;
350
- defaults[" default_int" ] = 123 ;
351
- defaults[" default_string" ] = " default_value" ;
349
+ defaults[" default_int" ] = static_cast <int64_t >(123 ); // int64_t
350
+ defaults[" default_double" ] = 45.67 ; // double
351
+ defaults[" default_bool" ] = true ; // bool
352
+ defaults[" default_string" ] = " test_string_value" ; // const char*
353
+ defaults[" default_to_clear" ] = " will_be_cleared" ; // Another string
354
+
352
355
firebase::analytics::SetDefaultEventParameters (defaults);
356
+ LogInfo (" Set initial default parameters." );
353
357
354
358
// Log an event - the defaults should be included automatically by the
355
359
// underlying SDK if logging immediately after setting is supported.
356
360
// Verification might need manual checking in the Analytics console or
357
361
// via platform-specific debug logs if possible.
358
- firebase::analytics::LogEvent (" event_with_defaults " );
359
- LogInfo (" Logged event_with_defaults " );
362
+ firebase::analytics::LogEvent (" event_with_mixed_defaults " );
363
+ LogInfo (" Logged event_with_mixed_defaults " );
360
364
361
- // Clear one default parameter by setting it to null.
362
- defaults[" default_int" ] = firebase::Variant::Null ();
365
+ // Clear one default parameter and update another.
366
+ defaults[" default_to_clear" ] = firebase::Variant::Null (); // Clear this one
367
+ defaults[" default_int" ] = static_cast <int64_t >(999 ); // Update this one
363
368
firebase::analytics::SetDefaultEventParameters (defaults);
369
+ LogInfo (" Cleared one parameter and updated another." );
364
370
365
371
// Log another event.
366
372
firebase::analytics::LogEvent (" event_with_one_default_cleared" );
@@ -369,22 +375,36 @@ TEST_F(FirebaseAnalyticsTest, TestSetDefaultEventParameters) {
369
375
// Set only one parameter, clearing others implicitly if underlying SDK works
370
376
// like that
371
377
std::map<std::string, firebase::Variant> single_default;
372
- single_default[" only_this " ] = 45.6 ;
378
+ single_default[" only_this_double " ] = 78.9 ;
373
379
firebase::analytics::SetDefaultEventParameters (single_default);
374
- firebase::analytics::LogEvent (" event_with_only_one_default" );
380
+ LogInfo (" Set a single different default parameter." );
381
+ firebase::analytics::LogEvent (
382
+ " event_with_only_one_default" ); // Changed log event name slightly
375
383
LogInfo (" Logged event_with_only_one_default" );
376
384
377
- // Clear all defaults by passing an empty map.
378
- std::map<std::string, firebase::Variant> empty_defaults;
379
- firebase::analytics::SetDefaultEventParameters (empty_defaults);
380
-
381
- // Log an event with no defaults.
382
- firebase::analytics::LogEvent (" event_with_no_defaults" );
383
- LogInfo (" Logged event_with_no_defaults" );
384
-
385
385
// If we reach here without crashing, consider the basic test passed for the
386
386
// C++ layer. Deeper verification requires platform tools.
387
387
LogInfo (" SetDefaultEventParameters() tests completed." );
388
388
}
389
389
390
+ TEST_F (FirebaseAnalyticsTest, TestClearDefaultEventParameters) {
391
+ LogInfo (" Testing ClearDefaultEventParameters()." );
392
+
393
+ // Set some defaults first.
394
+ std::map<std::string, firebase::Variant> defaults;
395
+ defaults[" temp_default" ] = " will_be_cleared" ;
396
+ firebase::analytics::SetDefaultEventParameters (defaults);
397
+
398
+ // Now clear them all.
399
+ firebase::analytics::ClearDefaultEventParameters ();
400
+
401
+ // Log an event - no defaults should be included.
402
+ firebase::analytics::LogEvent (" event_after_clear_defaults" );
403
+ LogInfo (" Logged event_after_clear_defaults" );
404
+
405
+ // If we reach here without crashing, consider the basic test passed for the
406
+ // C++ layer.
407
+ LogInfo (" ClearDefaultEventParameters() test completed." );
408
+ }
409
+
390
410
} // namespace firebase_testapp_automated
0 commit comments