@@ -173,6 +173,12 @@ class FirebaseGmaUITest : public FirebaseGmaTest {
173173 void SetUp () override ;
174174};
175175
176+ class FirebaseGmaMinimalTest : public FirebaseTest {
177+ public:
178+ FirebaseGmaMinimalTest ();
179+ ~FirebaseGmaMinimalTest () override ;
180+ };
181+
176182// Runs GMA Tests on methods and functions that should be run
177183// before GMA initializes.
178184class FirebaseGmaPreInitializationTests : public FirebaseGmaTest {
@@ -228,11 +234,11 @@ void FirebaseGmaTest::SetUpTestSuite() {
228234}
229235
230236void FirebaseGmaTest::TearDownTestSuite () {
231- // Workaround: GMA does some of its initialization in the main
232- // thread, so if you terminate it too quickly after initialization
233- // it can cause issues. Add a small delay here in case most of the
234- // tests are skipped.
235- ProcessEvents ( 1000 );
237+ // GMA does some of its initialization in the main thread, so if you terminate
238+ // it before initialization has completed, it can cause issues. So wait for
239+ // any pending GMA initialization to be completed before calling terminate.
240+ WaitForCompletion ( firebase::gma::InitializeLastResult (),
241+ " gma::InitializeLastResult " );
236242 LogDebug (" Shutdown GMA." );
237243 firebase::gma::Terminate ();
238244 LogDebug (" Shutdown Firebase App." );
@@ -301,6 +307,10 @@ firebase::Variant FirebaseGmaTest::GetVariantMap() {
301307 return variant_map;
302308}
303309
310+ FirebaseGmaMinimalTest::FirebaseGmaMinimalTest () {}
311+
312+ FirebaseGmaMinimalTest::~FirebaseGmaMinimalTest () {}
313+
304314FirebaseGmaUITest::FirebaseGmaUITest () {}
305315
306316FirebaseGmaUITest::~FirebaseGmaUITest () {}
@@ -340,6 +350,26 @@ void FirebaseGmaPreInitializationTests::SetUpTestSuite() {
340350
341351// Test cases below.
342352
353+ TEST_F (FirebaseGmaMinimalTest, TestInitializeGmaWithoutFirebase) {
354+ // Don't initialize mediation in this test so that a later test can still
355+ // verify that mediation has not been initialized.
356+ firebase::gma::DisableMediationInitialization ();
357+ LogDebug (" Initializing GMA without a Firebase App." );
358+ firebase::InitResult result;
359+ #if defined(ANDROID)
360+ ::firebase::gma::Initialize (app_framework::GetJniEnv(),
361+ app_framework::GetActivity(), &result);
362+ #else // !defined(ANDROID)
363+ ::firebase::gma::Initialize (&result);
364+ #endif // defined(ANDROID)
365+ EXPECT_EQ (result, ::firebase::kInitResultSuccess );
366+ WaitForCompletion (firebase::gma::InitializeLastResult (), " gma::Initialize" );
367+ LogDebug (" Successfully initialized GMA." );
368+
369+ LogDebug (" Shutdown GMA." );
370+ firebase::gma::Terminate ();
371+ }
372+
343373TEST_F (FirebaseGmaPreInitializationTests, TestDisableMediationInitialization) {
344374 // Note: This test should be disabled or put in an entirely different test
345375 // binrary if we ever wish to test mediation in this application.
0 commit comments