@@ -173,6 +173,12 @@ class FirebaseGmaUITest : public FirebaseGmaTest {
173
173
void SetUp () override ;
174
174
};
175
175
176
+ class FirebaseGmaMinimalTest : public FirebaseTest {
177
+ public:
178
+ FirebaseGmaMinimalTest ();
179
+ ~FirebaseGmaMinimalTest () override ;
180
+ };
181
+
176
182
// Runs GMA Tests on methods and functions that should be run
177
183
// before GMA initializes.
178
184
class FirebaseGmaPreInitializationTests : public FirebaseGmaTest {
@@ -228,11 +234,11 @@ void FirebaseGmaTest::SetUpTestSuite() {
228
234
}
229
235
230
236
void 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 " );
236
242
LogDebug (" Shutdown GMA." );
237
243
firebase::gma::Terminate ();
238
244
LogDebug (" Shutdown Firebase App." );
@@ -301,6 +307,10 @@ firebase::Variant FirebaseGmaTest::GetVariantMap() {
301
307
return variant_map;
302
308
}
303
309
310
+ FirebaseGmaMinimalTest::FirebaseGmaMinimalTest () {}
311
+
312
+ FirebaseGmaMinimalTest::~FirebaseGmaMinimalTest () {}
313
+
304
314
FirebaseGmaUITest::FirebaseGmaUITest () {}
305
315
306
316
FirebaseGmaUITest::~FirebaseGmaUITest () {}
@@ -340,6 +350,26 @@ void FirebaseGmaPreInitializationTests::SetUpTestSuite() {
340
350
341
351
// Test cases below.
342
352
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
+
343
373
TEST_F (FirebaseGmaPreInitializationTests, TestDisableMediationInitialization) {
344
374
// Note: This test should be disabled or put in an entirely different test
345
375
// binrary if we ever wish to test mediation in this application.
0 commit comments