diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 05c93a6188..2d4edf6f1d 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -17,7 +17,7 @@ on: required: true apis: description: 'CSV of apis to build and test' - default: 'analytics,app_check,auth,database,dynamic_links,firestore,functions,gma,installations,messaging,remote_config,storage,ump' + default: 'analytics,app_check,auth,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage,ump' required: true operating_systems: description: 'CSV of VMs to run on' @@ -186,7 +186,7 @@ jobs: # list. Then we can use fromJson to define the field in the matrix for the tests job. if [[ "${{ github.event.schedule }}" == "0 9 * * *" ]]; then # at 1am PST/2am PDT. Running integration tests and generate test report for all testapps except firestore - apis="analytics,app_check,auth,database,dynamic_links,functions,gma,installations,messaging,remote_config,storage,ump" + apis="analytics,app_check,auth,database,dynamic_links,functions,installations,messaging,remote_config,storage,ump" echo "::warning ::Running main nightly tests" elif [[ "${{ github.event.schedule }}" == "0 10 * * *" || "${{ github.event.schedule }}" == "0 11 * * *" ]]; then # at 2am PST/3am PDT and 3am PST/4am PDT. Running integration tests for firestore and generate test report. diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml index 23db829d3e..3a0fd70d48 100644 --- a/.github/workflows/update-dependencies.yml +++ b/.github/workflows/update-dependencies.yml @@ -8,9 +8,6 @@ on: updateiOS: description: 'update iOS dependencies?' default: 1 - includeGMA: - description: 'include GMA?' - default: 0 triggerTests: description: 'trigger tests on PR?' default: 1 @@ -68,20 +65,16 @@ jobs: - name: Run update script run: | - gma_flag= - if [[ ${{ github.event.inputs.includeGMA }} -eq 1 ]]; then - gma_flag="--include_gma" - fi if [[ ${{ github.event.inputs.updateiOS }} -eq 1 ]]; then if [[ ${{ github.event.inputs.updateAndroid }} -eq 1 ]]; then # Update both echo "Updating all dependencies" - python scripts/update_android_ios_dependencies.py --logfile=${UPDATE_LOGFILE} ${gma_flag} + python scripts/update_android_ios_dependencies.py --logfile=${UPDATE_LOGFILE} echo "CHOSEN_DEPS=mobile" >> $GITHUB_ENV else # Update iOS only echo "Updating iOS dependencies only" - python scripts/update_android_ios_dependencies.py --skip_android --logfile=${UPDATE_LOGFILE} ${gma_flag} + python scripts/update_android_ios_dependencies.py --skip_android --logfile=${UPDATE_LOGFILE} echo "CHOSEN_DEPS=iOS" >> $GITHUB_ENV fi # iOS: Update Firestore external version to match Firestore Cocoapod version. @@ -165,7 +158,7 @@ jobs: elif [[ ${{ github.event.inputs.updateAndroid }} -eq 1 ]]; then # Update Android only echo "Updating Android dependencies only" - python scripts/update_android_ios_dependencies.py --skip_ios --logfile=${UPDATE_LOGFILE} ${gma_flag} + python scripts/update_android_ios_dependencies.py --skip_ios --logfile=${UPDATE_LOGFILE} echo "CHOSEN_DEPS=Android" >> $GITHUB_ENV else echo "::error ::Neither Android nor iOS selected. Exiting." diff --git a/Android/firebase_dependencies.gradle b/Android/firebase_dependencies.gradle index 94b39ec52c..c7a19de54b 100644 --- a/Android/firebase_dependencies.gradle +++ b/Android/firebase_dependencies.gradle @@ -27,8 +27,6 @@ def firebaseDependenciesMap = [ 'dynamic_links' : ['com.google.firebase:firebase-dynamic-links'], 'firestore' : ['com.google.firebase:firebase-firestore'], 'functions' : ['com.google.firebase:firebase-functions'], - 'gma' : ['com.google.android.gms:play-services-ads:23.0.0', - 'com.google.android.ump:user-messaging-platform:2.2.0'], 'installations' : ['com.google.firebase:firebase-installations'], 'invites' : ['com.google.firebase:firebase-invites'], // Messaging has an additional local dependency to include. @@ -52,7 +50,6 @@ def firebaseResourceDependenciesMap = [ 'auth' : [':auth:auth_resources'], 'database' : [':database:database_resources'], 'firestore' : [':firestore:firestore_resources'], - 'gma' : [':gma:gma_resources'], 'remote_config' : [':remote_config:remote_config_resources'], 'storage' : [':storage:storage_resources'], 'ump' : [':ump:ump_resources'] @@ -94,9 +91,6 @@ class Dependencies { def getFirestore() { libSet.add('firestore') } - def getGma() { - libSet.add('gma') - } def getFunctions() { libSet.add('functions') } diff --git a/CMakeLists.txt b/CMakeLists.txt index aea6d80a34..a5a505120e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,6 @@ option(FIREBASE_INCLUDE_FIRESTORE option(FIREBASE_INCLUDE_FUNCTIONS "Include the Cloud Functions for Firebase library." ${FIREBASE_INCLUDE_LIBRARY_DEFAULT}) -option(FIREBASE_INCLUDE_GMA "Include the GMA library." - ${FIREBASE_INCLUDE_LIBRARY_DEFAULT}) option(FIREBASE_INCLUDE_UMP "Include the UMP library." ${FIREBASE_INCLUDE_LIBRARY_DEFAULT}) option(FIREBASE_INCLUDE_INSTALLATIONS @@ -125,9 +123,8 @@ if(FIREBASE_CPP_BUILD_TESTS OR FIREBASE_CPP_BUILD_STUB_TESTS) endif() if (PLATFORM STREQUAL TVOS OR PLATFORM STREQUAL SIMULATOR_TVOS) - # GMA, UMP, and FDL are not supported on tvOS. + # UMP and FDL are not supported on tvOS. set(FIREBASE_INCLUDE_DYNAMIC_LINKS OFF) - set(FIREBASE_INCLUDE_GMA OFF) set(FIREBASE_INCLUDE_UMP OFF) endif() @@ -635,9 +632,6 @@ endif() if (FIREBASE_INCLUDE_FUNCTIONS) add_subdirectory(functions) endif() -if (FIREBASE_INCLUDE_GMA) - add_subdirectory(gma) -endif() if (FIREBASE_INCLUDE_UMP) add_subdirectory(ump) endif() diff --git a/README.md b/README.md index 6a829a9a07..55e38e9bab 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,12 @@ iOS, and desktop platforms. It includes the following Firebase libraries: |[Google Analytics for Firebase](https://firebase.google.com/docs/analytics/)| |[Firebase Authentication](https://firebase.google.com/docs/auth/)|[Firebase Realtime Database](https://firebase.google.com/docs/database/)| |[Firebase Dynamic Links](https://firebase.google.com/docs/dynamic-links/)|[Cloud Firestore](https://firebase.google.com/docs/firestore/)| -|[Cloud Functions for Firebase](https://firebase.google.com/docs/functions/)|[Firebase Invites](https://firebase.google.com/docs/invites/)| -|[Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/)|[Firebase Remote Config](https://firebase.google.com/docs/remote-config/)| -|[Cloud Storage for Firebase](https://firebase.google.com/docs/storage/)| +|[Cloud Functions for Firebase](https://firebase.google.com/docs/functions/)|[Firebase Cloud Messaging](https://firebase.google.com/docs/cloud-messaging/)| +|[Firebase Remote Config](https://firebase.google.com/docs/remote-config/)|[Cloud Storage for Firebase](https://firebase.google.com/docs/storage/)| + +
+ +**Note:** The Google Mobile Ads (GMA) C++ SDK has been deprecated and was removed from this SDK.
@@ -117,7 +120,6 @@ The CMake following targets are available to build and link with: | Firebase Dynamic Links | firebase_dynamic_links | | Cloud Firestore | firebase_firestore | | Cloud Functions for Firebase | firebase_functions | -| Firebase Invites | firebase_invites | | Firebase Cloud Messaging | firebase_messaging | | Firebase Remote Config | firebase_remote_config | | Cloud Storage for Firebase | firebase_storage | @@ -222,7 +224,6 @@ release version of each Firebase library is: | Firebase Dynamic Links | :dynamic_links:assembleRelease | | Cloud Firestore | :firestore:assembleRelease | | Cloud Functions for Firebase | :functions:assembleRelease | -| Firebase Invites | :invites:assembleRelease | | Firebase Cloud Messaging | :messaging:assembleRelease | | Firebase Remote Config | :remote_config:assembleRelease | | Cloud Storage for Firebase | :storage:assembleRelease | diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 9b2d0b333a..6b1108ac31 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -541,17 +541,6 @@ if (IOS) ${FIREBASE_SOURCE_DIR}/functions/src/include/firebase/functions/callable_reference.h ${FIREBASE_SOURCE_DIR}/functions/src/include/firebase/functions/callable_result.h ${FIREBASE_SOURCE_DIR}/functions/src/include/firebase/functions/common.h) - set(gma_HDRS - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/ad_view.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/interstitial_ad.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/internal/native_ad.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/internal/query_info.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/rewarded_ad.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/types.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/ump.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/ump/consent_info.h - ${FIREBASE_SOURCE_DIR}/gma/src/include/firebase/gma/ump/types.h) set(installations_HDRS ${FIREBASE_SOURCE_DIR}/installations/src/include/firebase/installations.h) set(messaging_HDRS @@ -580,7 +569,6 @@ if (IOS) ${dynamic_links_HDRS} ${firestore_HDRS} ${functions_HDRS} - ${gma_HDRS} ${installations_HDRS} ${messaging_HDRS} ${remote_config_HDRS} diff --git a/build_scripts/ios/build.sh b/build_scripts/ios/build.sh index c466d35af7..f21e4ff36e 100755 --- a/build_scripts/ios/build.sh +++ b/build_scripts/ios/build.sh @@ -27,7 +27,7 @@ readonly SUPPORTED_PLATFORMS=(device simulator) readonly SUPPORTED_ARCHITECTURES=(arm64 x86_64) readonly DEVICE_ARCHITECTURES=(arm64) readonly SIMULATOR_ARCHITECTURES=(arm64 x86_64) -readonly SUPPORTED_TARGETS=(firebase_analytics firebase_auth firebase_app_check firebase_database firebase_dynamic_links firebase_firestore firebase_functions firebase_gma firebase_installations firebase_messaging firebase_remote_config firebase_storage firebase_ump) +readonly SUPPORTED_TARGETS=(firebase_analytics firebase_auth firebase_app_check firebase_database firebase_dynamic_links firebase_firestore firebase_functions firebase_installations firebase_messaging firebase_remote_config firebase_storage firebase_ump) # build default value buildpath="ios_build" diff --git a/build_scripts/packaging.conf b/build_scripts/packaging.conf index 8f1ee6f401..5010b2c4a2 100644 --- a/build_scripts/packaging.conf +++ b/build_scripts/packaging.conf @@ -2,5 +2,5 @@ # List of all Firebase products to include in the binary SDK package. readonly -a product_list=(analytics app app_check auth database -dynamic_links firestore functions gma installations messaging +dynamic_links firestore functions installations messaging remote_config storage ump) diff --git a/docs/Doxyfile b/docs/Doxyfile index fabb54e5da..fea93c1f66 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -13,7 +13,7 @@ SORT_GROUP_NAMES = YES JAVADOC_AUTOBRIEF = YES # Firebase-specific options. -PREDEFINED = DOXYGEN DOXYGEN_ADMOB FIREBASE_DEPRECATED FIREBASE_NAMESPACE=firebase +PREDEFINED = DOXYGEN FIREBASE_DEPRECATED FIREBASE_NAMESPACE=firebase MACRO_EXPANSION = YES # Expand FIREBASE_DEPRECATED macros. EXPAND_ONLY_PREDEF = YES # Expand FIREBASE_DEPRECATED macros. VERBATIM_HEADERS = NO diff --git a/gma/CMakeLists.txt b/gma/CMakeLists.txt deleted file mode 100644 index 2b0b225740..0000000000 --- a/gma/CMakeLists.txt +++ /dev/null @@ -1,156 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the firebase_gma library - -# Common source files used by all platforms -set(common_SRCS - src/common/ump/consent_info.cc - src/common/ump/consent_info_internal.cc - src/common/gma_common.cc - src/common/ad_view.cc - src/common/ad_view_internal.cc - src/common/interstitial_ad.cc - src/common/interstitial_ad_internal.cc - src/common/full_screen_ad_event_listener.cc - src/common/native_ad.cc - src/common/native_ad_internal.cc - src/common/query_info.cc - src/common/query_info_internal.cc - src/common/rewarded_ad.cc - src/common/rewarded_ad_internal.cc) - -# Define the resource build needed for Android -firebase_cpp_gradle(":gma:gma_resources:generateDexJarRelease" - "${CMAKE_CURRENT_LIST_DIR}/gma_resources/build/gma_resources_lib.jar") -binary_to_array("gma_resources" - "${CMAKE_CURRENT_LIST_DIR}/gma_resources/build/gma_resources_lib.jar" - "firebase_gma" - "${FIREBASE_GEN_FILE_DIR}/gma") - -# Source files used by the Android implementation. -set(android_SRCS - ${gma_resources_source} - src/android/ump/consent_info_internal_android.cc - src/android/ad_request_converter.cc - src/android/ad_error_android.cc - src/android/adapter_response_info_android.cc - src/android/gma_android.cc - src/android/ad_view_internal_android.cc - src/android/interstitial_ad_internal_android.cc - src/android/native_ad_image_android.cc - src/android/native_ad_internal_android.cc - src/android/query_info_internal_android.cc - src/android/response_info_android.cc - src/android/rewarded_ad_internal_android.cc) - -# Source files used by the iOS implementation. -set(ios_SRCS - src/ios/ump/consent_info_internal_ios.mm - src/ios/FADAdSize.mm - src/ios/FADAdView.mm - src/ios/FADInterstitialDelegate.mm - src/ios/FADNativeDelegate.mm - src/ios/FADRequest.mm - src/ios/FADRewardedAdDelegate.mm - src/ios/ad_error_ios.mm - src/ios/adapter_response_info_ios.mm - src/ios/gma_ios.mm - src/ios/ad_view_internal_ios.mm - src/ios/interstitial_ad_internal_ios.mm - src/ios/native_ad_image_ios.mm - src/ios/native_ad_internal_ios.mm - src/ios/query_info_internal_ios.mm - src/ios/response_info_ios.mm - src/ios/rewarded_ad_internal_ios.mm) - -# Source files used by the stub implementation. -set(stub_SRCS - src/stub/ump/consent_info_internal_stub.cc - src/stub/ad_error_stub.cc - src/stub/adapter_response_info_stub.cc - src/stub/gma_stub.cc - src/stub/native_ad_image_stub.cc - src/stub/response_info_stub.cc) - -if(ANDROID) - set(gma_platform_SRCS - "${android_SRCS}") -elseif(IOS) - set(gma_platform_SRCS - "${ios_SRCS}") -else() - set(gma_platform_SRCS - "${stub_SRCS}") -endif() - -add_library(firebase_gma STATIC - ${common_SRCS} - ${gma_platform_SRCS}) - -set_property(TARGET firebase_gma PROPERTY FOLDER "Firebase Cpp") - -# Set up the dependency on Firebase App. -target_link_libraries(firebase_gma - PUBLIC firebase_app) -# Public headers all refer to each other relative to the src/include directory, -# while private headers are relative to the entire C++ SDK directory. -target_include_directories(firebase_gma - PUBLIC - ${CMAKE_CURRENT_LIST_DIR}/src/include - PRIVATE - ${FIREBASE_CPP_SDK_ROOT_DIR} -) -target_compile_definitions(firebase_gma - PRIVATE - -DINTERNAL_EXPERIMENTAL=1 -) -# Automatically include headers that might not be declared. -if(MSVC) - add_definitions(/FI"assert.h" /FI"string.h" /FI"stdint.h") -else() - add_definitions(-include assert.h -include string.h) -endif() - -if(ANDROID) - firebase_cpp_proguard_file(gma) -elseif(IOS) - # GMA for iOS uses weak references, which requires enabling Automatic - # Reference Counting (ARC). Also enable BitCode. - target_compile_options(firebase_gma - PUBLIC "-fobjc-arc" "-fembed-bitcode") - target_link_libraries(firebase_gma - PUBLIC "-fembed-bitcode") - - setup_pod_headers( - firebase_gma - POD_NAMES - Google-Mobile-Ads-SDK - GoogleUserMessagingPlatform - ) - - # GMA expects the header files to be in a subfolder, so set up a symlink to - # accomplish that. - symlink_pod_headers(firebase_gma Google-Mobile-Ads-SDK GoogleMobileAds) - symlink_pod_headers(firebase_gma GoogleUserMessagingPlatform UserMessagingPlatform) - - if (FIREBASE_XCODE_TARGET_FORMAT STREQUAL "frameworks") - set_target_properties(firebase_gma PROPERTIES - FRAMEWORK TRUE - ) - endif() -endif() - -cpp_pack_library(firebase_gma "") -cpp_pack_public_headers() diff --git a/gma/build.gradle b/gma/build.gradle deleted file mode 100644 index 9b54eea9f6..0000000000 --- a/gma/build.gradle +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -buildscript { - repositories { - google() - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - } -} -allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: 'com.android.library' - -android { - compileSdkVersion 34 - ndkPath System.getenv('ANDROID_NDK_HOME') - buildToolsVersion '32.0.0' - - sourceSets { - main { - manifest.srcFile '../android_build_files/AndroidManifest.xml' - } - } - - externalNativeBuild { - cmake { - path '../CMakeLists.txt' - } - } - - defaultConfig { - minSdkVersion 23 - targetSdkVersion 34 - versionCode 1 - versionName "1.0" - - buildTypes { - release { - minifyEnabled false - } - } - - externalNativeBuild { - cmake { - targets 'firebase_gma' - // Args are: Re-use app library prebuilt by app gradle project. - // Don't configure all the cmake subprojects. - // Only include needed project. - arguments '-DFIREBASE_CPP_USE_PRIOR_GRADLE_BUILD=ON', - '-DFIREBASE_INCLUDE_LIBRARY_DEFAULT=OFF', - '-DFIREBASE_INCLUDE_GMA=ON' - } - } - } - - lintOptions { - abortOnError false - } -} - -dependencies { - implementation project(':app') -} -apply from: "$rootDir/android_build_files/android_abis.gradle" -apply from: "$rootDir/android_build_files/extract_and_dex.gradle" -apply from: "$rootDir/android_build_files/generate_proguard.gradle" -project.afterEvaluate { - generateProguardFile('gma') - setupDexDependencies(':gma:gma_resources') - preBuild.dependsOn(':app:build') - project.tasks.withType(com.android.build.gradle.internal.tasks.CheckAarMetadataTask) { - enabled = false - } -} diff --git a/gma/gma_additional.pro b/gma/gma_additional.pro deleted file mode 100644 index 57edbf9017..0000000000 --- a/gma/gma_additional.pro +++ /dev/null @@ -1,2 +0,0 @@ -# Additional ProGuard rules needed for the AdMob library. --keep class com.google.ads.mediation.admob.AdMobAdapter { *; } diff --git a/gma/integration_test/AndroidManifest.xml b/gma/integration_test/AndroidManifest.xml deleted file mode 100644 index 8aa98a1958..0000000000 --- a/gma/integration_test/AndroidManifest.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/gma/integration_test/CMakeLists.txt b/gma/integration_test/CMakeLists.txt deleted file mode 100644 index 29c6a6e4d1..0000000000 --- a/gma/integration_test/CMakeLists.txt +++ /dev/null @@ -1,242 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Cmake file for a single C++ integration test build. - -cmake_minimum_required(VERSION 2.8) - -find_program(FIREBASE_PYTHON_EXECUTABLE - NAMES python3 python - DOC "The Python interpreter to use, such as one from a venv" - REQUIRED -) - -# User settings for Firebase integration tests. -# Path to Firebase SDK. -# Try to read the path to the Firebase C++ SDK from an environment variable. -if (NOT "$ENV{FIREBASE_CPP_SDK_DIR}" STREQUAL "") - set(DEFAULT_FIREBASE_CPP_SDK_DIR "$ENV{FIREBASE_CPP_SDK_DIR}") -else() - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../cpp_sdk_version.json") - set(DEFAULT_FIREBASE_CPP_SDK_DIR "${CMAKE_CURRENT_LIST_DIR}/../..") - else() - set(DEFAULT_FIREBASE_CPP_SDK_DIR "firebase_cpp_sdk") - endif() -endif() -if ("${FIREBASE_CPP_SDK_DIR}" STREQUAL "") - set(FIREBASE_CPP_SDK_DIR ${DEFAULT_FIREBASE_CPP_SDK_DIR}) -endif() -if(NOT EXISTS ${FIREBASE_CPP_SDK_DIR}) - message(FATAL_ERROR "The Firebase C++ SDK directory does not exist: ${FIREBASE_CPP_SDK_DIR}. See the readme.md for more information") -endif() - -# Copy all prerequisite files for integration tests to run. -if(NOT ANDROID) - if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/../../setup_integration_tests.py) - # If this is running from inside the SDK directory, run the setup script. - execute_process( - COMMAND - ${FIREBASE_PYTHON_EXECUTABLE} - "${CMAKE_CURRENT_LIST_DIR}/../../setup_integration_tests.py" - "${CMAKE_CURRENT_LIST_DIR}" - RESULT_VARIABLE - FIREBASE_PYTHON_EXECUTABLE_RESULT - ) - if(NOT FIREBASE_PYTHON_EXECUTABLE_RESULT EQUAL 0) - message(FATAL_ERROR "Failed to run setup_integration_tests.py") - endif() - endif() -endif() - -# Windows runtime mode, either MD or MT depending on whether you are using -# /MD or /MT. For more information see: -# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx -set(MSVC_RUNTIME_MODE MD) - -project(firebase_testapp) - -# Integration test source files. -set(FIREBASE_APP_FRAMEWORK_SRCS - src/app_framework.cc - src/app_framework.h -) - -set(FIREBASE_TEST_FRAMEWORK_SRCS - src/firebase_test_framework.h - src/firebase_test_framework.cc -) - -set(FIREBASE_INTEGRATION_TEST_SRCS - src/integration_test.cc -) - -# The include directory for the testapp. -include_directories(src) - -# Firebase C++ SDK requires C++14. -set (CMAKE_CXX_STANDARD 14) -set (CMAKE_CXX_STANDARD_REQUIRED YES) # Don't fall back to an earlier version. - -# Download and unpack googletest (and googlemock) at configure time -set(GOOGLETEST_ROOT ${CMAKE_CURRENT_LIST_DIR}/external/googletest) -# Note: Once googletest is downloaded once, it won't be updated or -# downloaded again unless you delete the "external/googletest" -# directory. -if (NOT EXISTS ${GOOGLETEST_ROOT}/src/googletest/src/gtest-all.cc) - configure_file(googletest.cmake - ${CMAKE_CURRENT_LIST_DIR}/external/googletest/CMakeLists.txt COPYONLY) - execute_process(COMMAND ${CMAKE_COMMAND} . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/external/googletest ) - if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/external/googletest ) - if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") - endif() -endif() - -if(ANDROID) - # Build an Android application. - - # Source files used for the Android build. - set(FIREBASE_APP_FRAMEWORK_ANDROID_SRCS - src/android/android_app_framework.cc - ) - - # Source files used for the Android build. - set(FIREBASE_TEST_FRAMEWORK_ANDROID_SRCS - src/android/android_firebase_test_framework.cc - ) - - # Build native_app_glue as a static lib - add_library(native_app_glue STATIC - ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) - - # Export ANativeActivity_onCreate(), - # Refer to: https://github.com/android-ndk/ndk/issues/381. - set(CMAKE_SHARED_LINKER_FLAGS - "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") - - add_library(gtest STATIC - ${GOOGLETEST_ROOT}/src/googletest/src/gtest-all.cc) - target_include_directories(gtest - PRIVATE ${GOOGLETEST_ROOT}/src/googletest - PUBLIC ${GOOGLETEST_ROOT}/src/googletest/include) - add_library(gmock STATIC - ${GOOGLETEST_ROOT}/src/googlemock/src/gmock-all.cc) - target_include_directories(gmock - PRIVATE ${GOOGLETEST_ROOT}/src/googletest - PRIVATE ${GOOGLETEST_ROOT}/src/googlemock - PUBLIC ${GOOGLETEST_ROOT}/src/googletest/include - PUBLIC ${GOOGLETEST_ROOT}/src/googlemock/include) - - # Define the target as a shared library, as that is what gradle expects. - set(integration_test_target_name "android_integration_test_main") - add_library(${integration_test_target_name} SHARED - ${FIREBASE_APP_FRAMEWORK_SRCS} - ${FIREBASE_APP_FRAMEWORK_ANDROID_SRCS} - ${FIREBASE_INTEGRATION_TEST_SRCS} - ${FIREBASE_TEST_FRAMEWORK_SRCS} - ${FIREBASE_TEST_FRAMEWORK_ANDROID_SRCS} - ) - - target_include_directories(${integration_test_target_name} PRIVATE - ${ANDROID_NDK}/sources/android/native_app_glue) - - set(ADDITIONAL_LIBS log android atomic native_app_glue) -else() - # Build a desktop application. - add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) - - # Prevent overriding the parent project's compiler/linker - # settings on Windows - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - - # Add googletest directly to our build. This defines - # the gtest and gtest_main targets. - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/googletest/src - ${CMAKE_CURRENT_LIST_DIR}/external/googletest/build - EXCLUDE_FROM_ALL) - - # The gtest/gtest_main targets carry header search path - # dependencies automatically when using CMake 2.8.11 or - # later. Otherwise we have to add them here ourselves. - if (CMAKE_VERSION VERSION_LESS 2.8.11) - include_directories("${gtest_SOURCE_DIR}/include") - include_directories("${gmock_SOURCE_DIR}/include") - endif() - - # Windows runtime mode, either MD or MT depending on whether you are using - # /MD or /MT. For more information see: - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - set(MSVC_RUNTIME_MODE MD) - - # Platform abstraction layer for the desktop integration test. - set(FIREBASE_APP_FRAMEWORK_DESKTOP_SRCS - src/desktop/desktop_app_framework.cc - src/desktop/desktop_firebase_test_framework.cc - ) - - set(integration_test_target_name "integration_test") - add_executable(${integration_test_target_name} - ${FIREBASE_APP_FRAMEWORK_SRCS} - ${FIREBASE_APP_FRAMEWORK_DESKTOP_SRCS} - ${FIREBASE_TEST_FRAMEWORK_SRCS} - ${FIREBASE_INTEGRATION_TEST_SRCS} - ) - - if(APPLE) - set(ADDITIONAL_LIBS - gssapi_krb5 - pthread - "-framework CoreFoundation" - "-framework Foundation" - "-framework GSS" - "-framework Security" - ) - elseif(MSVC) - set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32) - else() - set(ADDITIONAL_LIBS pthread) - endif() - - # If a config file is present, copy it into the binary location so that it's - # possible to create the default Firebase app. - set(FOUND_JSON_FILE FALSE) - foreach(config "google-services-desktop.json" "google-services.json") - if (EXISTS "${CMAKE_CURRENT_LIST_DIR}/${config}") - add_custom_command( - TARGET ${integration_test_target_name} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_CURRENT_LIST_DIR}/${config}" $) - set(FOUND_JSON_FILE TRUE) - break() - endif() - endforeach() - if(NOT FOUND_JSON_FILE) - message(WARNING "Failed to find either google-services-desktop.json or google-services.json. See the readme.md for more information.") - endif() -endif() - -# Add the Firebase libraries to the target using the function from the SDK. -add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL) -# Note that firebase_app needs to be last in the list. -set(firebase_libs firebase_gma firebase_app) -set(gtest_libs gtest gmock) -target_link_libraries(${integration_test_target_name} ${firebase_libs} - ${gtest_libs} ${ADDITIONAL_LIBS}) diff --git a/gma/integration_test/Images.xcassets/AppIcon.appiconset/Contents.json b/gma/integration_test/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index d8db8d65fd..0000000000 --- a/gma/integration_test/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/gma/integration_test/Images.xcassets/LaunchImage.launchimage/Contents.json b/gma/integration_test/Images.xcassets/LaunchImage.launchimage/Contents.json deleted file mode 100644 index 6f870a4629..0000000000 --- a/gma/integration_test/Images.xcassets/LaunchImage.launchimage/Contents.json +++ /dev/null @@ -1,51 +0,0 @@ -{ - "images" : [ - { - "orientation" : "portrait", - "idiom" : "iphone", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "iphone", - "subtype" : "retina4", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "1x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "1x" - }, - { - "orientation" : "portrait", - "idiom" : "ipad", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - }, - { - "orientation" : "landscape", - "idiom" : "ipad", - "extent" : "full-screen", - "minimum-system-version" : "7.0", - "scale" : "2x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/gma/integration_test/Info.plist b/gma/integration_test/Info.plist deleted file mode 100644 index 953571e326..0000000000 --- a/gma/integration_test/Info.plist +++ /dev/null @@ -1,41 +0,0 @@ - - - - - GADApplicationIdentifier - ca-app-pub-3940256099942544~1458002511 - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - NSUserTrackingUsageDescription - This identifier will be used to deliver personalized ads to you. - CFBundleURLTypes - - - CFBundleURLSchemes - - REPLACE_WITH_REVERSED_CLIENT_ID - firebase-game-loop - firebase-ui-test - - - - - diff --git a/gma/integration_test/LaunchScreen.storyboard b/gma/integration_test/LaunchScreen.storyboard deleted file mode 100644 index 673e0f7e68..0000000000 --- a/gma/integration_test/LaunchScreen.storyboard +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/gma/integration_test/LibraryManifest.xml b/gma/integration_test/LibraryManifest.xml deleted file mode 100644 index a5db8d174d..0000000000 --- a/gma/integration_test/LibraryManifest.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - diff --git a/gma/integration_test/Podfile b/gma/integration_test/Podfile deleted file mode 100644 index c0d08178b1..0000000000 --- a/gma/integration_test/Podfile +++ /dev/null @@ -1,18 +0,0 @@ -source 'https://github.com/CocoaPods/Specs.git' -platform :ios, '13.0' -# Firebase GMA test application. -use_frameworks! :linkage => :static - -target 'integration_test' do - platform :ios, '13.0' - pod 'Firebase/CoreOnly', '11.14.0' - pod 'Google-Mobile-Ads-SDK', '11.2.0' - pod 'GoogleUserMessagingPlatform', '2.3.0' -end - -post_install do |installer| - # If this is running from inside the SDK directory, run the setup script. - system("if [[ -r ../../setup_integration_tests.py ]]; then python3 ../../setup_integration_tests.py .; fi") - system("python3 ./download_googletest.py") -end - diff --git a/gma/integration_test/build.gradle b/gma/integration_test/build.gradle deleted file mode 100644 index 16f9d2b87e..0000000000 --- a/gma/integration_test/build.gradle +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Top-level build file where you can add configuration options common to all sub-projects/modules. -buildscript { - repositories { - mavenLocal() - maven { url 'https://maven.google.com' } - mavenCentral() - } - dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' - // r8 on this version of the Android tools has a bug, - // so specify a different version to use. - classpath 'com.android.tools:r8:8.3.37' - classpath 'com.google.gms:google-services:4.4.1' - } -} - -allprojects { - repositories { - mavenLocal() - maven { url 'https://maven.google.com' } - mavenCentral() - } -} - -apply plugin: 'com.android.application' - -android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_11 - targetCompatibility JavaVersion.VERSION_11 - } - compileSdkVersion 34 - ndkPath System.getenv('ANDROID_NDK_HOME') - buildToolsVersion '32.0.0' - - sourceSets { - main { - jniLibs.srcDirs = ['libs'] - manifest.srcFile 'AndroidManifest.xml' - java.srcDirs = ['src/android/java'] - res.srcDirs = ['res'] - } - } - - defaultConfig { - applicationId 'com.google.android.admob.testapp' - minSdkVersion 23 - targetSdkVersion 34 - versionCode 1 - versionName '1.0' - externalNativeBuild.cmake { - arguments "-DFIREBASE_CPP_SDK_DIR=$gradle.firebase_cpp_sdk_dir" - } - multiDexEnabled true - } - externalNativeBuild.cmake { - path 'CMakeLists.txt' - } - buildTypes { - release { - minifyEnabled true - proguardFile getDefaultProguardFile('proguard-android.txt') - proguardFile file('proguard.pro') - } - } - lintOptions { - abortOnError false - } -} - -apply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle" -firebaseCpp.dependencies { - gma -} - -apply plugin: 'com.google.gms.google-services' - -task copyIntegrationTestFiles(type:Exec) { - // If this is running form inside the SDK directory, run the setup script. - if (project.file('../../setup_integration_tests.py').exists()) { - commandLine 'python3', '../../setup_integration_tests.py', project.projectDir.toString() - } - else { - commandLine 'echo', '' - } -} - -build.dependsOn(copyIntegrationTestFiles) - -project.afterEvaluate { - project.tasks.withType(com.android.build.gradle.internal.tasks.CheckAarMetadataTask) { - enabled = false - } -} diff --git a/gma/integration_test/empty.swift b/gma/integration_test/empty.swift deleted file mode 100644 index b637790955..0000000000 --- a/gma/integration_test/empty.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// empty.swift -// integration_test -// -// Created by David Della Bitta on 5/12/22. -// Copyright © 2022 Google. All rights reserved. -// - -import Foundation diff --git a/gma/integration_test/googletest.cmake b/gma/integration_test/googletest.cmake deleted file mode 100644 index a643a3e2f2..0000000000 --- a/gma/integration_test/googletest.cmake +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Download GoogleTest from GitHub as an external project. -# Pin to 1.11.0 because we touch internal GoogleTest structures that could change in the future. - -# This CMake file is taken from: -# https://github.com/google/googletest/blob/master/googletest/README.md#incorporating-into-an-existing-cmake-project - -cmake_minimum_required(VERSION 2.8.2) - -project(googletest-download NONE) - -include(ExternalProject) -ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG "release-1.11.0" - SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/src" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" -) diff --git a/gma/integration_test/gradle.properties b/gma/integration_test/gradle.properties deleted file mode 100644 index ac891ac594..0000000000 --- a/gma/integration_test/gradle.properties +++ /dev/null @@ -1,2 +0,0 @@ -android.useAndroidX = true -org.gradle.jvmargs=-Xmx2560m diff --git a/gma/integration_test/gradle/wrapper/gradle-wrapper.jar b/gma/integration_test/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 8c0fb64a86..0000000000 Binary files a/gma/integration_test/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gma/integration_test/gradle/wrapper/gradle-wrapper.properties b/gma/integration_test/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 2eb04a3b17..0000000000 --- a/gma/integration_test/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Mon Nov 27 14:03:45 PST 2017 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-7.5.1-all.zip diff --git a/gma/integration_test/gradlew b/gma/integration_test/gradlew deleted file mode 100755 index 06eaee39e2..0000000000 --- a/gma/integration_test/gradlew +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright 2021 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# For Cygwin, ensure paths are in UNIX format before anything is touched. -if $cygwin ; then - [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` -fi - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >&- -APP_HOME="`pwd -P`" -cd "$SAVED" >&- - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/gma/integration_test/gradlew.bat b/gma/integration_test/gradlew.bat deleted file mode 100644 index 51923e981d..0000000000 --- a/gma/integration_test/gradlew.bat +++ /dev/null @@ -1,104 +0,0 @@ -@rem Copyright 2021 Google LLC -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem http://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/gma/integration_test/integration_test.xcodeproj/project.pbxproj b/gma/integration_test/integration_test.xcodeproj/project.pbxproj deleted file mode 100644 index 3f0c3ff6ad..0000000000 --- a/gma/integration_test/integration_test.xcodeproj/project.pbxproj +++ /dev/null @@ -1,383 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 520BC0391C869159008CFBC3 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 520BC0381C869159008CFBC3 /* GoogleService-Info.plist */; }; - 529226D61C85F68000C89379 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 529226D51C85F68000C89379 /* Foundation.framework */; }; - 529226D81C85F68000C89379 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 529226D71C85F68000C89379 /* CoreGraphics.framework */; }; - 529226DA1C85F68000C89379 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 529226D91C85F68000C89379 /* UIKit.framework */; }; - D61C5F8E22BABA9C00A79141 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D61C5F8C22BABA9B00A79141 /* Images.xcassets */; }; - D61C5F9622BABAD200A79141 /* integration_test.cc in Sources */ = {isa = PBXBuildFile; fileRef = D61C5F9222BABAD100A79141 /* integration_test.cc */; }; - D62CCBC022F367140099BE9F /* gmock-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = D62CCBBF22F367140099BE9F /* gmock-all.cc */; }; - D640F3172819C85800AC956E /* empty.swift in Sources */ = {isa = PBXBuildFile; fileRef = D640F3162819C85800AC956E /* empty.swift */; }; - D66B16871CE46E8900E5638A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D66B16861CE46E8900E5638A /* LaunchScreen.storyboard */; }; - D67D355822BABD2200292C1D /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = D67D355622BABD2100292C1D /* gtest-all.cc */; }; - D686A3292A8B16F20034845A /* AppTrackingTransparency.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D686A3282A8B16F20034845A /* AppTrackingTransparency.framework */; }; - D6C179E922CB322900C2651A /* ios_app_framework.mm in Sources */ = {isa = PBXBuildFile; fileRef = D6C179E722CB322900C2651A /* ios_app_framework.mm */; }; - D6C179EA22CB322900C2651A /* ios_firebase_test_framework.mm in Sources */ = {isa = PBXBuildFile; fileRef = D6C179E822CB322900C2651A /* ios_firebase_test_framework.mm */; }; - D6C179EE22CB323300C2651A /* firebase_test_framework.cc in Sources */ = {isa = PBXBuildFile; fileRef = D6C179EC22CB323300C2651A /* firebase_test_framework.cc */; }; - D6C179F022CB32A000C2651A /* app_framework.cc in Sources */ = {isa = PBXBuildFile; fileRef = D6C179EF22CB32A000C2651A /* app_framework.cc */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 520BC0381C869159008CFBC3 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; - 529226D21C85F68000C89379 /* integration_test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = integration_test.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 529226D51C85F68000C89379 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; - 529226D71C85F68000C89379 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; - 529226D91C85F68000C89379 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; - 529226EE1C85F68000C89379 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; - D61C5F8C22BABA9B00A79141 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; - D61C5F8D22BABA9C00A79141 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - D61C5F9222BABAD100A79141 /* integration_test.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = integration_test.cc; path = src/integration_test.cc; sourceTree = ""; }; - D62CCBBF22F367140099BE9F /* gmock-all.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "gmock-all.cc"; path = "external/googletest/src/googlemock/src/gmock-all.cc"; sourceTree = ""; }; - D62CCBC122F367320099BE9F /* gmock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gmock.h; path = external/googletest/src/googlemock/include/gmock/gmock.h; sourceTree = ""; }; - D640F3162819C85800AC956E /* empty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = empty.swift; path = src/empty.swift; sourceTree = ""; }; - D66B16861CE46E8900E5638A /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = ""; }; - D67D355622BABD2100292C1D /* gtest-all.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "gtest-all.cc"; path = "external/googletest/src/googletest/src/gtest-all.cc"; sourceTree = ""; }; - D67D355722BABD2100292C1D /* gtest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = gtest.h; path = external/googletest/src/googletest/include/gtest/gtest.h; sourceTree = ""; }; - D686A3282A8B16F20034845A /* AppTrackingTransparency.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppTrackingTransparency.framework; path = System/Library/Frameworks/AppTrackingTransparency.framework; sourceTree = SDKROOT; }; - D6C179E722CB322900C2651A /* ios_app_framework.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ios_app_framework.mm; path = src/ios/ios_app_framework.mm; sourceTree = ""; }; - D6C179E822CB322900C2651A /* ios_firebase_test_framework.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ios_firebase_test_framework.mm; path = src/ios/ios_firebase_test_framework.mm; sourceTree = ""; }; - D6C179EB22CB323300C2651A /* firebase_test_framework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = firebase_test_framework.h; path = src/firebase_test_framework.h; sourceTree = ""; }; - D6C179EC22CB323300C2651A /* firebase_test_framework.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = firebase_test_framework.cc; path = src/firebase_test_framework.cc; sourceTree = ""; }; - D6C179ED22CB323300C2651A /* app_framework.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = app_framework.h; path = src/app_framework.h; sourceTree = ""; }; - D6C179EF22CB32A000C2651A /* app_framework.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = app_framework.cc; path = src/app_framework.cc; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 529226CF1C85F68000C89379 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 529226D81C85F68000C89379 /* CoreGraphics.framework in Frameworks */, - D686A3292A8B16F20034845A /* AppTrackingTransparency.framework in Frameworks */, - 529226DA1C85F68000C89379 /* UIKit.framework in Frameworks */, - 529226D61C85F68000C89379 /* Foundation.framework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 529226C91C85F68000C89379 = { - isa = PBXGroup; - children = ( - D61C5F8C22BABA9B00A79141 /* Images.xcassets */, - D61C5F8D22BABA9C00A79141 /* Info.plist */, - D66B16861CE46E8900E5638A /* LaunchScreen.storyboard */, - 520BC0381C869159008CFBC3 /* GoogleService-Info.plist */, - 5292271D1C85FB5500C89379 /* src */, - 529226D41C85F68000C89379 /* Frameworks */, - 529226D31C85F68000C89379 /* Products */, - ); - sourceTree = ""; - }; - 529226D31C85F68000C89379 /* Products */ = { - isa = PBXGroup; - children = ( - 529226D21C85F68000C89379 /* integration_test.app */, - ); - name = Products; - sourceTree = ""; - }; - 529226D41C85F68000C89379 /* Frameworks */ = { - isa = PBXGroup; - children = ( - D686A3282A8B16F20034845A /* AppTrackingTransparency.framework */, - 529226D51C85F68000C89379 /* Foundation.framework */, - 529226D71C85F68000C89379 /* CoreGraphics.framework */, - 529226D91C85F68000C89379 /* UIKit.framework */, - 529226EE1C85F68000C89379 /* XCTest.framework */, - ); - name = Frameworks; - sourceTree = ""; - }; - 5292271D1C85FB5500C89379 /* src */ = { - isa = PBXGroup; - children = ( - D640F3162819C85800AC956E /* empty.swift */, - D62CCBC122F367320099BE9F /* gmock.h */, - D62CCBBF22F367140099BE9F /* gmock-all.cc */, - D67D355622BABD2100292C1D /* gtest-all.cc */, - D67D355722BABD2100292C1D /* gtest.h */, - D6C179EF22CB32A000C2651A /* app_framework.cc */, - D6C179ED22CB323300C2651A /* app_framework.h */, - D6C179EC22CB323300C2651A /* firebase_test_framework.cc */, - D6C179EB22CB323300C2651A /* firebase_test_framework.h */, - D61C5F9222BABAD100A79141 /* integration_test.cc */, - 5292271E1C85FB5B00C89379 /* ios */, - ); - name = src; - sourceTree = ""; - }; - 5292271E1C85FB5B00C89379 /* ios */ = { - isa = PBXGroup; - children = ( - D6C179E722CB322900C2651A /* ios_app_framework.mm */, - D6C179E822CB322900C2651A /* ios_firebase_test_framework.mm */, - ); - name = ios; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 529226D11C85F68000C89379 /* integration_test */ = { - isa = PBXNativeTarget; - buildConfigurationList = 529226F91C85F68000C89379 /* Build configuration list for PBXNativeTarget "integration_test" */; - buildPhases = ( - 529226CE1C85F68000C89379 /* Sources */, - 529226CF1C85F68000C89379 /* Frameworks */, - 529226D01C85F68000C89379 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = integration_test; - productName = testapp; - productReference = 529226D21C85F68000C89379 /* integration_test.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 529226CA1C85F68000C89379 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0640; - ORGANIZATIONNAME = Google; - TargetAttributes = { - 529226D11C85F68000C89379 = { - CreatedOnToolsVersion = 6.4; - DevelopmentTeam = EQHXZ8M8AV; - LastSwiftMigration = 1320; - ProvisioningStyle = Automatic; - }; - }; - }; - buildConfigurationList = 529226CD1C85F68000C89379 /* Build configuration list for PBXProject "integration_test" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - English, - en, - ); - mainGroup = 529226C91C85F68000C89379; - productRefGroup = 529226D31C85F68000C89379 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 529226D11C85F68000C89379 /* integration_test */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 529226D01C85F68000C89379 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D61C5F8E22BABA9C00A79141 /* Images.xcassets in Resources */, - D66B16871CE46E8900E5638A /* LaunchScreen.storyboard in Resources */, - 520BC0391C869159008CFBC3 /* GoogleService-Info.plist in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 529226CE1C85F68000C89379 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - D67D355822BABD2200292C1D /* gtest-all.cc in Sources */, - D62CCBC022F367140099BE9F /* gmock-all.cc in Sources */, - D6C179EA22CB322900C2651A /* ios_firebase_test_framework.mm in Sources */, - D61C5F9622BABAD200A79141 /* integration_test.cc in Sources */, - D6C179E922CB322900C2651A /* ios_app_framework.mm in Sources */, - D640F3172819C85800AC956E /* empty.swift in Sources */, - D6C179F022CB32A000C2651A /* app_framework.cc in Sources */, - D6C179EE22CB323300C2651A /* firebase_test_framework.cc in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 529226F71C85F68000C89379 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 529226F81C85F68000C89379 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 13.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - TARGETED_DEVICE_FAMILY = "1,2"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 529226FA1C85F68000C89379 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - EXCLUDED_ARCHS = i386; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - ); - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "\"$(SRCROOT)/src\"", - "\"$(SRCROOT)/external/googletest/src/googletest/include\"", - "\"$(SRCROOT)/external/googletest/src/googlemock/include\"", - "\"$(SRCROOT)/external/googletest/src/googletest\"", - "\"$(SRCROOT)/external/googletest/src/googlemock\"", - ); - INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 5.3; - WRAPPER_EXTENSION = app; - }; - name = Debug; - }; - 529226FB1C85F68000C89379 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; - CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; - EXCLUDED_ARCHS = i386; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)", - ); - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "\"$(SRCROOT)/src\"", - "\"$(SRCROOT)/external/googletest/src/googletest/include\"", - "\"$(SRCROOT)/external/googletest/src/googlemock/include\"", - "\"$(SRCROOT)/external/googletest/src/googletest\"", - "\"$(SRCROOT)/external/googletest/src/googlemock\"", - ); - INFOPLIST_FILE = "$(SRCROOT)/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 5.3; - WRAPPER_EXTENSION = app; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 529226CD1C85F68000C89379 /* Build configuration list for PBXProject "integration_test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 529226F71C85F68000C89379 /* Debug */, - 529226F81C85F68000C89379 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 529226F91C85F68000C89379 /* Build configuration list for PBXNativeTarget "integration_test" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 529226FA1C85F68000C89379 /* Debug */, - 529226FB1C85F68000C89379 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 529226CA1C85F68000C89379 /* Project object */; -} diff --git a/gma/integration_test/proguard.pro b/gma/integration_test/proguard.pro deleted file mode 100644 index 2d04b8a9a5..0000000000 --- a/gma/integration_test/proguard.pro +++ /dev/null @@ -1,2 +0,0 @@ --ignorewarnings --keep,includedescriptorclasses public class com.google.firebase.example.LoggingUtils { * ; } diff --git a/gma/integration_test/res/layout/main.xml b/gma/integration_test/res/layout/main.xml deleted file mode 100644 index 56e8488b7a..0000000000 --- a/gma/integration_test/res/layout/main.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - diff --git a/gma/integration_test/res/values/strings.xml b/gma/integration_test/res/values/strings.xml deleted file mode 100644 index ff36817020..0000000000 --- a/gma/integration_test/res/values/strings.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - Firebase GMA Integration Test - diff --git a/gma/integration_test/settings.gradle b/gma/integration_test/settings.gradle deleted file mode 100644 index 7e56f6228e..0000000000 --- a/gma/integration_test/settings.gradle +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2021 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -def firebase_cpp_sdk_dir = System.getProperty('firebase_cpp_sdk.dir') -if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) { - firebase_cpp_sdk_dir = System.getenv('FIREBASE_CPP_SDK_DIR') - if (firebase_cpp_sdk_dir == null || firebase_cpp_sdk_dir.isEmpty()) { - if ((file('../../cpp_sdk_version.json')).exists()) { - firebase_cpp_sdk_dir = file('../..').absolutePath - } - else if ((file('firebase_cpp_sdk')).exists()) { - firebase_cpp_sdk_dir = 'firebase_cpp_sdk' - } else { - throw new StopActionException( - 'firebase_cpp_sdk.dir property or the FIREBASE_CPP_SDK_DIR ' + - 'environment variable must be set to reference the Firebase C++ ' + - 'SDK install directory. This is used to configure static library ' + - 'and C/C++ include paths for the SDK.') - } - } -} -if (!(new File(firebase_cpp_sdk_dir)).exists()) { - throw new StopActionException( - sprintf('Firebase C++ SDK directory %s does not exist', - firebase_cpp_sdk_dir)) -} -gradle.ext.firebase_cpp_sdk_dir = "$firebase_cpp_sdk_dir" -includeBuild("$firebase_cpp_sdk_dir") { - name = "firebase_cpp_sdk" -} diff --git a/gma/integration_test/src/integration_test.cc b/gma/integration_test/src/integration_test.cc deleted file mode 100644 index e26beb6ff3..0000000000 --- a/gma/integration_test/src/integration_test.cc +++ /dev/null @@ -1,3328 +0,0 @@ -// Copyright 2021 Google LLC. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "app_framework.h" // NOLINT -#include "firebase/app.h" -#include "firebase/gma.h" -#include "firebase/gma/types.h" -#include "firebase/gma/ump.h" -#include "firebase/util.h" -#include "firebase_test_framework.h" // NOLINT - -#if defined(ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) -// includes for phone-only tests. -#include -#include -#endif // defined(ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) - -// The TO_STRING macro is useful for command line defined strings as the quotes -// get stripped. -#define TO_STRING_EXPAND(X) #X -#define TO_STRING(X) TO_STRING_EXPAND(X) - -// Path to the Firebase config file to load. -#ifdef FIREBASE_CONFIG -#define FIREBASE_CONFIG_STRING TO_STRING(FIREBASE_CONFIG) -#else -#define FIREBASE_CONFIG_STRING "" -#endif // FIREBASE_CONFIG - -namespace firebase_testapp_automated { - -// The GMA app IDs for the test app. -#if defined(ANDROID) -// If you change the GMA app ID for your Android app, make sure to change it -// in AndroidManifest.xml as well. -const char* kGmaAppID = "ca-app-pub-3940256099942544~3347511713"; -#else -// If you change the GMA app ID for your iOS app, make sure to change the -// value for "GADApplicationIdentifier" in your Info.plist as well. -const char* kGmaAppID = "ca-app-pub-3940256099942544~1458002511"; -#endif - -// These ad units IDs have been created specifically for testing, and will -// always return test ads. -#if defined(ANDROID) -const char* kBannerAdUnit = "ca-app-pub-3940256099942544/6300978111"; -const char* kInterstitialAdUnit = "ca-app-pub-3940256099942544/1033173712"; -const char* kRewardedAdUnit = "ca-app-pub-3940256099942544/5224354917"; -const char* kNativeAdUnit = "ca-app-pub-3940256099942544/2247696110"; -#else -const char* kBannerAdUnit = "ca-app-pub-3940256099942544/2934735716"; -const char* kInterstitialAdUnit = "ca-app-pub-3940256099942544/4411468910"; -const char* kRewardedAdUnit = "ca-app-pub-3940256099942544/1712485313"; -const char* kNativeAdUnit = "ca-app-pub-3940256099942544/3986624511"; -#endif - -// Used in a test to send an errant ad unit id. -const char* kBadAdUnit = "oops"; - -// Standard Banner Ad Size. -static const int kBannerWidth = 320; -static const int kBannerHeight = 50; - -enum AdCallbackEvent { - AdCallbackEventClicked = 0, - AdCallbackEventClosed, - AdCallbackEventAdImpression, - AdCallbackEventOpened, - AdCallbackEventPaidEvent -}; - -// Error domains vary across phone SDKs. -#if defined(ANDROID) -const char* kErrorDomain = "com.google.android.gms.ads"; -#else -const char* kErrorDomain = "com.google.admob"; -#endif - -// Sample test device IDs to use in making the request. -// You can replace these with actual device IDs for certain tests (e.g. UMP) -// to work on hardware devices. -const std::vector kTestDeviceIDs = { - "2077ef9a63d2b398840261c8221a0c9b", "098fe087d987c9a878965454a65654d7"}; - -// Sample keywords to use in making the request. -static const std::vector kKeywords({"GMA", "C++", "Fun"}); - -// "Extra" key value pairs can be added to the request as well. Typically -// these are used when testing new features. -static const std::map kGmaAdapterExtras = { - {"the_name_of_an_extra", "the_value_for_that_extra"}, - {"heres", "a second example"}}; - -#if defined(ANDROID) -static const char* kAdNetworkExtrasClassName = - "com/google/ads/mediation/admob/AdMobAdapter"; -#else -static const char* kAdNetworkExtrasClassName = "GADExtras"; -#endif - -// Class nname of the GMA SDK returned in initialization results. -#if defined(ANDROID) -const char kGmaClassName[] = "com.google.android.gms.ads.MobileAds"; -#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE -const char kGmaClassName[] = "GADMobileAds"; -#else // desktop -const char kGmaClassName[] = "stub"; -#endif - -// Used to detect kAdErrorCodeAdNetworkClassLoadErrors when loading -// ads. -static const char* kAdNetworkExtrasInvalidClassName = "abc123321cba"; - -static const char* kContentUrl = "http://www.firebase.com"; - -static const std::vector kNeighboringContentURLs = { - "test_url1", "test_url2", "test_url3"}; - -using app_framework::LogDebug; -using app_framework::LogInfo; -using app_framework::LogWarning; -using app_framework::ProcessEvents; - -using firebase_test_framework::FirebaseTest; - -using testing::AnyOf; -using testing::Contains; -using testing::ElementsAre; -using testing::Eq; -using testing::HasSubstr; -using testing::Pair; -using testing::Property; - -class FirebaseGmaTest : public FirebaseTest { - public: - FirebaseGmaTest(); - ~FirebaseGmaTest() override; - - static void SetUpTestSuite(); - static void TearDownTestSuite(); - - void SetUp() override; - void TearDown() override; - - protected: - firebase::gma::AdRequest GetAdRequest(); - firebase::Variant GetVariantMap(); - - static firebase::App* shared_app_; -}; - -class FirebaseGmaUITest : public FirebaseGmaTest { - public: - FirebaseGmaUITest(); - ~FirebaseGmaUITest() override; - - void SetUp() override; -}; - -class FirebaseGmaMinimalTest : public FirebaseTest { - public: - FirebaseGmaMinimalTest(); - ~FirebaseGmaMinimalTest() override; -}; - -// Runs GMA Tests on methods and functions that should be run -// before GMA initializes. -class FirebaseGmaPreInitializationTests : public FirebaseGmaTest { - public: - FirebaseGmaPreInitializationTests(); - ~FirebaseGmaPreInitializationTests() override; - - static void SetUpTestSuite(); - - void SetUp() override; -}; - -firebase::App* FirebaseGmaTest::shared_app_ = nullptr; - -void PauseForVisualInspectionAndCallbacks() { - app_framework::ProcessEvents(300); -} - -void InitializeGma(firebase::App* shared_app) { - LogDebug("Initializing GMA."); - - ::firebase::ModuleInitializer initializer; - initializer.Initialize(shared_app, nullptr, - [](::firebase::App* app, void* /* userdata */) { - LogDebug("Try to initialize GMA"); - firebase::InitResult result; - ::firebase::gma::Initialize(*app, &result); - return result; - }); - - FirebaseGmaTest::WaitForCompletion(initializer.InitializeLastResult(), - "Initialize"); - - ASSERT_EQ(initializer.InitializeLastResult().error(), 0) - << initializer.InitializeLastResult().error_message(); - - LogDebug("Successfully initialized GMA."); -} - -void FirebaseGmaTest::SetUpTestSuite() { - LogDebug("Initialize Firebase App."); - - FindFirebaseConfig(FIREBASE_CONFIG_STRING); - -#if defined(ANDROID) - shared_app_ = ::firebase::App::Create(app_framework::GetJniEnv(), - app_framework::GetActivity()); -#else - shared_app_ = ::firebase::App::Create(); -#endif // defined(ANDROID) - - InitializeGma(shared_app_); -} - -void FirebaseGmaTest::TearDownTestSuite() { - // GMA does some of its initialization in the main thread, so if you terminate - // it before initialization has completed, it can cause issues. So wait for - // any pending GMA initialization to be completed before calling terminate. - WaitForCompletion(firebase::gma::InitializeLastResult(), - "gma::InitializeLastResult"); - LogDebug("Shutdown GMA."); - firebase::gma::Terminate(); - LogDebug("Shutdown Firebase App."); - delete shared_app_; - shared_app_ = nullptr; -} - -FirebaseGmaTest::FirebaseGmaTest() {} - -FirebaseGmaTest::~FirebaseGmaTest() {} - -void FirebaseGmaTest::SetUp() { - TEST_DOES_NOT_REQUIRE_USER_INTERACTION; - ProcessEvents(100); // Flush main thread queue. - FirebaseTest::SetUp(); - - // This example uses ad units that are specially configured to return test ads - // for every request. When using your own ad unit IDs, however, it's important - // to register the device IDs associated with any devices that will be used to - // test the app. This ensures that regardless of the ad unit ID, those - // devices will always receive test ads in compliance with GMA policy. - // - // Device IDs can be obtained by checking the logcat or the Xcode log while - // debugging. They appear as a long string of hex characters. - firebase::gma::RequestConfiguration request_configuration; - request_configuration.test_device_ids = kTestDeviceIDs; - request_configuration.test_device_ids.push_back(GetDebugDeviceId()); - firebase::gma::SetRequestConfiguration(request_configuration); -} - -void FirebaseGmaTest::TearDown() { FirebaseTest::TearDown(); } - -firebase::gma::AdRequest FirebaseGmaTest::GetAdRequest() { - firebase::gma::AdRequest request; - - // Additional keywords to be used in targeting. - for (auto keyword_iter = kKeywords.begin(); keyword_iter != kKeywords.end(); - ++keyword_iter) { - request.add_keyword((*keyword_iter).c_str()); - } - - for (auto extras_iter = kGmaAdapterExtras.begin(); - extras_iter != kGmaAdapterExtras.end(); ++extras_iter) { - request.add_extra(kAdNetworkExtrasClassName, extras_iter->first.c_str(), - extras_iter->second.c_str()); - } - - // Content URL - request.set_content_url(kContentUrl); - - // Neighboring Content URLs - request.add_neighboring_content_urls(kNeighboringContentURLs); - - return request; -} - -firebase::Variant FirebaseGmaTest::GetVariantMap() { - firebase::Variant in_key = firebase::Variant::FromMutableString("inner_key"); - firebase::Variant in_val = firebase::Variant::FromMutableString("inner_val"); - firebase::Variant out_key = firebase::Variant::FromMutableString("outer_key"); - - firebase::Variant out_val = firebase::Variant::EmptyMap(); - out_val.map()[in_key] = in_val; - - firebase::Variant variant_map = firebase::Variant::EmptyMap(); - variant_map.map()[out_key] = out_val; - - return variant_map; -} - -FirebaseGmaMinimalTest::FirebaseGmaMinimalTest() {} - -FirebaseGmaMinimalTest::~FirebaseGmaMinimalTest() {} - -FirebaseGmaUITest::FirebaseGmaUITest() {} - -FirebaseGmaUITest::~FirebaseGmaUITest() {} - -void FirebaseGmaUITest::SetUp() { - TEST_REQUIRES_USER_INTERACTION; - FirebaseTest::SetUp(); - // This example uses ad units that are specially configured to return test ads - // for every request. When using your own ad unit IDs, however, it's important - // to register the device IDs associated with any devices that will be used to - // test the app. This ensures that regardless of the ad unit ID, those - // devices will always receive test ads in compliance with GMA policy. - // - // Device IDs can be obtained by checking the logcat or the Xcode log while - // debugging. They appear as a long string of hex characters. - firebase::gma::RequestConfiguration request_configuration; - request_configuration.test_device_ids = kTestDeviceIDs; - request_configuration.test_device_ids.push_back(GetDebugDeviceId()); - firebase::gma::SetRequestConfiguration(request_configuration); -} - -FirebaseGmaPreInitializationTests::FirebaseGmaPreInitializationTests() {} - -FirebaseGmaPreInitializationTests::~FirebaseGmaPreInitializationTests() {} - -void FirebaseGmaPreInitializationTests::SetUp() { FirebaseTest::SetUp(); } - -void FirebaseGmaPreInitializationTests::SetUpTestSuite() { - LogDebug("Initialize Firebase App."); - FindFirebaseConfig(FIREBASE_CONFIG_STRING); -#if defined(ANDROID) - shared_app_ = ::firebase::App::Create(app_framework::GetJniEnv(), - app_framework::GetActivity()); -#else - shared_app_ = ::firebase::App::Create(); -#endif // defined(ANDROID) -} - -// Test cases below. - -TEST_F(FirebaseGmaMinimalTest, TestInitializeGmaWithoutFirebase) { - // Don't initialize mediation in this test so that a later test can still - // verify that mediation has not been initialized. - firebase::gma::DisableMediationInitialization(); - LogDebug("Initializing GMA without a Firebase App."); - firebase::InitResult result; -#if defined(ANDROID) - ::firebase::gma::Initialize(app_framework::GetJniEnv(), - app_framework::GetActivity(), &result); -#else // !defined(ANDROID) - ::firebase::gma::Initialize(&result); -#endif // defined(ANDROID) - EXPECT_EQ(result, ::firebase::kInitResultSuccess); - WaitForCompletion(firebase::gma::InitializeLastResult(), "gma::Initialize"); - LogDebug("Successfully initialized GMA."); - - LogDebug("Shutdown GMA."); - firebase::gma::Terminate(); -} - -TEST_F(FirebaseGmaPreInitializationTests, TestDisableMediationInitialization) { - // Note: This test should be disabled or put in an entirely different test - // binrary if we ever wish to test mediation in this application. - firebase::gma::DisableMediationInitialization(); - - // Ensure that GMA can initialize. - InitializeGma(shared_app_); - auto initialize_future = firebase::gma::InitializeLastResult(); - WaitForCompletion(initialize_future, "gma::Initialize"); - ASSERT_NE(initialize_future.result(), nullptr); - EXPECT_EQ(*initialize_future.result(), - firebase::gma::GetInitializationStatus()); - -#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) - // Check to see that only one Adapter was initialized, the base GMA adapter. - // Note: DisableMediationInitialization is only implemented on iOS. - std::map adapter_status = - firebase::gma::GetInitializationStatus().GetAdapterStatusMap(); - EXPECT_EQ(adapter_status.size(), 1); - EXPECT_THAT( - adapter_status, - Contains( - Pair(kGmaClassName, - Property(&firebase::gma::AdapterStatus::is_initialized, true)))) - << "Expected adapter class '" << kGmaClassName << "' is not loaded."; -#endif -} - -TEST_F(FirebaseGmaTest, TestInitializationStatus) { - // Ensure Initialize()'s result matches GetInitializationStatus(). - auto initialize_future = firebase::gma::InitializeLastResult(); - WaitForCompletion(initialize_future, "gma::Initialize"); - ASSERT_NE(initialize_future.result(), nullptr); - EXPECT_EQ(*initialize_future.result(), - firebase::gma::GetInitializationStatus()); - - for (auto adapter_status : - firebase::gma::GetInitializationStatus().GetAdapterStatusMap()) { - LogDebug("GMA Mediation Adapter '%s' %s (latency %d ms): %s", - adapter_status.first.c_str(), - (adapter_status.second.is_initialized() ? "loaded" : "NOT loaded"), - adapter_status.second.latency(), - adapter_status.second.description().c_str()); - } - - // Confirm that the default Google Mobile Ads SDK class name shows up in the - // list. It should either be is_initialized = true, or description should say - // "Timeout" (this is a special case we are using to deflake this test on - // Android emulator). - EXPECT_THAT( - initialize_future.result()->GetAdapterStatusMap(), - Contains(Pair( - kGmaClassName, - AnyOf(Property(&firebase::gma::AdapterStatus::is_initialized, true), - Property(&firebase::gma::AdapterStatus::description, - HasSubstr("Timeout")))))) - << "Expected adapter class '" << kGmaClassName << "' is not loaded."; -} - -TEST_F(FirebaseGmaPreInitializationTests, TestDisableSDKCrashReporting) { - // We can't test to see if this method successfully reconfigures crash - // reporting, but we're still calling it as a sanity check and to ensure - // the symbol exists in the library. - firebase::gma::DisableSDKCrashReporting(); -} - -TEST_F(FirebaseGmaTest, TestSetAppKeyEnabled) { - // We can't test to see if this method successfully enables/disables - // the app key, but we're still calling it as a sanity check and to - // ensure the symbol exists in the library. - firebase::gma::SetIsSameAppKeyEnabled(true); -} - -TEST_F(FirebaseGmaTest, TestGetAdRequest) { GetAdRequest(); } - -TEST_F(FirebaseGmaTest, TestGetVariantMap) { GetVariantMap(); } - -TEST_F(FirebaseGmaTest, TestGetAdRequestValues) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::AdRequest request = GetAdRequest(); - - // Content URL. - EXPECT_TRUE(request.content_url() == std::string(kContentUrl)); - - // Extras. - std::map > configured_extras = - request.extras(); - - EXPECT_EQ(configured_extras.size(), 1); - for (auto extras_name_iter = configured_extras.begin(); - extras_name_iter != configured_extras.end(); ++extras_name_iter) { - // Confirm class name. - const std::string class_name = extras_name_iter->first; - EXPECT_EQ(class_name, kAdNetworkExtrasClassName); - - // Grab the extras. - const std::map& configured_extras = - extras_name_iter->second; - EXPECT_EQ(configured_extras.size(), kGmaAdapterExtras.size()); - - // Check the extra key value pairs. - for (auto constant_extras_iter = kGmaAdapterExtras.begin(); - constant_extras_iter != kGmaAdapterExtras.end(); - ++constant_extras_iter) { - // Ensure the configured value matches the constant for the same key. - EXPECT_EQ(configured_extras.at(constant_extras_iter->first), - constant_extras_iter->second); - } - } - - const std::unordered_set configured_keywords = - request.keywords(); - EXPECT_EQ(configured_keywords.size(), kKeywords.size()); - for (auto keyword_iter = kKeywords.begin(); keyword_iter != kKeywords.end(); - ++keyword_iter) { - EXPECT_TRUE(configured_keywords.find(*keyword_iter) != - configured_keywords.end()); - } - - const std::unordered_set configured_neighboring_content_urls = - request.neighboring_content_urls(); - EXPECT_EQ(configured_neighboring_content_urls.size(), - kNeighboringContentURLs.size()); - for (auto url_iter = kNeighboringContentURLs.begin(); - url_iter != kNeighboringContentURLs.end(); ++url_iter) { - EXPECT_TRUE(configured_neighboring_content_urls.find(*url_iter) != - configured_neighboring_content_urls.end()); - } -} - -// A listener to detect when the AdInspector has been closed. Additionally, -// checks for errors when opening the AdInspector while it's already open. -class TestAdInspectorClosedListener - : public firebase::gma::AdInspectorClosedListener { - public: - TestAdInspectorClosedListener() - : num_closed_events_(0), num_successful_results_(0) {} - - // Called when the user clicked the ad. - void OnAdInspectorClosed(const firebase::gma::AdResult& ad_result) override { - ++num_closed_events_; - if (ad_result.is_successful()) { - ++num_successful_results_; - } else { -#if defined(ANDROID) - EXPECT_EQ(ad_result.ad_error().code(), - firebase::gma::kAdErrorCodeInsepctorAlreadyOpen); - EXPECT_STREQ(ad_result.ad_error().message().c_str(), - "Ad inspector cannot be opened because it is already open."); -#else - // The iOS GMA SDK returns internal errors for all AdInspector failures. - EXPECT_EQ(ad_result.ad_error().code(), - firebase::gma::kAdErrorCodeInternalError); - EXPECT_STREQ(ad_result.ad_error().message().c_str(), - "Ad Inspector cannot be opened because it is already open."); -#endif - } - } - - uint8_t num_closed_events() const { return num_closed_events_; } - uint8_t num_successful_results() const { return num_successful_results_; } - - private: - uint8_t num_closed_events_; - uint8_t num_successful_results_; -}; - -// This is for manual test only -// Ensure we can open the AdInspector and listen to its events. -TEST_F(FirebaseGmaTest, TestAdInspector) { - TEST_REQUIRES_USER_INTERACTION; - TestAdInspectorClosedListener listener; - - firebase::gma::OpenAdInspector(app_framework::GetWindowController(), - &listener); - - // Call OpenAdInspector, even on Desktop (above), to ensure the stub linked - // correctly. However, the rest of the testing is mobile-only beahvior. - SKIP_TEST_ON_DESKTOP; - - // Open the inspector a second time to generate a - // kAdErrorCodeInsepctorAlreadyOpen result. - app_framework::ProcessEvents(2000); - - firebase::gma::OpenAdInspector(app_framework::GetWindowController(), - &listener); - - while (listener.num_closed_events() < 2) { - app_framework::ProcessEvents(2000); - } - - EXPECT_EQ(listener.num_successful_results(), 1); -} - -// A simple listener to help test changes to a AdViews. -class TestBoundingBoxListener - : public firebase::gma::AdViewBoundingBoxListener { - public: - void OnBoundingBoxChanged(firebase::gma::AdView* ad_view, - firebase::gma::BoundingBox box) override { - bounding_box_changes_.push_back(box); - } - std::vector bounding_box_changes_; -}; - -// A simple listener to help test changes an Ad. -class TestAdListener : public firebase::gma::AdListener { - public: - TestAdListener() - : num_on_ad_clicked_(0), - num_on_ad_closed_(0), - num_on_ad_impression_(0), - num_on_ad_opened_(0) {} - - void OnAdClicked() override { num_on_ad_clicked_++; } - void OnAdClosed() override { num_on_ad_closed_++; } - void OnAdImpression() override { num_on_ad_impression_++; } - void OnAdOpened() override { num_on_ad_opened_++; } - - int num_on_ad_clicked_; - int num_on_ad_closed_; - int num_on_ad_impression_; - int num_on_ad_opened_; -}; - -// A simple listener track FullScreen presentation changes. -class TestFullScreenContentListener - : public firebase::gma::FullScreenContentListener { - public: - TestFullScreenContentListener() - : num_on_ad_clicked_(0), - num_on_ad_dismissed_full_screen_content_(0), - num_on_ad_failed_to_show_full_screen_content_(0), - num_on_ad_impression_(0), - num_on_ad_showed_full_screen_content_(0) {} - - int num_ad_clicked() const { return num_on_ad_clicked_; } - int num_ad_dismissed() const { - return num_on_ad_dismissed_full_screen_content_; - } - int num_ad_failed_to_show_content() const { - return num_on_ad_failed_to_show_full_screen_content_; - } - int num_ad_impressions() const { return num_on_ad_impression_; } - int num_ad_showed_content() const { - return num_on_ad_showed_full_screen_content_; - } - - void OnAdClicked() override { num_on_ad_clicked_++; } - - void OnAdDismissedFullScreenContent() override { - num_on_ad_dismissed_full_screen_content_++; - } - - void OnAdFailedToShowFullScreenContent( - const firebase::gma::AdError& ad_error) override { - num_on_ad_failed_to_show_full_screen_content_++; - failure_codes_.push_back(ad_error.code()); - } - - void OnAdImpression() override { num_on_ad_impression_++; } - - void OnAdShowedFullScreenContent() override { - num_on_ad_showed_full_screen_content_++; - } - - const std::vector failure_codes() const { - return failure_codes_; - } - - private: - int num_on_ad_clicked_; - int num_on_ad_dismissed_full_screen_content_; - int num_on_ad_failed_to_show_full_screen_content_; - int num_on_ad_impression_; - int num_on_ad_showed_full_screen_content_; - - std::vector failure_codes_; -}; - -// A simple listener track UserEarnedReward events. -class TestUserEarnedRewardListener - : public firebase::gma::UserEarnedRewardListener { - public: - TestUserEarnedRewardListener() : num_on_user_earned_reward_(0) {} - - int num_earned_rewards() const { return num_on_user_earned_reward_; } - - void OnUserEarnedReward(const firebase::gma::AdReward& reward) override { - ++num_on_user_earned_reward_; - EXPECT_EQ(reward.type(), "coins"); - EXPECT_EQ(reward.amount(), 10); - } - - private: - int num_on_user_earned_reward_; -}; - -// A simple listener track ad pay events. -class TestPaidEventListener : public firebase::gma::PaidEventListener { - public: - TestPaidEventListener() : num_on_paid_event_(0) {} - - int num_paid_events() const { return num_on_paid_event_; } - - void OnPaidEvent(const firebase::gma::AdValue& value) override { - ++num_on_paid_event_; - // These are the values for GMA test ads. If they change then we should - // alter the test to match the new expected values. - EXPECT_EQ(value.currency_code(), "USD"); - EXPECT_EQ(value.value_micros(), 0); - } - int num_on_paid_event_; -}; - -TEST_F(FirebaseGmaTest, TestAdSize) { - uint32_t kWidth = 50; - uint32_t kHeight = 10; - - using firebase::gma::AdSize; - - const AdSize adaptive_landscape = - AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(kWidth); - EXPECT_EQ(adaptive_landscape.width(), kWidth); - EXPECT_EQ(adaptive_landscape.height(), 0); - EXPECT_EQ(adaptive_landscape.type(), AdSize::kTypeAnchoredAdaptive); - EXPECT_EQ(adaptive_landscape.orientation(), AdSize::kOrientationLandscape); - - const AdSize adaptive_portrait = - AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(kWidth); - EXPECT_EQ(adaptive_portrait.width(), kWidth); - EXPECT_EQ(adaptive_portrait.height(), 0); - EXPECT_EQ(adaptive_portrait.type(), AdSize::kTypeAnchoredAdaptive); - EXPECT_EQ(adaptive_portrait.orientation(), AdSize::kOrientationPortrait); - - EXPECT_FALSE(adaptive_portrait == adaptive_landscape); - EXPECT_TRUE(adaptive_portrait != adaptive_landscape); - - const firebase::gma::AdSize adaptive_current = - AdSize::GetCurrentOrientationAnchoredAdaptiveBannerAdSize(kWidth); - EXPECT_EQ(adaptive_current.width(), kWidth); - EXPECT_EQ(adaptive_current.height(), 0); - EXPECT_EQ(adaptive_current.type(), AdSize::kTypeAnchoredAdaptive); - EXPECT_EQ(adaptive_current.orientation(), AdSize::kOrientationCurrent); - - const firebase::gma::AdSize custom_ad_size(kWidth, kHeight); - EXPECT_EQ(custom_ad_size.width(), kWidth); - EXPECT_EQ(custom_ad_size.height(), kHeight); - EXPECT_EQ(custom_ad_size.type(), AdSize::kTypeStandard); - EXPECT_EQ(custom_ad_size.orientation(), AdSize::kOrientationCurrent); - - const AdSize custom_ad_size_2(kWidth, kHeight); - EXPECT_TRUE(custom_ad_size == custom_ad_size_2); - EXPECT_FALSE(custom_ad_size != custom_ad_size_2); - - const AdSize banner = AdSize::kBanner; - EXPECT_EQ(banner.width(), 320); - EXPECT_EQ(banner.height(), 50); - EXPECT_EQ(banner.type(), AdSize::kTypeStandard); - EXPECT_EQ(banner.orientation(), AdSize::kOrientationCurrent); - - const AdSize fullbanner = AdSize::kFullBanner; - EXPECT_EQ(fullbanner.width(), 468); - EXPECT_EQ(fullbanner.height(), 60); - EXPECT_EQ(fullbanner.type(), AdSize::kTypeStandard); - EXPECT_EQ(fullbanner.orientation(), AdSize::kOrientationCurrent); - - const AdSize leaderboard = AdSize::kLeaderboard; - EXPECT_EQ(leaderboard.width(), 728); - EXPECT_EQ(leaderboard.height(), 90); - EXPECT_EQ(leaderboard.type(), AdSize::kTypeStandard); - EXPECT_EQ(leaderboard.orientation(), AdSize::kOrientationCurrent); - - const AdSize medium_rectangle = AdSize::kMediumRectangle; - EXPECT_EQ(medium_rectangle.width(), 300); - EXPECT_EQ(medium_rectangle.height(), 250); - EXPECT_EQ(medium_rectangle.type(), AdSize::kTypeStandard); - EXPECT_EQ(medium_rectangle.orientation(), AdSize::kOrientationCurrent); -} - -TEST_F(FirebaseGmaTest, TestRequestConfigurationSetGetEmptyConfig) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::RequestConfiguration set_configuration; - firebase::gma::SetRequestConfiguration(set_configuration); - firebase::gma::RequestConfiguration retrieved_configuration = - firebase::gma::GetRequestConfiguration(); - - EXPECT_EQ( - retrieved_configuration.max_ad_content_rating, - firebase::gma::RequestConfiguration::kMaxAdContentRatingUnspecified); - EXPECT_EQ( - retrieved_configuration.tag_for_child_directed_treatment, - firebase::gma::RequestConfiguration::kChildDirectedTreatmentUnspecified); - EXPECT_EQ(retrieved_configuration.tag_for_under_age_of_consent, - firebase::gma::RequestConfiguration::kUnderAgeOfConsentUnspecified); - EXPECT_EQ(retrieved_configuration.test_device_ids.size(), 0); -} - -TEST_F(FirebaseGmaTest, TestRequestConfigurationSetGet) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::RequestConfiguration set_configuration; - set_configuration.max_ad_content_rating = - firebase::gma::RequestConfiguration::kMaxAdContentRatingPG; - set_configuration.tag_for_child_directed_treatment = - firebase::gma::RequestConfiguration::kChildDirectedTreatmentTrue; - set_configuration.tag_for_under_age_of_consent = - firebase::gma::RequestConfiguration::kUnderAgeOfConsentFalse; - set_configuration.test_device_ids.push_back("1"); - set_configuration.test_device_ids.push_back("2"); - set_configuration.test_device_ids.push_back("3"); - firebase::gma::SetRequestConfiguration(set_configuration); - - firebase::gma::RequestConfiguration retrieved_configuration = - firebase::gma::GetRequestConfiguration(); - - EXPECT_EQ(retrieved_configuration.max_ad_content_rating, - firebase::gma::RequestConfiguration::kMaxAdContentRatingPG); - -#if defined(ANDROID) - EXPECT_EQ(retrieved_configuration.tag_for_child_directed_treatment, - firebase::gma::RequestConfiguration::kChildDirectedTreatmentTrue); - EXPECT_EQ(retrieved_configuration.tag_for_under_age_of_consent, - firebase::gma::RequestConfiguration::kUnderAgeOfConsentFalse); -#else // iOS - // iOS doesn't allow for the querying of these values. - EXPECT_EQ( - retrieved_configuration.tag_for_child_directed_treatment, - firebase::gma::RequestConfiguration::kChildDirectedTreatmentUnspecified); - EXPECT_EQ(retrieved_configuration.tag_for_under_age_of_consent, - firebase::gma::RequestConfiguration::kUnderAgeOfConsentUnspecified); -#endif - - EXPECT_EQ(retrieved_configuration.test_device_ids.size(), 3); - EXPECT_TRUE(std::count(retrieved_configuration.test_device_ids.begin(), - retrieved_configuration.test_device_ids.end(), "1")); - EXPECT_TRUE(std::count(retrieved_configuration.test_device_ids.begin(), - retrieved_configuration.test_device_ids.end(), "2")); - EXPECT_TRUE(std::count(retrieved_configuration.test_device_ids.begin(), - retrieved_configuration.test_device_ids.end(), "3")); -} - -// Simple Load Tests as a sanity check. These don't show the ad, just -// ensure that we can load them before diving into the interactive tests. -TEST_F(FirebaseGmaTest, TestAdViewLoadAd) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - firebase::Future load_ad_future; - const firebase::gma::AdResult* result_ptr = nullptr; - - load_ad_future = ad_view->LoadAd(GetAdRequest()); - WaitForCompletion(load_ad_future, "LoadAd"); - - result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - - EXPECT_EQ(ad_view->ad_size().width(), kBannerWidth); - EXPECT_EQ(ad_view->ad_size().height(), kBannerHeight); - EXPECT_EQ(ad_view->ad_size().type(), firebase::gma::AdSize::kTypeStandard); - - load_ad_future.Release(); - WaitForCompletion(ad_view->Destroy(), "Destroy"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestInterstitialAdLoad) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::InterstitialAd* interstitial = - new firebase::gma::InterstitialAd(); - - WaitForCompletion(interstitial->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // When the InterstitialAd is initialized, load an ad. - firebase::Future load_ad_future = - interstitial->LoadAd(kInterstitialAdUnit, GetAdRequest()); - - // This test behaves differently if it's running in UI mode - // (manually on a device) or in non-UI mode (via automated tests). - if (ShouldRunUITests()) { - // Run in manual mode: fail if any error occurs. - WaitForCompletion(load_ad_future, "LoadAd"); - } else { - // Run in automated test mode: don't fail if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - } - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - } - - load_ad_future.Release(); - delete interstitial; -} - -TEST_F(FirebaseGmaTest, TestRewardedAdLoad) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // When the RewardedAd is initialized, load an ad. - firebase::Future load_ad_future = - rewarded->LoadAd(kRewardedAdUnit, GetAdRequest()); - - // This test behaves differently if it's running in UI mode - // (manually on a device) or in non-UI mode (via automated tests). - if (ShouldRunUITests()) { - // Run in manual mode: fail if any error occurs. - WaitForCompletion(load_ad_future, "LoadAd"); - } else { - // Run in automated test mode: don't fail if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - } - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - // In UI mode, or in non-UI mode if a NoFill error didn't occur, check that - // the ad loaded correctly. - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - } - load_ad_future.Release(); - delete rewarded; -} - -TEST_F(FirebaseGmaTest, TestNativeAdLoad) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - - WaitForCompletion(native_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // When the NativeAd is initialized, load an ad. - firebase::Future load_ad_future = - native_ad->LoadAd(kNativeAdUnit, GetAdRequest()); - - // Don't fail loadAd, if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - - // Check image assets. - // Native ads usually contain only one large image asset. - // Check the validity of the first asset from the vector. - EXPECT_FALSE(native_ad->images().empty()); - EXPECT_FALSE(native_ad->images().at(0).image_uri().empty()); - EXPECT_GT(native_ad->images().at(0).scale(), 0); - - // Try loading large image asset. - firebase::Future load_image_future = - native_ad->images().at(0).LoadImage(); - WaitForCompletion(load_image_future, "LoadImage"); - const firebase::gma::ImageResult* img_result_ptr = - load_image_future.result(); - ASSERT_NE(img_result_ptr, nullptr); - EXPECT_TRUE(img_result_ptr->is_successful()); - EXPECT_GT(img_result_ptr->image().size(), 0); - - load_image_future.Release(); - } else if (load_ad_future.error() == firebase::gma::kAdErrorCodeNoFill) { - LogWarning("LoadAd returned NoFill in TestNativeAdLoad"); - } - - load_ad_future.Release(); - delete native_ad; -} - -TEST_F(FirebaseGmaTest, TestCreateQueryInfo) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::QueryInfo* query_info = new firebase::gma::QueryInfo(); - - WaitForCompletion(query_info->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - firebase::gma::AdRequest request = GetAdRequest(); - // Set the requester type to 8. QueryInfo gets generated without a - // query_info_type set, but throws a warning that it is missing. - request.add_extra(kAdNetworkExtrasClassName, "query_info_type", - "requester_type_8"); - // When the QueryInfo is initialized, generate a query info string. - firebase::Future create_query_info_future = - query_info->CreateQueryInfo(firebase::gma::kAdFormatNative, request); - - WaitForCompletion(create_query_info_future, "CreateQueryInfo"); - - if (create_query_info_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::QueryInfoResult* result_ptr = - create_query_info_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->query_info().empty()); - } - - create_query_info_future.Release(); - delete query_info; -} - -TEST_F(FirebaseGmaTest, TestCreateQueryInfoWithAdUnit) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::QueryInfo* query_info = new firebase::gma::QueryInfo(); - - WaitForCompletion(query_info->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - firebase::gma::AdRequest request = GetAdRequest(); - // Set the requester type to 8. QueryInfo gets generated without a - // query_info_type set, but throws a warning that it is missing. - request.add_extra(kAdNetworkExtrasClassName, "query_info_type", - "requester_type_8"); - // When the QueryInfo is initialized, generate a query info string. - // Providing a bad/empty ad unit does not affect the query info generation. - firebase::Future create_query_info_future = - query_info->CreateQueryInfoWithAdUnit(firebase::gma::kAdFormatNative, - request, kNativeAdUnit); - - WaitForCompletion(create_query_info_future, "CreateQueryInfoWithAdUnit"); - - if (create_query_info_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::QueryInfoResult* result_ptr = - create_query_info_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->query_info().empty()); - } - - create_query_info_future.Release(); - delete query_info; -} - -// Interactive test section. These have been placed up front so that the -// tester doesn't get bored waiting for them. -TEST_F(FirebaseGmaUITest, TestAdViewAdOpenedAdClosed) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - - // Set the listener. - TestAdListener ad_listener; - ad_view->SetAdListener(&ad_listener); - - TestPaidEventListener paid_event_listener; - ad_view->SetPaidEventListener(&paid_event_listener); - - // Load the AdView ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - ad_view->LoadAd(request); - WaitForCompletion(load_ad_future, "LoadAd"); - - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - WaitForCompletion(ad_view->Show(), "Show 0"); - - // Ad Events differ per platform. See the following for more info: - // https://www.googblogs.com/google-mobile-ads-sdk-a-note-on-ad-click-events/ - // and https://groups.google.com/g/google-admob-ads-sdk/c/lzdt5szxSVU -#if defined(ANDROID) - LogDebug("Click the Ad, and then close the ad to continue"); - - while (ad_listener.num_on_ad_opened_ == 0) { - app_framework::ProcessEvents(1000); - } - - while (ad_listener.num_on_ad_closed_ == 0) { - app_framework::ProcessEvents(1000); - } - - // Ensure all of the expected events were triggered on Android. - EXPECT_EQ(ad_listener.num_on_ad_clicked_, 1); - EXPECT_EQ(ad_listener.num_on_ad_impression_, 1); - EXPECT_EQ(ad_listener.num_on_ad_opened_, 1); - EXPECT_EQ(ad_listener.num_on_ad_closed_, 1); - EXPECT_EQ(paid_event_listener.num_paid_events(), 1); -#else - LogDebug("Click the Ad, and then close the ad to continue"); - - while (ad_listener.num_on_ad_clicked_ == 0) { - app_framework::ProcessEvents(1000); - } - - LogDebug("Waiting for a moment to ensure all callbacks are recorded."); - app_framework::ProcessEvents(2000); - - // Ensure all of the expected events were triggered on iOS. - EXPECT_EQ(ad_listener.num_on_ad_clicked_, 1); - EXPECT_EQ(ad_listener.num_on_ad_impression_, 1); - EXPECT_EQ(paid_event_listener.num_paid_events(), 1); - EXPECT_EQ(ad_listener.num_on_ad_opened_, 0); - EXPECT_EQ(ad_listener.num_on_ad_closed_, 0); -#endif - } - - load_ad_future.Release(); - ad_view->SetAdListener(nullptr); - ad_view->SetPaidEventListener(nullptr); - WaitForCompletion(ad_view->Destroy(), "Destroy the AdView"); - delete ad_view; -} - -TEST_F(FirebaseGmaUITest, TestInterstitialAdLoadAndShow) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::InterstitialAd* interstitial = - new firebase::gma::InterstitialAd(); - - WaitForCompletion(interstitial->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - TestFullScreenContentListener content_listener; - interstitial->SetFullScreenContentListener(&content_listener); - - TestPaidEventListener paid_event_listener; - interstitial->SetPaidEventListener(&paid_event_listener); - - // When the InterstitialAd is initialized, load an ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - interstitial->LoadAd(kInterstitialAdUnit, request); - WaitForCompletion(load_ad_future, "LoadAd"); - - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - WaitForCompletion(interstitial->Show(), "Show"); - - LogDebug("Click the Ad, and then return to the app to continue"); - - while (content_listener.num_ad_dismissed() == 0) { - app_framework::ProcessEvents(1000); - } - - LogDebug("Waiting for a moment to ensure all callbacks are recorded."); - app_framework::ProcessEvents(2000); - - EXPECT_EQ(content_listener.num_ad_clicked(), 1); - EXPECT_EQ(content_listener.num_ad_showed_content(), 1); - EXPECT_EQ(content_listener.num_ad_impressions(), 1); - EXPECT_EQ(content_listener.num_ad_failed_to_show_content(), 0); - EXPECT_EQ(content_listener.num_ad_dismissed(), 1); - EXPECT_EQ(paid_event_listener.num_paid_events(), 1); - -#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) - // Show the Ad again. Note: Android's Interstitial ads fail silently - // when attempting to show the ad twice. - LogDebug("Attempting to show ad again, checking for correct error result."); - WaitForCompletion(interstitial->Show(), "Show"); - app_framework::ProcessEvents(5000); - EXPECT_THAT(content_listener.failure_codes(), - ElementsAre(firebase::gma::kAdErrorCodeAdAlreadyUsed)); -#endif // TARGET_OS_IPHONE - } - - load_ad_future.Release(); - interstitial->SetFullScreenContentListener(nullptr); - interstitial->SetPaidEventListener(nullptr); - - delete interstitial; -} - -TEST_F(FirebaseGmaUITest, TestRewardedAdLoadAndShow) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - // TODO(@drsanta): remove when GMA whitelists CI devices. - TEST_REQUIRES_USER_INTERACTION_ON_IOS; - - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - TestFullScreenContentListener content_listener; - rewarded->SetFullScreenContentListener(&content_listener); - - TestPaidEventListener paid_event_listener; - rewarded->SetPaidEventListener(&paid_event_listener); - - // When the RewardedAd is initialized, load an ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - rewarded->LoadAd(kRewardedAdUnit, request); - WaitForCompletion(load_ad_future, "LoadAd"); - - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - firebase::gma::RewardedAd::ServerSideVerificationOptions options; - // We cannot programmatically verify that the GMA phone SDKs marshal - // these values properly (there are no get methods). At least invoke the - // method to ensure least we can set them without any exceptions occurring. - options.custom_data = "custom data"; - options.user_id = "123456"; - rewarded->SetServerSideVerificationOptions(options); - - TestUserEarnedRewardListener earned_reward_listener; - WaitForCompletion(rewarded->Show(&earned_reward_listener), "Show"); - - LogDebug( - "Wait for the Ad to finish playing, click the ad, return to the ad, " - "then close the ad to continue."); - - while (content_listener.num_ad_dismissed() == 0) { - app_framework::ProcessEvents(1000); - } - - LogDebug("Waiting for a moment to ensure all callbacks are recorded."); - app_framework::ProcessEvents(2000); - - // If not running the UI test in CI (running manually), keep this check. - // Else running the UI test in CI, skip this check. - if (!ShouldRunUITests()) { - EXPECT_EQ(content_listener.num_ad_clicked(), 1); - } - EXPECT_EQ(content_listener.num_ad_showed_content(), 1); - EXPECT_EQ(content_listener.num_ad_impressions(), 1); - EXPECT_EQ(content_listener.num_ad_dismissed(), 1); - EXPECT_EQ(content_listener.num_ad_failed_to_show_content(), 0); - EXPECT_EQ(earned_reward_listener.num_earned_rewards(), 1); - EXPECT_EQ(paid_event_listener.num_paid_events(), 1); - - // Show the Ad again - LogDebug("Attempting to show ad again, checking for correct error result."); - WaitForCompletion(rewarded->Show(&earned_reward_listener), "Show"); - app_framework::ProcessEvents(2000); - EXPECT_THAT(content_listener.failure_codes(), - testing::ElementsAre(firebase::gma::kAdErrorCodeAdAlreadyUsed)); - } - - load_ad_future.Release(); - rewarded->SetFullScreenContentListener(nullptr); - rewarded->SetPaidEventListener(nullptr); - - delete rewarded; -} - -// Other AdView Tests - -TEST_F(FirebaseGmaTest, TestAdViewLoadAdEmptyAdRequest) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - firebase::gma::AdRequest request; - firebase::Future load_ad_future; - const firebase::gma::AdResult* result_ptr = nullptr; - - load_ad_future = ad_view->LoadAd(request); - WaitForCompletion(load_ad_future, "LoadAd"); - result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - - EXPECT_EQ(ad_view->ad_size().width(), kBannerWidth); - EXPECT_EQ(ad_view->ad_size().height(), kBannerHeight); - EXPECT_EQ(ad_view->ad_size().type(), firebase::gma::AdSize::kTypeStandard); - - load_ad_future.Release(); - WaitForCompletion(ad_view->Destroy(), "Destroy"); - - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewLoadAdAnchorAdaptiveAd) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - using firebase::gma::AdSize; - AdSize banner_ad_size = - AdSize::GetCurrentOrientationAnchoredAdaptiveBannerAdSize(kBannerWidth); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - - WaitForCompletion(ad_view->LoadAd(GetAdRequest()), "LoadAd"); - - const AdSize ad_size = ad_view->ad_size(); - EXPECT_EQ(ad_size.width(), kBannerWidth); - EXPECT_NE(ad_size.height(), 0); - EXPECT_EQ(ad_size.type(), AdSize::kTypeAnchoredAdaptive); - EXPECT_EQ(ad_size.orientation(), AdSize::kOrientationCurrent); - WaitForCompletion(ad_view->Destroy(), "Destroy"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewLoadAdInlineAdaptiveAd) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - using firebase::gma::AdSize; - - using firebase::gma::AdSize; - AdSize banner_ad_size = - AdSize::GetCurrentOrientationInlineAdaptiveBannerAdSize(kBannerWidth); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - - WaitForCompletion(ad_view->LoadAd(GetAdRequest()), "LoadAd"); - - const AdSize ad_size = ad_view->ad_size(); - EXPECT_EQ(ad_size.width(), kBannerWidth); - EXPECT_NE(ad_size.height(), 0); - EXPECT_EQ(ad_size.type(), AdSize::kTypeInlineAdaptive); - EXPECT_EQ(ad_size.orientation(), AdSize::kOrientationCurrent); - WaitForCompletion(ad_view->Destroy(), "Destroy"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewLoadAdGetInlineAdaptiveBannerMaxHeight) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - using firebase::gma::AdSize; - AdSize banner_ad_size = - AdSize::GetInlineAdaptiveBannerAdSize(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - - WaitForCompletion(ad_view->LoadAd(GetAdRequest()), "LoadAd"); - - const AdSize ad_size = ad_view->ad_size(); - EXPECT_EQ(ad_size.width(), kBannerWidth); - EXPECT_NE(ad_size.height(), 0); - EXPECT_TRUE(ad_size.height() <= kBannerHeight); - EXPECT_EQ(ad_size.type(), AdSize::kTypeInlineAdaptive); - EXPECT_EQ(ad_size.orientation(), AdSize::kOrientationCurrent); - WaitForCompletion(ad_view->Destroy(), "Destroy"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewLoadAdDestroyNotCalled) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - WaitForCompletion(ad_view->LoadAd(GetAdRequest()), "LoadAd"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewAdSizeCompareOp) { - using firebase::gma::AdSize; - EXPECT_TRUE(AdSize(50, 100) == AdSize(50, 100)); - EXPECT_TRUE(AdSize(100, 50) == AdSize(100, 50)); - EXPECT_FALSE(AdSize(50, 100) == AdSize(100, 50)); - EXPECT_FALSE(AdSize(10, 10) == AdSize(50, 50)); - - EXPECT_FALSE(AdSize(50, 100) != AdSize(50, 100)); - EXPECT_FALSE(AdSize(100, 50) != AdSize(100, 50)); - EXPECT_TRUE(AdSize(50, 100) != AdSize(100, 50)); - EXPECT_TRUE(AdSize(10, 10) != AdSize(50, 50)); - - EXPECT_TRUE(AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100) == - AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100)); - EXPECT_FALSE(AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100) != - AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100)); - - EXPECT_TRUE(AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100) == - AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100)); - EXPECT_FALSE(AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100) != - AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100)); - - EXPECT_TRUE(AdSize::GetInlineAdaptiveBannerAdSize(100, 50) == - AdSize::GetInlineAdaptiveBannerAdSize(100, 50)); - EXPECT_FALSE(AdSize::GetInlineAdaptiveBannerAdSize(100, 50) != - AdSize::GetInlineAdaptiveBannerAdSize(100, 50)); - - EXPECT_TRUE(AdSize::GetLandscapeInlineAdaptiveBannerAdSize(100) == - AdSize::GetLandscapeInlineAdaptiveBannerAdSize(100)); - EXPECT_FALSE(AdSize::GetLandscapeInlineAdaptiveBannerAdSize(100) != - AdSize::GetLandscapeInlineAdaptiveBannerAdSize(100)); - - EXPECT_TRUE(AdSize::GetPortraitInlineAdaptiveBannerAdSize(100) == - AdSize::GetPortraitInlineAdaptiveBannerAdSize(100)); - EXPECT_TRUE(AdSize::GetLandscapeInlineAdaptiveBannerAdSize(100) == - AdSize::GetLandscapeInlineAdaptiveBannerAdSize(100)); - EXPECT_TRUE(AdSize::GetCurrentOrientationInlineAdaptiveBannerAdSize(100) == - AdSize::GetCurrentOrientationInlineAdaptiveBannerAdSize(100)); - - EXPECT_FALSE(AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100) == - AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100)); - EXPECT_TRUE(AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100) != - AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100)); - - EXPECT_FALSE(AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100) == - AdSize(100, 100)); - EXPECT_TRUE(AdSize::GetLandscapeAnchoredAdaptiveBannerAdSize(100) != - AdSize(100, 100)); - - EXPECT_FALSE(AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100) == - AdSize(100, 100)); - EXPECT_TRUE(AdSize::GetPortraitAnchoredAdaptiveBannerAdSize(100) != - AdSize(100, 100)); -} - -TEST_F(FirebaseGmaTest, TestAdViewDestroyBeforeInitialization) { - SKIP_TEST_ON_DESKTOP; - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Destroy(), "Destroy AdView"); -} - -TEST_F(FirebaseGmaTest, TestAdViewAdSizeBeforeInitialization) { - SKIP_TEST_ON_DESKTOP; - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - const firebase::gma::AdSize& ad_size = firebase::gma::AdSize(0, 0); - EXPECT_TRUE(ad_view->ad_size() == ad_size); - - WaitForCompletion(ad_view->Destroy(), "Destroy AdView"); -} - -TEST_F(FirebaseGmaTest, TestAdView) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - EXPECT_TRUE(ad_view->ad_size() == banner_ad_size); - - // Set the listener. - TestBoundingBoxListener bounding_box_listener; - ad_view->SetBoundingBoxListener(&bounding_box_listener); - PauseForVisualInspectionAndCallbacks(); - - int expected_num_bounding_box_changes = 0; - EXPECT_EQ(expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - // Load the AdView ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - ad_view->LoadAd(request); - WaitForCompletion(load_ad_future, "LoadAd"); - - const bool ad_loaded = - load_ad_future.error() == firebase::gma::kAdErrorCodeNone; - - // Suppress the extensive testing below if the ad failed to load. - if (ad_loaded) { - EXPECT_EQ(ad_view->ad_size().width(), kBannerWidth); - EXPECT_EQ(ad_view->ad_size().height(), kBannerHeight); - EXPECT_EQ(expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - // Make the AdView visible. - WaitForCompletion(ad_view->Show(), "Show 0"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - // Move to each of the six pre-defined positions. - WaitForCompletion(ad_view->SetPosition(firebase::gma::AdView::kPositionTop), - "SetPosition(Top)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionTop); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion( - ad_view->SetPosition(firebase::gma::AdView::kPositionTopLeft), - "SetPosition(TopLeft)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionTopLeft); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion( - ad_view->SetPosition(firebase::gma::AdView::kPositionTopRight), - "SetPosition(TopRight)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionTopRight); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion( - ad_view->SetPosition(firebase::gma::AdView::kPositionBottom), - "SetPosition(Bottom)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionBottom); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion( - ad_view->SetPosition(firebase::gma::AdView::kPositionBottomLeft), - "SetPosition(BottomLeft)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionBottomLeft); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion( - ad_view->SetPosition(firebase::gma::AdView::kPositionBottomRight), - "SetPosition(BottomRight)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionBottomRight); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - // Move to some coordinates. - WaitForCompletion(ad_view->SetPosition(100, 300), "SetPosition(x0, y0)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionUndefined); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion(ad_view->SetPosition(100, 400), "SetPosition(x1, y1)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionUndefined); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - // Try hiding and showing the AdView. - WaitForCompletion(ad_view->Hide(), "Hide 1"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion(ad_view->Show(), "Show 1"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - // Move again after hiding/showing. - WaitForCompletion(ad_view->SetPosition(100, 300), "SetPosition(x2, y2)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionUndefined); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion(ad_view->SetPosition(100, 400), "SetPosition(x3, y3)"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(ad_view->bounding_box().position, - firebase::gma::AdView::kPositionUndefined); - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - WaitForCompletion(ad_view->Hide(), "Hide 2"); - PauseForVisualInspectionAndCallbacks(); - EXPECT_EQ(expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - LogDebug("Waiting for a moment to ensure all callbacks are recorded."); - app_framework::ProcessEvents(2000); - } - - // Clean up the ad object. - load_ad_future.Release(); - WaitForCompletion(ad_view->Destroy(), "Destroy AdView"); - ad_view->SetBoundingBoxListener(nullptr); - delete ad_view; - - PauseForVisualInspectionAndCallbacks(); - - if (ad_loaded) { - // If the ad was show, do the final bounding box checks after the ad has - // been destroyed. -#if defined(ANDROID) || TARGET_OS_IPHONE - EXPECT_EQ(++expected_num_bounding_box_changes, - bounding_box_listener.bounding_box_changes_.size()); - - // As an extra check, all bounding boxes except the last should have the - // same size aspect ratio that we requested. For example if you requested a - // 320x50 banner, you can get one with the size 960x150. Use EXPECT_NEAR - // because the calculation can have a small bit of error. - double kAspectRatioAllowedError = 0.05; // Allow about 5% of error. - double expected_aspect_ratio = - static_cast(kBannerWidth) / static_cast(kBannerHeight); - for (int i = 0; i < bounding_box_listener.bounding_box_changes_.size() - 1; - ++i) { - double actual_aspect_ratio = - static_cast( - bounding_box_listener.bounding_box_changes_[i].width) / - static_cast( - bounding_box_listener.bounding_box_changes_[i].height); - EXPECT_NEAR(actual_aspect_ratio, expected_aspect_ratio, - kAspectRatioAllowedError) - << "AdView size " - << bounding_box_listener.bounding_box_changes_[i].width << "x" - << bounding_box_listener.bounding_box_changes_[i].height - << " does not have the same aspect ratio as requested size " - << kBannerWidth << "x" << kBannerHeight << "."; - } - - // And finally, the last bounding box change, when the AdView is deleted, - // should have invalid values (-1,-1, -1, -1). - EXPECT_TRUE( - bounding_box_listener.bounding_box_changes_.back().x == -1 && - bounding_box_listener.bounding_box_changes_.back().y == -1 && - bounding_box_listener.bounding_box_changes_.back().width == -1 && - bounding_box_listener.bounding_box_changes_.back().height == -1); -#endif // defined(ANDROID) || TARGET_OS_IPHONE - } -} - -TEST_F(FirebaseGmaTest, TestAdViewErrorNotInitialized) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - - WaitForCompletion(ad_view->LoadAd(GetAdRequest()), "LoadAd", - firebase::gma::kAdErrorCodeUninitialized); - - firebase::gma::AdView::Position position; - WaitForCompletion(ad_view->SetPosition(position), "SetPosition(position)", - firebase::gma::kAdErrorCodeUninitialized); - - WaitForCompletion(ad_view->SetPosition(0, 0), "SetPosition(x,y)", - firebase::gma::kAdErrorCodeUninitialized); - - WaitForCompletion(ad_view->Hide(), "Hide", - firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(ad_view->Show(), "Show", - firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(ad_view->Pause(), "Pause", - firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(ad_view->Resume(), "Resume", - firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(ad_view->Destroy(), "Destroy the AdView"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewErrorAlreadyInitialized) { - SKIP_TEST_ON_DESKTOP; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - { - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - firebase::Future first_initialize = ad_view->Initialize( - app_framework::GetWindowContext(), kBannerAdUnit, banner_ad_size); - firebase::Future second_initialize = ad_view->Initialize( - app_framework::GetWindowContext(), kBannerAdUnit, banner_ad_size); - - WaitForCompletion(first_initialize, "First Initialize 1"); - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - - first_initialize.Release(); - second_initialize.Release(); - WaitForCompletion(ad_view->Destroy(), "Destroy AdView 1"); - delete ad_view; - } - - // Reverse the order of the completion waits. - { - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - firebase::Future first_initialize = ad_view->Initialize( - app_framework::GetWindowContext(), kBannerAdUnit, banner_ad_size); - firebase::Future second_initialize = ad_view->Initialize( - app_framework::GetWindowContext(), kBannerAdUnit, banner_ad_size); - - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - WaitForCompletion(first_initialize, "First Initialize 1"); - - first_initialize.Release(); - second_initialize.Release(); - WaitForCompletion(ad_view->Destroy(), "Destroy AdView 2"); - delete ad_view; - } -} - -TEST_F(FirebaseGmaTest, TestAdViewErrorLoadInProgress) { - SKIP_TEST_ON_DESKTOP; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - - // Load the AdView ad. - // Note potential flake: this test assumes the attempt to load an ad - // won't resolve immediately. If it does then the result may be two - // successful ad loads instead of the expected - // kAdErrorCodeLoadInProgress error. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future first_load_ad = - ad_view->LoadAd(request); - firebase::Future second_load_ad = - ad_view->LoadAd(request); - - WaitForCompletion(second_load_ad, "Second LoadAd", - firebase::gma::kAdErrorCodeLoadInProgress); - WaitForCompletionAnyResult(first_load_ad, "First LoadAd"); - - const firebase::gma::AdResult* result_ptr = second_load_ad.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeLoadInProgress); - EXPECT_EQ(result_ptr->ad_error().message(), "Ad is currently loading."); - EXPECT_EQ(result_ptr->ad_error().domain(), "SDK"); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - first_load_ad.Release(); - second_load_ad.Release(); - - WaitForCompletion(ad_view->Destroy(), "Destroy the AdView"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewErrorBadAdUnitId) { - SKIP_TEST_ON_DESKTOP; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBadAdUnit, banner_ad_size), - "Initialize"); - - // Load the AdView ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad = ad_view->LoadAd(request); - WaitForCompletion(load_ad, "LoadAd", - firebase::gma::kAdErrorCodeInvalidRequest); - - const firebase::gma::AdResult* result_ptr = load_ad.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeInvalidRequest); - - EXPECT_FALSE(result_ptr->ad_error().message().empty()); - EXPECT_EQ(result_ptr->ad_error().domain(), kErrorDomain); - - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - load_ad.Release(); - - WaitForCompletion(ad_view->Destroy(), "Destroy the AdView"); - delete ad_view; -} - -TEST_F(FirebaseGmaTest, TestAdViewErrorBadExtrasClassName) { - SKIP_TEST_ON_DESKTOP; - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - - // Load the AdView ad. - firebase::gma::AdRequest request = GetAdRequest(); - request.add_extra(kAdNetworkExtrasInvalidClassName, "shouldnot", "work"); - WaitForCompletion(ad_view->LoadAd(request), "LoadAd", - firebase::gma::kAdErrorCodeAdNetworkClassLoadError); - WaitForCompletion(ad_view->Destroy(), "Destroy the AdView"); - delete ad_view; -} - -// Other InterstitialAd Tests - -TEST_F(FirebaseGmaTest, TestInterstitialAdLoadEmptyRequest) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::InterstitialAd* interstitial = - new firebase::gma::InterstitialAd(); - - WaitForCompletion(interstitial->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // When the InterstitialAd is initialized, load an ad. - firebase::gma::AdRequest request; - - firebase::Future load_ad_future = - interstitial->LoadAd(kInterstitialAdUnit, request); - - // This test behaves differently if it's running in UI mode - // (manually on a device) or in non-UI mode (via automated tests). - if (ShouldRunUITests()) { - // Run in manual mode: fail if any error occurs. - WaitForCompletion(load_ad_future, "LoadAd"); - } else { - // Run in automated test mode: don't fail if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - } - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - } - load_ad_future.Release(); - delete interstitial; -} - -TEST_F(FirebaseGmaTest, TestInterstitialAdErrorNotInitialized) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::InterstitialAd* interstitial_ad = - new firebase::gma::InterstitialAd(); - - firebase::gma::AdRequest request = GetAdRequest(); - WaitForCompletion(interstitial_ad->LoadAd(kInterstitialAdUnit, request), - "LoadAd", firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(interstitial_ad->Show(), "Show", - firebase::gma::kAdErrorCodeUninitialized); - - delete interstitial_ad; -} - -TEST_F(FirebaseGmaTest, TesInterstitialAdErrorAlreadyInitialized) { - SKIP_TEST_ON_DESKTOP; - - { - firebase::gma::InterstitialAd* interstitial_ad = - new firebase::gma::InterstitialAd(); - firebase::Future first_initialize = - interstitial_ad->Initialize(app_framework::GetWindowContext()); - firebase::Future second_initialize = - interstitial_ad->Initialize(app_framework::GetWindowContext()); - - WaitForCompletion(first_initialize, "First Initialize 1"); - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - - first_initialize.Release(); - second_initialize.Release(); - - delete interstitial_ad; - } - - // Reverse the order of the completion waits. - { - firebase::gma::InterstitialAd* interstitial_ad = - new firebase::gma::InterstitialAd(); - firebase::Future first_initialize = - interstitial_ad->Initialize(app_framework::GetWindowContext()); - firebase::Future second_initialize = - interstitial_ad->Initialize(app_framework::GetWindowContext()); - - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - WaitForCompletion(first_initialize, "First Initialize 1"); - - first_initialize.Release(); - second_initialize.Release(); - - delete interstitial_ad; - } -} - -TEST_F(FirebaseGmaTest, TestInterstitialAdErrorLoadInProgress) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::InterstitialAd* interstitial_ad = - new firebase::gma::InterstitialAd(); - WaitForCompletion( - interstitial_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the interstitial ad. - // Note potential flake: this test assumes the attempt to load an ad - // won't resolve immediately. If it does then the result may be two - // successful ad loads instead of the expected - // kAdErrorCodeLoadInProgress error. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future first_load_ad = - interstitial_ad->LoadAd(kInterstitialAdUnit, request); - firebase::Future second_load_ad = - interstitial_ad->LoadAd(kInterstitialAdUnit, request); - - WaitForCompletion(second_load_ad, "Second LoadAd", - firebase::gma::kAdErrorCodeLoadInProgress); - WaitForCompletionAnyResult(first_load_ad, "First LoadAd"); - - const firebase::gma::AdResult* result_ptr = second_load_ad.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeLoadInProgress); - EXPECT_EQ(result_ptr->ad_error().message(), "Ad is currently loading."); - EXPECT_EQ(result_ptr->ad_error().domain(), "SDK"); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - first_load_ad.Release(); - second_load_ad.Release(); - delete interstitial_ad; -} - -TEST_F(FirebaseGmaTest, TestInterstitialAdErrorBadAdUnitId) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::InterstitialAd* interstitial_ad = - new firebase::gma::InterstitialAd(); - WaitForCompletion( - interstitial_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the interstitial ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - interstitial_ad->LoadAd(kBadAdUnit, request); - WaitForCompletion(load_ad_future, "LoadAd", - firebase::gma::kAdErrorCodeInvalidRequest); - - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeInvalidRequest); - EXPECT_FALSE(result_ptr->ad_error().message().empty()); - EXPECT_EQ(result_ptr->ad_error().domain(), kErrorDomain); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - load_ad_future.Release(); - delete interstitial_ad; -} - -TEST_F(FirebaseGmaTest, TestInterstitialAdErrorBadExtrasClassName) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::InterstitialAd* interstitial_ad = - new firebase::gma::InterstitialAd(); - WaitForCompletion( - interstitial_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the interstitial ad. - firebase::gma::AdRequest request = GetAdRequest(); - request.add_extra(kAdNetworkExtrasInvalidClassName, "shouldnot", "work"); - WaitForCompletion(interstitial_ad->LoadAd(kInterstitialAdUnit, request), - "LoadAd", - firebase::gma::kAdErrorCodeAdNetworkClassLoadError); - delete interstitial_ad; -} - -// Other RewardedAd Tests. - -TEST_F(FirebaseGmaTest, TestRewardedAdLoadEmptyRequest) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - // Note: while showing an ad requires user interaction in another test, - // this test is mean as a baseline loadAd functionality test. - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // When the RewardedAd is initialized, load an ad. - firebase::gma::AdRequest request; - firebase::Future load_ad_future = - rewarded->LoadAd(kRewardedAdUnit, request); - - // This test behaves differently if it's running in UI mode - // (manually on a device) or in non-UI mode (via automated tests). - if (ShouldRunUITests()) { - // Run in manual mode: fail if any error occurs. - WaitForCompletion(load_ad_future, "LoadAd"); - } else { - // Run in automated test mode: don't fail if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - } - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - // In UI mode, or in non-UI mode if a NoFill error didn't occur, check that - // the ad loaded correctly. - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - } - load_ad_future.Release(); - delete rewarded; -} - -TEST_F(FirebaseGmaTest, TestRewardedAdErrorNotInitialized) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::RewardedAd* rewarded_ad = new firebase::gma::RewardedAd(); - - firebase::gma::AdRequest request = GetAdRequest(); - WaitForCompletion(rewarded_ad->LoadAd(kRewardedAdUnit, request), "LoadAd", - firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(rewarded_ad->Show(/*listener=*/nullptr), "Show", - firebase::gma::kAdErrorCodeUninitialized); - - delete rewarded_ad; -} - -TEST_F(FirebaseGmaTest, TesRewardedAdErrorAlreadyInitialized) { - SKIP_TEST_ON_DESKTOP; - - { - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - firebase::Future first_initialize = - rewarded->Initialize(app_framework::GetWindowContext()); - firebase::Future second_initialize = - rewarded->Initialize(app_framework::GetWindowContext()); - - WaitForCompletionAnyResult(first_initialize, "First Initialize 1"); - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - - first_initialize.Release(); - second_initialize.Release(); - - delete rewarded; - } - - // Reverse the order of the completion waits. - { - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - firebase::Future first_initialize = - rewarded->Initialize(app_framework::GetWindowContext()); - firebase::Future second_initialize = - rewarded->Initialize(app_framework::GetWindowContext()); - - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - WaitForCompletionAnyResult(first_initialize, "First Initialize 1"); - - first_initialize.Release(); - second_initialize.Release(); - - delete rewarded; - } -} - -TEST_F(FirebaseGmaTest, TestRewardedAdErrorLoadInProgress) { - SKIP_TEST_ON_DESKTOP; - - // TODO(@drsanta): remove when GMA whitelists CI devices. - TEST_REQUIRES_USER_INTERACTION_ON_IOS; - - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the rewarded ad. - // Note potential flake: this test assumes the attempt to load an ad - // won't resolve immediately. If it does then the result may be two - // successful ad loads instead of the expected - // kAdErrorCodeLoadInProgress error. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future first_load_ad = - rewarded->LoadAd(kRewardedAdUnit, request); - firebase::Future second_load_ad = - rewarded->LoadAd(kRewardedAdUnit, request); - - WaitForCompletion(second_load_ad, "Second LoadAd", - firebase::gma::kAdErrorCodeLoadInProgress); - WaitForCompletionAnyResult(first_load_ad, "First LoadAd"); - - const firebase::gma::AdResult* result_ptr = second_load_ad.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeLoadInProgress); - EXPECT_EQ(result_ptr->ad_error().message(), "Ad is currently loading."); - EXPECT_EQ(result_ptr->ad_error().domain(), "SDK"); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - first_load_ad.Release(); - second_load_ad.Release(); - delete rewarded; -} - -TEST_F(FirebaseGmaTest, TestRewardedAdErrorBadAdUnitId) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the rewarded ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - rewarded->LoadAd(kBadAdUnit, request); - WaitForCompletion(load_ad_future, "LoadAd", - firebase::gma::kAdErrorCodeInvalidRequest); - - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeInvalidRequest); - EXPECT_FALSE(result_ptr->ad_error().message().empty()); - EXPECT_EQ(result_ptr->ad_error().domain(), kErrorDomain); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - load_ad_future.Release(); - delete rewarded; -} - -TEST_F(FirebaseGmaTest, TestRewardedAdErrorBadExtrasClassName) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the rewarded ad. - firebase::gma::AdRequest request = GetAdRequest(); - request.add_extra(kAdNetworkExtrasInvalidClassName, "shouldnot", "work"); - WaitForCompletion(rewarded->LoadAd(kRewardedAdUnit, request), "LoadAd", - firebase::gma::kAdErrorCodeAdNetworkClassLoadError); - delete rewarded; -} - -// Other NativeAd Tests - -TEST_F(FirebaseGmaTest, TestNativeAdLoadEmptyRequest) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - - WaitForCompletion(native_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // When the NativeAd is initialized, load an ad. - firebase::gma::AdRequest request; - - firebase::Future load_ad_future = - native_ad->LoadAd(kNativeAdUnit, request); - - // Don't fail loadAd, if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - EXPECT_FALSE(result_ptr->response_info().adapter_responses().empty()); - EXPECT_FALSE( - result_ptr->response_info().mediation_adapter_class_name().empty()); - EXPECT_FALSE(result_ptr->response_info().response_id().empty()); - EXPECT_FALSE(result_ptr->response_info().ToString().empty()); - } else if (load_ad_future.error() == firebase::gma::kAdErrorCodeNoFill) { - LogWarning("LoadAd returned NoFill in TestNativeAdLoadEmptyRequest"); - } - - load_ad_future.Release(); - delete native_ad; -} - -TEST_F(FirebaseGmaTest, TestNativeRecordImpression) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - - WaitForCompletion(native_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Set the listener. - TestAdListener ad_listener; - native_ad->SetAdListener(&ad_listener); - - // When the NativeAd is initialized, load an ad. - firebase::Future load_ad_future = - native_ad->LoadAd(kNativeAdUnit, GetAdRequest()); - - // Don't fail loadAd, if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - - // Proceed verifying the RecordImpression, only when loadAd is successful. - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - - firebase::Variant impression_payload = GetVariantMap(); - -#if defined(ANDROID) - // Android doesn't have a return type for this API. - WaitForCompletion(native_ad->RecordImpression(impression_payload), - "RecordImpression"); -#else // iOS - // Test Ad unit IDs are not allowlisted to record impression and the request - // is expected to be rejected by the server. iOS returns the failure. - WaitForCompletion(native_ad->RecordImpression(impression_payload), - "RecordImpression", - firebase::gma::kAdErrorCodeInvalidRequest); -#endif - - // Use an allowlisted Ad unit ID that can record an impression, to verify - // the impression count while testing locally. - EXPECT_EQ(ad_listener.num_on_ad_impression_, 0); - - firebase::Variant str_variant = - firebase::Variant::FromMutableString("test"); - WaitForCompletion(native_ad->RecordImpression(str_variant), - "RecordImpression 2", - firebase::gma::kAdErrorCodeInvalidArgument); - } else if (load_ad_future.error() == firebase::gma::kAdErrorCodeNoFill) { - LogWarning("LoadAd returned NoFill in TestNativeRecordImpression"); - } - - load_ad_future.Release(); - delete native_ad; -} - -TEST_F(FirebaseGmaTest, TestNativePerformClick) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_SIMULATOR; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - - WaitForCompletion(native_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Set the listener. - TestAdListener ad_listener; - native_ad->SetAdListener(&ad_listener); - - // When the NativeAd is initialized, load an ad. - firebase::Future load_ad_future = - native_ad->LoadAd(kNativeAdUnit, GetAdRequest()); - - // Don't fail loadAd, if NoFill occurred. - WaitForCompletion( - load_ad_future, "LoadAd (ignoring NoFill error)", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - - // Proceed verifying the PerformClick, only when loadAd is successful. - if (load_ad_future.error() == firebase::gma::kAdErrorCodeNone) { - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_TRUE(result_ptr->is_successful()); - - firebase::Variant click_payload = GetVariantMap(); - - // Android and iOS doesn't have a return type for this API. - WaitForCompletion(native_ad->PerformClick(click_payload), "PerformClick"); - - // Test Ad unit IDs are not allowlisted to use PerformClick API and the - // request is expected to be rejected by the server. Use an allowlisted Ad - // unit ID to verify the ad click count while testing locally. - EXPECT_EQ(ad_listener.num_on_ad_clicked_, 0); - - firebase::Variant str_variant = - firebase::Variant::FromMutableString("test"); - WaitForCompletion(native_ad->PerformClick(str_variant), "PerformClick 2", - firebase::gma::kAdErrorCodeInvalidArgument); - } else if (load_ad_future.error() == firebase::gma::kAdErrorCodeNoFill) { - LogWarning("LoadAd returned NoFill in TestNativePerformClick"); - } - - load_ad_future.Release(); - delete native_ad; -} - -TEST_F(FirebaseGmaTest, TestNativeAdErrorNotInitialized) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - - firebase::gma::AdRequest request = GetAdRequest(); - WaitForCompletion(native_ad->LoadAd(kNativeAdUnit, request), "LoadAd", - firebase::gma::kAdErrorCodeUninitialized); - - firebase::Variant variant = firebase::Variant::EmptyMap(); - WaitForCompletion(native_ad->RecordImpression(variant), "RecordImpression", - firebase::gma::kAdErrorCodeUninitialized); - WaitForCompletion(native_ad->PerformClick(variant), "PerformClick", - firebase::gma::kAdErrorCodeUninitialized); - - delete native_ad; -} - -TEST_F(FirebaseGmaTest, TestNativeAdErrorAlreadyInitialized) { - SKIP_TEST_ON_DESKTOP; - - { - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - firebase::Future first_initialize = - native_ad->Initialize(app_framework::GetWindowContext()); - firebase::Future second_initialize = - native_ad->Initialize(app_framework::GetWindowContext()); - - WaitForCompletion(first_initialize, "First Initialize 1"); - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - - first_initialize.Release(); - second_initialize.Release(); - - delete native_ad; - } - - // Reverse the order of the completion waits. - { - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - firebase::Future first_initialize = - native_ad->Initialize(app_framework::GetWindowContext()); - firebase::Future second_initialize = - native_ad->Initialize(app_framework::GetWindowContext()); - - WaitForCompletion(second_initialize, "Second Initialize 1", - firebase::gma::kAdErrorCodeAlreadyInitialized); - WaitForCompletion(first_initialize, "First Initialize 1"); - - first_initialize.Release(); - second_initialize.Release(); - - delete native_ad; - } -} - -TEST_F(FirebaseGmaTest, TestNativeAdErrorBadAdUnitId) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - WaitForCompletion(native_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the native ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future load_ad_future = - native_ad->LoadAd(kBadAdUnit, request); - WaitForCompletion(load_ad_future, "LoadAd", - firebase::gma::kAdErrorCodeInvalidRequest); - - const firebase::gma::AdResult* result_ptr = load_ad_future.result(); - ASSERT_NE(result_ptr, nullptr); - EXPECT_FALSE(result_ptr->is_successful()); - EXPECT_EQ(result_ptr->ad_error().code(), - firebase::gma::kAdErrorCodeInvalidRequest); - EXPECT_FALSE(result_ptr->ad_error().message().empty()); - EXPECT_EQ(result_ptr->ad_error().domain(), kErrorDomain); - const firebase::gma::ResponseInfo response_info = - result_ptr->ad_error().response_info(); - EXPECT_TRUE(response_info.adapter_responses().empty()); - - load_ad_future.Release(); - delete native_ad; -} - -TEST_F(FirebaseGmaTest, TestNativeAdErrorBadExtrasClassName) { - SKIP_TEST_ON_DESKTOP; - - firebase::gma::NativeAd* native_ad = new firebase::gma::NativeAd(); - WaitForCompletion(native_ad->Initialize(app_framework::GetWindowContext()), - "Initialize"); - - // Load the native ad. - firebase::gma::AdRequest request = GetAdRequest(); - request.add_extra(kAdNetworkExtrasInvalidClassName, "shouldnot", "work"); - WaitForCompletion(native_ad->LoadAd(kNativeAdUnit, request), "LoadAd", - firebase::gma::kAdErrorCodeAdNetworkClassLoadError); - delete native_ad; -} - -// Stress tests. These take a while so run them near the end. -TEST_F(FirebaseGmaTest, TestAdViewStress) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_EMULATOR; - - // TODO(@drsanta): remove when GMA whitelists CI devices - TEST_REQUIRES_USER_INTERACTION_ON_IOS; - TEST_REQUIRES_USER_INTERACTION_ON_ANDROID; - - for (int i = 0; i < 10; ++i) { - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "TestAdViewStress Initialize"); - - // Load the AdView ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future future = ad_view->LoadAd(request); - WaitForCompletion( - future, "TestAdViewStress LoadAd", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - // Stress tests may exhaust the ad pool. If so, loadAd will return - // kAdErrorCodeNoFill. - if (future.error() == firebase::gma::kAdErrorCodeNone) { - EXPECT_EQ(ad_view->ad_size().width(), kBannerWidth); - EXPECT_EQ(ad_view->ad_size().height(), kBannerHeight); - } - WaitForCompletion(ad_view->Destroy(), "Destroy the AdView"); - delete ad_view; - } -} - -TEST_F(FirebaseGmaTest, TestInterstitialAdStress) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_EMULATOR; - - // TODO(@drsanta): remove when GMA whitelists CI devices - TEST_REQUIRES_USER_INTERACTION_ON_IOS; - TEST_REQUIRES_USER_INTERACTION_ON_ANDROID; - - for (int i = 0; i < 10; ++i) { - firebase::gma::InterstitialAd* interstitial = - new firebase::gma::InterstitialAd(); - - WaitForCompletion( - interstitial->Initialize(app_framework::GetWindowContext()), - "TestInterstitialAdStress Initialize"); - - // When the InterstitialAd is initialized, load an ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future future = - interstitial->LoadAd(kInterstitialAdUnit, request); - WaitForCompletion( - future, "TestInterstitialAdStress LoadAd", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - // Stress tests may exhaust the ad pool. If so, loadAd will return - // kAdErrorCodeNoFill. - delete interstitial; - } -} - -TEST_F(FirebaseGmaTest, TestRewardedAdStress) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_EMULATOR; - - // TODO(@drsanta): remove when GMA whitelists CI devices. - TEST_REQUIRES_USER_INTERACTION_ON_IOS; - TEST_REQUIRES_USER_INTERACTION_ON_ANDROID; - - for (int i = 0; i < 10; ++i) { - firebase::gma::RewardedAd* rewarded = new firebase::gma::RewardedAd(); - - WaitForCompletion(rewarded->Initialize(app_framework::GetWindowContext()), - "TestRewardedAdStress Initialize"); - - // When the RewardedAd is initialized, load an ad. - firebase::gma::AdRequest request = GetAdRequest(); - firebase::Future future = - rewarded->LoadAd(kRewardedAdUnit, request); - WaitForCompletion( - future, "TestRewardedAdStress LoadAd", - {firebase::gma::kAdErrorCodeNone, firebase::gma::kAdErrorCodeNoFill}); - // Stress tests may exhaust the ad pool. If so, loadAd will return - // kAdErrorCodeNoFill. - delete rewarded; - } -} - -#if defined(ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) -// Test runs & compiles for phones only. - -struct ThreadArgs { - firebase::gma::AdView* ad_view; - sem_t* semaphore; -}; - -static void* DeleteAdViewOnSignal(void* args) { - ThreadArgs* thread_args = static_cast(args); - sem_wait(thread_args->semaphore); - delete thread_args->ad_view; - return nullptr; -} - -TEST_F(FirebaseGmaTest, TestAdViewMultithreadDeletion) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_MOBILE; // TODO(b/172832275): This test is temporarily - // disabled on all platforms due to flakiness - // on Android. Once it's fixed, this test should - // be re-enabled on mobile. - - const firebase::gma::AdSize banner_ad_size(kBannerWidth, kBannerHeight); - - for (int i = 0; i < 5; ++i) { - firebase::gma::AdView* ad_view = new firebase::gma::AdView(); - WaitForCompletion(ad_view->Initialize(app_framework::GetWindowContext(), - kBannerAdUnit, banner_ad_size), - "Initialize"); - sem_t semaphore; - sem_init(&semaphore, 0, 1); - - ThreadArgs args = {ad_view, &semaphore}; - - pthread_t t1; - int err = pthread_create(&t1, nullptr, &DeleteAdViewOnSignal, &args); - EXPECT_EQ(err, 0); - - ad_view->Destroy(); - sem_post(&semaphore); - - // Blocks until DeleteAdViewOnSignal function is done. - void* result = nullptr; - err = pthread_join(t1, &result); - - EXPECT_EQ(err, 0); - EXPECT_EQ(result, nullptr); - - sem_destroy(&semaphore); - } -} -#endif // #if defined(ANDROID) || (defined(TARGET_OS_IPHONE) && - // TARGET_OS_IPHONE) - -class FirebaseGmaUmpTest : public FirebaseGmaTest { - public: - FirebaseGmaUmpTest() : consent_info_(nullptr) {} - - // Whether to call ConsentInfo::Reset() upon initialization, which - // resets UMP's consent state to as if the app was first installed. - enum ResetOption { kReset, kNoReset }; - - void InitializeUmp(ResetOption reset = kReset); - void TerminateUmp(ResetOption reset = kReset); - - void SetUp() override; - void TearDown() override; - - protected: - firebase::gma::ump::ConsentInfo* consent_info_; -}; - -void FirebaseGmaUmpTest::InitializeUmp(ResetOption reset) { - using firebase::gma::ump::ConsentInfo; - firebase::InitResult result; - consent_info_ = ConsentInfo::GetInstance(*shared_app_, &result); - - EXPECT_NE(consent_info_, nullptr); - EXPECT_EQ(result, firebase::kInitResultSuccess); - - if (consent_info_ != nullptr && reset == kReset) { - consent_info_->Reset(); - } -} - -void FirebaseGmaUmpTest::TerminateUmp(ResetOption reset) { - if (consent_info_) { - if (reset == kReset) { - consent_info_->Reset(); - } - delete consent_info_; - consent_info_ = nullptr; - } -} - -void FirebaseGmaUmpTest::SetUp() { - FirebaseGmaTest::SetUp(); - InitializeUmp(); - ASSERT_NE(consent_info_, nullptr); -} - -void FirebaseGmaUmpTest::TearDown() { - TerminateUmp(); - FirebaseGmaTest::TearDown(); -} - -// Tests for User Messaging Platform -TEST_F(FirebaseGmaUmpTest, TestUmpInitialization) { - // Initialize handled automatically in test setup. - EXPECT_NE(consent_info_, nullptr); - // Terminate handled automatically in test teardown. -} - -// Tests for User Messaging Platform -TEST_F(FirebaseGmaUmpTest, TestUmpDefaultsToUnknownStatus) { - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusUnknown); - EXPECT_EQ(consent_info_->GetConsentFormStatus(), - firebase::gma::ump::kConsentFormStatusUnknown); - EXPECT_EQ(consent_info_->GetPrivacyOptionsRequirementStatus(), - firebase::gma::ump::kPrivacyOptionsRequirementStatusUnknown); - EXPECT_FALSE(consent_info_->CanRequestAds()); -} - -// Tests for User Messaging Platform -TEST_F(FirebaseGmaUmpTest, TestUmpGetInstanceIsAlwaysEqual) { - using firebase::gma::ump::ConsentInfo; - - EXPECT_NE(consent_info_, nullptr); - - // Ensure that GetInstance() with any options is always equal. - EXPECT_EQ(consent_info_, ConsentInfo::GetInstance()); - EXPECT_EQ(consent_info_, ConsentInfo::GetInstance(*shared_app_)); - -#if defined(ANDROID) - EXPECT_EQ(consent_info_, - ConsentInfo::GetInstance(app_framework::GetJniEnv(), - app_framework::GetActivity())); - - firebase::App* second_app = firebase::App::Create( - firebase::AppOptions(), "2ndApp", app_framework::GetJniEnv(), - app_framework::GetActivity()); -#else - firebase::App* second_app = - firebase::App::Create(firebase::AppOptions(), "2ndApp"); -#endif // defined(ANDROID) - - EXPECT_EQ(consent_info_, ConsentInfo::GetInstance(*second_app)); - - delete second_app; -} - -TEST_F(FirebaseGmaUmpTest, TestUmpRequestConsentInfoUpdate) { - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - - firebase::Future future = - consent_info_->RequestConsentInfoUpdate(params); - - EXPECT_TRUE(future == consent_info_->RequestConsentInfoUpdateLastResult()); - - WaitForCompletion(future, "RequestConsentInfoUpdate", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - // Retry only network errors. - EXPECT_NE(future.error(), firebase::gma::ump::kConsentRequestErrorNetwork); - - FLAKY_TEST_SECTION_END(); - - EXPECT_NE(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusUnknown); - EXPECT_NE(consent_info_->GetConsentFormStatus(), - firebase::gma::ump::kConsentFormStatusUnknown); - EXPECT_NE(consent_info_->GetPrivacyOptionsRequirementStatus(), - firebase::gma::ump::kPrivacyOptionsRequirementStatusUnknown); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpRequestConsentInfoUpdateDebugEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future = - consent_info_->RequestConsentInfoUpdate(params); - - WaitForCompletion(future, "RequestConsentInfoUpdate", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - // Retry only network errors. - EXPECT_NE(future.error(), firebase::gma::ump::kConsentRequestErrorNetwork); - - FLAKY_TEST_SECTION_END(); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusRequired); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpRequestConsentInfoUpdateDebugNonEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future = - consent_info_->RequestConsentInfoUpdate(params); - - WaitForCompletion(future, "RequestConsentInfoUpdate", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - // Retry only network errors. - EXPECT_NE(future.error(), firebase::gma::ump::kConsentRequestErrorNetwork); - - FLAKY_TEST_SECTION_END(); - - EXPECT_THAT(consent_info_->GetConsentStatus(), - AnyOf(Eq(firebase::gma::ump::kConsentStatusNotRequired), - Eq(firebase::gma::ump::kConsentStatusRequired))); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpLoadForm) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusRequired); - - EXPECT_EQ(consent_info_->GetConsentFormStatus(), - firebase::gma::ump::kConsentFormStatusAvailable); - - // Load the form. Run this step with retry in case of network timeout. - WaitForCompletion( - RunWithRetry([&]() { return consent_info_->LoadConsentForm(); }), - "LoadConsentForm", - {firebase::gma::ump::kConsentFormSuccess, - firebase::gma::ump::kConsentFormErrorTimeout}); - - firebase::Future future = consent_info_->LoadConsentFormLastResult(); - - EXPECT_EQ(consent_info_->GetConsentFormStatus(), - firebase::gma::ump::kConsentFormStatusAvailable); - - if (future.error() == firebase::gma::ump::kConsentFormErrorTimeout) { - LogWarning("Timed out after multiple tries, but passing anyway."); - } -} - -TEST_F(FirebaseGmaUmpTest, TestUmpShowForm) { - TEST_REQUIRES_USER_INTERACTION; - - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusRequired); - - EXPECT_EQ(consent_info_->GetConsentFormStatus(), - firebase::gma::ump::kConsentFormStatusAvailable); - - WaitForCompletion(consent_info_->LoadConsentForm(), "LoadConsentForm"); - - EXPECT_EQ(consent_info_->GetConsentFormStatus(), - firebase::gma::ump::kConsentFormStatusAvailable); - - firebase::Future future = - consent_info_->ShowConsentForm(app_framework::GetWindowController()); - - EXPECT_TRUE(future == consent_info_->ShowConsentFormLastResult()); - - WaitForCompletion(future, "ShowConsentForm"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusObtained); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnderAgeOfConsent) { - SKIP_TEST_ON_IOS_SIMULATOR; - - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = true; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future = - consent_info_->RequestConsentInfoUpdate(params); - - WaitForCompletion(future, "RequestConsentInfoUpdate", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - // Retry only network errors. - EXPECT_NE(future.error(), firebase::gma::ump::kConsentRequestErrorNetwork); - - FLAKY_TEST_SECTION_END(); - - firebase::Future load_future = consent_info_->LoadConsentForm(); - WaitForCompletion(load_future, "LoadConsentForm", - {firebase::gma::ump::kConsentFormErrorUnavailable, - firebase::gma::ump::kConsentFormErrorTimeout, - firebase::gma::ump::kConsentFormSuccess}); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpLoadFormUnavailableDebugNonEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future = - consent_info_->RequestConsentInfoUpdate(params); - - WaitForCompletion(future, "RequestConsentInfoUpdate", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - // Retry only network errors. - EXPECT_NE(future.error(), firebase::gma::ump::kConsentRequestErrorNetwork); - - FLAKY_TEST_SECTION_END(); - - if (consent_info_->GetConsentStatus() != - firebase::gma::ump::kConsentStatusRequired) { - WaitForCompletion(consent_info_->LoadConsentForm(), "LoadConsentForm", - firebase::gma::ump::kConsentFormErrorUnavailable); - } -} - -TEST_F(FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugNonEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future = - consent_info_->RequestConsentInfoUpdate(params); - - WaitForCompletion(future, "RequestConsentInfoUpdate", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - // Retry only network errors. - EXPECT_NE(future.error(), firebase::gma::ump::kConsentRequestErrorNetwork); - - FLAKY_TEST_SECTION_END(); - - EXPECT_THAT(consent_info_->GetConsentStatus(), - AnyOf(Eq(firebase::gma::ump::kConsentStatusNotRequired), - Eq(firebase::gma::ump::kConsentStatusRequired))); - - if (consent_info_->GetConsentStatus() == - firebase::gma::ump::kConsentStatusNotRequired || - ShouldRunUITests()) { - // If ConsentStatus is Required, we only want to do this next part if UI - // interaction is allowed, as it will show a consent form which won't work - // in automated testing. - firebase::Future future = - consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()); - - EXPECT_TRUE(future == - consent_info_->LoadAndShowConsentFormIfRequiredLastResult()); - - WaitForCompletion(future, "LoadAndShowConsentFormIfRequired"); - } -} - -TEST_F(FirebaseGmaUmpTest, TestUmpLoadAndShowIfRequiredDebugEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - TEST_REQUIRES_USER_INTERACTION; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusRequired); - - firebase::Future future = - consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()); - - EXPECT_TRUE(future == - consent_info_->LoadAndShowConsentFormIfRequiredLastResult()); - - WaitForCompletion(future, "LoadAndShowConsentFormIfRequired"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusObtained); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpPrivacyOptions) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - using firebase::gma::ump::PrivacyOptionsRequirementStatus; - - TEST_REQUIRES_USER_INTERACTION; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusRequired); - - EXPECT_FALSE(consent_info_->CanRequestAds()); - - WaitForCompletion(consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()), - "LoadAndShowConsentFormIfRequired"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusObtained); - - EXPECT_TRUE(consent_info_->CanRequestAds()) << "After consent obtained"; - - LogInfo( - "******** On the Privacy Options screen that is about to appear, please " - "select DO NOT CONSENT."); - - ProcessEvents(5000); - - EXPECT_EQ(consent_info_->GetPrivacyOptionsRequirementStatus(), - firebase::gma::ump::kPrivacyOptionsRequirementStatusRequired); - - firebase::Future future = consent_info_->ShowPrivacyOptionsForm( - app_framework::GetWindowController()); - - EXPECT_TRUE(future == consent_info_->ShowPrivacyOptionsFormLastResult()); - - WaitForCompletion(future, "ShowPrivacyOptionsForm"); -} - -TEST_F(FirebaseGmaUmpTest, TestCanRequestAdsNonEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - EXPECT_THAT(consent_info_->GetConsentStatus(), - AnyOf(Eq(firebase::gma::ump::kConsentStatusNotRequired), - Eq(firebase::gma::ump::kConsentStatusRequired))); - - if (consent_info_->GetConsentStatus() == - firebase::gma::ump::kConsentStatusNotRequired) { - EXPECT_TRUE(consent_info_->CanRequestAds()); - } -} - -TEST_F(FirebaseGmaUmpTest, TestCanRequestAdsEEA) { - using firebase::gma::ump::ConsentDebugSettings; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - EXPECT_EQ(consent_info_->GetConsentStatus(), - firebase::gma::ump::kConsentStatusRequired); - - EXPECT_FALSE(consent_info_->CanRequestAds()); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpCleanupWithDelay) { - // Ensure that if ConsentInfo is deleted after a delay, Futures are - // properly invalidated. - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future_request = - consent_info_->RequestConsentInfoUpdate(params); - firebase::Future future_load = consent_info_->LoadConsentForm(); - firebase::Future future_show = - consent_info_->ShowConsentForm(app_framework::GetWindowController()); - firebase::Future future_load_and_show = - consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()); - firebase::Future future_privacy = consent_info_->ShowPrivacyOptionsForm( - app_framework::GetWindowController()); - - ProcessEvents(5000); - - TerminateUmp(kNoReset); - - EXPECT_EQ(future_request.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_load.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_show.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_load_and_show.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_privacy.status(), firebase::kFutureStatusInvalid); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpCleanupRaceCondition) { - // Ensure that if ConsentInfo is deleted immediately, operations - // (and their Futures) are properly invalidated. - - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future_request = - consent_info_->RequestConsentInfoUpdate(params); - firebase::Future future_load = consent_info_->LoadConsentForm(); - firebase::Future future_show = - consent_info_->ShowConsentForm(app_framework::GetWindowController()); - firebase::Future future_load_and_show = - consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()); - firebase::Future future_privacy = consent_info_->ShowPrivacyOptionsForm( - app_framework::GetWindowController()); - - TerminateUmp(kNoReset); - - EXPECT_EQ(future_request.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_load.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_show.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_load_and_show.status(), firebase::kFutureStatusInvalid); - EXPECT_EQ(future_privacy.status(), firebase::kFutureStatusInvalid); - - ProcessEvents(5000); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpCallbacksOnWrongInstance) { - // Ensure that if ConsentInfo is deleted and then recreated, stale - // callbacks don't call into the new instance and cause crashes. - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - LogDebug("RequestConsentInfoUpdate"); - consent_info_->RequestConsentInfoUpdate(params).OnCompletion( - [](const firebase::Future&) { - LogDebug("RequestConsentInfoUpdate done"); - }); - LogDebug("LoadConsentForm"); - consent_info_->LoadConsentForm().OnCompletion( - [](const firebase::Future&) { LogDebug("LoadConsentForm done"); }); - // In automated tests, only check RequestConsentInfoUpdate and LoadConsentForm - // as the rest may show UI. - if (ShouldRunUITests()) { - LogDebug("ShowConsentForm"); - consent_info_->ShowConsentForm(app_framework::GetWindowController()) - .OnCompletion([](const firebase::Future&) { - LogDebug("ShowConsentForm done"); - }); - LogDebug("LoadAndShowConsentFormIfRequired"); - consent_info_ - ->LoadAndShowConsentFormIfRequired(app_framework::GetWindowController()) - .OnCompletion([](const firebase::Future&) { - LogDebug("LoadAndShowConsentFormIfRequired done"); - }); - LogDebug("ShowPrivacyOptionsForm"); - consent_info_->ShowPrivacyOptionsForm(app_framework::GetWindowController()) - .OnCompletion([](const firebase::Future&) { - LogDebug("ShowPrivacyOptionsForm done"); - }); - } - - LogDebug("Terminate"); - TerminateUmp(kNoReset); - - LogDebug("Initialize"); - InitializeUmp(kNoReset); - - // Give the operations time to complete. - LogDebug("Wait"); - ProcessEvents(5000); - - LogDebug("Done"); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgress) { - SKIP_TEST_ON_DESKTOP; - SKIP_TEST_ON_IOS_SIMULATOR; // LoadAndShowConsentFormIfRequired - // is too quick on simulator. - - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - // Check that all of the UMP operations properly return an OperationInProgress - // error if called more than once at the same time. - - // This depends on timing, so it's inherently flaky. - FLAKY_TEST_SECTION_BEGIN(); - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyNonEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future_request_1 = - consent_info_->RequestConsentInfoUpdate(params); - firebase::Future future_request_2 = - consent_info_->RequestConsentInfoUpdate(params); - WaitForCompletion( - future_request_2, "RequestConsentInfoUpdate second", - firebase::gma::ump::kConsentRequestErrorOperationInProgress); - WaitForCompletion(future_request_1, "RequestConsentInfoUpdate first", - {firebase::gma::ump::kConsentRequestSuccess, - firebase::gma::ump::kConsentRequestErrorNetwork}); - - consent_info_->Reset(); - - FLAKY_TEST_SECTION_END(); -} - -TEST_F(FirebaseGmaUmpTest, TestUmpMethodsReturnOperationInProgressWithUI) { - SKIP_TEST_ON_DESKTOP; - TEST_REQUIRES_USER_INTERACTION; - - using firebase::gma::ump::ConsentFormStatus; - using firebase::gma::ump::ConsentRequestParameters; - using firebase::gma::ump::ConsentStatus; - - // Check that all of the UMP operations properly return an OperationInProgress - // error if called more than once at the same time. This test include methods - // with UI interaction. - - ConsentRequestParameters params; - params.tag_for_under_age_of_consent = false; - params.debug_settings.debug_geography = - firebase::gma::ump::kConsentDebugGeographyEEA; - params.debug_settings.debug_device_ids = kTestDeviceIDs; - params.debug_settings.debug_device_ids.push_back(GetDebugDeviceId()); - - firebase::Future future_request_1 = - consent_info_->RequestConsentInfoUpdate(params); - firebase::Future future_request_2 = - consent_info_->RequestConsentInfoUpdate(params); - WaitForCompletion( - future_request_2, "RequestConsentInfoUpdate second", - firebase::gma::ump::kConsentRequestErrorOperationInProgress); - WaitForCompletion(future_request_1, "RequestConsentInfoUpdate first"); - - firebase::Future future_load_1 = consent_info_->LoadConsentForm(); - firebase::Future future_load_2 = consent_info_->LoadConsentForm(); - WaitForCompletion(future_load_2, "LoadConsentForm second", - firebase::gma::ump::kConsentFormErrorOperationInProgress); - WaitForCompletion(future_load_1, "LoadConsentForm first"); - - firebase::Future future_show_1 = - consent_info_->ShowConsentForm(app_framework::GetWindowController()); - firebase::Future future_show_2 = - consent_info_->ShowConsentForm(app_framework::GetWindowController()); - WaitForCompletion(future_show_2, "ShowConsentForm second", - firebase::gma::ump::kConsentFormErrorOperationInProgress); - WaitForCompletion(future_show_1, "ShowConsentForm first"); - - firebase::Future future_privacy_1 = - consent_info_->ShowPrivacyOptionsForm( - app_framework::GetWindowController()); - firebase::Future future_privacy_2 = - consent_info_->ShowPrivacyOptionsForm( - app_framework::GetWindowController()); - WaitForCompletion(future_privacy_2, "ShowPrivacyOptionsForm second", - firebase::gma::ump::kConsentFormErrorOperationInProgress); - WaitForCompletion(future_privacy_1, "ShowPrivacyOptionsForm first"); - - consent_info_->Reset(); - // Request again so we can test LoadAndShowConsentFormIfRequired. - WaitForCompletion(consent_info_->RequestConsentInfoUpdate(params), - "RequestConsentInfoUpdate"); - - firebase::Future future_load_and_show_1 = - consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()); - firebase::Future future_load_and_show_2 = - consent_info_->LoadAndShowConsentFormIfRequired( - app_framework::GetWindowController()); - WaitForCompletion(future_load_and_show_2, - "LoadAndShowConsentFormIfRequired second", - firebase::gma::ump::kConsentFormErrorOperationInProgress); - WaitForCompletion(future_load_and_show_1, - "LoadAndShowConsentFormIfRequired first"); -} - -} // namespace firebase_testapp_automated diff --git a/ios_pod/Podfile b/ios_pod/Podfile index f81729bd8a..378e034804 100644 --- a/ios_pod/Podfile +++ b/ios_pod/Podfile @@ -5,7 +5,6 @@ use_frameworks! target 'GetPods' do pod 'Firebase/Core', '11.14.0' - pod 'Google-Mobile-Ads-SDK', '11.2.0' pod 'GoogleUserMessagingPlatform', '2.3.0' pod 'Firebase/Analytics', '11.14.0' pod 'Firebase/AppCheck', '11.14.0' diff --git a/release_build_files/Android/firebase_dependencies.gradle b/release_build_files/Android/firebase_dependencies.gradle index 142de79cc7..c9d1fc0584 100644 --- a/release_build_files/Android/firebase_dependencies.gradle +++ b/release_build_files/Android/firebase_dependencies.gradle @@ -27,8 +27,6 @@ def firebaseDependenciesMap = [ 'dynamic_links' : ['com.google.firebase:firebase-dynamic-links'], 'firestore' : ['com.google.firebase:firebase-firestore'], 'functions' : ['com.google.firebase:firebase-functions'], - 'gma' : ['com.google.android.gms:play-services-ads:23.0.0', - 'com.google.android.ump:user-messaging-platform:2.2.0'], 'installations' : ['com.google.firebase:firebase-installations'], 'invites' : ['com.google.firebase:firebase-invites'], // Messaging has an additional local dependency to include. @@ -75,9 +73,6 @@ class Dependencies { def getFunctions() { libSet.add('functions') } - def getGma() { - libSet.add('gma') - } def getInstallations() { libSet.add('installations') } diff --git a/release_build_files/CMakeLists.txt b/release_build_files/CMakeLists.txt index 594440937d..1d7f4c692c 100644 --- a/release_build_files/CMakeLists.txt +++ b/release_build_files/CMakeLists.txt @@ -96,7 +96,6 @@ add_firebase_target(firebase_database) add_firebase_target(firebase_dynamic_links) add_firebase_target(firebase_firestore) add_firebase_target(firebase_functions) -add_firebase_target(firebase_gma) add_firebase_target(firebase_installations) add_firebase_target(firebase_messaging) add_firebase_target(firebase_performance) diff --git a/release_build_files/readme.md b/release_build_files/readme.md index 0ecbafb0d9..eea1f03b77 100644 --- a/release_build_files/readme.md +++ b/release_build_files/readme.md @@ -10,7 +10,6 @@ on *iOS* and *Android*: * Firebase Dynamic Links (deprecated SDK) * Cloud Firestore * Firebase Functions -* Google Mobile Ads (deprecated SDK) * Firebase Installations * Firebase Instance ID (deprecated SDK) * Firebase Realtime Database @@ -131,14 +130,6 @@ Firebase Functions | libfirebase_functions | | (Maven package) | | com.google.firebase:firebase-auth | | (Maven package) -Google Mobile Ads | libfirebase_gma.a -| | libfirebase_app.a -| | com.google.firebase:firebase-analytics -| | (Maven package) -| | com.google.android.gms:play-services-ads:23.0.0 -| | (Maven package) -| | com.google.android.ump:user-messaging-platform:2.2.0 -| | (Maven package) Firebase Installations | libfirebase_installations.a | | libfirebase_app.a | | com.google.firebase:firebase-installations @@ -208,7 +199,6 @@ firebaseCpp.dependencies { dynamicLinks firestore functions - gma installations messaging remoteConfig @@ -258,11 +248,6 @@ Firebase Functions | firebase_functions.xcframework | | firebase.xcframework | | Firebase/Functions Cocoapod (11.14.0) | | Firebase/Auth Cocoapod (11.14.0) -Google Mobile Ads | firebase_gma.xcframework -| | firebase.xcframework -| | Firebase/CoreOnly Cocoapod (11.14.0) -| | Google-Mobile-Ads-SDK Cocoapod (11.2.0) -| | GoogleUserMessagingPlatform Cocoapod (2.3.0) Firebase Installations | firebase_installations.xcframework | | firebase.xcframework | | FirebaseInstallations Cocoapod (11.14.0) @@ -325,11 +310,6 @@ Firebase Functions | libfirebase_functions.a | | libfirebase_auth.a (optional) | | Firebase/Functions Cocoapod (11.14.0) | | Firebase/Auth Cocoapod (11.14.0) -Google Mobile Ads | libfirebase_gma.a -| | libfirebase_app.a -| | Firebase/CoreOnly Cocoapod (11.14.0) -| | Google-Mobile-Ads-SDK Cocoapod (11.2.0) -| | GoogleUserMessagingPlatform Cocoapod (2.3.0) Firebase Installations | libfirebase_installations.a | | libfirebase_app.a | | FirebaseInstallations Cocoapod (11.14.0) @@ -397,8 +377,6 @@ Firebase Analytics (stub) | libfirebase_analytics.a | | libfirebase_app.a Firebase Dynamic Links (stub) | libfirebase_dynamic_links.a | | libfirebase_app.a -Google Mobile Ads (stub) | libfirebase_gma.a -| | libfirebase_app.a Firebase Installations (stub) | libfirebase_installations.a | | libfirebase_app.a Firebase Cloud Messaging (stub) | libfirebase_messaging.a @@ -442,8 +420,6 @@ Firebase Analytics (stub) | firebase_analytics.framework | | firebase.framework Firebase Dynamic Links (stub) | firebase_dynamic_links.framework | | firebase.framework -Google Mobile Ads (stub) | libfirebase_gma.a -| | libfirebase_app.a Firebase Installations (stub) | firebase_installations.framework | | firebase.framework Firebase Cloud Messaging (stub) | firebase_messaging.framework @@ -488,8 +464,6 @@ Firebase Analytics (stub) | firebase_analytics.lib | | firebase_app.lib Firebase Dynamic Links (stub) | firebase_dynamic_links.lib | | firebase_app.lib -Google Mobile Ads (stub) | firebase_gma.lib -| | firebase_app.lib Firebase Installations (stub) | firebase_installations.lib | | firebase_app.lib Firebase Cloud Messaging (stub) | firebase_messaging.lib @@ -682,6 +656,9 @@ code. provides a more direct way for Firebase to interact with your specified AppDelegate. See "Platform Notes > iOS Method Swizzling > Specifying Your AppDelegate Class Directly (iOS)" for details. + - Google Mobile Ads (GMA) C++ SDK has been removed from the Firebase C++ SDK. + It was previously deprecated. For more information, see the + [SDK documentation](https://developers.google.com/admob/cpp/sdk). ### 12.8.0 - Changes diff --git a/scripts/gha/build_ios_tvos.py b/scripts/gha/build_ios_tvos.py index 77e7cd5796..434c30610a 100644 --- a/scripts/gha/build_ios_tvos.py +++ b/scripts/gha/build_ios_tvos.py @@ -51,10 +51,9 @@ 'supported_targets' : ('firebase_analytics', 'firebase_app_check', 'firebase_auth', 'firebase_database', 'firebase_dynamic_links', 'firebase_firestore', - 'firebase_functions', 'firebase_gma', - 'firebase_installations', 'firebase_messaging', - 'firebase_remote_config', 'firebase_storage', - 'firebase_ump'), + 'firebase_functions', 'firebase_installations', + 'firebase_messaging', 'firebase_remote_config', + 'firebase_storage', 'firebase_ump'), 'device': { 'architectures' : ['arm64'], 'toolchain' : 'cmake/toolchains/ios.cmake', @@ -591,9 +590,9 @@ def parse_cmdline_args(): default=( 'firebase_analytics', 'firebase_app_check', 'firebase_auth', 'firebase_database', 'firebase_dynamic_links', 'firebase_firestore', - 'firebase_functions', 'firebase_gma', - 'firebase_installations', 'firebase_messaging', - 'firebase_remote_config', 'firebase_storage', 'firebase_ump'), + 'firebase_functions', 'firebase_installations', + 'firebase_messaging', 'firebase_remote_config', + 'firebase_storage', 'firebase_ump'), help='List of CMake build targets') parser.add_argument('-o', '--os', nargs='+', default=('ios', 'tvos'), help='List of operating systems to build for.') diff --git a/scripts/gha/integration_testing/build_testapps.json b/scripts/gha/integration_testing/build_testapps.json index 4e0c479144..f20b0ccbeb 100755 --- a/scripts/gha/integration_testing/build_testapps.json +++ b/scripts/gha/integration_testing/build_testapps.json @@ -98,20 +98,6 @@ ], "provision": "Firebase_Dev_Wildcard.mobileprovision" }, - { - "name": "gma", - "full_name": "FirebaseGma", - "bundle_id": "com.google.ios.admob.testapp", - "ios_target": "integration_test", - "tvos_target": "", - "has_uitests": true, - "testapp_path": "gma/integration_test", - "frameworks": [ - "firebase_gma.xcframework", - "firebase.xcframework" - ], - "provision": "Google_Development.mobileprovision" - }, { "name": "ump", "full_name": "FirebaseUmp", @@ -273,7 +259,6 @@ "'dynamic_links' : ['com.google.firebase:firebase-dynamic-links:[0,)'],", "'firestore' : ['com.google.firebase:firebase-firestore:[0,)'],", "'functions' : ['com.google.firebase:firebase-functions:[0,)'],", - "'gma' : ['com.google.firebase:firebase-ads:[0,)',", "'instance_id' : ['com.google.firebase:firebase-iid:[0,)'],", "'messaging' : ['com.google.firebase.messaging.cpp:firebase_messaging_cpp@aar',", "'com.google.firebase:firebase-messaging:[0,)'],", diff --git a/scripts/gha/print_matrix_configuration.py b/scripts/gha/print_matrix_configuration.py index 3dd900d1c2..bdb32afd31 100644 --- a/scripts/gha/print_matrix_configuration.py +++ b/scripts/gha/print_matrix_configuration.py @@ -134,7 +134,7 @@ } }, "config": { - "apis": "analytics,app_check,auth,database,dynamic_links,firestore,functions,gma,installations,messaging,remote_config,storage", + "apis": "analytics,app_check,auth,database,dynamic_links,firestore,functions,installations,messaging,remote_config,storage", "mobile_test_on": "real,virtual" } }, @@ -316,9 +316,11 @@ def scan_changes_in_file(parm_key, auto_diff, path, requested_api_list): change_lines = [l for l in change_lines if len(l) > 20] changed_apis = set() for line in change_lines: - if ("Google-Mobile-Ads" in line or "GoogleUserMessagingPlatform" in line or - "play-services-ads" in line or "user-messaging-platform" in line): - changed_apis.add("gma") + if ("GoogleUserMessagingPlatform" in line or + "user-messaging-platform" in line): + # This is for UMP, not GMA, so keep it if UMP is in requested_api_list + if "ump" in requested_api_list: + changed_apis.add("ump") else: changed_apis.update(requested_api_list) break diff --git a/scripts/gha/report_build_status.py b/scripts/gha/report_build_status.py index 8c41169f33..6fd10cb587 100644 --- a/scripts/gha/report_build_status.py +++ b/scripts/gha/report_build_status.py @@ -191,10 +191,6 @@ def format_errors(all_errors, severity, event): if product == 'missing_log': product_name = 'missing logs' - elif product == 'gma': - product_name = product.upper() - elif product == 'ump': - product_name = product.upper() else: product_name = product.replace('_', ' ').title() @@ -726,9 +722,11 @@ def main(argv): else: test_name_str = test_name + product_display_name = product.replace("_", " ").title() + print("| %d | %s | %s | %s | %s %s
   Logs: %s |" % ( test_list[test_id]['count'], latest, - product, platform, + product_display_name, platform, test_name_str, severity, " ".join(link_list))) else: print("%d\t%s\t%s\t%s\t%s\t%s" % (test_list[test_id]['count'], latest, severity, product, platform, test_name)) diff --git a/scripts/gha/ui_testing/uitest_android/app/src/androidTest/java/com/google/firebase/uitest/UITest.java b/scripts/gha/ui_testing/uitest_android/app/src/androidTest/java/com/google/firebase/uitest/UITest.java index 40a46427e3..0add3168aa 100644 --- a/scripts/gha/ui_testing/uitest_android/app/src/androidTest/java/com/google/firebase/uitest/UITest.java +++ b/scripts/gha/ui_testing/uitest_android/app/src/androidTest/java/com/google/firebase/uitest/UITest.java @@ -41,78 +41,12 @@ public class UITest { private static final String TAG = "UITestResult"; - private static final String GMA_PACKAGE = "com.google.android.admob.testapp"; - private static final String MESSAGING_PACKAGE = "com.google.firebase.cpp.messaging.testapp"; private static final int DEFAULT_TIMEOUT = 5000; private static final int WAIT_UI_TIMEOUT = 30000; - @Test - public void testGMA() throws UiObjectNotFoundException, InterruptedException { - // Start from the home screen & Launch the app - UiDevice device = UiDevice.getInstance(getInstrumentation()); - device.pressHome(); - launchApp(GMA_PACKAGE); - device.wait(Until.hasObject(By.pkg(GMA_PACKAGE).depth(0)), - DEFAULT_TIMEOUT); // Wait for the app to appear - Log.e(TAG, "GMA launched"); - - // 1 TestAdViewAdOpenedAdClosed - UiObject2 reference = device.wait(Until.findObject(By.text("Test Ad")), 60 * 1000); - Assert.assertNotNull(reference); - Log.e(TAG, "TestAdVie loaded"); - Thread.sleep(DEFAULT_TIMEOUT); - // click on the bottom of the "Test Ad" TextView, where the Ad present - int x = reference.getVisibleBounds().centerX(); - int y = reference.getVisibleBounds().bottom + 5; - device.click(x, y); - Thread.sleep(DEFAULT_TIMEOUT); - device.pressBack(); // back to testapp - Log.e(TAG, "TestAdViewAdClick closed"); - - Thread.sleep(DEFAULT_TIMEOUT); - - // 2 TestInterstitialAdLoadAndShow - reference = device.wait(Until.findObject(By.text("Test Ad")), WAIT_UI_TIMEOUT); - Assert.assertNotNull(reference); - Log.e(TAG, "InterstitialAd2 loaded"); - Thread.sleep(DEFAULT_TIMEOUT); - // click the center point of the device, where the Ad present - x = device.getDisplayWidth() / 2; - y = device.getDisplayHeight() / 2; - device.click(x, y); - Log.e(TAG, "InterstitialAd2 clicked"); - Thread.sleep(DEFAULT_TIMEOUT); - device.pressBack(); // back to testapp - Thread.sleep(DEFAULT_TIMEOUT); - // click the top left corner close bottom. - // Use "Test Ad" TextView bottom position as the reference - x = reference.getVisibleBounds().bottom; - y = reference.getVisibleBounds().bottom; - device.click(x, y); - Log.e(TAG, "InterstitialAd2 closed"); - - Thread.sleep(DEFAULT_TIMEOUT); - - // 3 TestRewardedAdLoadAndShow - reference = device.wait(Until.findObject(By.text("Test Ad")), WAIT_UI_TIMEOUT); - Assert.assertNotNull(reference); - Log.e(TAG, "RewardedAd loaded"); - // click the top right corner close bottom. - x = device.getDisplayWidth() - reference.getVisibleBounds().bottom; - y = reference.getVisibleBounds().bottom; - Thread.sleep(30 * 1000); - device.click(x, y); - Log.e(TAG, "RewardedAd closed"); - - // Finish GMA Tests - Thread.sleep(60 * 1000); - // reference = device.wait(Until.findObject(By.text("Test Ad")), WAIT_UI_TIMEOUT); - // Assert.assertNull(reference); - } - private void launchApp(String packageName) { Context context = getApplicationContext(); Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); diff --git a/scripts/gha/ui_testing/uitest_apple/FirebaseCppUITestAppUITests/FirebaseCppUITestAppUITests.swift b/scripts/gha/ui_testing/uitest_apple/FirebaseCppUITestAppUITests/FirebaseCppUITestAppUITests.swift index 708606fce9..65cac05d61 100644 --- a/scripts/gha/ui_testing/uitest_apple/FirebaseCppUITestAppUITests/FirebaseCppUITestAppUITests.swift +++ b/scripts/gha/ui_testing/uitest_apple/FirebaseCppUITestAppUITests/FirebaseCppUITestAppUITests.swift @@ -21,115 +21,6 @@ import XCTest class FirebaseCppUITestAppUITests: XCTestCase { - func testGMA() { - // Launch this Helper App - let helperApp = XCUIApplication() - - // Periodically check and dismiss dialogs with "Allow" or "OK" - Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { (_) in -#if os(iOS) - NSLog("finding springboard ...") - let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard") - for button in [springboard.buttons["Open"], springboard.buttons["Allow"], springboard.buttons["OK"]] { - if button.exists { - NSLog("Dismissing system dialog") - button.tap() - } - } -#elseif os(tvOS) - NSLog("finding pineboard ...") - let pineboard = XCUIApplication(bundleIdentifier: "com.apple.PineBoard") - for button in [pineboard.buttons["Open"], pineboard.buttons["Allow"], pineboard.buttons["OK"]] { - if button.exists { - NSLog("Dismissing system dialog") - let remote: XCUIRemote = XCUIRemote.shared - remote.press(.select) - } - } -#endif - } - - // Launch UI Test App - helperApp.launch() - // Wait until UI Test App open Integration Test App - helperApp.wait(for: .runningBackground, timeout: 20) - - // Wait until Integration Test App closed (testing finished) - let expectation = XCTestExpectation(description: "Integration Test App closed") - Timer.scheduledTimer(withTimeInterval: 5, repeats: true) { (_) in - if helperApp.state == .runningForeground { - NSLog("Integration Test App closed... UI Test App back to foreground...") - expectation.fulfill() - } else { - NSLog("Testing... UI Test App in background...") - } - } - - - // Start Automated UI Test - let app = XCUIApplication(bundleIdentifier: "com.google.ios.admob.testapp") - - // 1. TestAdViewAdOpenedAdClosed - var reference = app.staticTexts["Test mode"] - XCTAssertTrue(reference.waitForExistence(timeout: 60)) - // Click on the center point of the "Test Ad" TextView, where the Ad present - var x = (reference.frame.origin.x + reference.frame.width)/2 - var y = (reference.frame.origin.y + reference.frame.height)/2 - sleep(5) // Wait until button hittable - let ad_view = app.findElement(at: CGPoint(x: x, y: y)) - ad_view.tap() - sleep(5) - app.activate() - - sleep(5) - - // 2. TestInterstitialAdLoadAndShow - reference = app.staticTexts["Test mode"] - XCTAssertTrue(reference.waitForExistence(timeout: 60)) - // Click the center point of the device, where the Ad present - x = app.frame.width/2 - y = app.frame.height/2 - sleep(5) // Wait until button hittable - let interstitial_ad = app.findElement(at: CGPoint(x: x, y: y)) - interstitial_ad.tap() - sleep(5) - app.activate() - sleep(5) - // Click the top left corner close bottom. - // Use "Test Ad" TextView bottom position as the reference - x = (reference.frame.origin.y + reference.frame.height)/2 - y = (reference.frame.origin.y + reference.frame.height)/2 - sleep(5) // Wait until button hittable - let interstitial_ad_close_button = app.findElement(at: CGPoint(x: x, y: y)) - interstitial_ad_close_button.tap() - - sleep(5) - - // 3. TestRewardedAdLoadAndShow - reference = app.staticTexts["Test mode"] - XCTAssertTrue(reference.waitForExistence(timeout: 60)) - // Click the top right corner close bottom. - x = app.frame.width - (reference.frame.origin.y + reference.frame.height)/2 - y = (reference.frame.origin.y + reference.frame.height)/2 - sleep(15) // Wait until button hittable - let rewarded_ad_close_button = app.findElement(at: CGPoint(x: x, y: y)) - rewarded_ad_close_button.tap() - - let close_video_button = app.webViews.staticTexts["CLOSE VIDEO"] - if close_video_button.waitForExistence(timeout: 5) { - sleep(5) - close_video_button.tap() - sleep(5) - rewarded_ad_close_button.tap() - } - - // Finish GMA Tests - sleep(60) - reference = app.staticTexts["Test mode"] - XCTAssertFalse(reference.exists) - app.terminate() - } - } extension XCUIApplication { diff --git a/scripts/update_android_ios_dependencies.py b/scripts/update_android_ios_dependencies.py index f29e3ec07f..c8517f5e4f 100644 --- a/scripts/update_android_ios_dependencies.py +++ b/scripts/update_android_ios_dependencies.py @@ -185,18 +185,6 @@ def get_files(dirs_and_files, file_extension, file_name=None, 'FirebaseStorage', ] -# List of GMA pods we are also interested in. -PODS_GMA = [ - 'Google-Mobile-Ads-SDK', - 'GoogleUserMessagingPlatform' -] - -ANDROID_GMA_PACKAGES = [ - 'firebase-ads', - 'play-services-ads', - 'user-messaging-platform', -] - def get_pod_versions(specs_repo, pods=PODS, ignore_pods=None, allow_experimental=False): """Get available pods and their versions from the specs repo @@ -727,8 +715,6 @@ def parse_cmdline_args(): parser.add_argument('--ignore_android_packages', nargs='+', default=(), help='Ignore Android packages which have any of the items ' 'specified in this list as substrings.') - parser.add_argument('--include_gma', action='store_true', - help='Also update GMA dependencies') parser.add_argument('--depfiles', nargs='+', default=('Android/firebase_dependencies.gradle', 'release_build_files/Android/firebase_dependencies.gradle'), @@ -775,7 +761,7 @@ def main(): if not args.skip_ios: latest_pod_versions_map = get_latest_pod_versions( args.specs_repo, - (PODS + PODS_GMA) if args.include_gma else PODS, + PODS, set(args.ignore_ios_pods), args.allow_experimental) pod_files = get_files(args.podfiles, file_extension='', file_name='Podfile', ignore_directories=set(args.ignore_directories)) @@ -786,11 +772,8 @@ def main(): modify_readme_file_pods(readme_file, latest_pod_versions_map, args.dryrun) if not args.skip_android: - ignore_android_packages = set(args.ignore_android_packages) - if not args.include_gma: - ignore_android_packages.update(ANDROID_GMA_PACKAGES) latest_android_versions_map = get_latest_maven_versions( - ignore_android_packages, args.allow_experimental) + set(args.ignore_android_packages), args.allow_experimental) dep_files = get_files(args.depfiles, file_extension='.gradle', file_name='firebase_dependencies.gradle', ignore_directories=set(args.ignore_directories)) diff --git a/settings.gradle b/settings.gradle index ad2d909d3d..759afe58eb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,8 +14,6 @@ include ':app', ':firestore', ':firestore:firestore_resources', ':functions', - ':gma', - ':gma:gma_resources', ':installations', ':messaging', ':messaging:messaging_java', diff --git a/setup_integration_tests.py b/setup_integration_tests.py index 6565df3d4d..93fa787aa0 100755 --- a/setup_integration_tests.py +++ b/setup_integration_tests.py @@ -40,7 +40,6 @@ 'firestore/integration_test', 'firestore/integration_test_internal', 'functions/integration_test', - 'gma/integration_test', 'installations/integration_test', 'messaging/integration_test', 'remote_config/integration_test',