From 0f147caf15603863d31a18fdec8f1fa6d6954413 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Tue, 10 May 2022 16:11:27 -0700 Subject: [PATCH 1/5] Add internal integration test to App, running all unit tests on device --- app/integration_test/src/integration_test.cc | 16 + .../AndroidManifest.xml | 43 ++ app/integration_test_internal/CMakeLists.txt | 335 ++++++++++ app/integration_test_internal/CMakeLists.txt~ | 302 +++++++++ .../AppIcon.appiconset/Contents.json | 98 +++ .../LaunchImage.launchimage/Contents.json | 51 ++ app/integration_test_internal/Info.plist | 41 ++ .../LaunchScreen.storyboard | 7 + .../LibraryManifest.xml | 23 + app/integration_test_internal/Podfile | 15 + app/integration_test_internal/build.gradle | 94 +++ .../download_googletest.py | 80 +++ .../googletest.cmake | 35 + .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 49896 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + app/integration_test_internal/gradlew | 178 ++++++ app/integration_test_internal/gradlew.bat | 104 +++ .../project.pbxproj | 377 +++++++++++ app/integration_test_internal/proguard.pro | 2 + .../res/layout/main.xml | 28 + .../res/values/strings.xml | 20 + .../res/values/strings.xml~ | 20 + app/integration_test_internal/settings.gradle | 39 ++ .../src/android/android_app_framework.cc | 599 ++++++++++++++++++ .../android_firebase_test_framework.cc | 225 +++++++ .../google/firebase/example/LoggingUtils.java | 163 +++++ .../firebase/example/SimpleHttpRequest.java | 118 ++++ .../example/SimplePersistentStorage.java | 45 ++ .../firebase/example/TextEntryField.java | 100 +++ .../src/app_framework.cc | 96 +++ .../src/app_framework.h | 131 ++++ .../src/desktop/desktop_app_framework.cc | 224 +++++++ .../desktop_firebase_test_framework.cc | 52 ++ app/integration_test_internal/src/empty.swift | 15 + .../src/firebase_test_framework.cc | 389 ++++++++++++ .../src/firebase_test_framework.h | 501 +++++++++++++++ .../src/integration_test.cc | 68 ++ .../src/ios/.clang-format | 2 + .../src/ios/ios_app_framework.mm | 381 +++++++++++ .../src/ios/ios_firebase_test_framework.mm | 194 ++++++ app/rest/tests/request_file_test.cc | 13 +- .../integration_testing/build_testapps.json | 3 +- 42 files changed, 5230 insertions(+), 3 deletions(-) create mode 100644 app/integration_test_internal/AndroidManifest.xml create mode 100644 app/integration_test_internal/CMakeLists.txt create mode 100644 app/integration_test_internal/CMakeLists.txt~ create mode 100644 app/integration_test_internal/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 app/integration_test_internal/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 app/integration_test_internal/Info.plist create mode 100644 app/integration_test_internal/LaunchScreen.storyboard create mode 100644 app/integration_test_internal/LibraryManifest.xml create mode 100644 app/integration_test_internal/Podfile create mode 100644 app/integration_test_internal/build.gradle create mode 100755 app/integration_test_internal/download_googletest.py create mode 100644 app/integration_test_internal/googletest.cmake create mode 100644 app/integration_test_internal/gradle/wrapper/gradle-wrapper.jar create mode 100644 app/integration_test_internal/gradle/wrapper/gradle-wrapper.properties create mode 100755 app/integration_test_internal/gradlew create mode 100644 app/integration_test_internal/gradlew.bat create mode 100644 app/integration_test_internal/integration_test.xcodeproj/project.pbxproj create mode 100644 app/integration_test_internal/proguard.pro create mode 100644 app/integration_test_internal/res/layout/main.xml create mode 100644 app/integration_test_internal/res/values/strings.xml create mode 100644 app/integration_test_internal/res/values/strings.xml~ create mode 100644 app/integration_test_internal/settings.gradle create mode 100644 app/integration_test_internal/src/android/android_app_framework.cc create mode 100644 app/integration_test_internal/src/android/android_firebase_test_framework.cc create mode 100644 app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java create mode 100644 app/integration_test_internal/src/android/java/com/google/firebase/example/SimpleHttpRequest.java create mode 100644 app/integration_test_internal/src/android/java/com/google/firebase/example/SimplePersistentStorage.java create mode 100644 app/integration_test_internal/src/android/java/com/google/firebase/example/TextEntryField.java create mode 100644 app/integration_test_internal/src/app_framework.cc create mode 100644 app/integration_test_internal/src/app_framework.h create mode 100644 app/integration_test_internal/src/desktop/desktop_app_framework.cc create mode 100644 app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc create mode 100644 app/integration_test_internal/src/empty.swift create mode 100644 app/integration_test_internal/src/firebase_test_framework.cc create mode 100644 app/integration_test_internal/src/firebase_test_framework.h create mode 100644 app/integration_test_internal/src/integration_test.cc create mode 100644 app/integration_test_internal/src/ios/.clang-format create mode 100644 app/integration_test_internal/src/ios/ios_app_framework.mm create mode 100644 app/integration_test_internal/src/ios/ios_firebase_test_framework.mm diff --git a/app/integration_test/src/integration_test.cc b/app/integration_test/src/integration_test.cc index c22acb8bec..bf57e0cc25 100644 --- a/app/integration_test/src/integration_test.cc +++ b/app/integration_test/src/integration_test.cc @@ -42,6 +42,8 @@ using firebase_test_framework::FirebaseTest; class FirebaseAppTest : public FirebaseTest { public: FirebaseAppTest(); + static void SetUpTestSuite(); + static void TearDownTestSuite(); }; FirebaseAppTest::FirebaseAppTest() { @@ -56,6 +58,20 @@ FirebaseAppTest::FirebaseAppTest() { #define APP_CREATE_PARAMS #endif // defined(__ANDROID__) +void FirebaseAppTest::SetUpTestSuite() { + // Nothing to do here. +} + +void FirebaseAppTest::TearDownTestSuite() { + // The App integration test is too fast for FTL, so pause a few seconds + // here. + ProcessEvents(1000); + ProcessEvents(1000); + ProcessEvents(1000); + ProcessEvents(1000); + ProcessEvents(1000); +} + TEST_F(FirebaseAppTest, TestDefaultAppWithDefaultOptions) { firebase::App* default_app; default_app = firebase::App::Create(APP_CREATE_PARAMS); diff --git a/app/integration_test_internal/AndroidManifest.xml b/app/integration_test_internal/AndroidManifest.xml new file mode 100644 index 0000000000..6691ae2a44 --- /dev/null +++ b/app/integration_test_internal/AndroidManifest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/integration_test_internal/CMakeLists.txt b/app/integration_test_internal/CMakeLists.txt new file mode 100644 index 0000000000..2c0fb68de8 --- /dev/null +++ b/app/integration_test_internal/CMakeLists.txt @@ -0,0 +1,335 @@ +# Copyright 2020 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) + +set(FIREBASE_PYTHON_EXECUTABLE "python" CACHE FILEPATH + "The Python interpreter to use, such as one from a venv") + +# 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}") + 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_PORTABLE_SRCS + # Copy of the standard integration test source file. + src/integration_test.cc + # All of the unit tests from App and other SDKs. + ${FIREBASE_CPP_SDK_DIR}/app/tests/app_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/assert_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/base64_openssh_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/base64_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/callback_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/cleanup_notifier_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/flexbuffer_matcher_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/future_manager_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/future_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/google_services_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_info_desktop_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/intrusive_list_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/jobject_reference_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/locale_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/log_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/logger_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/optional_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/path_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/reference_count_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/scheduler_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/semaphore_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/thread_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/time_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/util_android_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/util_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/uuid_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/variant_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/variant_util_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/memory/atomic_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/memory/shared_ptr_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/memory/unique_ptr_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/meta/move_test.cc +) + +add_definitions(-DFIREBASE_INTEGRATION_TEST) +set(FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_binary_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_file_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_json_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_binary_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_json_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/transport_curl_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/transport_mock_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/util_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/www_form_url_encoded_test.cc +) + + +if(IOS) + set(FIREBASE_INTEGRATION_TEST_SRCS + ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ) +elif(ANDROID) + set(FIREBASE_INTEGRATION_TEST_SRCS + ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ) +else() # DESKTOP + set(FIREBASE_INTEGRATION_TEST_SRCS + ${FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS} + ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ) +endif() + +# The include directory for the testapp. +include_directories(src) +# The include directory for the C++ SDK root. +include_directories(${FIREBASE_CPP_SDK_DIR}) +# The include directory for the C++ SDK root. +include_directories(${FIREBASE_CPP_SDK_DIR}) + +# Integration test uses some features that require C++ 11, such as lambdas. +set (CMAKE_CXX_STANDARD 11) + +# 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 + ) + + 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() + +# Don't include other Firebase libraries, only Firebase App +option(FIREBASE_INCLUDE_LIBRARY_DEFAULT "" OFF) +option(FIREBASE_CPP_BUILD_TESTS "" ON) +add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL) + +get_directory_property(ZLIB_SOURCE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION ZLIB_SOURCE_DIR) +get_directory_property(ZLIB_BINARY_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION ZLIB_BINARY_DIR) +get_directory_property(FLATBUFFERS_SOURCE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION FLATBUFFERS_SOURCE_DIR) +get_directory_property(FIREBASE_GEN_FILE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION FIREBASE_GEN_FILE_DIR) + +# Additional include paths populated by top-level SDK CMakeLists +if(NOT ANDROID AND NOT IOS) + # Turn absl-isms into gtest-isms + target_compile_definitions(${integration_test_target_name} + PUBLIC + "-DCHECK=ASSERT_TRUE" + "-DCHECK_EQ=ASSERT_EQ" + ) + target_include_directories(${integration_test_target_name} + PUBLIC + ${FLATBUFFERS_SOURCE_DIR}/include + ${FIREBASE_GEN_FILE_DIR} + ${ZLIB_SOURCE_DIR}/.. + ) + set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} sample_resource_lib) + if(LINUX) + pkg_check_modules(LIBSECRET libsecret-1) + if(NOT LIBSECRET_FOUND) + message(FATAL_ERROR "Unable to find libsecret, which is needed by \ + Firebase. It can be installed on supported \ + systems via: \ + apt-get install libsecret-1-dev") + endif() + target_include_directories(${integration_test_target_name} + PUBLIC + ${LIBSECRET_INCLUDE_DIRS} + ) + endif() +endif() + +# Add the Firebase libraries to the target using the function from the SDK. +# Note that firebase_app needs to be last in the list. +set(firebase_libs firebase_app) +set(gtest_libs gtest gmock) +target_link_libraries(${integration_test_target_name} ${firebase_libs} + ${gtest_libs} ${ADDITIONAL_LIBS}) diff --git a/app/integration_test_internal/CMakeLists.txt~ b/app/integration_test_internal/CMakeLists.txt~ new file mode 100644 index 0000000000..d3e477133b --- /dev/null +++ b/app/integration_test_internal/CMakeLists.txt~ @@ -0,0 +1,302 @@ +# Copyright 2020 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) + +set(FIREBASE_PYTHON_EXECUTABLE "python" CACHE FILEPATH + "The Python interpreter to use, such as one from a venv") + +# 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}") + 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_PORTABLE_SRCS + # Copy of the standard integration test source file. + src/integration_test.cc + # All of the unit tests from App and other SDKs. + ../tests/app_test.cc + ../tests/assert_test.cc + ../tests/base64_openssh_test.cc + ../tests/base64_test.cc + ../tests/callback_test.cc + ../tests/cleanup_notifier_test.cc + ../tests/flexbuffer_matcher_test.cc + ../tests/future_manager_test.cc + ../tests/future_test.cc + ../tests/google_services_test.cc + ../tests/heartbeat_info_desktop_test.cc + ../tests/intrusive_list_test.cc + ../tests/jobject_reference_test.cc + ../tests/locale_test.cc + ../tests/log_test.cc + ../tests/logger_test.cc + ../tests/optional_test.cc + ../tests/path_test.cc + ../tests/reference_count_test.cc + ../tests/scheduler_test.cc + ../tests/semaphore_test.cc + ../tests/thread_test.cc + ../tests/time_test.cc + ../tests/util_android_test.cc + ../tests/util_test.cc + ../tests/uuid_test.cc + ../tests/variant_test.cc + ../tests/variant_util_test.cc + ../memory/atomic_test.cc + ../memory/shared_ptr_test.cc + ../memory/unique_ptr_test.cc + ../meta/move_test.cc +) + +set(FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS + ../rest/tests/request_binary_test.cc + ../rest/tests/request_file_test.cc + ../rest/tests/request_json_test.cc + ../rest/tests/request_test.cc + ../rest/tests/response_binary_test.cc + ../rest/tests/response_json_test.cc + ../rest/tests/response_test.cc + ../rest/tests/transport_curl_test.cc + ../rest/tests/transport_mock_test.cc + ../rest/tests/util_test.cc + ../rest/tests/www_form_url_encoded_test.cc +) + + +if(IOS) + set(FIREBASE_INTEGRATION_TEST_SRCS + ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ) +elif(ANDROID) + set(FIREBASE_INTEGRATION_TEST_SRCS + ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ) +else() # DESKTOP + set(FIREBASE_INTEGRATION_TEST_SRCS + ${FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS} + ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ) +endif() + +# The include directory for the testapp. +include_directories(src) +# The include directory for the C++ SDK root. +include_directories(${FIREBASE_CPP_SDK_DIR}) +# The include directory for the C++ SDK root. +include_directories(${FIREBASE_CPP_SDK_DIR}) + +# Integration test uses some features that require C++ 11, such as lambdas. +set (CMAKE_CXX_STANDARD 11) + +# 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 + ) + + 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() + +# Don't include other Firebase libraries, only Firebase App +option(FIREBASE_INCLUDE_LIBRARY_DEFAULT "" OFF) +add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL) +if(DESKTOP) + include_directories(${ZLIB_SOURCE_DIR}) + include_directories(${ZLIB_BINARY_DIR}) +endif() + +# Add the Firebase libraries to the target using the function from the SDK. +# Note that firebase_app needs to be last in the list. +set(firebase_libs firebase_app) +set(gtest_libs gtest gmock) +target_link_libraries(${integration_test_target_name} ${firebase_libs} + ${gtest_libs} ${ADDITIONAL_LIBS}) diff --git a/app/integration_test_internal/Images.xcassets/AppIcon.appiconset/Contents.json b/app/integration_test_internal/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..d8db8d65fd --- /dev/null +++ b/app/integration_test_internal/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "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/app/integration_test_internal/Images.xcassets/LaunchImage.launchimage/Contents.json b/app/integration_test_internal/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 0000000000..6f870a4629 --- /dev/null +++ b/app/integration_test_internal/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "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/app/integration_test_internal/Info.plist b/app/integration_test_internal/Info.plist new file mode 100644 index 0000000000..35a91415a6 --- /dev/null +++ b/app/integration_test_internal/Info.plist @@ -0,0 +1,41 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + google + CFBundleURLSchemes + + REPLACE_WITH_REVERSED_CLIENT_ID + + + + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + + diff --git a/app/integration_test_internal/LaunchScreen.storyboard b/app/integration_test_internal/LaunchScreen.storyboard new file mode 100644 index 0000000000..673e0f7e68 --- /dev/null +++ b/app/integration_test_internal/LaunchScreen.storyboard @@ -0,0 +1,7 @@ + + + + + + + diff --git a/app/integration_test_internal/LibraryManifest.xml b/app/integration_test_internal/LibraryManifest.xml new file mode 100644 index 0000000000..a3de7a677f --- /dev/null +++ b/app/integration_test_internal/LibraryManifest.xml @@ -0,0 +1,23 @@ + + + + + + + diff --git a/app/integration_test_internal/Podfile b/app/integration_test_internal/Podfile new file mode 100644 index 0000000000..9e4cc47b75 --- /dev/null +++ b/app/integration_test_internal/Podfile @@ -0,0 +1,15 @@ +source 'https://github.com/CocoaPods/Specs.git' +platform :ios, '10.0' +# Firebase App test application. +use_frameworks! :linkage => :static + +target 'integration_test' do + pod 'Firebase/Analytics', '9.0.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/app/integration_test_internal/build.gradle b/app/integration_test_internal/build.gradle new file mode 100644 index 0000000000..20c9e2df2e --- /dev/null +++ b/app/integration_test_internal/build.gradle @@ -0,0 +1,94 @@ +// Copyright 2020 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:3.3.3' + classpath 'com.google.gms:google-services:4.0.1' + } +} + +allprojects { + repositories { + mavenLocal() + maven { url 'https://maven.google.com' } + mavenCentral() + } +} + +apply plugin: 'com.android.application' + +android { + compileOptions { + sourceCompatibility 1.8 + targetCompatibility 1.8 + } + compileSdkVersion 28 + buildToolsVersion '28.0.3' + + sourceSets { + main { + jniLibs.srcDirs = ['libs'] + manifest.srcFile 'AndroidManifest.xml' + java.srcDirs = ['src/android/java'] + res.srcDirs = ['res'] + } + } + + defaultConfig { + applicationId 'com.google.android.analytics.testapp' + minSdkVersion 19 + targetSdkVersion 28 + versionCode 1 + versionName '1.0' + externalNativeBuild.cmake { + arguments "-DFIREBASE_CPP_SDK_DIR=$gradle.firebase_cpp_sdk_dir" + } + } + externalNativeBuild.cmake { + path 'CMakeLists.txt' + } + buildTypes { + release { + minifyEnabled true + proguardFile getDefaultProguardFile('proguard-android.txt') + proguardFile file('proguard.pro') + } + } +} + +apply from: "$gradle.firebase_cpp_sdk_dir/Android/firebase_dependencies.gradle" +firebaseCpp.dependencies { + app +} + +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 'python', '../../setup_integration_tests.py', project.projectDir.toString() + } + else { + commandLine 'echo', '' + } +} + +build.dependsOn(copyIntegrationTestFiles) diff --git a/app/integration_test_internal/download_googletest.py b/app/integration_test_internal/download_googletest.py new file mode 100755 index 0000000000..21515bc06f --- /dev/null +++ b/app/integration_test_internal/download_googletest.py @@ -0,0 +1,80 @@ +#!/usr/bin/python + +# Copyright 2019 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 into a subdirectory.""" + +# pylint: disable=superfluous-parens,g-import-not-at-top + +import io +import os +import shutil +import tempfile +import zipfile + +# Import urllib in a way that is compatible with Python 2 and Python 3. +try: + import urllib.request + compatible_urlopen = urllib.request.urlopen +except ImportError: + import urllib2 + compatible_urlopen = urllib2.urlopen + +# Run from inside the script directory +SRC_DIR = os.path.relpath(os.path.dirname(__file__)) +TAG = os.path.basename(__file__) + +# Pin to 1.11.0 because we touch internal GoogleTest structures that could change in the future. +GOOGLETEST_ZIP = 'https://github.com/google/googletest/archive/refs/tags/release-1.11.0.zip' +# Top-level directory inside the zip file to ignore. +GOOGLETEST_DIR = os.path.join('googletest-release-1.11.0') + +# The GoogleTest code is copied into this subdirectory. +# This structure matches where the files are placed by CMake. +DESTINATION_DIR = os.path.join(SRC_DIR, 'external/googletest/src') + +CHECK_EXISTS = os.path.join( + SRC_DIR, 'external/googletest/src/googletest/src/gtest-all.cc') + +# Don't download it again if it already exists. +if os.path.exists(CHECK_EXISTS): + print('%s: GoogleTest already downloaded, skipping.' % (TAG)) + exit(0) + +# Download the zipfile into memory, extract into /tmp, then move into the +# current directory. + +try: + # Download to a temporary directory. + zip_extract_path = tempfile.mkdtemp(suffix='googletestdownload') + print('%s: Downloading GoogleTest from %s' % (TAG, GOOGLETEST_ZIP)) + zip_download = compatible_urlopen(GOOGLETEST_ZIP) + zip_file = io.BytesIO(zip_download.read()) + print('%s: Extracting GoogleTest...' % (TAG)) + zip_ref = zipfile.ZipFile(zip_file, mode='r') + zip_ref.extractall(zip_extract_path) + if os.path.exists(DESTINATION_DIR): + shutil.rmtree(DESTINATION_DIR) + shutil.move(os.path.join(zip_extract_path, GOOGLETEST_DIR), DESTINATION_DIR) + print('%s: Finished.' % (TAG)) +except Exception as e: + raise +finally: + # Clean up the temp directory if we created one. + if os.path.exists(zip_extract_path): + shutil.rmtree(zip_extract_path) + +if not os.path.exists(CHECK_EXISTS): + print('%s: Failed to download GoogleTest to %s' % (TAG, DESTINATION_DIR)) + exit(1) diff --git a/app/integration_test_internal/googletest.cmake b/app/integration_test_internal/googletest.cmake new file mode 100644 index 0000000000..2261a3a7f6 --- /dev/null +++ b/app/integration_test_internal/googletest.cmake @@ -0,0 +1,35 @@ +# Copyright 2020 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/app/integration_test_internal/gradle/wrapper/gradle-wrapper.jar b/app/integration_test_internal/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..8c0fb64a8698b08ecc4158d828ca593c4928e9dd GIT binary patch literal 49896 zcmagFb986H(k`5d^NVfUwr$(C?M#x1ZQHiZiEVpg+jrjgoQrerx!>1o_ul)D>ebz~ zs=Mmxr&>W81QY-S1PKWQ%N-;H^tS;2*XwVA`dej1RRn1z<;3VgfE4~kaG`A%QSPsR z#ovnZe+tS9%1MfeDyz`RirvdjPRK~p(#^q2(^5@O&NM19EHdvN-A&StN>0g6QA^VN z0Gx%Gq#PD$QMRFzmK+utjS^Y1F0e8&u&^=w5K<;4Rz|i3A=o|IKLY+g`iK6vfr9?+ z-`>gmU&i?FGSL5&F?TXFu`&Js6h;15QFkXp2M1H9|Eq~bpov-GU(uz%mH0n55wUl- zv#~ccAz`F5wlQ>e_KlJS3@{)B?^v*EQM=IxLa&76^y51a((wq|2-`qON>+4dLc{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uJ>tvx*p$5@flA>QRl455b&{*U?xU8`)nF2T$uu_(l8VNtq z?pBiRQIckGzk8W&SFSB=g6eG`ZC;6v9w`?eF*S}3E@N`2ropeHP)E}o?qJkyVEI;K$!)bWY zt9>4WmDVJh7U~m$|K`T#hF!v|znj^=M;69uXrFys#51XT;DbMr4H)>7UQ1e2(cuQf z4kr~Tt1tpBB2GaJ(|j~lHgW40EgMMVqR6eJoJig1SBg|2=$~4I3P0eP$q%_`sS&4~ z26=&a&tLjQbch1`cVXa-2fTl1y8}->|Nqu?uVrNTov!=VKh)g89wUPTgAzkSKZ57_ zr=B^mcldE3K04t4{;RaG53&9yovq;@aR#VHx+R1^^*kr-vEEd!uea68Z<{R%_DD6fn&T4 zu;fDj07L-(_fLSJGdkeh&c&7A(ZLj`7iwnkAcqUexU;WjUkqeg1m1-IUZTIZA(4dtr2Gr`e{BIejlCgS<33MB=1!8?a74!F%=Uo7N`F@k} ze+1C_eU4Y_$mvdjci zwEtCIphA2PBzBhng5=M#e4r%)RW5rVD|_`PvY$7BK`}w~d>%0O9sY#*LUAq=^OjMF^PY5m<7!=s5jyRfosCQAo#hL`h5vN-M}6Q z0Li}){5?wi8)GVHNkF|U9*8V5ej)nhb^TLw1KqiPK(@{P1^L&P=`ZNt?_+}&0(8Uh zfyyZFPgMV7ECt;Jdw|`|{}b$w4&x77VxR>8wUs|GQ5FBf1UlvasqX$qfk5rI4>Wfr zztH>y`=daAef**C12yJ7;LDf&3;h3X+5@dGPy@vS(RSs3CWimbTp=g \(.*\)$'` + 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/app/integration_test_internal/gradlew.bat b/app/integration_test_internal/gradlew.bat new file mode 100644 index 0000000000..4ba75ee288 --- /dev/null +++ b/app/integration_test_internal/gradlew.bat @@ -0,0 +1,104 @@ +@rem Copyright 2020 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/app/integration_test_internal/integration_test.xcodeproj/project.pbxproj b/app/integration_test_internal/integration_test.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..03e93aa3e0 --- /dev/null +++ b/app/integration_test_internal/integration_test.xcodeproj/project.pbxproj @@ -0,0 +1,377 @@ +// !$*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 */; }; + D66B16871CE46E8900E5638A /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D66B16861CE46E8900E5638A /* LaunchScreen.storyboard */; }; + D67D355822BABD2200292C1D /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = D67D355622BABD2100292C1D /* gtest-all.cc */; }; + D6BDBF0C2819C7FE004AD146 /* empty.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6BDBF0B2819C7FE004AD146 /* empty.swift */; }; + 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 = ""; }; + 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 = ""; }; + D6BDBF0B2819C7FE004AD146 /* empty.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = empty.swift; path = src/empty.swift; sourceTree = ""; }; + 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 */, + 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 = ( + 529226D51C85F68000C89379 /* Foundation.framework */, + 529226D71C85F68000C89379 /* CoreGraphics.framework */, + 529226D91C85F68000C89379 /* UIKit.framework */, + 529226EE1C85F68000C89379 /* XCTest.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 5292271D1C85FB5500C89379 /* src */ = { + isa = PBXGroup; + children = ( + D6BDBF0B2819C7FE004AD146 /* 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 */, + D6BDBF0C2819C7FE004AD146 /* 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 = 10.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 = 10.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 = ""; + 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.0; + 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 = ""; + 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.0; + 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/app/integration_test_internal/proguard.pro b/app/integration_test_internal/proguard.pro new file mode 100644 index 0000000000..2d04b8a9a5 --- /dev/null +++ b/app/integration_test_internal/proguard.pro @@ -0,0 +1,2 @@ +-ignorewarnings +-keep,includedescriptorclasses public class com.google.firebase.example.LoggingUtils { * ; } diff --git a/app/integration_test_internal/res/layout/main.xml b/app/integration_test_internal/res/layout/main.xml new file mode 100644 index 0000000000..cbe90c3ebe --- /dev/null +++ b/app/integration_test_internal/res/layout/main.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/app/integration_test_internal/res/values/strings.xml b/app/integration_test_internal/res/values/strings.xml new file mode 100644 index 0000000000..75e8818615 --- /dev/null +++ b/app/integration_test_internal/res/values/strings.xml @@ -0,0 +1,20 @@ + + + + Firebase App Internal Integration Test + diff --git a/app/integration_test_internal/res/values/strings.xml~ b/app/integration_test_internal/res/values/strings.xml~ new file mode 100644 index 0000000000..0c439bd88d --- /dev/null +++ b/app/integration_test_internal/res/values/strings.xml~ @@ -0,0 +1,20 @@ + + + + Firebase App Integration Test + diff --git a/app/integration_test_internal/settings.gradle b/app/integration_test_internal/settings.gradle new file mode 100644 index 0000000000..e30c259ab6 --- /dev/null +++ b/app/integration_test_internal/settings.gradle @@ -0,0 +1,39 @@ +// Copyright 2018 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 ((new File('../../cpp_sdk_version.json')).exists()) { + firebase_cpp_sdk_dir = new File('../..').absolutePath + } + else if ((new 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" \ No newline at end of file diff --git a/app/integration_test_internal/src/android/android_app_framework.cc b/app/integration_test_internal/src/android/android_app_framework.cc new file mode 100644 index 0000000000..1a31065fbc --- /dev/null +++ b/app/integration_test_internal/src/android/android_app_framework.cc @@ -0,0 +1,599 @@ +// Copyright 2016 Google Inc. 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 +#include +#include +#include + +#include "app_framework.h" // NOLINT + +// This implementation is derived from http://github.com/google/fplutil + +// Number of seconds to delay after the app is finished before exiting. +// (Plus a longer delay if the app returns an error code other than 0, to give +// the user more time to see the errors.) +const int kExitDelaySeconds = 10; +const int kExitDelaySecondsIfError = 60; + +static struct android_app* g_app_state = nullptr; +static bool g_destroy_requested = false; +static bool g_started = false; +static bool g_restarted = false; +static pthread_mutex_t g_started_mutex; + +// Handle state changes from via native app glue. +static void OnAppCmd(struct android_app* app, int32_t cmd) { + g_destroy_requested |= cmd == APP_CMD_DESTROY; +} + +namespace app_framework { + +// Process events pending on the main thread. +// Returns true when the app receives an event requesting exit. +bool ProcessEvents(int msec) { + int looperId; + do { + struct android_poll_source* source = nullptr; + int events; + looperId = ALooper_pollAll(msec, nullptr, &events, + reinterpret_cast(&source)); + if (looperId >= 0 && source) { + source->process(g_app_state, source); + } + } while (looperId != ALOOPER_POLL_TIMEOUT && !g_destroy_requested && + !g_restarted); + return g_destroy_requested | g_restarted; +} + +std::string PathForResource() { + ANativeActivity* nativeActivity = g_app_state->activity; + std::string result(nativeActivity->internalDataPath); + return result + "/"; +} + +// Get the activity. +jobject GetActivity() { return g_app_state->activity->clazz; } + +// Get the window context. For Android, it's a jobject pointing to the Activity. +jobject GetWindowContext() { return g_app_state->activity->clazz; } + +// Find a class, attempting to load the class if it's not found. +jclass FindClass(JNIEnv* env, jobject activity_object, const char* class_name) { + jclass class_object = env->FindClass(class_name); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + // If the class isn't found it's possible NativeActivity is being used by + // the application which means the class path is set to only load system + // classes. The following falls back to loading the class using the + // Activity before retrieving a reference to it. + jclass activity_class = env->FindClass("android/app/Activity"); + jmethodID activity_get_class_loader = env->GetMethodID( + activity_class, "getClassLoader", "()Ljava/lang/ClassLoader;"); + + jobject class_loader_object = + env->CallObjectMethod(activity_object, activity_get_class_loader); + + jclass class_loader_class = env->FindClass("java/lang/ClassLoader"); + jmethodID class_loader_load_class = + env->GetMethodID(class_loader_class, "loadClass", + "(Ljava/lang/String;)Ljava/lang/Class;"); + jstring class_name_object = env->NewStringUTF(class_name); + + class_object = static_cast(env->CallObjectMethod( + class_loader_object, class_loader_load_class, class_name_object)); + + if (env->ExceptionCheck()) { + env->ExceptionClear(); + class_object = nullptr; + } + env->DeleteLocalRef(class_name_object); + env->DeleteLocalRef(class_loader_object); + } + return class_object; +} + +// Vars that we need available for appending text to the log window: +class LoggingUtilsData { + public: + LoggingUtilsData() + : logging_utils_class_(nullptr), + logging_utils_add_log_text_(0), + logging_utils_init_log_window_(0), + logging_utils_get_did_touch_(0) {} + + ~LoggingUtilsData() { + JNIEnv* env = GetJniEnv(); + assert(env); + if (logging_utils_class_) { + env->DeleteGlobalRef(logging_utils_class_); + } + } + + void Init() { + JNIEnv* env = GetJniEnv(); + assert(env); + + jclass logging_utils_class = FindClass( + env, GetActivity(), "com/google/firebase/example/LoggingUtils"); + assert(logging_utils_class != 0); + + // Need to store as global references so it don't get moved during garbage + // collection. + logging_utils_class_ = + static_cast(env->NewGlobalRef(logging_utils_class)); + env->DeleteLocalRef(logging_utils_class); + + logging_utils_init_log_window_ = env->GetStaticMethodID( + logging_utils_class_, "initLogWindow", "(Landroid/app/Activity;)V"); + logging_utils_add_log_text_ = env->GetStaticMethodID( + logging_utils_class_, "addLogText", "(Ljava/lang/String;)V"); + logging_utils_get_did_touch_ = + env->GetStaticMethodID(logging_utils_class_, "getDidTouch", "()Z"); + logging_utils_get_log_file_ = env->GetStaticMethodID( + logging_utils_class_, "getLogFile", "()Ljava/lang/String;"); + logging_utils_start_log_file_ = + env->GetStaticMethodID(logging_utils_class_, "startLogFile", + "(Landroid/app/Activity;Ljava/lang/String;)Z"); + + env->CallStaticVoidMethod(logging_utils_class_, + logging_utils_init_log_window_, GetActivity()); + } + + void AppendText(const char* text) { + if (logging_utils_class_ == 0) return; // haven't been initted yet + JNIEnv* env = GetJniEnv(); + assert(env); + jstring text_string = env->NewStringUTF(text); + env->CallStaticVoidMethod(logging_utils_class_, logging_utils_add_log_text_, + text_string); + env->DeleteLocalRef(text_string); + } + + bool DidTouch() { + if (logging_utils_class_ == 0) return false; // haven't been initted yet + JNIEnv* env = GetJniEnv(); + assert(env); + return env->CallStaticBooleanMethod(logging_utils_class_, + logging_utils_get_did_touch_); + } + + bool IsLoggingToFile() { + if (logging_utils_class_ == 0) return false; // haven't been initted yet + JNIEnv* env = GetJniEnv(); + assert(env); + jobject file_uri = env->CallStaticObjectMethod(logging_utils_class_, + logging_utils_get_log_file_); + if (file_uri == nullptr) { + return false; + } else { + env->DeleteLocalRef(file_uri); + return true; + } + } + + bool StartLoggingToFile(const char* path) { + if (logging_utils_class_ == 0) return false; // haven't been initted yet + JNIEnv* env = GetJniEnv(); + assert(env); + jstring path_string = env->NewStringUTF(path); + jboolean b = env->CallStaticBooleanMethod(logging_utils_class_, + logging_utils_start_log_file_, + GetActivity(), path_string); + env->DeleteLocalRef(path_string); + return b ? true : false; + } + + private: + jclass logging_utils_class_; + jmethodID logging_utils_add_log_text_; + jmethodID logging_utils_init_log_window_; + jmethodID logging_utils_get_did_touch_; + jmethodID logging_utils_get_log_file_; + jmethodID logging_utils_start_log_file_; +}; + +LoggingUtilsData* g_logging_utils_data; + +// Checks if a JNI exception has happened, and if so, logs it to the console. +void CheckJNIException() { + JNIEnv* env = GetJniEnv(); + if (env->ExceptionCheck()) { + // Get the exception text. + jthrowable exception = env->ExceptionOccurred(); + env->ExceptionClear(); + + // Convert the exception to a string. + jclass object_class = env->FindClass("java/lang/Object"); + jmethodID toString = + env->GetMethodID(object_class, "toString", "()Ljava/lang/String;"); + jstring s = (jstring)env->CallObjectMethod(exception, toString); + const char* exception_text = env->GetStringUTFChars(s, nullptr); + + // Log the exception text. + __android_log_print(ANDROID_LOG_INFO, TESTAPP_NAME, + "-------------------JNI exception:"); + __android_log_print(ANDROID_LOG_INFO, TESTAPP_NAME, "%s", exception_text); + __android_log_print(ANDROID_LOG_INFO, TESTAPP_NAME, "-------------------"); + + // Also, assert fail. + assert(false); + + // In the event we didn't assert fail, clean up. + env->ReleaseStringUTFChars(s, exception_text); + env->DeleteLocalRef(s); + env->DeleteLocalRef(exception); + } +} + +// Log a message that can be viewed in "adb logcat". +void LogMessageV(bool suppress, const char* format, va_list list) { + static const int kLineBufferSize = 1024; + char buffer[kLineBufferSize + 2]; + + int string_len = vsnprintf(buffer, kLineBufferSize, format, list); + string_len = string_len < kLineBufferSize ? string_len : kLineBufferSize; + // append a linebreak to the buffer: + buffer[string_len] = '\n'; + buffer[string_len + 1] = '\0'; + + if (GetPreserveFullLog()) { + AddToFullLog(buffer); + } + if (!suppress) { + fputs(buffer, stdout); + fflush(stdout); + } +} + +void LogMessage(const char* format, ...) { + va_list list; + va_start(list, format); + LogMessageV(false, format, list); + va_end(list); +} + +static bool g_save_full_log = false; +static std::vector g_full_logs; // NOLINT + +void AddToFullLog(const char* str) { g_full_logs.push_back(std::string(str)); } + +bool GetPreserveFullLog() { return g_save_full_log; } +void SetPreserveFullLog(bool b) { g_save_full_log = b; } + +void ClearFullLog() { g_full_logs.clear(); } + +void OutputFullLog() { + for (int i = 0; i < g_full_logs.size(); ++i) { + fputs(g_full_logs[i].c_str(), stdout); + } + fflush(stdout); + ClearFullLog(); +} + +// Log a message that can be viewed in the console. +void AddToTextView(const char* str) { + app_framework::g_logging_utils_data->AppendText(str); + CheckJNIException(); +} + +// Get the JNI environment. +JNIEnv* GetJniEnv() { + JavaVM* vm = g_app_state->activity->vm; + JNIEnv* env; + jint result = vm->AttachCurrentThread(&env, nullptr); + return result == JNI_OK ? env : nullptr; +} + +bool IsLoggingToFile() { + return app_framework::g_logging_utils_data->IsLoggingToFile(); +} + +bool StartLoggingToFile(const char* path) { + return app_framework::g_logging_utils_data->StartLoggingToFile(path); +} + +// Remove all lines starting with these strings. +static const char* const filter_lines[] = {"referenceTable ", nullptr}; + +bool should_filter(const char* str) { + for (int i = 0; filter_lines[i] != nullptr; ++i) { + if (strncmp(str, filter_lines[i], strlen(filter_lines[i])) == 0) + return true; + } + return false; +} + +void* stdout_logger(void* filedes_ptr) { + int fd = reinterpret_cast(filedes_ptr)[0]; + static std::string buffer; + char bufchar; + while (int n = read(fd, &bufchar, 1)) { + if (bufchar == '\0') { + break; + } else if (bufchar == '\n') { + if (!should_filter(buffer.c_str())) { + __android_log_print(ANDROID_LOG_INFO, TESTAPP_NAME, "%s", + buffer.c_str()); + buffer = buffer + bufchar; // Add the newline + app_framework::AddToTextView(buffer.c_str()); + } + buffer.clear(); + } else { + buffer = buffer + bufchar; + } + } + JavaVM* jvm; + if (app_framework::GetJniEnv()->GetJavaVM(&jvm) == 0) { + jvm->DetachCurrentThread(); + } + return nullptr; +} + +struct FunctionData { + void* (*func)(void*); + void* data; +}; + +static void* CallFunction(void* bg_void) { + FunctionData* bg = reinterpret_cast(bg_void); + void* (*func)(void*) = bg->func; + void* data = bg->data; + // Clean up the data that was passed to us. + delete bg; + // Call the background function. + void* result = func(data); + // Then clean up the Java thread. + JavaVM* jvm; + if (app_framework::GetJniEnv()->GetJavaVM(&jvm) == 0) { + jvm->DetachCurrentThread(); + } + return result; +} + +void RunOnBackgroundThread(void* (*func)(void*), void* data) { + pthread_t thread; + // Rather than running pthread_create(func, data), we must package them into a + // struct, because the c++ thread needs to clean up the JNI thread after it + // finishes. + FunctionData* bg = new FunctionData; + bg->func = func; + bg->data = data; + pthread_create(&thread, nullptr, CallFunction, bg); + pthread_detach(thread); +} + +// Vars that we need available for reading text from the user. +class TextEntryFieldData { + public: + TextEntryFieldData() + : text_entry_field_class_(nullptr), text_entry_field_read_text_(0) {} + + ~TextEntryFieldData() { + JNIEnv* env = GetJniEnv(); + assert(env); + if (text_entry_field_class_) { + env->DeleteGlobalRef(text_entry_field_class_); + } + } + + void Init() { + JNIEnv* env = GetJniEnv(); + assert(env); + + jclass text_entry_field_class = FindClass( + env, GetActivity(), "com/google/firebase/example/TextEntryField"); + if (text_entry_field_class == 0) { + // No text entry allowed in this testapp, the Java class is not loaded. + return; + } + + // Need to store as global references so it don't get moved during garbage + // collection. + text_entry_field_class_ = + static_cast(env->NewGlobalRef(text_entry_field_class)); + env->DeleteLocalRef(text_entry_field_class); + + static const JNINativeMethod kNativeMethods[] = { + {"nativeSleep", "(I)Z", reinterpret_cast(ProcessEvents)}}; + env->RegisterNatives(text_entry_field_class_, kNativeMethods, + sizeof(kNativeMethods) / sizeof(kNativeMethods[0])); + text_entry_field_read_text_ = env->GetStaticMethodID( + text_entry_field_class_, "readText", + "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;" + "Ljava/lang/String;)Ljava/lang/String;"); + } + + // Call TextEntryField.readText(), which shows a text entry dialog and spins + // until the user enters some text (or cancels). If the user cancels, returns + // an empty string. + std::string ReadText(const char* title, const char* message, + const char* placeholder) { + if (text_entry_field_class_ == 0) { + LogMessage( + "ERROR: ReadText() failed, no TextEntryField Java class is loaded."); + return ""; // Haven't been initialized. + } + JNIEnv* env = GetJniEnv(); + assert(env); + jstring title_string = env->NewStringUTF(title); + jstring message_string = env->NewStringUTF(message); + jstring placeholder_string = env->NewStringUTF(placeholder); + jobject result_string = env->CallStaticObjectMethod( + text_entry_field_class_, text_entry_field_read_text_, GetActivity(), + title_string, message_string, placeholder_string); + env->DeleteLocalRef(title_string); + env->DeleteLocalRef(message_string); + env->DeleteLocalRef(placeholder_string); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + if (result_string == nullptr) { + // Check if readText() returned null, which will be the case if an + // exception occurred or if TextEntryField returned null for some reason. + return ""; + } + const char* result_buffer = + env->GetStringUTFChars(static_cast(result_string), 0); + std::string result(result_buffer); + env->ReleaseStringUTFChars(static_cast(result_string), + result_buffer); + return result; + } + + private: + jclass text_entry_field_class_; + jmethodID text_entry_field_read_text_; +}; + +TextEntryFieldData* g_text_entry_field_data; + +// Use a Java class, TextEntryField, to prompt the user to enter some text. +// This function blocks until text was entered or the dialog was canceled. +// If the user cancels, returns an empty string. +std::string ReadTextInput(const char* title, const char* message, + const char* placeholder) { + assert(g_text_entry_field_data); + return g_text_entry_field_data->ReadText(title, message, placeholder); +} + +void SetEnvironmentVariableFromStringExtra(JNIEnv* env, const char* extra_name, + jobject intent) { + jclass intent_class = env->GetObjectClass(intent); + jmethodID get_string_extra = env->GetMethodID( + intent_class, "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;"); + env->DeleteLocalRef(intent_class); + + jstring extra_name_jstring = env->NewStringUTF(extra_name); + jstring extra_value_jstring = (jstring)env->CallObjectMethod( + intent, get_string_extra, extra_name_jstring); + env->DeleteLocalRef(extra_name_jstring); + + if (extra_value_jstring != nullptr) { + const char* extra_value = + env->GetStringUTFChars(extra_value_jstring, nullptr); + setenv(extra_name, extra_value, /*overwrite=*/1); + env->ReleaseStringUTFChars(extra_value_jstring, extra_value); + env->DeleteLocalRef(extra_value_jstring); + } +} + +void SetExtrasAsEnvironmentVariables() { + JNIEnv* env = app_framework::GetJniEnv(); + jobject activity = app_framework::GetActivity(); + + jclass activity_class = env->GetObjectClass(activity); + jmethodID get_intent = env->GetMethodID(activity_class, "getIntent", + "()Landroid/content/Intent;"); + env->DeleteLocalRef(activity_class); + + jobject intent = env->CallObjectMethod(activity, get_intent); + SetEnvironmentVariableFromStringExtra(env, "USE_FIRESTORE_EMULATOR", intent); + SetEnvironmentVariableFromStringExtra(env, "FIRESTORE_EMULATOR_PORT", intent); + + env->DeleteLocalRef(intent); +} + +} // namespace app_framework + +// Execute common_main(), flush pending events and finish the activity. +extern "C" void android_main(struct android_app* state) { + // native_app_glue spawns a new thread, calling android_main() when the + // activity onStart() or onRestart() methods are called. This code handles + // the case where we're re-entering this method on a different thread by + // signalling the existing thread to exit, waiting for it to complete before + // reinitializing the application. + if (g_started) { + g_restarted = true; + // Wait for the existing thread to exit. + pthread_mutex_lock(&g_started_mutex); + pthread_mutex_unlock(&g_started_mutex); + } else { + g_started_mutex = PTHREAD_MUTEX_INITIALIZER; + } + pthread_mutex_lock(&g_started_mutex); + g_started = true; + + // Save native app glue state and setup a callback to track the state. + g_destroy_requested = false; + g_app_state = state; + g_app_state->onAppCmd = OnAppCmd; + + // Create the logging display. + app_framework::g_logging_utils_data = new app_framework::LoggingUtilsData(); + app_framework::g_logging_utils_data->Init(); + + // Create the text entry dialog. + app_framework::g_text_entry_field_data = + new app_framework::TextEntryFieldData(); + app_framework::g_text_entry_field_data->Init(); + + // Pipe stdout to AddToTextView so we get the gtest output. + int filedes[2]; + assert(pipe(filedes) != -1); + assert(dup2(filedes[1], STDOUT_FILENO) != -1); + pthread_t thread; + pthread_create(&thread, nullptr, app_framework::stdout_logger, + reinterpret_cast(filedes)); + + app_framework::SetExtrasAsEnvironmentVariables(); + + // Execute cross platform entry point. + // Copy the app name into a non-const array, as googletest requires that + // main() take non-const char* argv[] so it can modify the arguments. + char* argv[1]; + argv[0] = new char[strlen(TESTAPP_NAME) + 1]; + strcpy(argv[0], TESTAPP_NAME); // NOLINT + int return_value = common_main(1, argv); + delete[] argv[0]; + argv[0] = nullptr; + + app_framework::ProcessEvents(10); + + // Signal to stdout_logger to exit. + write(filedes[1], "\0", 1); + pthread_join(thread, nullptr); + close(filedes[0]); + close(filedes[1]); + // Pause a few seconds so you can see the results. If the user touches + // the screen during that time, don't exit until they choose to. + bool should_exit = false; + int exit_delay_seconds = + return_value ? kExitDelaySecondsIfError : kExitDelaySeconds; + do { + should_exit = app_framework::ProcessEvents(exit_delay_seconds * 1000); + } while (app_framework::g_logging_utils_data->DidTouch() && !should_exit); + + // Clean up logging display. + delete app_framework::g_logging_utils_data; + app_framework::g_logging_utils_data = nullptr; + + // Finish the activity. + if (!g_restarted) ANativeActivity_finish(state->activity); + + g_app_state->activity->vm->DetachCurrentThread(); + g_started = false; + g_restarted = false; + pthread_mutex_unlock(&g_started_mutex); +} diff --git a/app/integration_test_internal/src/android/android_firebase_test_framework.cc b/app/integration_test_internal/src/android/android_firebase_test_framework.cc new file mode 100644 index 0000000000..12c092f2d9 --- /dev/null +++ b/app/integration_test_internal/src/android/android_firebase_test_framework.cc @@ -0,0 +1,225 @@ +// Copyright 2019 Google Inc. 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 "firebase_test_framework.h" // NOLINT + +namespace firebase_test_framework { + +using app_framework::LogDebug; +using app_framework::LogError; + +// Blocking HTTP request helper function. +static bool SendHttpRequest(const char* url, + const std::map& headers, + const std::string* post_body, int* response_code, + std::string* response_str) { + JNIEnv* env = app_framework::GetJniEnv(); + jobject activity = app_framework::GetActivity(); + jclass simple_http_request_class = app_framework::FindClass( + env, activity, "com/google/firebase/example/SimpleHttpRequest"); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + jmethodID constructor = env->GetMethodID(simple_http_request_class, "", + "(Ljava/lang/String;)V"); + jmethodID set_post_data = + env->GetMethodID(simple_http_request_class, "setPostData", "([B)V"); + jmethodID add_header = + env->GetMethodID(simple_http_request_class, "addHeader", + "(Ljava/lang/String;Ljava/lang/String;)V"); + jmethodID perform = env->GetMethodID(simple_http_request_class, "perform", + "()Ljava/lang/String;"); + jmethodID get_response_code = + env->GetMethodID(simple_http_request_class, "getResponseCode", "()I"); + + jstring url_jstring = env->NewStringUTF(url); + // http_request = new SimpleHttpRequestClass(url); + jobject http_request = + env->NewObject(simple_http_request_class, constructor, url_jstring); + env->DeleteLocalRef(url_jstring); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + if (http_request) env->DeleteLocalRef(http_request); + return false; + } + // for (header : headers) { + // http_request.addHeader(header.key, header.value); + // } + for (auto i = headers.begin(); i != headers.end(); ++i) { + jstring key_jstring = env->NewStringUTF(i->first.c_str()); + jstring value_jstring = env->NewStringUTF(i->second.c_str()); + env->CallVoidMethod(http_request, add_header, key_jstring, value_jstring); + env->DeleteLocalRef(key_jstring); + env->DeleteLocalRef(value_jstring); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + if (http_request) env->DeleteLocalRef(http_request); + return false; + } + } + if (post_body != nullptr) { + // http_request.setPostBody(post_body); + jbyteArray post_body_array = env->NewByteArray(post_body->length()); + env->SetByteArrayRegion(post_body_array, 0, post_body->length(), + reinterpret_cast(post_body->c_str())); + env->CallVoidMethod(http_request, set_post_data, post_body_array); + env->DeleteLocalRef(post_body_array); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + if (http_request) env->DeleteLocalRef(http_request); + return false; + } + } + // String response = http_request.perform(); + jobject response = env->CallObjectMethod(http_request, perform); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + jstring response_jstring = static_cast(response); + // int response_code = http_request.getResponseCode(); + jint response_code_jint = env->CallIntMethod(http_request, get_response_code); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + } + LogDebug("HTTP status code %d", response_code_jint); + if (response_code) *response_code = response_code_jint; + + env->DeleteLocalRef(http_request); + if (response_jstring == nullptr) { + return false; + } + const char* response_text = env->GetStringUTFChars(response_jstring, nullptr); + LogDebug("Got response: %s", response_text); + if (response_str) *response_str = response_text; + env->ReleaseStringUTFChars(response_jstring, response_text); + env->DeleteLocalRef(response); + return true; +} + +// Blocking HTTP request helper function, for testing only. +bool FirebaseTest::SendHttpGetRequest( + const char* url, const std::map& headers, + int* response_code, std::string* response_str) { + return SendHttpRequest(url, headers, nullptr, response_code, response_str); +} + +bool FirebaseTest::SendHttpPostRequest( + const char* url, const std::map& headers, + const std::string& post_body, int* response_code, + std::string* response_str) { + return SendHttpRequest(url, headers, &post_body, response_code, response_str); +} + +bool FirebaseTest::OpenUrlInBrowser(const char* url) { + JNIEnv* env = app_framework::GetJniEnv(); + jobject activity = app_framework::GetActivity(); + jclass simple_http_request_class = app_framework::FindClass( + env, activity, "com/google/firebase/example/SimpleHttpRequest"); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + jmethodID open_url = + env->GetStaticMethodID(simple_http_request_class, "openUrlInBrowser", + "(Ljava/lang/String;Landroid/app/Activity;)V"); + jstring url_jstring = env->NewStringUTF(url); + env->CallStaticVoidMethod(simple_http_request_class, open_url, url_jstring, + activity); + env->DeleteLocalRef(url_jstring); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + return true; +} + +bool FirebaseTest::SetPersistentString(const char* key, const char* value) { + if (key == nullptr) { + LogError("SetPersistentString: null key is not allowed."); + return false; + } + JNIEnv* env = app_framework::GetJniEnv(); + jobject activity = app_framework::GetActivity(); + jclass simple_persistent_storage_class = app_framework::FindClass( + env, activity, "com/google/firebase/example/SimplePersistentStorage"); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + jmethodID set_string = env->GetStaticMethodID( + simple_persistent_storage_class, "setString", + "(Landroid/app/Activity;Ljava/lang/String;Ljava/lang/String;)V"); + jstring key_jstring = env->NewStringUTF(key); + jstring value_jstring = value ? env->NewStringUTF(value) : nullptr; + env->CallStaticVoidMethod(simple_persistent_storage_class, set_string, + activity, key_jstring, value_jstring); + env->DeleteLocalRef(key_jstring); + if (value_jstring) { + env->DeleteLocalRef(value_jstring); + } + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + return true; +} + +bool FirebaseTest::GetPersistentString(const char* key, + std::string* value_out) { + JNIEnv* env = app_framework::GetJniEnv(); + jobject activity = app_framework::GetActivity(); + jclass simple_persistent_storage_class = app_framework::FindClass( + env, activity, "com/google/firebase/example/SimplePersistentStorage"); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + jmethodID get_string = env->GetStaticMethodID( + simple_persistent_storage_class, "getString", + "(Landroid/app/Activity;Ljava/lang/String;)Ljava/lang/String;"); + jstring key_jstring = env->NewStringUTF(key); + jstring value_jstring = static_cast(env->CallStaticObjectMethod( + simple_persistent_storage_class, get_string, activity, key_jstring)); + env->DeleteLocalRef(key_jstring); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + if (value_jstring) { + env->DeleteLocalRef(value_jstring); + } + return false; + } + if (value_jstring == nullptr) { + return false; + } + const char* value_text = env->GetStringUTFChars(value_jstring, nullptr); + if (value_out) *value_out = std::string(value_text); + env->ReleaseStringUTFChars(value_jstring, value_text); + env->DeleteLocalRef(value_jstring); + return true; +} + +} // namespace firebase_test_framework diff --git a/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java b/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java new file mode 100644 index 0000000000..a8fabf28b1 --- /dev/null +++ b/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java @@ -0,0 +1,163 @@ +// Copyright 2016 Google Inc. 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. + +package com.google.firebase.example; + +import android.app.Activity; +import android.content.Intent; +import android.graphics.Typeface; +import android.net.Uri; +import android.os.Handler; +import android.os.Looper; +import android.text.Editable; +import android.text.TextWatcher; +import android.view.MotionEvent; +import android.view.View; +import android.view.Window; +import android.widget.LinearLayout; +import android.widget.ScrollView; +import android.widget.TextView; +import java.io.DataOutputStream; +import java.io.FileNotFoundException; +import java.io.IOException; + +/** + * A utility class, encapsulating the data and methods required to log arbitrary + * text to the screen, via a non-editable TextView. + */ +public class LoggingUtils { + private static TextView textView = null; + private static ScrollView scrollView = null; + // Tracks if the log window was touched at least once since the testapp was started. + private static boolean didTouch = false; + // If a test log file is specified, this is the log file's URI... + private static Uri logFile = null; + // ...and this is the stream to write to. + private static DataOutputStream logFileStream = null; + + /** Initializes the log window with the given activity and a monospace font. */ + public static void initLogWindow(Activity activity) { + initLogWindow(activity, true); + } + + /** + * Initializes the log window with the given activity, specifying whether to use a monospaced + * font. + */ + public static void initLogWindow(Activity activity, boolean monospace) { + LinearLayout linearLayout = new LinearLayout(activity); + scrollView = new ScrollView(activity); + textView = new TextView(activity); + textView.setTag("Logger"); + if (monospace) { + textView.setTypeface(Typeface.MONOSPACE); + textView.setTextSize(10); + } + linearLayout.addView(scrollView); + scrollView.addView(textView); + Window window = activity.getWindow(); + window.takeSurface(null); + window.setContentView(linearLayout); + + // Force the TextView to stay scrolled to the bottom. + textView.addTextChangedListener(new TextWatcher() { + @Override + public void afterTextChanged(Editable e) { + // If the user never interacted with the screen, scroll to bottom. + if (scrollView != null && !didTouch) { + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + scrollView.fullScroll(View.FOCUS_DOWN); + } + }); + } + } + + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} + + @Override + public void onTextChanged(CharSequence s, int start, int count, int after) {} + }); + textView.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View v, MotionEvent event) { + didTouch = true; + return false; + } + }); + + Intent launchIntent = activity.getIntent(); + // Check if we are running on Firebase Test Lab, and set up a log file if we are. + if (launchIntent.getAction().equals("com.google.intent.action.TEST_LOOP")) { + startLogFile(activity, launchIntent.getData().toString()); + } + } + + /** Adds some text to the log window. */ + public static void addLogText(final String text) { + new Handler(Looper.getMainLooper()).post(new Runnable() { + @Override + public void run() { + if (textView != null) { + textView.append(text); + if (logFileStream != null) { + try { + logFileStream.writeBytes(text); + } catch (IOException e) { + // It doesn't really matter if something went wrong writing to the test log. + } + } + } + } + }); + } + + /** + * Returns true if the user ever touched the log window during this run (to scroll it or + * otherwise), false if they never have. + */ + public static boolean getDidTouch() { + return didTouch; + } + + /** Start logging to a file at the given URI string. Used in TEST_LOOP mode. */ + public static boolean startLogFile(Activity activity, String logFileUri) { + logFile = Uri.parse(logFileUri); + if (logFile != null) { + try { + logFileStream = + new DataOutputStream(activity.getContentResolver().openOutputStream(logFile)); + } catch (FileNotFoundException e) { + addLogText("Failed to open log file " + logFile.getEncodedPath() + ": " + e); + return false; + } + return true; + } + return false; + } + + /** + * If the logger is logging to a file in local storage, return the URI for that file (which you + * can later pass into startLogFile in the future), otherwise return null if not logging to file. + */ + public static String getLogFile() { + if (logFile != null && logFileStream != null) { + return logFile.toString(); + } else { + return null; + } + } +} diff --git a/app/integration_test_internal/src/android/java/com/google/firebase/example/SimpleHttpRequest.java b/app/integration_test_internal/src/android/java/com/google/firebase/example/SimpleHttpRequest.java new file mode 100644 index 0000000000..d56a2d6763 --- /dev/null +++ b/app/integration_test_internal/src/android/java/com/google/firebase/example/SimpleHttpRequest.java @@ -0,0 +1,118 @@ +// Copyright 2019 Google Inc. 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. + +package com.google.firebase.example; + +import android.app.Activity; +import android.content.Intent; +import android.net.Uri; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +/** + * A simple client for performing synchronous HTTP/HTTPS requests, used for testing purposes only. + */ +public final class SimpleHttpRequest { + private URL url; + private final HashMap headers; + private byte[] postData; + private int responseCode; + /** Create a new SimpleHttpRequest with a default URL. */ + public SimpleHttpRequest(String urlString) throws MalformedURLException { + this.headers = new HashMap<>(); + this.postData = null; + setUrl(urlString); + } + /** Set the URL to the given string, or null if it can't be parsed. */ + public void setUrl(String urlString) throws MalformedURLException { + this.url = new URL(urlString); + } + /** Get the previously-set URL. */ + public URL getUrl() { + return this.url; + } + /** Set the HTTP POST body, and set this request to a POST request. */ + public void setPostData(byte[] postData) { + this.postData = postData; + } + /** Clear out the HTTP POST body, setting this request back to a GET request. */ + public void clearPostData() { + this.postData = null; + } + /** Add a header key-value pair. */ + public void addHeader(String key, String value) { + this.headers.put(key, value); + } + /** Clear previously-set headers. */ + public void clearHeaders() { + this.headers.clear(); + } + + /** Get the response code returned by the server, after perform() is finished. */ + public int getResponseCode() { + return this.responseCode; + } + + /** + * Perform a HTTP request to the given URL, with the given headers. If postData is non-null, use a + * POST request, else use a GET request. This method blocks until getting a response. + */ + public String perform() throws IOException { + if (this.url == null) { + return null; + } + + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setRequestMethod(postData != null ? "POST" : "GET"); + for (Map.Entry entry : this.headers.entrySet()) { + connection.setRequestProperty(entry.getKey(), entry.getValue()); + } + if (this.postData != null) { + connection.setDoOutput(true); + connection.setFixedLengthStreamingMode(postData.length); + connection.getOutputStream().write(postData); + } + responseCode = connection.getResponseCode(); + StringBuilder result = new StringBuilder(); + BufferedReader inputStream = + new BufferedReader(new InputStreamReader(connection.getInputStream())); + String line; + while ((line = inputStream.readLine()) != null) { + result.append(line); + } + connection.disconnect(); + return result.toString(); + } + + /** A one-off helper method to simply open a URL in a browser window. */ + public static void openUrlInBrowser(String urlString, Activity activity) { + if (urlString.startsWith("data:")) { + // Use makeMainSelectorActivity to handle data: URLs. + activity.startActivity( + Intent.makeMainSelectorActivity(Intent.ACTION_MAIN, Intent.CATEGORY_APP_BROWSER) + .setData(Uri.parse(urlString))); + } else { + // Otherwise use the default intent handler for the URL. + Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setData(Uri.parse(urlString)); + activity.startActivity(intent); + } + } +} diff --git a/app/integration_test_internal/src/android/java/com/google/firebase/example/SimplePersistentStorage.java b/app/integration_test_internal/src/android/java/com/google/firebase/example/SimplePersistentStorage.java new file mode 100644 index 0000000000..62d596c678 --- /dev/null +++ b/app/integration_test_internal/src/android/java/com/google/firebase/example/SimplePersistentStorage.java @@ -0,0 +1,45 @@ +// Copyright 2019 Google Inc. 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. + +package com.google.firebase.example; + +import android.app.Activity; +import android.content.SharedPreferences; + +/** Static utilties for saving and loading shared preference strings. */ +public final class SimplePersistentStorage { + private static final String PREF_NAME = "firebase_automated_test"; + /** + * Sets a given key's value in persistent storage to the given string. Specify null to delete the + * key. + */ + public static void setString(Activity activity, String key, String value) { + SharedPreferences pref = activity.getSharedPreferences(PREF_NAME, 0); + SharedPreferences.Editor editor = pref.edit(); + if (value != null) { + editor.putString(key, value); + } else { + editor.remove(key); + } + editor.commit(); + } + + /** Gets the value of the given key in persistent storage, or null if the key is not found. */ + public static String getString(Activity activity, String key) { + SharedPreferences pref = activity.getSharedPreferences(PREF_NAME, 0); + return pref.getString(key, null); + } + + private SimplePersistentStorage() {} +} diff --git a/app/integration_test_internal/src/android/java/com/google/firebase/example/TextEntryField.java b/app/integration_test_internal/src/android/java/com/google/firebase/example/TextEntryField.java new file mode 100644 index 0000000000..940b5e19ca --- /dev/null +++ b/app/integration_test_internal/src/android/java/com/google/firebase/example/TextEntryField.java @@ -0,0 +1,100 @@ +// Copyright 2016 Google Inc. 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. + +package com.google.firebase.example; + +import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; +import android.widget.EditText; + +/** + * A utility class, with a method to prompt the user to enter a line of text, and a native method to + * sleep for a given number of milliseconds. + */ +public class TextEntryField { + private static Object lock = new Object(); + private static String resultText = null; + + /** + * Prompt the user with a text field, blocking until the user fills it out, then returns the text + * they entered. If the user cancels, returns an empty string. + */ + public static String readText( + final Activity activity, final String title, final String message, final String placeholder) { + resultText = null; + // Show the alert dialog on the main thread. + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + AlertDialog.Builder alertBuilder = new AlertDialog.Builder(activity); + alertBuilder.setTitle(title); + alertBuilder.setMessage(message); + + // Set up and add the text field. + final EditText textField = new EditText(activity); + textField.setHint(placeholder); + alertBuilder.setView(textField); + + alertBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int whichButton) { + synchronized (lock) { + resultText = textField.getText().toString(); + } + } + }); + + alertBuilder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int whichButton) { + synchronized (lock) { + resultText = ""; + } + } + }); + + alertBuilder.setOnCancelListener(new DialogInterface.OnCancelListener() { + @Override + public void onCancel(DialogInterface dialog) { + synchronized (lock) { + resultText = ""; + } + } + }); + alertBuilder.show(); + } + }); + + // In our original thread, wait for the dialog to finish, then return its result. + while (true) { + // Pause a second, waiting for the user to enter text. + if (nativeSleep(1000)) { + // If this returns true, an exit was requested. + return ""; + } + synchronized (lock) { + if (resultText != null) { + // resultText will be set to non-null when a dialog button is clicked, or the dialog + // is canceled. + String result = resultText; + resultText = null; // Consume the result. + return result; + } + } + } + } + + private static native boolean nativeSleep(int milliseconds); +} diff --git a/app/integration_test_internal/src/app_framework.cc b/app/integration_test_internal/src/app_framework.cc new file mode 100644 index 0000000000..bed0d01526 --- /dev/null +++ b/app/integration_test_internal/src/app_framework.cc @@ -0,0 +1,96 @@ +// Copyright 2019 Google Inc. 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 "app_framework.h" // NOLINT + +#include +#include + +#include +#include +#include +#include +#include + +namespace app_framework { + +// Base logging methods, implemented by platform-specific files. +void LogMessage(const char* format, ...); +void LogMessageV(bool filtered, const char* format, va_list list); + +enum LogLevel g_log_level = kInfo; + +void SetLogLevel(LogLevel log_level) { g_log_level = log_level; } + +LogLevel GetLogLevel() { return g_log_level; } + +void LogDebug(const char* format, ...) { + va_list list; + va_start(list, format); + std::string format_str("DEBUG: "); + format_str += format; + app_framework::LogMessageV(g_log_level > kDebug, format_str.c_str(), list); + va_end(list); +} + +void LogInfo(const char* format, ...) { + va_list list; + va_start(list, format); + std::string format_str("INFO: "); + format_str += format; + app_framework::LogMessageV(g_log_level > kInfo, format_str.c_str(), list); + va_end(list); +} + +void LogWarning(const char* format, ...) { + va_list list; + va_start(list, format); + std::string format_str("WARNING: "); + format_str += format; + app_framework::LogMessageV(g_log_level > kWarning, format_str.c_str(), list); + va_end(list); +} + +void LogError(const char* format, ...) { + va_list list; + va_start(list, format); + std::string format_str("ERROR: "); + format_str += format; + app_framework::LogMessageV(g_log_level > kError, format_str.c_str(), list); + va_end(list); +} + +#if !defined(_WIN32) // Windows requires its own version of time-handling code. +int64_t GetCurrentTimeInMicroseconds() { + struct timeval now; + gettimeofday(&now, nullptr); + return now.tv_sec * 1000000LL + now.tv_usec; +} +#endif // !defined(_WIN32) + +#if defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +void ChangeToFileDirectory(const char*) {} +#endif // defined(__ANDROID__) || (defined(TARGET_OS_IPHONE) && + // TARGET_OS_IPHONE) + +#if defined(_WIN32) +#define stat _stat +#endif // defined(_WIN32) + +bool FileExists(const char* file_path) { + struct stat s; + return stat(file_path, &s) == 0; +} + +} // namespace app_framework diff --git a/app/integration_test_internal/src/app_framework.h b/app/integration_test_internal/src/app_framework.h new file mode 100644 index 0000000000..580b3bd939 --- /dev/null +++ b/app/integration_test_internal/src/app_framework.h @@ -0,0 +1,131 @@ +// Copyright 2016 Google Inc. 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. + +#ifndef APP_FRAMEWORK_H_ // NOLINT +#define APP_FRAMEWORK_H_ // NOLINT + +#include +#include + +#if defined(__APPLE__) +#include +#endif // defined(__APPLE__) + +#if !defined(_WIN32) +#include +#endif +#if defined(__ANDROID__) +#include +#include +#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +extern "C" { +#include +} // extern "C" +#endif // platforms + +// Defined using -DTESTAPP_NAME=some_app_name when compiling this +// file. +#ifndef TESTAPP_NAME +#define TESTAPP_NAME "android_main" +#endif // TESTAPP_NAME + +extern "C" int common_main(int argc, char* argv[]); + +namespace app_framework { + +// Platform-independent logging methods. +enum LogLevel { kDebug = 0, kInfo, kWarning, kError }; +void SetLogLevel(LogLevel log_level); +LogLevel GetLogLevel(); +void LogError(const char* format, ...); +void LogWarning(const char* format, ...); +void LogInfo(const char* format, ...); +void LogDebug(const char* format, ...); + +// Set this to true to have all log messages saved regardless of loglevel; you +// can output them later via OutputFullLog or clear them via ClearFullLog. +void SetPreserveFullLog(bool b); +// Get the value previously set by SetPreserveFullLog. +bool GetPreserveFullLog(); + +// Add a line of text to the "full log" to be output via OutputFullLog. +void AddToFullLog(const char* str); + +// Clear the logs that were saved. +void ClearFullLog(); + +// Output the full saved logs (if you SetPreserveFullLog(true) earlier). +void OutputFullLog(); + +// Platform-independent method to flush pending events for the main thread. +// Returns true when an event requesting program-exit is received. +bool ProcessEvents(int msec); + +// Returns a path to a writable directory for the given platform. +std::string PathForResource(); + +// Returns the number of microseconds since the epoch. +int64_t GetCurrentTimeInMicroseconds(); + +// On desktop, change the current working directory to the directory +// containing the specified file. On mobile, this is a no-op. +void ChangeToFileDirectory(const char* file_path); + +// Return whether the file exists. +bool FileExists(const char* file_path); + +// WindowContext represents the handle to the parent window. Its type +// (and usage) vary based on the OS. +#if defined(__ANDROID__) +typedef jobject WindowContext; // A jobject to the Java Activity. +#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +typedef id WindowContext; // A pointer to an iOS UIView. +#else +typedef void* WindowContext; // A void* for any other environments. +#endif + +#if defined(__ANDROID__) +// Get the JNI environment. +JNIEnv* GetJniEnv(); +// Get the activity. +jobject GetActivity(); +// Find a class, attempting to load the class if it's not found. +jclass FindClass(JNIEnv* env, jobject activity_object, const char* class_name); +#endif // defined(__ANDROID__) + +// Returns true if the logger is currently logging to a file. +bool IsLoggingToFile(); + +// Start logging to the given file. You only need to do this if the app has been +// restarted since it was initially run in test loop mode. +bool StartLoggingToFile(const char* path); + +// Returns a variable that describes the window context for the app. On Android +// this will be a jobject pointing to the Activity. On iOS, it's an id pointing +// to the root view of the view controller. +WindowContext GetWindowContext(); + +// Run the given function on a detached background thread. +void RunOnBackgroundThread(void* (*func)(void* data), void* data); + +// Prompt the user with a dialog box to enter a line of text, blocking +// until the user enters the text or the dialog box is canceled. +// Returns the text that was entered, or an empty string if the user +// canceled. +std::string ReadTextInput(const char* title, const char* message, + const char* placeholder); + +} // namespace app_framework + +#endif // APP_FRAMEWORK_H_ // NOLINT diff --git a/app/integration_test_internal/src/desktop/desktop_app_framework.cc b/app/integration_test_internal/src/desktop/desktop_app_framework.cc new file mode 100644 index 0000000000..0b90cd4bfa --- /dev/null +++ b/app/integration_test_internal/src/desktop/desktop_app_framework.cc @@ -0,0 +1,224 @@ +// Copyright 2016 Google Inc. 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 // NOLINT +#include + +#ifdef _WIN32 +#include +#define chdir _chdir +#else +#include +#include +#include +#endif // _WIN32 + +#ifdef _WIN32 +#include +#endif // _WIN32 + +#include "app_framework.h" // NOLINT + +static bool quit = false; + +#ifdef _WIN32 +static BOOL WINAPI SignalHandler(DWORD event) { + if (!(event == CTRL_C_EVENT || event == CTRL_BREAK_EVENT)) { + return FALSE; + } + quit = true; + return TRUE; +} +#else +static void SignalHandler(int /* ignored */) { quit = true; } +#endif // _WIN32 + +namespace app_framework { + +bool ProcessEvents(int msec) { +#ifdef _WIN32 + Sleep(msec); +#else + usleep(msec * 1000); +#endif // _WIN32 + return quit; +} + +std::string PathForResource() { +#if defined(_WIN32) + // On Windows we should hvae TEST_TMPDIR or TEMP or TMP set. + char buf[MAX_PATH + 1]; + if (GetEnvironmentVariable("TEST_TMPDIR", buf, sizeof(buf)) || + GetEnvironmentVariable("TEMP", buf, sizeof(buf)) || + GetEnvironmentVariable("TMP", buf, sizeof(buf))) { + std::string path(buf); + // Add trailing slash. + if (path[path.size() - 1] != '\\') path += '\\'; + return path; + } +#else + // Linux and OS X should either have the TEST_TMPDIR environment variable set + // or use /tmp. + if (const char* value = getenv("TEST_TMPDIR")) { + std::string path(value); + // Add trailing slash. + if (path[path.size() - 1] != '/') path += '/'; + return path; + } + struct stat s; + if (stat("/tmp", &s) == 0) { + if (s.st_mode & S_IFDIR) { + return std::string("/tmp/"); + } + } +#endif // defined(_WIN32) + // If nothing else, use the current directory. + return std::string(); +} +void LogMessageV(bool suppress, const char* format, va_list list) { + // Save the log to the Full Logs list regardless of whether it should be + // suppressed. + static const int kLineBufferSize = 1024; + char buffer[kLineBufferSize + 2]; + int string_len = vsnprintf(buffer, kLineBufferSize, format, list); + string_len = string_len < kLineBufferSize ? string_len : kLineBufferSize; + // Append a linebreak to the buffer. + buffer[string_len] = '\n'; + buffer[string_len + 1] = '\0'; + if (GetPreserveFullLog()) { + AddToFullLog(buffer); + } + if (!suppress) { + fputs(buffer, stdout); + fflush(stdout); + } +} + +void LogMessage(const char* format, ...) { + va_list list; + va_start(list, format); + LogMessageV(false, format, list); + va_end(list); +} + +static bool g_save_full_log = false; +static std::vector g_full_logs; // NOLINT +static std::mutex g_full_log_mutex; + +void AddToFullLog(const char* str) { + std::lock_guard guard(g_full_log_mutex); + g_full_logs.push_back(std::string(str)); +} + +bool GetPreserveFullLog() { return g_save_full_log; } +void SetPreserveFullLog(bool b) { g_save_full_log = b; } + +void ClearFullLog() { + std::lock_guard guard(g_full_log_mutex); + g_full_logs.clear(); +} + +void OutputFullLog() { + std::lock_guard guard(g_full_log_mutex); + for (int i = 0; i < g_full_logs.size(); ++i) { + fputs(g_full_logs[i].c_str(), stdout); + } + fflush(stdout); + g_full_logs.clear(); +} + +WindowContext GetWindowContext() { return nullptr; } + +// Change the current working directory to the directory containing the +// specified file. +void ChangeToFileDirectory(const char* file_path) { + std::string path(file_path); + std::replace(path.begin(), path.end(), '\\', '/'); + auto slash = path.rfind('/'); + if (slash != std::string::npos) { + std::string directory = path.substr(0, slash); + if (!directory.empty()) { + LogDebug("chdir %s", directory.c_str()); + chdir(directory.c_str()); + } + } +} + +#if defined(_WIN32) // The other platforms are implemented in app_framework.cc. +// Returns the number of microseconds since the epoch. +int64_t GetCurrentTimeInMicroseconds() { + FILETIME file_time; + GetSystemTimeAsFileTime(&file_time); + + ULARGE_INTEGER now; + now.LowPart = file_time.dwLowDateTime; + now.HighPart = file_time.dwHighDateTime; + + // Windows file time is expressed in 100s of nanoseconds. + // To convert to microseconds, multiply x10. + return now.QuadPart * 10LL; +} +#endif // defined(_WIN32) + +void RunOnBackgroundThread(void* (*func)(void*), void* data) { + // On desktop, use std::thread as Windows doesn't support pthreads. + std::thread thread(func, data); + thread.detach(); +} + +std::string ReadTextInput(const char* title, const char* message, + const char* placeholder) { + if (title && *title) { + int len = strlen(title); + printf("\n"); + for (int i = 0; i < len; ++i) { + printf("="); + } + printf("\n%s\n", title); + for (int i = 0; i < len; ++i) { + printf("="); + } + } + printf("\n%s", message); + if (placeholder && *placeholder) { + printf(" [%s]", placeholder); + } + printf(": "); + fflush(stdout); + std::string input_line; + std::getline(std::cin, input_line); + return input_line.empty() ? std::string(placeholder) : input_line; +} + +bool IsLoggingToFile() { return false; } + +} // namespace app_framework + +int main(int argc, char* argv[]) { +#ifdef _WIN32 + SetConsoleCtrlHandler((PHANDLER_ROUTINE)SignalHandler, TRUE); +#else + signal(SIGINT, SignalHandler); +#endif // _WIN32 + return common_main(argc, argv); +} diff --git a/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc b/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc new file mode 100644 index 0000000000..8ffbf9bb44 --- /dev/null +++ b/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc @@ -0,0 +1,52 @@ +// Copyright 2019 Google Inc. 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 "firebase_test_framework.h" // NOLINT + +namespace firebase_test_framework { + +using app_framework::LogWarning; + +bool FirebaseTest::SendHttpGetRequest( + const char* url, const std::map& headers, + int* response_code, std::string* response_str) { + LogWarning("SendHttpGetRequest is not implemented on desktop."); + return false; +} + +bool FirebaseTest::SendHttpPostRequest( + const char* url, const std::map& headers, + const std::string& post_body, int* response_code, + std::string* response_str) { + LogWarning("SendHttpPostRequest is not implemented on desktop."); + return false; +} + +bool FirebaseTest::OpenUrlInBrowser(const char* url) { + LogWarning("OpenUrlInBrowser is not implemented on desktop."); + return false; +} + +bool FirebaseTest::SetPersistentString(const char* key, const char* value) { + LogWarning("SetPersistentString is not implemented on desktop."); + return false; +} + +bool FirebaseTest::GetPersistentString(const char* key, + std::string* value_out) { + LogWarning("GetPersistentString is not implemented on desktop."); + return false; +} + +} // namespace firebase_test_framework diff --git a/app/integration_test_internal/src/empty.swift b/app/integration_test_internal/src/empty.swift new file mode 100644 index 0000000000..e1cb622251 --- /dev/null +++ b/app/integration_test_internal/src/empty.swift @@ -0,0 +1,15 @@ +// Copyright 2019 Google Inc. 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. + +// This empty Swift file is needed to ensure the Swift runtime is included. diff --git a/app/integration_test_internal/src/firebase_test_framework.cc b/app/integration_test_internal/src/firebase_test_framework.cc new file mode 100644 index 0000000000..eacafd45a4 --- /dev/null +++ b/app/integration_test_internal/src/firebase_test_framework.cc @@ -0,0 +1,389 @@ +// Copyright 2019 Google Inc. 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 "firebase_test_framework.h" // NOLINT + +#include +#include +#include +#include + +#include "firebase/future.h" + +namespace firebase { +namespace internal { +// Borrow Firebase's internal Base64 encoder and decoder. +extern bool Base64Encode(const std::string& input, std::string* output); +extern bool Base64Decode(const std::string& input, std::string* output); +} // namespace internal +} // namespace firebase + +namespace firebase_test_framework { + +int FirebaseTest::argc_ = 0; +char** FirebaseTest::argv_ = nullptr; +bool FirebaseTest::found_config_ = false; + +FirebaseTest::FirebaseTest() : app_(nullptr) {} + +FirebaseTest::~FirebaseTest() { assert(app_ == nullptr); } + +void FirebaseTest::SetUp() {} + +void FirebaseTest::TearDown() { + if (HasFailure()) { + app_framework::SetPreserveFullLog(false); + app_framework::LogError( + "Test %s failed.\nFull test log:\n%s", + ::testing::UnitTest::GetInstance()->current_test_info()->name(), + "========================================================"); + app_framework::SetPreserveFullLog(true); + app_framework::AddToFullLog( + "========================================================\n"); + app_framework::OutputFullLog(); + } else { + app_framework::ClearFullLog(); + } +} + +void FirebaseTest::FindFirebaseConfig(const char* try_directory) { +#if !defined(__ANDROID__) && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + static const char kDefaultGoogleServicesPath[] = "google-services.json"; + + if (!found_config_) { + if (try_directory[0] != '\0' && app_framework::FileExists(try_directory)) { + app_framework::ChangeToFileDirectory(try_directory); + } else if (app_framework::FileExists(kDefaultGoogleServicesPath)) { + // It's in the current directory, don't do anything. + } else { + // Try the directory the binary is in. + app_framework::ChangeToFileDirectory(argv_[0]); + } + // Only do this once. + found_config_ = true; + } +#endif // !defined(__ANDROID__) && !(defined(TARGET_OS_IPHONE) && + // TARGET_OS_IPHONE) + (void)try_directory; +} + +void FirebaseTest::InitializeApp() { + if (app_) return; // Already initialized. + + app_framework::LogDebug("Initialize Firebase App."); + +#if defined(__ANDROID__) + app_ = ::firebase::App::Create(app_framework::GetJniEnv(), + app_framework::GetActivity()); +#else + app_ = ::firebase::App::Create(); +#endif // defined(__ANDROID__) +} + +void FirebaseTest::TerminateApp() { + if (!app_) return; // Already terminated. + + app_framework::LogDebug("Shutdown Firebase App."); + delete app_; + app_ = nullptr; +} + +bool FirebaseTest::RunFlakyBlockBase(bool (*flaky_block)(void* context), + void* context, const char* name) { + // Run flaky_block(context). If it returns true, all is well, return true. + // If it returns false, something flaky failed; wait a moment and try again. + const int kRetryDelaysMs[] = {// Roughly exponential backoff for the retries. + 100, 1000, 5000, 10000, 30000}; + const int kNumAttempts = + 1 + (sizeof(kRetryDelaysMs) / sizeof(kRetryDelaysMs[0])); + + int attempt = 0; + + while (attempt < kNumAttempts) { + bool result = flaky_block(context); + if (result || (attempt == kNumAttempts - 1)) { + return result; + } + app_framework::LogDebug("RunFlakyBlock%s%s: Attempt %d failed", + *name ? " " : "", name, attempt + 1); + int delay_ms = kRetryDelaysMs[attempt]; + app_framework::ProcessEvents(delay_ms); + attempt++; + } + return false; +} + +firebase::FutureBase FirebaseTest::RunWithRetryBase( + firebase::FutureBase (*run_future)(void* context), void* context, + const char* name, int expected_error) { + // Run run_future(context), which returns a Future, then wait for that Future + // to complete. If the Future returns Invalid, or if its error() does + // not match expected_error, pause a moment and try again. + // + // In most cases, this will return the Future once it's been completed. + // However, if it reaches the last attempt, it will return immediately once + // the operation begins. This is because at this point we want to return the + // results whether or not the operation succeeds. + const int kRetryDelaysMs[] = {// Roughly exponential backoff for the retries. + 100, 1000, 5000, 10000, 30000}; + const int kNumAttempts = + 1 + (sizeof(kRetryDelaysMs) / sizeof(kRetryDelaysMs[0])); + + int attempt = 0; + firebase::FutureBase future; + + while (attempt < kNumAttempts) { + future = run_future(context); + if (attempt == kNumAttempts - 1) { + // This is the last attempt, return immediately. + break; + } + + // Wait for completion, then check status and error. + while (future.status() == firebase::kFutureStatusPending) { + app_framework::ProcessEvents(100); + } + if (future.status() != firebase::kFutureStatusComplete) { + app_framework::LogDebug( + "RunWithRetry%s%s: Attempt %d returned invalid status", + *name ? " " : "", name, attempt + 1); + } else if (future.error() != expected_error) { + app_framework::LogDebug( + "RunWithRetry%s%s: Attempt %d returned error %d, expected %d", + *name ? " " : "", name, attempt + 1, future.error(), expected_error); + } else { + // Future is completed and the error matches what's expected, no need to + // retry further. + break; + } + int delay_ms = kRetryDelaysMs[attempt]; + app_framework::LogDebug( + "RunWithRetry%s%s: Pause %d milliseconds before retrying.", + *name ? " " : "", name, delay_ms); + app_framework::ProcessEvents(delay_ms); + attempt++; + } + return future; +} + +bool FirebaseTest::WaitForCompletion(const firebase::FutureBase& future, + const char* name, int expected_error) { + app_framework::LogDebug("WaitForCompletion %s", name); + while (future.status() == firebase::kFutureStatusPending) { + app_framework::ProcessEvents(100); + } + EXPECT_EQ(future.status(), firebase::kFutureStatusComplete) + << name << " returned an invalid status."; + EXPECT_EQ(future.error(), expected_error) + << name << " returned error " << future.error() << ": " + << future.error_message(); + return (future.status() == firebase::kFutureStatusComplete && + future.error() == expected_error); +} + +bool FirebaseTest::WaitForCompletionAnyResult( + const firebase::FutureBase& future, const char* name) { + app_framework::LogDebug("WaitForCompletion %s", name); + while (future.status() == firebase::kFutureStatusPending) { + app_framework::ProcessEvents(100); + } + EXPECT_EQ(future.status(), firebase::kFutureStatusComplete) + << name << " returned an invalid status."; + return (future.status() == firebase::kFutureStatusComplete); +} + +static void VariantToStringInternal(const firebase::Variant& variant, + std::ostream& out, + const std::string& indent) { + if (variant.is_null()) { + out << "null"; + } else if (variant.is_int64()) { + out << variant.int64_value(); + } else if (variant.is_double()) { + out << variant.double_value(); + } else if (variant.is_bool()) { + out << (variant.bool_value() ? "true" : "false"); + } else if (variant.is_string()) { + out << variant.string_value(); + } else if (variant.is_blob()) { + out << "blob[" << variant.blob_size() << "] = <"; + char hex[3]; + for (size_t i = 0; i < variant.blob_size(); ++i) { + snprintf(hex, sizeof(hex), "%02x", variant.blob_data()[i]); + if (i != 0) out << " "; + out << hex; + } + out << ">"; + } else if (variant.is_vector()) { + out << "[" << std::endl; + const auto& v = variant.vector(); + for (auto it = v.begin(); it != v.end(); ++it) { + out << indent + " "; + VariantToStringInternal(*it, out, indent + " "); + auto next_it = it; + next_it++; + if (next_it != v.end()) out << ","; + out << std::endl; + } + out << "]"; + } else if (variant.is_map()) { + out << "[" << std::endl; + const auto& m = variant.map(); + for (auto it = m.begin(); it != m.end(); ++it) { + out << indent + " "; + VariantToStringInternal(it->first, out, indent + " "); + out << ": "; + VariantToStringInternal(it->second, out, indent + " "); + auto next_it = it; + next_it++; + if (next_it != m.end()) out << ","; + out << std::endl; + } + out << "]"; + } else { + out << ""; + } +} + +std::string FirebaseTest::VariantToString(const firebase::Variant& variant) { + std::ostringstream out; + VariantToStringInternal(variant, out, ""); + return out.str(); +} + +bool FirebaseTest::IsUserInteractionAllowed() { + // In the trivial case, just check whether we are logging to file. If not, + // assume interaction is allowed. + return !app_framework::IsLoggingToFile(); +} + +bool FirebaseTest::Base64Encode(const std::string& input, std::string* output) { + return ::firebase::internal::Base64Encode(input, output); +} + +bool FirebaseTest::Base64Decode(const std::string& input, std::string* output) { + return ::firebase::internal::Base64Decode(input, output); +} + +class LogTestEventListener : public testing::EmptyTestEventListener { + public: + void OnTestPartResult( + const testing::TestPartResult& test_part_result) override { + if (test_part_result.failed() && test_part_result.message()) { + app_framework::AddToFullLog(test_part_result.message()); + app_framework::AddToFullLog("\n"); + } + }; +}; + +} // namespace firebase_test_framework + +namespace firebase { +// gtest requires that the operator<< be in the same namespace as the item you +// are outputting. +std::ostream& operator<<(std::ostream& os, const Variant& v) { + return os << firebase_test_framework::FirebaseTest::VariantToString(v); +} +} // namespace firebase + +namespace { + +std::vector ArgcArgvToVector(int argc, char* argv[]) { + std::vector args_vector; + for (int i = 0; i < argc; ++i) { + args_vector.push_back(argv[i]); + } + return args_vector; +} + +char** VectorToArgcArgv(const std::vector& args_vector, + int* argc) { + // Ensure that `argv` ends with a null terminator. This is a POSIX requirement + // (see https://man7.org/linux/man-pages/man2/execve.2.html) and googletest + // relies on it. Without this null terminator, the + // `ParseGoogleTestFlagsOnlyImpl()` function in googletest accesses invalid + // memory and causes an Address Sanitizer failure. + char** argv = new char*[args_vector.size() + 1]; + for (int i = 0; i < args_vector.size(); ++i) { + const char* arg = args_vector[i].c_str(); + char* arg_copy = new char[std::strlen(arg) + 1]; + std::strcpy(arg_copy, arg); + argv[i] = arg_copy; + } + argv[args_vector.size()] = nullptr; + *argc = static_cast(args_vector.size()); + return argv; +} + +/** + * Makes changes to argc and argv before passing them to `InitGoogleTest`. + * + * This function is a convenience function for developers to edit during + * development/debugging to customize the the arguments specified to googletest + * when directly specifying command-line arguments is not available, such as on + * Android and iOS. For example, to debug a specific test, add the + * --gtest_filter argument, and to list all tests add the --gtest_list_tests + * argument. + * + * @param argc A pointer to the `argc` that will be specified to + * `InitGoogleTest`; the integer to which this pointer points will be updated + * with the new length of `argv`. + * @param argv The `argv` that contains the arguments that would have otherwise + * been specified to `InitGoogleTest()`; they will not be modified. + * + * @return The new `argv` to be specified to `InitGoogleTest()`. + */ +char** EditMainArgsForGoogleTest(int* argc, char* argv[]) { + // Put the args into a vector of strings because modifying string objects in + // a vector is far easier than modifying a char** array. + const std::vector original_args = ArgcArgvToVector(*argc, argv); + std::vector modified_args(original_args); + + // Add elements to the `modified_args` vector to specify to googletest. + // e.g. modified_args.push_back("--gtest_list_tests"); + // e.g. modified_args.push_back("--gtest_filter=MyTestFixture.MyTest"); + + // Disable googletest's exception handling logic when debugging test failures + // due to exceptions. This can be helpful because when exceptions are handled + // by googletest (the default) the stack traces are lost; however, when they + // are instead allowed to bubble up and crash the app then helpful stack + // traces are usually included as part of the crash dump. + // See https://goo.gle/2WcC3fV for details. + // modified_args.push_back("--gtest_catch_exceptions=0"); + + // Create a new `argv` with the elements from the `modified_args` vector and + // write the new count back to `argc`. The memory leaks produced by + // `VectorToArgcArgv` acceptable because they last for the entire application. + // Calling `VectorToArgcArgv` also fixes an invalid memory access performed by + // googletest by adding the required null element to the end of `argv`. + return VectorToArgcArgv(modified_args, argc); +} + +} // namespace + +extern "C" int common_main(int argc, char* argv[]) { + argv = EditMainArgsForGoogleTest(&argc, argv); + ::testing::InitGoogleTest(&argc, argv); + firebase_test_framework::FirebaseTest::SetArgs(argc, argv); + app_framework::SetLogLevel(app_framework::kDebug); + // Anything below the given log level will be preserved, and printed out in + // the event of test failure. + app_framework::SetPreserveFullLog(true); + ::testing::TestEventListeners& listeners = + ::testing::UnitTest::GetInstance()->listeners(); + listeners.Append(new firebase_test_framework::LogTestEventListener()); + int result = RUN_ALL_TESTS(); + + return result; +} diff --git a/app/integration_test_internal/src/firebase_test_framework.h b/app/integration_test_internal/src/firebase_test_framework.h new file mode 100644 index 0000000000..ef466b7f1a --- /dev/null +++ b/app/integration_test_internal/src/firebase_test_framework.h @@ -0,0 +1,501 @@ +// Copyright 2019 Google Inc. 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. + +#ifndef FIREBASE_TEST_FRAMEWORK_H_ // NOLINT +#define FIREBASE_TEST_FRAMEWORK_H_ // NOLINT + +#include +#include +#include +#include + +#include "app_framework.h" // NOLINT +#include "firebase/app.h" +#include "firebase/future.h" +#include "firebase/internal/platform.h" +#include "firebase/util.h" +#include "firebase/variant.h" +#include "gmock/gmock.h" +#include "gtest/gtest.h" + +// Include this internal header so we have access to UnitTestImpl and +// ClearTestPartResults. We are not supposed to use these, but we do anyway as a +// workaround for handling flaky test sections. +#include "gtest/../../src/gtest-internal-inl.h" + +namespace firebase_test_framework { + +// Use this macro to skip an entire test if it requires interactivity and we are +// not running in interactive mode (for example, on FTL). +#define TEST_REQUIRES_USER_INTERACTION \ + if (!IsUserInteractionAllowed()) { \ + app_framework::LogInfo("Skipping %s, as it requires user interaction.", \ + test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } + +#if TARGET_OS_IPHONE +#define TEST_REQUIRES_USER_INTERACTION_ON_IOS TEST_REQUIRES_USER_INTERACTION +#define TEST_REQUIRES_USER_INTERACTION_ON_ANDROID ((void)0) +#elif defined(ANDROID) +#define TEST_REQUIRES_USER_INTERACTION_ON_IOS ((void)0) +#define TEST_REQUIRES_USER_INTERACTION_ON_ANDROID TEST_REQUIRES_USER_INTERACTION +#else +#define TEST_REQUIRES_USER_INTERACTION_ON_IOS ((void)0) +#define TEST_REQUIRES_USER_INTERACTION_ON_ANDROID ((void)0) +#endif // TARGET_OS_IPHONE + +// Macros for skipping tests on various platforms. +// +// Simply place the macro at the top of the test to skip that test on +// the given platform. +// For example: +// TEST_F(MyFirebaseTest, TestThatFailsOnDesktop) { +// SKIP_TEST_ON_DESKTOP; +// EXPECT_TRUE(do_test_things(...)) +// } +// +// SKIP_TEST_ON_MOBILE +// SKIP_TEST_ON_IOS +// SKIP_TEST_ON_ANDROID +// SKIP_TEST_ON_DESKTOP +// SKIP_TEST_ON_LINUX +// SKIP_TEST_ON_WINDOWS +// SKIP_TEST_ON_MACOS +// +// Also includes a special macro SKIP_TEST_IF_USING_STLPORT if compiling for +// Android STLPort, which does not fully support C++11. + +#if !defined(ANDROID) && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#define SKIP_TEST_ON_DESKTOP \ + { \ + app_framework::LogInfo("Skipping %s on desktop.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_DESKTOP ((void)0) +#endif // !defined(ANDROID) && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + +#if (defined(TARGET_OS_OSX) && TARGET_OS_OSX) +#define SKIP_TEST_ON_MACOS \ + { \ + app_framework::LogInfo("Skipping %s on MacOS.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_MACOS ((void)0) +#endif // (defined(TARGET_OS_OSX) && TARGET_OS_OSX) + +#if defined(_WIN32) +#define SKIP_TEST_ON_WINDOWS \ + { \ + app_framework::LogInfo("Skipping %s on Windows.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_WINDOWS ((void)0) +#endif // defined(_WIN32) + +#if defined(__linux__) +#define SKIP_TEST_ON_LINUX \ + { \ + app_framework::LogInfo("Skipping %s on Linux.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_LINUX ((void)0) +#endif // defined(__linux__) + +#if defined(ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#define SKIP_TEST_ON_MOBILE \ + { \ + app_framework::LogInfo("Skipping %s on mobile.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_MOBILE ((void)0) +#endif // defined(ANDROID) || (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + +#if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) +#define SKIP_TEST_ON_IOS \ + { \ + app_framework::LogInfo("Skipping %s on iOS.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_IOS ((void)0) +#endif // (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) + +#if (defined(TARGET_OS_TV) && TARGET_OS_TV) +#define SKIP_TEST_ON_TVOS \ + { \ + app_framework::LogInfo("Skipping %s on tvOS.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_TVOS ((void)0) +#endif // (defined(TARGET_OS_TV) && TARGET_OS_TV) + +#if defined(ANDROID) +#define SKIP_TEST_ON_ANDROID \ + { \ + app_framework::LogInfo("Skipping %s on Android.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_ANDROID ((void)0) +#endif // defined(ANDROID) + +#if defined(STLPORT) +#define SKIP_TEST_IF_USING_STLPORT \ + { \ + app_framework::LogInfo("Skipping %s due to incompatibility with STLPort.", \ + test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_IF_USING_STLPORT ((void)0) +#endif // defined(STLPORT) + +#if defined(QUICK_CHECK) +#define SKIP_TEST_ON_QUICK_CHECK \ + { \ + app_framework::LogInfo("Skipping %s on quick check.", test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } +#else +#define SKIP_TEST_ON_QUICK_CHECK ((void)0) +#endif // defined(QUICK_CHECK) + +#define KNOWN_FAILURE(explanation) \ + { FAIL() << test_info_->name() << " has a known failure: " << explanation; } + +#if FIREBASE_PLATFORM_LINUX || FIREBASE_PLATFORM_OSX +#define DEATHTEST_SIGABRT "SIGABRT" +#else +#define DEATHTEST_SIGABRT "" +#endif + +// Macros to surround a flaky section of your test. +// If this section fails, it will retry several times until it succeeds. +#define FLAKY_TEST_SECTION_BEGIN() RunFlakyTestSection([&]() { (void)0 +#define FLAKY_TEST_SECTION_END() \ + }) + +class FirebaseTest : public testing::Test { + public: + FirebaseTest(); + ~FirebaseTest() override; + + void SetUp() override; + void TearDown() override; + + // Check the given directory, the current directory, and the directory + // containing the binary for google-services.json, and change to whichever + // directory contains it. + static void FindFirebaseConfig(const char* try_directory); + + static void SetArgs(int argc, char* argv[]) { + argc_ = argc; + argv_ = argv; + } + + // Convert a Variant into a string (including all nested Variants) for + // debugging. + static std::string VariantToString(const firebase::Variant& variant); + + // Run an operation that returns a bool. If it fails (and the bool returns + // false), try it again, after a short delay. Returns true once it succeeds, + // or if it fails enough times, returns false. + // This is designed to allow you to try a flaky set of operations multiple + // times until it succeeds. + // + // Note that the callback must return a bool or a type implicitly convertable + // to bool. + template + static bool RunFlakyBlock(CallbackType flaky_callback, + ContextType* context_typed, const char* name = "") { + struct RunData { + CallbackType callback; + ContextType* context; + }; + RunData run_data = {flaky_callback, context_typed}; + return RunFlakyBlockBase( + [](void* ctx) { + CallbackType callback = static_cast(ctx)->callback; + ContextType* context = static_cast(ctx)->context; + return callback(context); + }, + static_cast(&run_data), name); + } + + // Same as RunFlakyBlock above, but use std::function to allow captures. + static bool RunFlakyBlock(std::function flaky_callback, + const char* name = "") { + struct RunData { + std::function* callback; + }; + RunData run_data = {&flaky_callback}; + return RunFlakyBlockBase( + [](void* ctx) { + auto& callback = *static_cast(ctx)->callback; + return callback(); + }, + static_cast(&run_data), name); + } + + protected: + // Set up firebase::App with default settings. + void InitializeApp(); + // Shut down firebase::App. + void TerminateApp(); + + // Returns true if interactive tests are allowed, false if only + // fully-automated tests should be run. + bool AreInteractiveTestsAllowed(); + + // Give the static helper methods "public" visibility so that they can be used + // by helper functions defined outside of subclasses of `FirebaseTest`, such + // as functions defined in anonymous namespaces. + public: + // Get a persistent string value that was previously set via + // SetPersistentString. Returns true if the value was set, false if not or if + // something went wrong. + static bool GetPersistentString(const char* key, std::string* value_out); + // Set a persistent string value that can be accessed the next time the test + // loads. Specify nullptr for value to delete the key. Returns true if + // successful, false if something went wrong. + static bool SetPersistentString(const char* key, const char* value); + + // Returns true if the future completed as expected, fails the test and + // returns false otherwise. + static bool WaitForCompletion(const firebase::FutureBase& future, + const char* name, int expected_error = 0); + + // Just wait for completion, not caring what the result is (as long as + // it's not Invalid). Returns true, unless Invalid. + static bool WaitForCompletionAnyResult(const firebase::FutureBase& future, + const char* name); + + // Run a flaky section of a test. If any expectations fail, it will clear + // those failures and retry the section. + // + // Typically, you wouldn't use this method directly. Instead, you should use + // it via the FLAKY_TEST_SECTION_BEGIN() and FLAKY_TEST_SECTION_END() macros + // defined above. + // + // For example: + // TEST_F(MyTestClass, MyTestCase) { + // /* do some non-flaky stuff here */ + // FLAKY_TEST_SECTION_BEGIN(); + // /* do some stuff that might need to be retried here */ + // FLAKY_TEST_SECTION_END(); + // /* do some more non-flaky stuff here */ + // } + void RunFlakyTestSection(std::function flaky_test_section) { + // Save the current state of test results. + auto saved_test_results = SaveTestPartResults(); + RunFlakyBlock([&]() { + RestoreTestPartResults(saved_test_results); + + flaky_test_section(); + + return !HasFailure(); + }); + } + + // Run an operation that returns a Future (via a callback), retrying with + // exponential backoff if the operation fails. + // + // Blocks until the operation succeeds (the Future completes, with error + // matching expected_error) or if the final attempt is started (in which case + // the Future returned may still be in progress). You should use + // WaitForCompletion to await the results of this function in any case. + // + // For example, to add retry, you would change: + // + // bool success = WaitForCompletion( + // auth_->DeleteUser(auth->current_user()), + // "DeleteUser"); + // To this: + // + // bool success = WaitForCompletion(RunWithRetry( + // [](Auth* auth) { + // return auth->DeleteUser(auth->current_user()); + // }, auth_), "DeleteUser")); + template + static firebase::FutureBase RunWithRetry(CallbackType run_future_typed, + ContextType* context_typed, + const char* name = "", + int expected_error = 0) { + struct RunData { + CallbackType callback; + ContextType* context; + }; + RunData run_data = {run_future_typed, context_typed}; + return RunWithRetryBase( + [](void* ctx) { + CallbackType callback = static_cast(ctx)->callback; + ContextType* context = static_cast(ctx)->context; + return static_cast(callback(context)); + }, + static_cast(&run_data), name, expected_error); + } + + // Same as RunWithRetry, but templated to return a Future + // rather than a FutureBase, in case you want to use the result data + // of the Future. You need to explicitly provide the template parameter, + // e.g. RunWithRetry(..) to return a Future. + template + static firebase::Future RunWithRetry( + CallbackType run_future_typed, ContextType* context_typed, + const char* name = "", int expected_error = 0) { + struct RunData { + CallbackType callback; + ContextType* context; + }; + RunData run_data = {run_future_typed, context_typed}; + firebase::FutureBase result_base = RunWithRetryBase( + [](void* ctx) { + CallbackType callback = static_cast(ctx)->callback; + ContextType* context = static_cast(ctx)->context; + // The following line checks that CallbackType actually returns a + // Future. If it returns any other type, the compiler will + // complain about implicit conversion to Future here. + firebase::Future future_result = callback(context); + return static_cast(future_result); + }, + static_cast(&run_data), name, expected_error); + // Future and FutureBase are reinterpret_cast-compatible, by design. + return *reinterpret_cast*>(&result_base); + } + + // Same as RunWithRetry above, but use std::function to allow captures. + static firebase::FutureBase RunWithRetry( + std::function run_future, const char* name = "", + int expected_error = 0) { + struct RunData { + std::function* callback; + }; + RunData run_data = {&run_future}; + return RunWithRetryBase( + [](void* ctx) { + auto& callback = *static_cast(ctx)->callback; + return static_cast(callback()); + }, + static_cast(&run_data), name, expected_error); + } + // Same as RunWithRetry, but use std::function to allow captures. + template + static firebase::Future RunWithRetry( + std::function()> run_future, + const char* name = "", int expected_error = 0) { + struct RunData { + std::function()>* callback; + }; + RunData run_data = {&run_future}; + firebase::FutureBase result_base = RunWithRetryBase( + [](void* ctx) { + auto& callback = *static_cast(ctx)->callback; + // The following line checks that CallbackType actually returns a + // Future. If it returns any other type, the compiler will + // complain about implicit conversion to Future here. + firebase::Future future_result = callback(); + return static_cast(future_result); + }, + static_cast(&run_data), name, expected_error); + // Future and FutureBase are reinterpret_cast-compatible, by design. + return *reinterpret_cast*>(&result_base); + } + + // Blocking HTTP request helper function, for testing only. + static bool SendHttpGetRequest( + const char* url, const std::map& headers, + int* response_code, std::string* response); + + // Blocking HTTP request helper function, for testing only. + static bool SendHttpPostRequest( + const char* url, const std::map& headers, + const std::string& post_body, int* response_code, std::string* response); + + // Open a URL in a browser window, for testing only. + static bool OpenUrlInBrowser(const char* url); + + // Returns true if we can run tests that require interaction, false if not. + static bool IsUserInteractionAllowed(); + + // Encode a binary string to base64. Returns true if the encoding succeeded, + // false if it failed. + static bool Base64Encode(const std::string& input, std::string* output); + // Decode a base64 string to binary. Returns true if the decoding succeeded, + // false if it failed. + static bool Base64Decode(const std::string& input, std::string* output); + + firebase::App* app_; + static int argc_; + static char** argv_; + static bool found_config_; + + private: + // Untyped version of RunWithRetry, with implementation. + // This is kept private because the templated version should be used instead, + // for type safety. + static firebase::FutureBase RunWithRetryBase( + firebase::FutureBase (*run_future)(void* context), void* context, + const char* name, int expected_error); + // Untyped version of RunFlakyBlock, with implementation. + // This is kept private because the templated version should be used instead, + // for type safety. + static bool RunFlakyBlockBase(bool (*flaky_block)(void* context), + void* context, const char* name = ""); + + std::vector<::testing::TestPartResult> SaveTestPartResults() { + return ::testing::internal::TestResultAccessor::test_part_results( + *::testing::internal::GetUnitTestImpl()->current_test_result()); + } + + void RestoreTestPartResults( + const std::vector<::testing::TestPartResult>& test_part_results) { + const std::vector& existing_results = + ::testing::internal::TestResultAccessor::test_part_results( + *::testing::internal::GetUnitTestImpl()->current_test_result()); + // Overwrite the existing test_part_results with the previously-saved + // version. + const_cast&>(existing_results) + .assign(test_part_results.begin(), test_part_results.end()); + } +}; + +} // namespace firebase_test_framework + +namespace firebase { +// Define an operator<< for Variant so that googletest can output its values +// nicely. +std::ostream& operator<<(std::ostream& os, const Variant& v); +} // namespace firebase + +extern "C" int common_main(int argc, char* argv[]); + +#endif // FIREBASE_TEST_FRAMEWORK_H_ // NOLINT diff --git a/app/integration_test_internal/src/integration_test.cc b/app/integration_test_internal/src/integration_test.cc new file mode 100644 index 0000000000..c22acb8bec --- /dev/null +++ b/app/integration_test_internal/src/integration_test.cc @@ -0,0 +1,68 @@ +// Copyright 2019 Google Inc. 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 "app_framework.h" // NOLINT +#include "firebase_test_framework.h" // NOLINT + +// 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 { + +using firebase_test_framework::FirebaseTest; + +class FirebaseAppTest : public FirebaseTest { + public: + FirebaseAppTest(); +}; + +FirebaseAppTest::FirebaseAppTest() { + FindFirebaseConfig(FIREBASE_CONFIG_STRING); +} + +// For simplicity of test code, handle the Android-specific arguments here. +#if defined(__ANDROID__) +#define APP_CREATE_PARAMS \ + app_framework::GetJniEnv(), app_framework::GetActivity() +#else +#define APP_CREATE_PARAMS +#endif // defined(__ANDROID__) + +TEST_F(FirebaseAppTest, TestDefaultAppWithDefaultOptions) { + firebase::App* default_app; + default_app = firebase::App::Create(APP_CREATE_PARAMS); + EXPECT_NE(default_app, nullptr); + + delete default_app; + default_app = nullptr; +} + +} // namespace firebase_testapp_automated diff --git a/app/integration_test_internal/src/ios/.clang-format b/app/integration_test_internal/src/ios/.clang-format new file mode 100644 index 0000000000..9d159247d5 --- /dev/null +++ b/app/integration_test_internal/src/ios/.clang-format @@ -0,0 +1,2 @@ +DisableFormat: true +SortIncludes: false diff --git a/app/integration_test_internal/src/ios/ios_app_framework.mm b/app/integration_test_internal/src/ios/ios_app_framework.mm new file mode 100644 index 0000000000..b7a32a1bc3 --- /dev/null +++ b/app/integration_test_internal/src/ios/ios_app_framework.mm @@ -0,0 +1,381 @@ +// Copyright 2016 Google Inc. 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. + +#import + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "app_framework.h" + +@interface AppDelegate : UIResponder + +@property(nonatomic, strong) UIWindow *window; + +@end + +@interface FTAViewController : UIViewController + +@property(atomic, strong) NSString *textEntryResult; + +@end + +static NSString *const kGameLoopUrlPrefix = @"firebase-game-loop"; +static NSString *const kGameLoopCompleteUrlScheme = @"firebase-game-loop-complete://"; +static const float kGameLoopSecondsToPauseBeforeQuitting = 5.0f; + +// Test Loop on iOS doesn't provide the app under test a path to save logs to, so set it here. +#define GAMELOOP_DEFAULT_LOG_FILE "Results1.json" + +enum class RunningState { kRunning, kShuttingDown, kShutDown }; + +// Note: g_running_state and g_exit_status must only be accessed while holding the lock from +// g_running_state_condition; also, any changes to these values should be followed up with a +// call to [g_running_state_condition broadcast]. +static NSCondition *g_running_state_condition; +static RunningState g_running_state = RunningState::kRunning; +static int g_exit_status = -1; + +static UITextView *g_text_view; +static UIView *g_parent_view; +static FTAViewController *g_view_controller; +static bool g_gameloop_launch = false; +static NSURL *g_results_url; +static NSString *g_file_name; +static NSString *g_file_url_path; + +@implementation FTAViewController + +- (void)viewDidLoad { + [super viewDidLoad]; + g_parent_view = self.view; + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + // Copy the app name into a non-const array, as googletest requires that + // main() take non-const char* argv[] so it can modify the arguments. + char *argv[1]; + argv[0] = new char[strlen(TESTAPP_NAME) + 1]; + strcpy(argv[0], TESTAPP_NAME); // NOLINT + int common_main_result = common_main(1, argv); + + [g_running_state_condition lock]; + g_exit_status = common_main_result; + g_running_state = RunningState::kShutDown; + [g_running_state_condition broadcast]; + [g_running_state_condition unlock]; + + delete[] argv[0]; + argv[0] = nullptr; + [NSThread sleepForTimeInterval:kGameLoopSecondsToPauseBeforeQuitting]; + dispatch_async(dispatch_get_main_queue(), ^{ + [UIApplication.sharedApplication openURL:[NSURL URLWithString:kGameLoopCompleteUrlScheme] + options:[NSDictionary dictionary] + completionHandler:nil]; + }); + }); +} + +@end +namespace app_framework { + +bool ProcessEvents(int msec) { + NSDate *endDate = [NSDate dateWithTimeIntervalSinceNow:static_cast(msec) / 1000.0f]; + [g_running_state_condition lock]; + + if (g_running_state == RunningState::kRunning) { + [g_running_state_condition waitUntilDate:endDate]; + } + + RunningState running_status = g_running_state; + [g_running_state_condition unlock]; + + return running_status != RunningState::kRunning; +} + +std::string PathForResource() { + NSArray *paths = + NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = paths.firstObject; + // Force a trailing slash by removing any that exists, then appending another. + return std::string( + [[documentsDirectory stringByStandardizingPath] stringByAppendingString:@"/"].UTF8String); +} + +WindowContext GetWindowContext() { return g_parent_view; } + +// Log a message that can be viewed in the console. +void LogMessageV(bool suppress, const char *format, va_list list) { + NSString *formatString = @(format); + + NSString *message = [[NSString alloc] initWithFormat:formatString arguments:list]; + message = [message stringByAppendingString:@"\n"]; + + if (GetPreserveFullLog()) { + AddToFullLog(message.UTF8String); + } + if (!suppress) { + fputs(message.UTF8String, stdout); + fflush(stdout); + } +} + +void LogMessage(const char *format, ...) { + va_list list; + va_start(list, format); + LogMessageV(false, format, list); + va_end(list); +} + +static bool g_save_full_log = false; +static std::vector g_full_logs; // NOLINT + +void AddToFullLog(const char *str) { g_full_logs.push_back(std::string(str)); } + +bool GetPreserveFullLog() { return g_save_full_log; } +void SetPreserveFullLog(bool b) { g_save_full_log = b; } + +void ClearFullLog() { g_full_logs.clear(); } + +void OutputFullLog() { + for (int i = 0; i < g_full_logs.size(); ++i) { + fputs(g_full_logs[i].c_str(), stdout); + } + fflush(stdout); + ClearFullLog(); +} + +// Log a message that can be viewed in the console. +void AddToTextView(const char *str) { + NSString *message = @(str); + + dispatch_async(dispatch_get_main_queue(), ^{ + g_text_view.text = [g_text_view.text stringByAppendingString:message]; + NSRange range = NSMakeRange(g_text_view.text.length, 0); + [g_text_view scrollRangeToVisible:range]; + }); + if (g_gameloop_launch) { + NSData *data = [message dataUsingEncoding:NSUTF8StringEncoding]; + if ([NSFileManager.defaultManager fileExistsAtPath:g_file_url_path]) { + NSFileHandle *fileHandler = [NSFileHandle fileHandleForUpdatingAtPath:g_file_url_path]; + [fileHandler seekToEndOfFile]; + [fileHandler writeData:data]; + [fileHandler closeFile]; + } else { + NSLog(@"Write to file %@", g_file_url_path); + [data writeToFile:g_file_url_path atomically:YES]; + } + } +} + +// Remove all lines starting with these strings. +static const char *const filter_lines[] = {nullptr}; + +bool should_filter(const char *str) { + for (int i = 0; filter_lines[i] != nullptr; ++i) { + if (strncmp(str, filter_lines[i], strlen(filter_lines[i])) == 0) return true; + } + return false; +} + +void *stdout_logger(void *filedes_ptr) { + int fd = reinterpret_cast(filedes_ptr)[0]; + std::string buffer; + char bufchar; + while (size_t n = read(fd, &bufchar, 1)) { + if (bufchar == '\0') { + break; + } else if (bufchar == '\n') { + if (!should_filter(buffer.c_str())) { + NSLog(@"%s", buffer.c_str()); + buffer = buffer + bufchar; // Add the newline + app_framework::AddToTextView(buffer.c_str()); + } + buffer.clear(); + } else { + buffer = buffer + bufchar; + } + } + return nullptr; +} + +void RunOnBackgroundThread(void *(*func)(void *), void *data) { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + func(data); + }); +} + +// Create an alert dialog via UIAlertController, and prompt the user to enter a line of text. +// This function spins until the text has been entered (or the alert dialog was canceled). +// If the user cancels, returns an empty string. +std::string ReadTextInput(const char *title, const char *message, const char *placeholder) { + assert(g_view_controller); + // This should only be called from a background thread, as it blocks, which will mess up the main + // thread. + assert(![NSThread isMainThread]); + + g_view_controller.textEntryResult = nil; + + dispatch_async(dispatch_get_main_queue(), ^{ + UIAlertController *alertController = + [UIAlertController alertControllerWithTitle:@(title) + message:@(message) + preferredStyle:UIAlertControllerStyleAlert]; + [alertController addTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) { + textField.placeholder = @(placeholder); + }]; + UIAlertAction *confirmAction = [UIAlertAction + actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction *_Nonnull action) { + g_view_controller.textEntryResult = alertController.textFields.firstObject.text; + }]; + [alertController addAction:confirmAction]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" + style:UIAlertActionStyleCancel + handler:^(UIAlertAction *_Nonnull action) { + g_view_controller.textEntryResult = @""; + }]; + [alertController addAction:cancelAction]; + [g_view_controller presentViewController:alertController animated:YES completion:nil]; + }); + + while (true) { + // Pause a second, waiting for the user to enter text. + if (ProcessEvents(1000)) { + // If this returns true, an exit was requested. + return ""; + } + if (g_view_controller.textEntryResult != nil) { + // textEntryResult will be set to non-nil when a dialog button is clicked. + std::string result = g_view_controller.textEntryResult.UTF8String; + g_view_controller.textEntryResult = nil; // Consume the result. + return result; + } + } +} + +bool IsLoggingToFile() { return g_file_url_path; } + +bool StartLoggingToFile(const char *file_path) { + NSURL *home_url = [NSURL fileURLWithPath:NSHomeDirectory()]; + g_results_url = [home_url URLByAppendingPathComponent:@"/Documents/GameLoopResults"]; + g_file_name = @(file_path); + g_file_url_path = [g_results_url URLByAppendingPathComponent:g_file_name].path; + NSError *error; + if (![NSFileManager.defaultManager fileExistsAtPath:[g_results_url path]]) { + if (![NSFileManager.defaultManager createDirectoryAtPath:g_results_url.path + withIntermediateDirectories:true + attributes:nil + error:&error]) { + app_framework::LogError("Couldn't create directory %s: %s", g_results_url.path, + error.description.UTF8String); + g_file_url_path = nil; + return false; + } + } + return true; +} + +} // namespace app_framework + +int main(int argc, char *argv[]) { + // Pipe stdout to call LogToTextView so we can see the gtest output. + int filedes[2]; + assert(pipe(filedes) != -1); + assert(dup2(filedes[1], STDOUT_FILENO) != -1); + pthread_t thread; + pthread_create(&thread, nullptr, app_framework::stdout_logger, reinterpret_cast(filedes)); + @autoreleasepool { + UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } + // Signal to stdout_logger to exit. + write(filedes[1], "\0", 1); + pthread_join(thread, nullptr); + close(filedes[0]); + close(filedes[1]); + + int exit_status = -1; + [g_running_state_condition lock]; + exit_status = g_exit_status; + [g_running_state_condition unlock]; + + NSLog(@"Application Exit"); + return exit_status; +} + +@implementation AppDelegate +- (BOOL)application:(UIApplication *)app + openURL:(NSURL *)url + options:(NSDictionary *)options { +#if TARGET_OS_SIMULATOR + setenv("USE_FIRESTORE_EMULATOR", "true", 1); +#endif + + if ([url.scheme isEqual:kGameLoopUrlPrefix]) { + g_gameloop_launch = true; + app_framework::StartLoggingToFile(GAMELOOP_DEFAULT_LOG_FILE); + return YES; + } + NSLog(@"The testapp will not log to files since it is not launched by URL %@", + kGameLoopUrlPrefix); + return NO; +} + +- (BOOL)application:(UIApplication *)application + didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + g_running_state_condition = [[NSCondition alloc] init]; + + self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; + g_view_controller = [[FTAViewController alloc] init]; + self.window.rootViewController = g_view_controller; + [self.window makeKeyAndVisible]; + + g_text_view = [[UITextView alloc] initWithFrame:g_view_controller.view.bounds]; + + g_text_view.accessibilityIdentifier = @"Logger"; +#if TARGET_OS_IOS + g_text_view.editable = NO; +#endif // TARGET_OS_IOS + g_text_view.scrollEnabled = YES; + g_text_view.userInteractionEnabled = YES; + g_text_view.font = [UIFont fontWithName:@"Courier" size:10]; + [g_view_controller.view addSubview:g_text_view]; + + return YES; +} + +- (void)applicationWillTerminate:(UIApplication *)application { + [g_running_state_condition lock]; + + if (g_running_state == RunningState::kRunning) { + g_running_state = RunningState::kShuttingDown; + [g_running_state_condition broadcast]; + } + + while (g_running_state != RunningState::kShutDown) { + [g_running_state_condition wait]; + } + + [g_running_state_condition unlock]; +} +@end diff --git a/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm b/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm new file mode 100644 index 0000000000..4c9112f412 --- /dev/null +++ b/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm @@ -0,0 +1,194 @@ +// Copyright 2019 Google Inc. 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 "firebase_test_framework.h" // NOLINT + +#import +#import + +namespace firebase_test_framework { + +using app_framework::LogDebug; +using app_framework::LogError; +using app_framework::ProcessEvents; + +// Default HTTP timeout of 1 minute. +const int kHttpTimeoutSeconds = 60; + +// A simple helper function for performing synchronous HTTP/HTTPS requests, used for testing +// purposes only. +static bool SendHttpRequest(const char* method, const char* url, + const std::map& headers, + const std::string& post_body, int* response_code, + std::string* response_str) { + NSMutableURLRequest* url_request = [[NSMutableURLRequest alloc] init]; + url_request.URL = [NSURL URLWithString:@(url)]; + url_request.HTTPMethod = @(method); + url_request.timeoutInterval = kHttpTimeoutSeconds; + if (strcmp(method, "POST") == 0) { + url_request.HTTPBody = [NSData dataWithBytes:post_body.c_str() length:post_body.length()]; + } + // Set all the headers. + for (auto i = headers.begin(); i != headers.end(); ++i) { + [url_request addValue:@(i->second.c_str()) forHTTPHeaderField:@(i->first.c_str())]; + } + __block dispatch_semaphore_t sem = dispatch_semaphore_create(0); + __block NSError* response_error; + __block NSHTTPURLResponse* http_response; + __block NSData* response_data; + LogDebug("Sending HTTP %s request to %s", method, url); + @try { + [[NSURLSession.sharedSession + dataTaskWithRequest:url_request + completionHandler:^(NSData* __nullable data, NSURLResponse* __nullable response, + NSError* __nullable error) { + response_data = data; + http_response = (NSHTTPURLResponse*)(response); + response_error = error; + dispatch_semaphore_signal(sem); + }] resume]; + } @catch (NSException* e) { + LogError("NSURLSession exception: %s", e.reason.UTF8String); + return false; + } + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); + + LogDebug("HTTP status code %ld", http_response.statusCode); + if (http_response && response_code) { + *response_code = static_cast(http_response.statusCode); + } + std::string response_text = + response_data.bytes + ? std::string(reinterpret_cast(response_data.bytes), response_data.length) + : std::string(); + LogDebug("Got response: %s", response_text.c_str()); + if (response_str) { + *response_str = response_text; + } + if (response_error) { + LogError("HTTP error: %s", response_error.localizedDescription.UTF8String); + return false; + } + return true; +} + +// Blocking HTTP request helper function, for testing only. +bool FirebaseTest::SendHttpGetRequest(const char* url, + const std::map& headers, + int* response_code, std::string* response_str) { + return SendHttpRequest("GET", url, headers, "", response_code, response_str); +} + +bool FirebaseTest::SendHttpPostRequest(const char* url, + const std::map& headers, + const std::string& post_body, int* response_code, + std::string* response_str) { + return SendHttpRequest("POST", url, headers, post_body, response_code, response_str); +} + +bool FirebaseTest::OpenUrlInBrowser(const char* url) { +#if TARGET_OS_IOS + if (strncmp(url, "data:", strlen("data:")) == 0) { + // Workaround because Safari can't load data: URLs by default. + // Instead, copy the URL to the clipboard and ask the user to paste it into Safari. + + // data: URLs are in the format data:text/html, + // Preserve everything until the first comma, then URL-encode the rest. + const char* payload = strchr(url, ','); + if (payload == nullptr) { + return false; + } + payload++; // Move past the comma. + std::string scheme_and_encoding(url); + scheme_and_encoding.resize(payload - url); + UIPasteboard* pasteboard = [UIPasteboard generalPasteboard]; + pasteboard.string = [@(scheme_and_encoding.c_str()) + stringByAppendingString:[@(payload) stringByAddingPercentEncodingWithAllowedCharacters: + [NSCharacterSet URLHostAllowedCharacterSet]]]; + dispatch_semaphore_t sem = dispatch_semaphore_create(0); + UIAlertController* alert = + [UIAlertController alertControllerWithTitle:@"Paste URL" + message:@"Opening Safari. Please tap twice on the " + @"address bar and select \"Paste and Go\"." + preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:^(UIAlertAction* action) { + dispatch_semaphore_signal(sem); + }]; + [alert addAction:ok]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[UIApplication sharedApplication].keyWindow.rootViewController presentViewController:alert + animated:YES + completion:nil]; + }); + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); + return OpenUrlInBrowser("http://"); + } else { + // Not a data: URL, load it normally. + dispatch_semaphore_t sem = dispatch_semaphore_create(0); + __block BOOL succeeded = NO; + NSURL* nsurl = [NSURL URLWithString:@(url)]; + [UIApplication.sharedApplication openURL:nsurl + options:[NSDictionary dictionary] + completionHandler:^(BOOL success) { + succeeded = success; + dispatch_semaphore_signal(sem); + }]; + dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER); + return succeeded ? true : false; + } +#else // Non-iOS Apple platforms (eg:tvOS) + return false; +#endif //TARGET_OS_IOS +} + +bool FirebaseTest::SetPersistentString(const char* key, const char* value) { + if (!key) { + LogError("SetPersistentString: null key is not allowed."); + return false; + } + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + if (!defaults) { + return false; + } + if (value) { + [defaults setObject:@(value) forKey:@(key)]; + } else { + // If value is null, remove this key. + [defaults removeObjectForKey:@(key)]; + } + [defaults synchronize]; + return true; +} + +bool FirebaseTest::GetPersistentString(const char* key, std::string* value_out) { + if (!key) { + return false; + } + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; + if (!defaults) { + return false; + } + if (![defaults objectForKey:@(key)]) { + return false; // for missing key + } + NSString* str = [defaults stringForKey:@(key)]; + if (value_out) { + *value_out = std::string(str.UTF8String); + } + return true; +} + +} // namespace firebase_test_framework diff --git a/app/rest/tests/request_file_test.cc b/app/rest/tests/request_file_test.cc index 6663046055..38b13675c1 100644 --- a/app/rest/tests/request_file_test.cc +++ b/app/rest/tests/request_file_test.cc @@ -21,7 +21,12 @@ #include #include +#ifdef FIREBASE_INTEGRATION_TEST +#include "app_framework.h" +#else // Normal unit test, use absl #include "absl/flags/flag.h" +#endif // FIREBASE_INTEGRATION_TEST + #include "app/rest/tests/request_test.h" #include "gmock/gmock.h" #include "gtest/gtest.h" @@ -32,8 +37,12 @@ namespace test { class RequestFileTest : public ::testing::Test { public: - RequestFileTest() - : filename_(absl::GetFlag(FLAGS_test_tmpdir) + "/a_file.txt"), + RequestFileTest() : +#ifdef FIREBASE_INTEGRATION_TEST + filename_(app_framework::PathForResource()), +#else // Normal unit test, use absl + filename_(absl::GetFlag(FLAGS_test_tmpdir) + "/a_file.txt"), +#endif // FIREBASE_INTEGRATION_TEST file_(nullptr), file_size_(0) {} diff --git a/scripts/gha/integration_testing/build_testapps.json b/scripts/gha/integration_testing/build_testapps.json index 4e628a9aea..a8a6c3fdaa 100755 --- a/scripts/gha/integration_testing/build_testapps.json +++ b/scripts/gha/integration_testing/build_testapps.json @@ -6,7 +6,8 @@ "bundle_id": "com.google.ios.analytics.testapp", "ios_target": "integration_test", "tvos_target": "integration_test_tvos", - "testapp_path": "analytics/integration_test", + "testapp_path": "app/integration_test", + "internal_testapp_path": "firestore/integration_test_internal", "frameworks": [ "firebase_analytics.xcframework", "firebase.xcframework" From 57c9581bfec03130f75cb295254a76aa30c3c3a7 Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Tue, 26 Jul 2022 16:45:05 -0700 Subject: [PATCH 2/5] Format code. --- admob/tools/ios/testapp/testapp/main.m | 5 ++--- analytics/src/analytics_ios.mm | 2 +- app/integration_test/src/integration_test.cc | 2 +- app/rest/tests/request_file_test.cc | 12 +++++++----- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/admob/tools/ios/testapp/testapp/main.m b/admob/tools/ios/testapp/testapp/main.m index 35f5ab1db6..a6b3b3ebd4 100644 --- a/admob/tools/ios/testapp/testapp/main.m +++ b/admob/tools/ios/testapp/testapp/main.m @@ -3,9 +3,8 @@ #import #import "AppDelegate.h" -int main(int argc, char * argv[]) { +int main(int argc, char* argv[]) { @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); } - } diff --git a/analytics/src/analytics_ios.mm b/analytics/src/analytics_ios.mm index 5aa97232ee..8b2af199a9 100644 --- a/analytics/src/analytics_ios.mm +++ b/analytics/src/analytics_ios.mm @@ -284,5 +284,5 @@ Thread get_id_thread( internal::FutureData::Get()->api()->LastResult(internal::kAnalyticsFnGetAnalyticsInstanceId)); } -} // namespace measurement +} // namespace analytics } // namespace firebase diff --git a/app/integration_test/src/integration_test.cc b/app/integration_test/src/integration_test.cc index bf57e0cc25..a6d722632e 100644 --- a/app/integration_test/src/integration_test.cc +++ b/app/integration_test/src/integration_test.cc @@ -61,7 +61,7 @@ FirebaseAppTest::FirebaseAppTest() { void FirebaseAppTest::SetUpTestSuite() { // Nothing to do here. } - + void FirebaseAppTest::TearDownTestSuite() { // The App integration test is too fast for FTL, so pause a few seconds // here. diff --git a/app/rest/tests/request_file_test.cc b/app/rest/tests/request_file_test.cc index 38b13675c1..ca2ef8a57c 100644 --- a/app/rest/tests/request_file_test.cc +++ b/app/rest/tests/request_file_test.cc @@ -37,14 +37,16 @@ namespace test { class RequestFileTest : public ::testing::Test { public: - RequestFileTest() : + RequestFileTest() + : #ifdef FIREBASE_INTEGRATION_TEST - filename_(app_framework::PathForResource()), -#else // Normal unit test, use absl - filename_(absl::GetFlag(FLAGS_test_tmpdir) + "/a_file.txt"), + filename_(app_framework::PathForResource()), +#else // Normal unit test, use absl + filename_(absl::GetFlag(FLAGS_test_tmpdir) + "/a_file.txt"), #endif // FIREBASE_INTEGRATION_TEST file_(nullptr), - file_size_(0) {} + file_size_(0) { + } void SetUp() override; void TearDown() override; From cbfd89b89fed964a3240f59fe7c56d9a2d9add8f Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 22 Dec 2022 11:25:41 -0800 Subject: [PATCH 3/5] Additional cmake logic --- app/integration_test_internal/CMakeLists.txt | 65 +++++++++++++++---- .../src/android/android_app_framework.cc | 47 ++++++++++++-- .../android_firebase_test_framework.cc | 22 +++++++ .../google/firebase/example/LoggingUtils.java | 14 ++++ .../src/app_framework.h | 12 ++++ .../src/desktop/desktop_app_framework.cc | 5 ++ .../desktop_firebase_test_framework.cc | 5 ++ .../src/firebase_test_framework.cc | 10 +-- .../src/firebase_test_framework.h | 63 +++++++++++++++--- .../src/integration_test.cc | 16 +++++ .../src/ios/ios_app_framework.mm | 28 +++++++- .../src/ios/ios_firebase_test_framework.mm | 9 +++ .../integration_testing/build_testapps.json | 2 +- 13 files changed, 264 insertions(+), 34 deletions(-) diff --git a/app/integration_test_internal/CMakeLists.txt b/app/integration_test_internal/CMakeLists.txt index 2c0fb68de8..5f2f965aa1 100644 --- a/app/integration_test_internal/CMakeLists.txt +++ b/app/integration_test_internal/CMakeLists.txt @@ -16,8 +16,11 @@ cmake_minimum_required(VERSION 2.8) -set(FIREBASE_PYTHON_EXECUTABLE "python" CACHE FILEPATH - "The Python interpreter to use, such as one from a venv") +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. @@ -42,7 +45,17 @@ endif() 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}") + 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() @@ -53,6 +66,12 @@ set(MSVC_RUNTIME_MODE MD) project(firebase_testapp) +# Ensure min/max macros don't get declared on Windows +# (so we can use std::min/max), before including the Firebase subdirectories. +if(MSVC) + add_definitions(-DNOMINMAX) +endif() + # Integration test source files. set(FIREBASE_APP_FRAMEWORK_SRCS src/app_framework.cc @@ -78,7 +97,8 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS ${FIREBASE_CPP_SDK_DIR}/app/tests/future_manager_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/future_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/google_services_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_info_desktop_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_storage_desktop_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_controller_desktop_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/intrusive_list_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/jobject_reference_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/locale_test.cc @@ -152,6 +172,9 @@ 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} . + -G ${CMAKE_GENERATOR} + -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} RESULT_VARIABLE result WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/external/googletest ) if(result) @@ -187,13 +210,17 @@ if(ANDROID) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") - add_library(gtest STATIC - ${GOOGLETEST_ROOT}/src/googletest/src/gtest-all.cc) + if (NOT TARGET gtest) + add_library(gtest STATIC + ${GOOGLETEST_ROOT}/src/googletest/src/gtest-all.cc) + endif() 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) + if (NOT TARGET gmock) + add_library(gmock STATIC + ${GOOGLETEST_ROOT}/src/googlemock/src/gmock-all.cc) + endif() target_include_directories(gmock PRIVATE ${GOOGLETEST_ROOT}/src/googletest PRIVATE ${GOOGLETEST_ROOT}/src/googlemock @@ -224,9 +251,11 @@ else() # 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) + if (NOT (TARGET gtest OR TARGET gmock)) + add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/googletest/src + ${CMAKE_CURRENT_LIST_DIR}/external/googletest/build + EXCLUDE_FROM_ALL) + endif() # The gtest/gtest_main targets carry header search path # dependencies automatically when using CMake 2.8.11 or @@ -254,6 +283,14 @@ else() ${FIREBASE_INTEGRATION_TEST_SRCS} ) + # Set a preprocessor define so that tests can distinguish between tests for + # the desktop platforms (e.g. Windows, macOS, or Linux) and mobile platforms + # (e.g. Android, iOS). + target_compile_definitions(${integration_test_target_name} + PRIVATE + FIREBASE_TESTS_TARGET_DESKTOP + ) + if(APPLE) set(ADDITIONAL_LIBS gssapi_krb5 @@ -262,6 +299,7 @@ else() "-framework Foundation" "-framework GSS" "-framework Security" + "-framework SystemConfiguration" ) elseif(MSVC) set(ADDITIONAL_LIBS advapi32 ws2_32 crypt32) @@ -289,6 +327,7 @@ endif() # Don't include other Firebase libraries, only Firebase App option(FIREBASE_INCLUDE_LIBRARY_DEFAULT "" OFF) + option(FIREBASE_CPP_BUILD_TESTS "" ON) add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL) @@ -330,6 +369,4 @@ endif() # Add the Firebase libraries to the target using the function from the SDK. # Note that firebase_app needs to be last in the list. set(firebase_libs firebase_app) -set(gtest_libs gtest gmock) -target_link_libraries(${integration_test_target_name} ${firebase_libs} - ${gtest_libs} ${ADDITIONAL_LIBS}) +target_link_libraries(${integration_test_target_name} ${firebase_libs} gtest gmock ${ADDITIONAL_LIBS}) diff --git a/app/integration_test_internal/src/android/android_app_framework.cc b/app/integration_test_internal/src/android/android_app_framework.cc index 1a31065fbc..3da216d718 100644 --- a/app/integration_test_internal/src/android/android_app_framework.cc +++ b/app/integration_test_internal/src/android/android_app_framework.cc @@ -78,6 +78,10 @@ jobject GetActivity() { return g_app_state->activity->clazz; } // Get the window context. For Android, it's a jobject pointing to the Activity. jobject GetWindowContext() { return g_app_state->activity->clazz; } +// Get the window controller. For Android, this is the same as the +// WindowContext. +jobject GetWindowController() { return GetWindowContext(); } + // Find a class, attempting to load the class if it's not found. jclass FindClass(JNIEnv* env, jobject activity_object, const char* class_name) { jclass class_object = env->FindClass(class_name); @@ -155,13 +159,17 @@ class LoggingUtilsData { logging_utils_start_log_file_ = env->GetStaticMethodID(logging_utils_class_, "startLogFile", "(Landroid/app/Activity;Ljava/lang/String;)Z"); + logging_utils_should_run_uitests_ = + env->GetStaticMethodID(logging_utils_class_, "shouldRunUITests", "()Z"); + logging_utils_should_run_nonuitests_ = env->GetStaticMethodID( + logging_utils_class_, "shouldRunNonUITests", "()Z"); env->CallStaticVoidMethod(logging_utils_class_, logging_utils_init_log_window_, GetActivity()); } void AppendText(const char* text) { - if (logging_utils_class_ == 0) return; // haven't been initted yet + if (logging_utils_class_ == 0) return; // haven't been initialized yet JNIEnv* env = GetJniEnv(); assert(env); jstring text_string = env->NewStringUTF(text); @@ -171,15 +179,35 @@ class LoggingUtilsData { } bool DidTouch() { - if (logging_utils_class_ == 0) return false; // haven't been initted yet + if (logging_utils_class_ == 0) + return false; // haven't been initialized yet JNIEnv* env = GetJniEnv(); assert(env); return env->CallStaticBooleanMethod(logging_utils_class_, logging_utils_get_did_touch_); } + bool ShouldRunUITests() { + if (logging_utils_class_ == 0) + return false; // haven't been initialized yet + JNIEnv* env = GetJniEnv(); + assert(env); + return env->CallStaticBooleanMethod(logging_utils_class_, + logging_utils_should_run_uitests_); + } + + bool ShouldRunNonUITests() { + if (logging_utils_class_ == 0) + return false; // haven't been initialized yet + JNIEnv* env = GetJniEnv(); + assert(env); + return env->CallStaticBooleanMethod(logging_utils_class_, + logging_utils_should_run_nonuitests_); + } + bool IsLoggingToFile() { - if (logging_utils_class_ == 0) return false; // haven't been initted yet + if (logging_utils_class_ == 0) + return false; // haven't been initialized yet JNIEnv* env = GetJniEnv(); assert(env); jobject file_uri = env->CallStaticObjectMethod(logging_utils_class_, @@ -193,7 +221,8 @@ class LoggingUtilsData { } bool StartLoggingToFile(const char* path) { - if (logging_utils_class_ == 0) return false; // haven't been initted yet + if (logging_utils_class_ == 0) + return false; // haven't been initialized yet JNIEnv* env = GetJniEnv(); assert(env); jstring path_string = env->NewStringUTF(path); @@ -211,6 +240,8 @@ class LoggingUtilsData { jmethodID logging_utils_get_did_touch_; jmethodID logging_utils_get_log_file_; jmethodID logging_utils_start_log_file_; + jmethodID logging_utils_should_run_uitests_; + jmethodID logging_utils_should_run_nonuitests_; }; LoggingUtilsData* g_logging_utils_data; @@ -305,6 +336,14 @@ JNIEnv* GetJniEnv() { return result == JNI_OK ? env : nullptr; } +bool ShouldRunUITests() { + return app_framework::g_logging_utils_data->ShouldRunUITests(); +} + +bool ShouldRunNonUITests() { + return app_framework::g_logging_utils_data->ShouldRunNonUITests(); +} + bool IsLoggingToFile() { return app_framework::g_logging_utils_data->IsLoggingToFile(); } diff --git a/app/integration_test_internal/src/android/android_firebase_test_framework.cc b/app/integration_test_internal/src/android/android_firebase_test_framework.cc index 12c092f2d9..32fc26dc31 100644 --- a/app/integration_test_internal/src/android/android_firebase_test_framework.cc +++ b/app/integration_test_internal/src/android/android_firebase_test_framework.cc @@ -222,4 +222,26 @@ bool FirebaseTest::GetPersistentString(const char* key, return true; } +bool FirebaseTest::IsRunningOnEmulator() { + JNIEnv* env = app_framework::GetJniEnv(); + jobject activity = app_framework::GetActivity(); + jclass test_helper_class = app_framework::FindClass( + env, activity, "com/google/firebase/example/TestHelper"); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + jmethodID is_running_on_emulator = + env->GetStaticMethodID(test_helper_class, "isRunningOnEmulator", "()Z"); + jboolean result = + env->CallStaticBooleanMethod(test_helper_class, is_running_on_emulator); + if (env->ExceptionCheck()) { + env->ExceptionDescribe(); + env->ExceptionClear(); + return false; + } + return result ? true : false; +} + } // namespace firebase_test_framework diff --git a/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java b/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java index a8fabf28b1..d32044042f 100644 --- a/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java +++ b/app/integration_test_internal/src/android/java/com/google/firebase/example/LoggingUtils.java @@ -43,6 +43,8 @@ public class LoggingUtils { private static boolean didTouch = false; // If a test log file is specified, this is the log file's URI... private static Uri logFile = null; + private static boolean shouldRunUITests = true; + private static boolean shouldRunNonUITests = true; // ...and this is the stream to write to. private static DataOutputStream logFileStream = null; @@ -102,6 +104,10 @@ public boolean onTouch(View v, MotionEvent event) { Intent launchIntent = activity.getIntent(); // Check if we are running on Firebase Test Lab, and set up a log file if we are. if (launchIntent.getAction().equals("com.google.intent.action.TEST_LOOP")) { + shouldRunUITests = false; + startLogFile(activity, launchIntent.getData().toString()); + } else if (launchIntent.getAction().equals("com.google.intent.action.UI_TEST")) { + shouldRunNonUITests = false; startLogFile(activity, launchIntent.getData().toString()); } } @@ -160,4 +166,12 @@ public static String getLogFile() { return null; } } + + public static boolean shouldRunUITests() { + return shouldRunUITests; + } + + public static boolean shouldRunNonUITests() { + return shouldRunNonUITests; + } } diff --git a/app/integration_test_internal/src/app_framework.h b/app/integration_test_internal/src/app_framework.h index 580b3bd939..5464d09681 100644 --- a/app/integration_test_internal/src/app_framework.h +++ b/app/integration_test_internal/src/app_framework.h @@ -104,6 +104,12 @@ jobject GetActivity(); jclass FindClass(JNIEnv* env, jobject activity_object, const char* class_name); #endif // defined(__ANDROID__) +// Returns ture if we run tests that require interaction. +bool ShouldRunUITests(); + +// Returns true if we run tests that do not require interaction. +bool ShouldRunNonUITests(); + // Returns true if the logger is currently logging to a file. bool IsLoggingToFile(); @@ -116,6 +122,12 @@ bool StartLoggingToFile(const char* path); // to the root view of the view controller. WindowContext GetWindowContext(); +// Returns a variable that describes the controller of the app's UI. On Android +// this will be a jobject pointing to the Activity, the same as +// GetWindowContext(). On iOS, it's an id pointing to the UIViewController of +// the parent UIView. +WindowContext GetWindowController(); + // Run the given function on a detached background thread. void RunOnBackgroundThread(void* (*func)(void* data), void* data); diff --git a/app/integration_test_internal/src/desktop/desktop_app_framework.cc b/app/integration_test_internal/src/desktop/desktop_app_framework.cc index 0b90cd4bfa..9f58bd4383 100644 --- a/app/integration_test_internal/src/desktop/desktop_app_framework.cc +++ b/app/integration_test_internal/src/desktop/desktop_app_framework.cc @@ -148,6 +148,7 @@ void OutputFullLog() { } WindowContext GetWindowContext() { return nullptr; } +WindowContext GetWindowController() { return nullptr; } // Change the current working directory to the directory containing the // specified file. @@ -210,6 +211,10 @@ std::string ReadTextInput(const char* title, const char* message, return input_line.empty() ? std::string(placeholder) : input_line; } +bool ShouldRunUITests() { return true; } + +bool ShouldRunNonUITests() { return true; } + bool IsLoggingToFile() { return false; } } // namespace app_framework diff --git a/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc b/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc index 8ffbf9bb44..ec01ae7bc7 100644 --- a/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc +++ b/app/integration_test_internal/src/desktop/desktop_firebase_test_framework.cc @@ -49,4 +49,9 @@ bool FirebaseTest::GetPersistentString(const char* key, return false; } +bool FirebaseTest::IsRunningOnEmulator() { + // No emulators on desktop. + return false; +} + } // namespace firebase_test_framework diff --git a/app/integration_test_internal/src/firebase_test_framework.cc b/app/integration_test_internal/src/firebase_test_framework.cc index eacafd45a4..726664a573 100644 --- a/app/integration_test_internal/src/firebase_test_framework.cc +++ b/app/integration_test_internal/src/firebase_test_framework.cc @@ -262,10 +262,12 @@ std::string FirebaseTest::VariantToString(const firebase::Variant& variant) { return out.str(); } -bool FirebaseTest::IsUserInteractionAllowed() { - // In the trivial case, just check whether we are logging to file. If not, - // assume interaction is allowed. - return !app_framework::IsLoggingToFile(); +bool FirebaseTest::ShouldRunUITests() { + return app_framework::ShouldRunUITests(); +} + +bool FirebaseTest::ShouldRunNonUITests() { + return app_framework::ShouldRunNonUITests(); } bool FirebaseTest::Base64Encode(const std::string& input, std::string* output) { diff --git a/app/integration_test_internal/src/firebase_test_framework.h b/app/integration_test_internal/src/firebase_test_framework.h index ef466b7f1a..c136657d79 100644 --- a/app/integration_test_internal/src/firebase_test_framework.h +++ b/app/integration_test_internal/src/firebase_test_framework.h @@ -36,14 +36,26 @@ namespace firebase_test_framework { +// Use this macro to skip an entire test if it is an non UI Test and we are +// not running it in UItest mode (for example, on UI Test workflow). +#define TEST_DOES_NOT_REQUIRE_USER_INTERACTION \ + if (!ShouldRunNonUITests()) { \ + app_framework::LogInfo( \ + "Skipping %s, as it is a Non UI Test.", \ + ::testing::UnitTest::GetInstance()->current_test_info()->name()); \ + GTEST_SKIP(); \ + return; \ + } + // Use this macro to skip an entire test if it requires interactivity and we are // not running in interactive mode (for example, on FTL). -#define TEST_REQUIRES_USER_INTERACTION \ - if (!IsUserInteractionAllowed()) { \ - app_framework::LogInfo("Skipping %s, as it requires user interaction.", \ - test_info_->name()); \ - GTEST_SKIP(); \ - return; \ +#define TEST_REQUIRES_USER_INTERACTION \ + if (!ShouldRunUITests()) { \ + app_framework::LogInfo( \ + "Skipping %s, as it requires user interaction.", \ + ::testing::UnitTest::GetInstance()->current_test_info()->name()); \ + GTEST_SKIP(); \ + return; \ } #if TARGET_OS_IPHONE @@ -74,6 +86,8 @@ namespace firebase_test_framework { // SKIP_TEST_ON_LINUX // SKIP_TEST_ON_WINDOWS // SKIP_TEST_ON_MACOS +// SKIP_TEST_ON_SIMULATOR / SKIP_TEST_ON_EMULATOR (identical) +// SKIP_TEST_ON_IOS_SIMULATOR / SKIP_TEST_ON_ANDROID_EMULATOR // // Also includes a special macro SKIP_TEST_IF_USING_STLPORT if compiling for // Android STLPort, which does not fully support C++11. @@ -166,6 +180,31 @@ namespace firebase_test_framework { #define SKIP_TEST_ON_ANDROID ((void)0) #endif // defined(ANDROID) +// Android needs to determine emulator at runtime, so we can't just use #ifdef. +#define SKIP_TEST_ON_SIMULATOR \ + { \ + if (IsRunningOnEmulator()) { \ + app_framework::LogInfo("Skipping %s on simulator/emulator.", \ + test_info_->name()); \ + GTEST_SKIP(); \ + return; \ + } \ + } + +// Accept either name, simulator or emulator. +#define SKIP_TEST_ON_EMULATOR SKIP_TEST_ON_SIMULATOR + +#if defined(ANDROID) +#define SKIP_TEST_ON_ANDROID_EMULATOR SKIP_TEST_ON_EMULATOR +#define SKIP_TEST_ON_IOS_SIMULATOR ((void)0) +#elif defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE +#define SKIP_TEST_ON_ANDROID_EMULATOR ((void)0) +#define SKIP_TEST_ON_IOS_SIMULATOR SKIP_TEST_ON_SIMULATOR +#else +#define SKIP_TEST_ON_IOS_SIMULATOR ((void)0) +#define SKIP_TEST_ON_ANDROID_EMULATOR ((void)0) +#endif + #if defined(STLPORT) #define SKIP_TEST_IF_USING_STLPORT \ { \ @@ -289,6 +328,10 @@ class FirebaseTest : public testing::Test { // successful, false if something went wrong. static bool SetPersistentString(const char* key, const char* value); + // Return true if the app is running on simulator/emulator, false if + // on a real device (or on desktop). + static bool IsRunningOnEmulator(); + // Returns true if the future completed as expected, fails the test and // returns false otherwise. static bool WaitForCompletion(const firebase::FutureBase& future, @@ -443,8 +486,12 @@ class FirebaseTest : public testing::Test { // Open a URL in a browser window, for testing only. static bool OpenUrlInBrowser(const char* url); - // Returns true if we can run tests that require interaction, false if not. - static bool IsUserInteractionAllowed(); + // Returns true if we run tests that require interaction, false if not. + static bool ShouldRunUITests(); + + // Returns true if we run tests that do not require interaction, false if + // not. + static bool ShouldRunNonUITests(); // Encode a binary string to base64. Returns true if the encoding succeeded, // false if it failed. diff --git a/app/integration_test_internal/src/integration_test.cc b/app/integration_test_internal/src/integration_test.cc index c22acb8bec..a6d722632e 100644 --- a/app/integration_test_internal/src/integration_test.cc +++ b/app/integration_test_internal/src/integration_test.cc @@ -42,6 +42,8 @@ using firebase_test_framework::FirebaseTest; class FirebaseAppTest : public FirebaseTest { public: FirebaseAppTest(); + static void SetUpTestSuite(); + static void TearDownTestSuite(); }; FirebaseAppTest::FirebaseAppTest() { @@ -56,6 +58,20 @@ FirebaseAppTest::FirebaseAppTest() { #define APP_CREATE_PARAMS #endif // defined(__ANDROID__) +void FirebaseAppTest::SetUpTestSuite() { + // Nothing to do here. +} + +void FirebaseAppTest::TearDownTestSuite() { + // The App integration test is too fast for FTL, so pause a few seconds + // here. + ProcessEvents(1000); + ProcessEvents(1000); + ProcessEvents(1000); + ProcessEvents(1000); + ProcessEvents(1000); +} + TEST_F(FirebaseAppTest, TestDefaultAppWithDefaultOptions) { firebase::App* default_app; default_app = firebase::App::Create(APP_CREATE_PARAMS); diff --git a/app/integration_test_internal/src/ios/ios_app_framework.mm b/app/integration_test_internal/src/ios/ios_app_framework.mm index b7a32a1bc3..b63ca42b70 100644 --- a/app/integration_test_internal/src/ios/ios_app_framework.mm +++ b/app/integration_test_internal/src/ios/ios_app_framework.mm @@ -42,6 +42,7 @@ @interface FTAViewController : UIViewController @end static NSString *const kGameLoopUrlPrefix = @"firebase-game-loop"; +static NSString *const kUITestUrlPrefix = @"firebase-ui-test"; static NSString *const kGameLoopCompleteUrlScheme = @"firebase-game-loop-complete://"; static const float kGameLoopSecondsToPauseBeforeQuitting = 5.0f; @@ -59,8 +60,10 @@ @interface FTAViewController : UIViewController static UITextView *g_text_view; static UIView *g_parent_view; +static UIViewController *g_parent_view_controller; static FTAViewController *g_view_controller; static bool g_gameloop_launch = false; +static bool g_uitest_launch = false; static NSURL *g_results_url; static NSString *g_file_name; static NSString *g_file_url_path; @@ -70,6 +73,16 @@ @implementation FTAViewController - (void)viewDidLoad { [super viewDidLoad]; g_parent_view = self.view; + g_parent_view_controller = nil; + UIResponder *responder = [g_parent_view nextResponder]; + while (responder != nil) { + if ([responder isKindOfClass:[UIViewController class]]) { + g_parent_view_controller = (UIViewController *)responder; + break; + } + responder = [responder nextResponder]; + } + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // Copy the app name into a non-const array, as googletest requires that // main() take non-const char* argv[] so it can modify the arguments. @@ -122,6 +135,7 @@ bool ProcessEvents(int msec) { } WindowContext GetWindowContext() { return g_parent_view; } +WindowContext GetWindowController() { return g_parent_view_controller; } // Log a message that can be viewed in the console. void LogMessageV(bool suppress, const char *format, va_list list) { @@ -173,7 +187,7 @@ void AddToTextView(const char *str) { NSRange range = NSMakeRange(g_text_view.text.length, 0); [g_text_view scrollRangeToVisible:range]; }); - if (g_gameloop_launch) { + if (g_gameloop_launch || g_uitest_launch) { NSData *data = [message dataUsingEncoding:NSUTF8StringEncoding]; if ([NSFileManager.defaultManager fileExistsAtPath:g_file_url_path]) { NSFileHandle *fileHandler = [NSFileHandle fileHandleForUpdatingAtPath:g_file_url_path]; @@ -274,6 +288,10 @@ void RunOnBackgroundThread(void *(*func)(void *), void *data) { } } +bool ShouldRunUITests() { return !g_gameloop_launch; } + +bool ShouldRunNonUITests() { return !g_uitest_launch; } + bool IsLoggingToFile() { return g_file_url_path; } bool StartLoggingToFile(const char *file_path) { @@ -335,9 +353,13 @@ - (BOOL)application:(UIApplication *)app g_gameloop_launch = true; app_framework::StartLoggingToFile(GAMELOOP_DEFAULT_LOG_FILE); return YES; + } else if ([url.scheme isEqual:kUITestUrlPrefix]) { + g_uitest_launch = true; + app_framework::StartLoggingToFile(GAMELOOP_DEFAULT_LOG_FILE); + return YES; } - NSLog(@"The testapp will not log to files since it is not launched by URL %@", - kGameLoopUrlPrefix); + NSLog(@"The testapp will not log to files since it is not launched by URL %@ or %@", + kGameLoopUrlPrefix, kUITestUrlPrefix); return NO; } diff --git a/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm b/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm index 4c9112f412..0d07e417b6 100644 --- a/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm +++ b/app/integration_test_internal/src/ios/ios_firebase_test_framework.mm @@ -191,4 +191,13 @@ static bool SendHttpRequest(const char* method, const char* url, return true; } +bool FirebaseTest::IsRunningOnEmulator() { + // On iOS/tvOS it's an easy compile-time definition. +#if TARGET_OS_SIMULATOR + return true; +#else + return false; +#endif +} + } // namespace firebase_test_framework diff --git a/scripts/gha/integration_testing/build_testapps.json b/scripts/gha/integration_testing/build_testapps.json index d651772fe1..ae484e6679 100755 --- a/scripts/gha/integration_testing/build_testapps.json +++ b/scripts/gha/integration_testing/build_testapps.json @@ -7,7 +7,7 @@ "ios_target": "integration_test", "tvos_target": "integration_test_tvos", "testapp_path": "app/integration_test", - "internal_testapp_path": "firestore/integration_test_internal", + "internal_testapp_path": "app/integration_test_internal", "frameworks": [ "firebase_analytics.xcframework", "firebase.xcframework" From d50de36281e8d2a0e583627f4a51d139f304b48c Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Thu, 22 Dec 2022 12:22:01 -0800 Subject: [PATCH 4/5] Remove extra includes and tests that don't build yet. --- app/integration_test/src/integration_test.cc | 1 + app/integration_test_internal/CMakeLists.txt | 70 +------------------ .../src/integration_test.cc | 1 + app/tests/app_test.cc | 7 +- app/tests/base64_openssh_test.cc | 18 ++--- app/tests/future_manager_test.cc | 2 - 6 files changed, 18 insertions(+), 81 deletions(-) diff --git a/app/integration_test/src/integration_test.cc b/app/integration_test/src/integration_test.cc index a6d722632e..0805ae1712 100644 --- a/app/integration_test/src/integration_test.cc +++ b/app/integration_test/src/integration_test.cc @@ -37,6 +37,7 @@ namespace firebase_testapp_automated { +using app_framework::ProcessEvents; using firebase_test_framework::FirebaseTest; class FirebaseAppTest : public FirebaseTest { diff --git a/app/integration_test_internal/CMakeLists.txt b/app/integration_test_internal/CMakeLists.txt index 5f2f965aa1..7409bf409f 100644 --- a/app/integration_test_internal/CMakeLists.txt +++ b/app/integration_test_internal/CMakeLists.txt @@ -87,9 +87,7 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS # Copy of the standard integration test source file. src/integration_test.cc # All of the unit tests from App and other SDKs. - ${FIREBASE_CPP_SDK_DIR}/app/tests/app_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/assert_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/base64_openssh_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/base64_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/callback_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/cleanup_notifier_test.cc @@ -125,13 +123,11 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS add_definitions(-DFIREBASE_INTEGRATION_TEST) set(FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_binary_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_file_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_json_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_binary_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_json_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/transport_curl_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/transport_mock_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/util_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/www_form_url_encoded_test.cc @@ -159,35 +155,12 @@ include_directories(src) include_directories(${FIREBASE_CPP_SDK_DIR}) # The include directory for the C++ SDK root. include_directories(${FIREBASE_CPP_SDK_DIR}) +# OpenSSL include directories. +include_directories(${OPENSSL_INCLUDE_DIR}) # Integration test uses some features that require C++ 11, such as lambdas. set (CMAKE_CXX_STANDARD 11) -# 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} . - -G ${CMAKE_GENERATOR} - -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - 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. @@ -210,23 +183,6 @@ if(ANDROID) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") - if (NOT TARGET gtest) - add_library(gtest STATIC - ${GOOGLETEST_ROOT}/src/googletest/src/gtest-all.cc) - endif() - target_include_directories(gtest - PRIVATE ${GOOGLETEST_ROOT}/src/googletest - PUBLIC ${GOOGLETEST_ROOT}/src/googletest/include) - if (NOT TARGET gmock) - add_library(gmock STATIC - ${GOOGLETEST_ROOT}/src/googlemock/src/gmock-all.cc) - endif() - 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 @@ -245,26 +201,6 @@ 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. - if (NOT (TARGET gtest OR TARGET gmock)) - add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/external/googletest/src - ${CMAKE_CURRENT_LIST_DIR}/external/googletest/build - EXCLUDE_FROM_ALL) - endif() - - # 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 @@ -368,5 +304,5 @@ endif() # Add the Firebase libraries to the target using the function from the SDK. # Note that firebase_app needs to be last in the list. -set(firebase_libs firebase_app) +set(firebase_libs firebase_app firebase_testing) target_link_libraries(${integration_test_target_name} ${firebase_libs} gtest gmock ${ADDITIONAL_LIBS}) diff --git a/app/integration_test_internal/src/integration_test.cc b/app/integration_test_internal/src/integration_test.cc index a6d722632e..0805ae1712 100644 --- a/app/integration_test_internal/src/integration_test.cc +++ b/app/integration_test_internal/src/integration_test.cc @@ -37,6 +37,7 @@ namespace firebase_testapp_automated { +using app_framework::ProcessEvents; using firebase_test_framework::FirebaseTest; class FirebaseAppTest : public FirebaseTest { diff --git a/app/tests/app_test.cc b/app/tests/app_test.cc index ad60202f22..ca16a9f541 100644 --- a/app/tests/app_test.cc +++ b/app/tests/app_test.cc @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "absl/flags/flag.h" #if defined(FIREBASE_ANDROID_FOR_DESKTOP) #ifndef __ANDROID__ #define __ANDROID__ @@ -82,12 +81,14 @@ using testing::Not; namespace firebase { +extern std::string g_test_srcdir; +std::string g_test_srcdir; + class AppTest : public ::testing::Test { protected: AppTest() : current_path_buffer_(nullptr) { #if TEST_RESOURCES_AVAILABLE - test_data_dir_ = absl::GetFlag(FLAGS_test_srcdir) + - "/google3/firebase/app/client/cpp/testdata"; + test_data_dir_ = g_test_srcdir + "/google3/firebase/app/client/cpp/testdata"; broken_test_data_dir_ = test_data_dir_ + "/broken"; #endif // TEST_RESOURCES_AVAILABLE } diff --git a/app/tests/base64_openssh_test.cc b/app/tests/base64_openssh_test.cc index fd9b08e3c6..cf3cf4e6e3 100644 --- a/app/tests/base64_openssh_test.cc +++ b/app/tests/base64_openssh_test.cc @@ -14,7 +14,6 @@ * limitations under the License. */ -#include "absl/strings/string_view.h" #include "app/src/base64.h" #include "app/src/log.h" #include "gmock/gmock.h" @@ -32,12 +31,12 @@ size_t OpenSSHEncodedLength(size_t input_size) { return length; } -bool OpenSSHEncode(absl::string_view input, std::string* output) { - size_t base64_length = OpenSSHEncodedLength(input.size()); +bool OpenSSHEncode(const char* input, size_t input_size, std::string* output) { + size_t base64_length = OpenSSHEncodedLength(input_size); output->resize(base64_length); if (EVP_EncodeBlock(reinterpret_cast(&(*output)[0]), reinterpret_cast(&input[0]), - input.size()) == 0u) { + input_size) == 0u) { return false; } // Trim the terminating null character. @@ -53,13 +52,13 @@ size_t OpenSSHDecodedLength(size_t input_size) { return length; } -bool OpenSSHDecode(absl::string_view input, std::string* output) { - size_t decoded_length = OpenSSHDecodedLength(input.size()); +bool OpenSSHDecode(const char* input, size_t input_size, std::string* output) { + size_t decoded_length = OpenSSHDecodedLength(input_size); output->resize(decoded_length); if (EVP_DecodeBase64(reinterpret_cast(&(*output)[0]), &decoded_length, decoded_length, reinterpret_cast(&(input)[0]), - input.size()) == 0) { + input_size) == 0) { return false; } // Decoded length includes null termination, remove. @@ -80,14 +79,15 @@ TEST(Base64TestAgainstOpenSSH, TestEncodingAgainstOpenSSH) { std::string encoded_firebase, encoded_openssh; ASSERT_TRUE(Base64EncodeWithPadding(orig, &encoded_firebase)); - ASSERT_TRUE(OpenSSHEncode(orig, &encoded_openssh)); + ASSERT_TRUE(OpenSSHEncode(orig, bytes, &encoded_openssh)); EXPECT_EQ(encoded_firebase, encoded_openssh) << "Encoding mismatch on source buffer: " << orig; std::string decoded_firebase_to_openssh; std::string decoded_openssh_to_firebase; ASSERT_TRUE(Base64Decode(encoded_openssh, &decoded_openssh_to_firebase)); - ASSERT_TRUE(OpenSSHDecode(encoded_firebase, &decoded_firebase_to_openssh)); + ASSERT_TRUE(OpenSSHDecode(&encoded_firebase[0], encoded_firebase.length(), + &decoded_firebase_to_openssh)); EXPECT_EQ(decoded_openssh_to_firebase, decoded_firebase_to_openssh) << "Cross-decoding mismatch on source buffer: " << orig; EXPECT_EQ(orig, decoded_firebase_to_openssh); diff --git a/app/tests/future_manager_test.cc b/app/tests/future_manager_test.cc index fa4f3603a5..228c67f6d4 100644 --- a/app/tests/future_manager_test.cc +++ b/app/tests/future_manager_test.cc @@ -27,8 +27,6 @@ #include "app/src/thread.h" #include "gmock/gmock.h" #include "gtest/gtest.h" -#include "thread/fiber/fiber.h" -#include "util/random/mt_random_thread_safe.h" using ::testing::Eq; using ::testing::IsNull; From a4a0610112b2885022b2feb87fe46778a8ae661f Mon Sep 17 00:00:00 2001 From: Jon Simantov Date: Sun, 1 Jan 2023 23:18:19 -0800 Subject: [PATCH 5/5] Fix test build. --- CMakeLists.txt | 2 +- app/integration_test_internal/CMakeLists.txt | 26 +++++++++++++++----- app/tests/google_services_test.cc | 5 +--- app/tests/intrusive_list_test.cc | 4 --- app/tests/variant_test.cc | 4 +++ scripts/gha/build_testapps.py | 2 +- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 82a1b8c948..bd0451e285 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2018 Google LLC + # Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/app/integration_test_internal/CMakeLists.txt b/app/integration_test_internal/CMakeLists.txt index 7409bf409f..6372fa11e4 100644 --- a/app/integration_test_internal/CMakeLists.txt +++ b/app/integration_test_internal/CMakeLists.txt @@ -92,13 +92,10 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS ${FIREBASE_CPP_SDK_DIR}/app/tests/callback_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/cleanup_notifier_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/flexbuffer_matcher_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/flexbuffer_matcher.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/future_manager_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/future_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/google_services_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_storage_desktop_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_controller_desktop_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/intrusive_list_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/jobject_reference_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/locale_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/log_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/logger_test.cc @@ -109,7 +106,6 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS ${FIREBASE_CPP_SDK_DIR}/app/tests/semaphore_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/thread_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/time_test.cc - ${FIREBASE_CPP_SDK_DIR}/app/tests/util_android_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/util_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/uuid_test.cc ${FIREBASE_CPP_SDK_DIR}/app/tests/variant_test.cc @@ -120,8 +116,12 @@ set(FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS ${FIREBASE_CPP_SDK_DIR}/app/meta/move_test.cc ) +add_definitions(-DINTERNAL_EXPERIMENTAL) add_definitions(-DFIREBASE_INTEGRATION_TEST) +#add_definitions(-DFIREBASE_TESTING) set(FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS +# ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_storage_desktop_test.cc +# ${FIREBASE_CPP_SDK_DIR}/app/tests/heartbeat_controller_desktop_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_binary_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_json_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/request_test.cc @@ -129,6 +129,7 @@ set(FIREBASE_INTEGRATION_TEST_DESKTOP_SRCS ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_json_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/response_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/transport_mock_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/rest/transport_mock.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/util_test.cc ${FIREBASE_CPP_SDK_DIR}/app/rest/tests/www_form_url_encoded_test.cc ) @@ -141,6 +142,8 @@ if(IOS) elif(ANDROID) set(FIREBASE_INTEGRATION_TEST_SRCS ${FIREBASE_INTEGRATION_TEST_PORTABLE_SRCS} + ${FIREBASE_CPP_SDK_DIR}/app/tests/jobject_reference_test.cc + ${FIREBASE_CPP_SDK_DIR}/app/tests/util_android_test.cc ) else() # DESKTOP set(FIREBASE_INTEGRATION_TEST_SRCS @@ -265,12 +268,15 @@ endif() option(FIREBASE_INCLUDE_LIBRARY_DEFAULT "" OFF) option(FIREBASE_CPP_BUILD_TESTS "" ON) +set(CURL_STATICLIB ON CACHE BOOL "") + add_subdirectory(${FIREBASE_CPP_SDK_DIR} bin/ EXCLUDE_FROM_ALL) get_directory_property(ZLIB_SOURCE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION ZLIB_SOURCE_DIR) get_directory_property(ZLIB_BINARY_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION ZLIB_BINARY_DIR) get_directory_property(FLATBUFFERS_SOURCE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION FLATBUFFERS_SOURCE_DIR) get_directory_property(FIREBASE_GEN_FILE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION FIREBASE_GEN_FILE_DIR) +get_directory_property(GOOGLETEST_SOURCE_DIR DIRECTORY ${FIREBASE_CPP_SDK_DIR} DEFINITION GOOGLETEST_SOURCE_DIR) # Additional include paths populated by top-level SDK CMakeLists if(NOT ANDROID AND NOT IOS) @@ -302,7 +308,15 @@ if(NOT ANDROID AND NOT IOS) endif() endif() + +# gtest include directories. +target_include_directories(${integration_test_target_name} + PRIVATE ${GOOGLETEST_SOURCE_DIR}/googletest + PRIVATE ${GOOGLETEST_SOURCE_DIR}/googlemock + PUBLIC ${GOOGLETEST_SOURCE_DIR}/googletest/include + PUBLIC ${GOOGLETEST_SOURCE_DIR}/googlemock/include) + # Add the Firebase libraries to the target using the function from the SDK. # Note that firebase_app needs to be last in the list. -set(firebase_libs firebase_app firebase_testing) +set(firebase_libs firebase_app firebase_rest_lib firebase_testing flatbuffers libcurl) target_link_libraries(${integration_test_target_name} ${firebase_libs} gtest gmock ${ADDITIONAL_LIBS}) diff --git a/app/tests/google_services_test.cc b/app/tests/google_services_test.cc index 78557fa8f4..b6230bcd25 100644 --- a/app/tests/google_services_test.cc +++ b/app/tests/google_services_test.cc @@ -16,7 +16,6 @@ #include -#include "absl/flags/flag.h" #include "app/google_services_resource.h" #include "app/src/log.h" #include "flatbuffers/idl.h" @@ -53,9 +52,7 @@ bool Parse(const char* config) { // Test the conformity of the provided .json file. TEST(GoogleServicesTest, TestConformity) { // This is an actual .json, copied from Firebase auth sample app. - std::string json_file = - absl::GetFlag(FLAGS_test_srcdir) + - "/google3/firebase/app/client/cpp/testdata/google-services.json"; + std::string json_file = "google-services.json"; std::string json_str; EXPECT_TRUE(flatbuffers::LoadFile(json_file.c_str(), false, &json_str)); EXPECT_FALSE(json_str.empty()); diff --git a/app/tests/intrusive_list_test.cc b/app/tests/intrusive_list_test.cc index db43bf5add..375c818ee7 100644 --- a/app/tests/intrusive_list_test.cc +++ b/app/tests/intrusive_list_test.cc @@ -1223,7 +1223,3 @@ TEST_F(intrusive_list_test, erase_range) { EXPECT_EQ(list_.size(), 0); } -int main(int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/app/tests/variant_test.cc b/app/tests/variant_test.cc index 28d9d6f483..5a80f9bb97 100644 --- a/app/tests/variant_test.cc +++ b/app/tests/variant_test.cc @@ -48,6 +48,10 @@ class VariantInternal { using firebase::internal::VariantInternal; +#ifndef DEATHTEST_SIGABRT +#define DEATHTEST_SIGABRT "" +#endif + namespace firebase { namespace testing { diff --git a/scripts/gha/build_testapps.py b/scripts/gha/build_testapps.py index 7a2960a58f..be7e6e7520 100644 --- a/scripts/gha/build_testapps.py +++ b/scripts/gha/build_testapps.py @@ -352,7 +352,7 @@ def _build( except subprocess.SubprocessError as e: failures.append( Failure(testapp=testapp, platform=_DESKTOP, error_message=str(e))) - _rm_dir_safe(os.path.join(project_dir, "bin")) + ### _rm_dir_safe(os.path.join(project_dir, "bin")) logging.info("END %s, %s", testapp, _DESKTOP) if _ANDROID in platforms: