Skip to content

Commit 063a08e

Browse files
committed
Makesure the DLL is loaded
1 parent 872764d commit 063a08e

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

analytics/integration_test/src/integration_test.cc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ void FirebaseAnalyticsTest::SetUpTestSuite() {
7070
#endif // defined(__ANDROID__)
7171

7272
firebase::analytics::Initialize(*shared_app_);
73+
LogInfo("Analytics DLL Loaded: %s",
74+
firebase::analytics::IsAnalyticsDllLoaded() ? "true" : "false");
7375
did_test_setconsent_ = false;
7476
}
7577

@@ -249,17 +251,28 @@ TEST_F(FirebaseAnalyticsTest, TestSetLogCallback) {
249251
std::promise<void> finishedPromise;
250252
std::future<void> finished = finishedPromise.get_future();
251253
bool log_callback_called = false;
254+
ProcessEvents(1000);
255+
ProcessEvents(1000);
256+
ProcessEvents(1000);
257+
ProcessEvents(1000);
258+
ProcessEvents(1000);
252259

253260
// Save the current log level, and set to verbose for this test.
254261
firebase::LogLevel current_log_level = firebase::GetLogLevel();
255262
firebase::SetLogLevel(firebase::LogLevel::kLogLevelVerbose);
256-
263+
ProcessEvents(1000);
264+
ProcessEvents(1000);
265+
ProcessEvents(1000);
266+
ProcessEvents(1000);
257267
firebase::analytics::SetLogCallback(
258268
[&](firebase::LogLevel log_level, const char* message) {
259269
log_callback_called = true;
260270
finishedPromise.set_value();
261271
});
262272

273+
274+
275+
263276
// Pass kUnknown to trigger a warning log directly from the DLL (on
264277
// Windows),
265278
firebase::analytics::NotifyAppLifecycleChange(firebase::analytics::kUnknown);

analytics/src/analytics_desktop.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ bool IsInitialized() { return g_initialized; }
134134

135135
} // namespace internal
136136

137+
#if defined(_WIN32)
138+
bool IsAnalyticsDllLoaded() { return g_analytics_module != 0; }
139+
#else
140+
bool IsAnalyticsDllLoaded() { return false; }
141+
#endif // defined(_WIN32)
142+
137143
// Terminates the Analytics desktop API.
138144
// Call this function when Analytics is no longer needed to free up resources.
139145
void Terminate() {

analytics/src/include/firebase/analytics.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,11 @@ using LogCallback = std::function<void(LogLevel, const char*)>;
623623
/// @param[in] callback The callback to use. Must be thread-safe.
624624
void SetLogCallback(const LogCallback& callback);
625625

626+
/// @brief Returns true if the Google Analytics DLL was successfully loaded.
627+
///
628+
/// @returns true if the DLL was loaded, false otherwise.
629+
bool IsAnalyticsDllLoaded();
630+
626631
/// @brief The state of an app in its lifecycle.
627632
///
628633
/// kUnknown is an invalid state that is used to capture uninitialized values.

0 commit comments

Comments
 (0)