Skip to content

Commit 208c9ea

Browse files
committed
fix: add in test for the DLL
1 parent 52db94f commit 208c9ea

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

analytics/integration_test/src/integration_test.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "firebase/analytics/user_property_names.h"
2828
#include "firebase/app.h"
2929
#include "firebase/util.h"
30+
#include "analytics/src/analytics_internal.h"
3031
#include "firebase_test_framework.h" // NOLINT
3132

3233
// The TO_STRING macro is useful for command line defined strings as the quotes
@@ -353,4 +354,12 @@ TEST_F(FirebaseAnalyticsTest, TestSetConsent) {
353354
did_test_setconsent_ = true;
354355
}
355356

357+
TEST_F(FirebaseAnalyticsTest, TestIsAnalyticsDllLoaded) {
358+
#if defined(_WIN32)
359+
EXPECT_TRUE(firebase::analytics::internal::IsAnalyticsDllLoaded());
360+
#else
361+
GTEST_SKIP();
362+
#endif // defined(_WIN32)
363+
}
364+
356365
} // namespace firebase_testapp_automated

analytics/src/analytics_android.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "analytics/src/analytics_common.h"
2525
#include "analytics/src/include/firebase/analytics.h"
26+
#include "analytics/src/analytics_internal.h"
2627
#include "app/src/assert.h"
2728
#include "app/src/include/firebase/app.h"
2829
#include "app/src/include/firebase/version.h"
@@ -165,6 +166,8 @@ namespace internal {
165166
// Determine whether the analytics module is initialized.
166167
bool IsInitialized() { return g_app != nullptr; }
167168

169+
bool IsAnalyticsDllLoaded() { return false; }
170+
168171
} // namespace internal
169172

170173
// Clean up the API.

analytics/src/analytics_desktop.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "app/src/include/firebase/future.h"
2626
#include "app/src/include/firebase/variant.h"
2727
#include "app/src/log.h"
28+
#include "analytics/src/analytics_internal.h"
2829

2930
#if defined(_WIN32)
3031
#include <windows.h>
@@ -41,6 +42,16 @@ namespace analytics {
4142
static HMODULE g_analytics_module = 0;
4243
#endif // defined(_WIN32)
4344

45+
namespace internal {
46+
bool IsAnalyticsDllLoaded() {
47+
#if defined(_WIN32)
48+
return g_analytics_module != 0;
49+
#else
50+
return false;
51+
#endif // defined(_WIN32)
52+
}
53+
} // namespace internal
54+
4455
// Future data for analytics.
4556
// This is initialized in `Initialize()` and cleaned up in `Terminate()`.
4657
static bool g_initialized = false;

analytics/src/analytics_internal.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright 2025 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#ifndef FIREBASE_ANALYTICS_SRC_ANALYTICS_INTERNAL_H_
16+
#define FIREBASE_ANALYTICS_SRC_ANALYTICS_INTERNAL_H_
17+
18+
namespace firebase {
19+
namespace analytics {
20+
namespace internal {
21+
22+
// Checks if the Analytics DLL is loaded.
23+
// Returns true if the DLL is loaded and functions are available.
24+
// Returns false otherwise (e.g. on non-Windows desktop platforms or if loading
25+
// failed).
26+
bool IsAnalyticsDllLoaded();
27+
28+
} // namespace internal
29+
} // namespace analytics
30+
} // namespace firebase
31+
32+
#endif // FIREBASE_ANALYTICS_SRC_ANALYTICS_INTERNAL_H_

analytics/src/analytics_ios.mm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "analytics/src/include/firebase/analytics.h"
2424

2525
#include "analytics/src/analytics_common.h"
26+
#include "analytics/src/analytics_internal.h"
2627
#include "app/src/assert.h"
2728
#include "app/src/include/firebase/internal/mutex.h"
2829
#include "app/src/include/firebase/version.h"
@@ -133,6 +134,8 @@ void Initialize(const ::firebase::App& app) {
133134
// Determine whether the analytics module is initialized.
134135
bool IsInitialized() { return g_initialized; }
135136

137+
bool IsAnalyticsDllLoaded() { return false; }
138+
136139
} // namespace internal
137140

138141
// Terminate the API.

0 commit comments

Comments
 (0)