Просмотр исходного кода

[Infra] Remove `HeartbeatLoggingTestUtils.podspec` (#11370)

* [Infra] Remove HeartbeatLoggingTestUtils.podspec

* Review
Nick Cooke 2 лет назад
Родитель
Сommit
1e040186a6

+ 18 - 23
FirebaseAppCheck.podspec

@@ -54,29 +54,24 @@ Pod::Spec.new do |s|
     'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
   }
 
-  # Using environment variable because of the dependency on the unpublished
-  # HeartbeatLoggingTestUtils.
-  if ENV['POD_LIB_LINT_ONLY'] && ENV['POD_LIB_LINT_ONLY'] == '1' then
-    s.test_spec 'unit' do |unit_tests|
-      unit_tests.platforms = {
-        :ios => ios_deployment_target,
-        :osx => osx_deployment_target,
-        :tvos => tvos_deployment_target
-      }
-      unit_tests.source_files = [
-        base_dir + 'Tests/Unit/**/*.[mh]',
-        base_dir + 'Tests/Utils/**/*.[mh]',
-        'SharedTestUtilities/AppCheckFake/*',
-        'SharedTestUtilities/AppCheckBackoffWrapperFake/*',
-        'SharedTestUtilities/Date/*',
-        'SharedTestUtilities/URLSession/*',
-      ]
-
-      unit_tests.resources = base_dir + 'Tests/Fixture/**/*'
-      unit_tests.dependency 'OCMock'
-      unit_tests.dependency 'HeartbeatLoggingTestUtils'
-      unit_tests.requires_app_host = true
-    end
+  s.test_spec 'unit' do |unit_tests|
+    unit_tests.platforms = {
+      :ios => ios_deployment_target,
+      :osx => osx_deployment_target,
+      :tvos => tvos_deployment_target
+    }
+    unit_tests.source_files = [
+      base_dir + 'Tests/Unit/**/*.[mh]',
+      base_dir + 'Tests/Utils/**/*.[mh]',
+      'SharedTestUtilities/AppCheckFake/*',
+      'SharedTestUtilities/AppCheckBackoffWrapperFake/*',
+      'SharedTestUtilities/Date/*',
+      'SharedTestUtilities/URLSession/*',
+    ]
+
+    unit_tests.resources = base_dir + 'Tests/Fixture/**/*'
+    unit_tests.dependency 'OCMock'
+    unit_tests.requires_app_host = true
   end
 
   s.test_spec 'integration' do |integration_tests|

+ 1 - 1
FirebaseAppCheck/Tests/Unit/Core/FIRAppCheckAPIServiceTests.m

@@ -19,7 +19,7 @@
 #import <OCMock/OCMock.h>
 #import "FBLPromise+Testing.h"
 
-@import HeartbeatLoggingTestUtils;
+@import FirebaseCoreInternal;
 
 #import <GoogleUtilities/GULURLSessionDataResponse.h>
 #import <GoogleUtilities/NSURLSession+GULPromises.h>

+ 45 - 50
FirebaseAuth.podspec

@@ -58,57 +58,52 @@ supports email and password accounts, as well as several 3rd party authenticatio
   s.dependency 'GoogleUtilities/Environment', '~> 7.8'
   s.dependency 'GTMSessionFetcher/Core', '>= 2.1', '< 4.0'
 
-  # Using environment variable because of the dependency on the unpublished
-  # HeartbeatLoggingTestUtils.
-  if ENV['POD_LIB_LINT_ONLY'] && ENV['POD_LIB_LINT_ONLY'] == '1' then
-    s.test_spec 'unit' do |unit_tests|
-      unit_tests.scheme = { :code_coverage => true }
-      # Unit tests can't run on watchOS.
-      unit_tests.platforms = {
-        :ios => ios_deployment_target,
-        :osx => osx_deployment_target,
-        :tvos => tvos_deployment_target
-      }
-      unit_tests.source_files = 'FirebaseAuth/Tests/Unit/*.[mh]'
-      unit_tests.osx.exclude_files = [
-        'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenManagerTests.m',
-        'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenTests.m',
-        'FirebaseAuth/Tests/Unit/FIRAuthAppCredentialManagerTests.m',
-        'FirebaseAuth/Tests/Unit/FIRAuthNotificationManagerTests.m',
-        'FirebaseAuth/Tests/Unit/FIRAuthURLPresenterTests.m',
-        'FirebaseAuth/Tests/Unit/FIREmailLink*',
-        'FirebaseAuth/Tests/Unit/FIRPhoneAuthProviderTests.m',
-        'FirebaseAuth/Tests/Unit/FIRSendVerificationCode*',
-        'FirebaseAuth/Tests/Unit/FIRSignInWithGameCenterTests.m',
-        'FirebaseAuth/Tests/Unit/FIRVerifyClient*',
-        'FirebaseAuth/Tests/Unit/FIRVerifyPhoneNumber*',
-        'FirebaseAuth/Tests/Unit/FIROAuthProviderTests.m',
-        'FirebaseAuth/Tests/Unit/FIRMultiFactorResolverTests.m',
-      ]
-      unit_tests.tvos.exclude_files = [
-        'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenManagerTests.m',
-        'FirebaseAuth/Tests/Unit/FIRAuthNotificationManagerTests.m',
-        'FirebaseAuth/Tests/Unit/FIRAuthURLPresenterTests.m',
-        'FirebaseAuth/Tests/Unit/FIREmailLink*',
-        'FirebaseAuth/Tests/Unit/FIRPhoneAuthProviderTests.m',
-        'FirebaseAuth/Tests/Unit/FIRSendVerificationCode*',
-        'FirebaseAuth/Tests/Unit/FIRSignInWithGameCenterTests.m',
-        'FirebaseAuth/Tests/Unit/FIRVerifyClient*',
-        'FirebaseAuth/Tests/Unit/FIRVerifyPhoneNumber*',
-        'FirebaseAuth/Tests/Unit/FIROAuthProviderTests.m',
-        'FirebaseAuth/Tests/Unit/FIRMultiFactorResolverTests.m',
-      ]
-      # app_host is needed for tests with keychain
-      unit_tests.requires_app_host = true
-      unit_tests.dependency 'OCMock'
-      unit_tests.dependency 'HeartbeatLoggingTestUtils'
+  s.test_spec 'unit' do |unit_tests|
+    unit_tests.scheme = { :code_coverage => true }
+    # Unit tests can't run on watchOS.
+    unit_tests.platforms = {
+      :ios => ios_deployment_target,
+      :osx => osx_deployment_target,
+      :tvos => tvos_deployment_target
+    }
+    unit_tests.source_files = 'FirebaseAuth/Tests/Unit/*.[mh]'
+    unit_tests.osx.exclude_files = [
+      'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenManagerTests.m',
+      'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenTests.m',
+      'FirebaseAuth/Tests/Unit/FIRAuthAppCredentialManagerTests.m',
+      'FirebaseAuth/Tests/Unit/FIRAuthNotificationManagerTests.m',
+      'FirebaseAuth/Tests/Unit/FIRAuthURLPresenterTests.m',
+      'FirebaseAuth/Tests/Unit/FIREmailLink*',
+      'FirebaseAuth/Tests/Unit/FIRPhoneAuthProviderTests.m',
+      'FirebaseAuth/Tests/Unit/FIRSendVerificationCode*',
+      'FirebaseAuth/Tests/Unit/FIRSignInWithGameCenterTests.m',
+      'FirebaseAuth/Tests/Unit/FIRVerifyClient*',
+      'FirebaseAuth/Tests/Unit/FIRVerifyPhoneNumber*',
+      'FirebaseAuth/Tests/Unit/FIROAuthProviderTests.m',
+      'FirebaseAuth/Tests/Unit/FIRMultiFactorResolverTests.m',
+    ]
+    unit_tests.tvos.exclude_files = [
+      'FirebaseAuth/Tests/Unit/FIRAuthAPNSTokenManagerTests.m',
+      'FirebaseAuth/Tests/Unit/FIRAuthNotificationManagerTests.m',
+      'FirebaseAuth/Tests/Unit/FIRAuthURLPresenterTests.m',
+      'FirebaseAuth/Tests/Unit/FIREmailLink*',
+      'FirebaseAuth/Tests/Unit/FIRPhoneAuthProviderTests.m',
+      'FirebaseAuth/Tests/Unit/FIRSendVerificationCode*',
+      'FirebaseAuth/Tests/Unit/FIRSignInWithGameCenterTests.m',
+      'FirebaseAuth/Tests/Unit/FIRVerifyClient*',
+      'FirebaseAuth/Tests/Unit/FIRVerifyPhoneNumber*',
+      'FirebaseAuth/Tests/Unit/FIROAuthProviderTests.m',
+      'FirebaseAuth/Tests/Unit/FIRMultiFactorResolverTests.m',
+    ]
+    # app_host is needed for tests with keychain
+    unit_tests.requires_app_host = true
+    unit_tests.dependency 'OCMock'
 
-      # This pre-processor directive is used to selectively disable keychain
-      # related code that blocks unit testing on macOS.
-      s.osx.pod_target_xcconfig = {
-        'GCC_PREPROCESSOR_DEFINITIONS' => 'FIREBASE_AUTH_MACOS_TESTING=1'
-      }
+    # This pre-processor directive is used to selectively disable keychain
+    # related code that blocks unit testing on macOS.
+    s.osx.pod_target_xcconfig = {
+      'GCC_PREPROCESSOR_DEFINITIONS' => 'FIREBASE_AUTH_MACOS_TESTING=1'
+    }
 
-    end
   end
 end

+ 0 - 2
FirebaseAuth/Tests/Sample/Podfile

@@ -20,8 +20,6 @@ target 'AuthSample' do
 
   target 'Auth_ApiTests' do
     inherit! :search_paths
-    # `HeartbeatLoggingTestUtils` is unpublished.
-    pod 'HeartbeatLoggingTestUtils', :path => '../../../'
   end
 
   target 'SwiftApiTests' do

+ 1 - 1
FirebaseAuth/Tests/Unit/FIRAuthBackendRPCImplementationTests.m

@@ -16,7 +16,7 @@
 
 #import <XCTest/XCTest.h>
 
-@import HeartbeatLoggingTestUtils;
+@import FirebaseCoreInternal;
 
 #import "FirebaseAuth/Sources/Backend/FIRAuthBackend.h"
 #import "FirebaseAuth/Sources/Backend/FIRAuthRPCRequest.h"

+ 15 - 20
FirebaseCore.podspec

@@ -58,26 +58,21 @@ Firebase Core includes FIRApp and FIROptions which provide central configuration
     'OTHER_CFLAGS' => '-fno-autolink'
   }
 
-  # Using environment variable because of the dependency on the unpublished
-  # HeartbeatLoggingTestUtils.
-  if ENV['POD_LIB_LINT_ONLY'] && ENV['POD_LIB_LINT_ONLY'] == '1' then
-    s.test_spec 'unit' do |unit_tests|
-      unit_tests.scheme = { :code_coverage => true }
-      unit_tests.platforms = {
-        :ios => ios_deployment_target,
-        :osx => '10.15',
-        :tvos => tvos_deployment_target
-      }
-      unit_tests.source_files = [
-        'FirebaseCore/Tests/Unit/**/*.[mh]',
-        'SharedTestUtilities/FIROptionsMock.[mh]',
-      ]
-
-      unit_tests.requires_app_host = true
-      unit_tests.dependency 'OCMock'
-      unit_tests.dependency 'HeartbeatLoggingTestUtils'
-      unit_tests.resources = 'FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist'
-    end
+  s.test_spec 'unit' do |unit_tests|
+    unit_tests.scheme = { :code_coverage => true }
+    unit_tests.platforms = {
+      :ios => ios_deployment_target,
+      :osx => '10.15',
+      :tvos => tvos_deployment_target
+    }
+    unit_tests.source_files = [
+      'FirebaseCore/Tests/Unit/**/*.[mh]',
+      'SharedTestUtilities/FIROptionsMock.[mh]',
+    ]
+
+    unit_tests.requires_app_host = true
+    unit_tests.dependency 'OCMock'
+    unit_tests.resources = 'FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist'
   end
 
   s.test_spec 'swift-unit' do |swift_unit_tests|

+ 140 - 0
FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatLoggingTestUtils.swift

@@ -0,0 +1,140 @@
+// Copyright 2021 Google LLC
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#if DEBUG
+
+  import Foundation
+
+  /// A utility class intended to be used only in testing contexts.
+  @objc(FIRHeartbeatLoggingTestUtils)
+  @objcMembers
+  public class HeartbeatLoggingTestUtils: NSObject {
+    /// This should mirror the `Constants` enum in the `HeartbeatLogging` module.
+    /// See `HeartbeatLogging/Sources/StorageFactory.swift`.
+    public enum Constants {
+      /// The name of the file system directory where heartbeat data is stored.
+      public static let heartbeatFileStorageDirectoryPath = "google-heartbeat-storage"
+      /// The name of the user defaults suite where heartbeat data is stored.
+      public static let heartbeatUserDefaultsSuiteName = "com.google.heartbeat.storage"
+    }
+
+    public static var dateFormatter: DateFormatter {
+      HeartbeatsPayload.dateFormatter
+    }
+
+    public static var emptyHeartbeatsPayload: _ObjC_HeartbeatsPayload {
+      let literalData = """
+         {
+           "version": 2,
+           "heartbeats": []
+         }
+      """
+      .data(using: .utf8)!
+
+      let decoder = JSONDecoder()
+      decoder.dateDecodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
+
+      let heartbeatsPayload = try! decoder.decode(HeartbeatsPayload.self, from: literalData)
+      return _ObjC_HeartbeatsPayload(heartbeatsPayload)
+    }
+
+    public static var nonEmptyHeartbeatsPayload: _ObjC_HeartbeatsPayload {
+      let literalData = """
+         {
+           "version": 2,
+           "heartbeats": [
+             {
+               "agent": "dummy_agent_1",
+               "dates": ["2021-11-01", "2021-11-02"]
+             },
+             {
+               "agent": "dummy_agent_2",
+               "dates": ["2021-11-03"]
+             }
+           ]
+         }
+      """
+      .data(using: .utf8)!
+
+      let decoder = JSONDecoder()
+      decoder.dateDecodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
+
+      let heartbeatsPayload = try! decoder.decode(HeartbeatsPayload.self, from: literalData)
+      return _ObjC_HeartbeatsPayload(heartbeatsPayload)
+    }
+
+    @objc(assertEncodedPayloadString:isEqualToLiteralString:withError:)
+    public static func assertEqualPayloadStrings(_ encoded: String, _ literal: String) throws {
+      var encodedData = Data(base64URLEncoded: encoded)!
+      if encodedData.count > 0 {
+        encodedData = try! encodedData.unzipped()
+      }
+
+      let literalData = literal.data(using: .utf8)!
+
+      let decoder = JSONDecoder()
+      decoder.dateDecodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
+
+      let payloadFromEncoded = try? decoder.decode(HeartbeatsPayload.self, from: encodedData)
+
+      let payloadFromLiteral = try? decoder.decode(HeartbeatsPayload.self, from: literalData)
+
+      let encoder = JSONEncoder()
+      encoder.dateEncodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
+      encoder.outputFormatting = .prettyPrinted
+
+      let payloadDataFromEncoded = try! encoder.encode(payloadFromEncoded)
+      let payloadDataFromLiteral = try! encoder.encode(payloadFromLiteral)
+
+      assert(
+        payloadFromEncoded == payloadFromLiteral,
+        """
+        Mismatched payloads!
+
+        Payload 1:
+        \(String(data: payloadDataFromEncoded, encoding: .utf8) ?? "")
+
+        Payload 2:
+        \(String(data: payloadDataFromLiteral, encoding: .utf8) ?? "")
+
+        """
+      )
+    }
+
+    /// Removes all underlying storage containers used by the module.
+    /// - Throws: An error if the storage container could not be removed.
+    public static func removeUnderlyingHeartbeatStorageContainers() throws {
+      #if os(tvOS)
+        UserDefaults().removePersistentDomain(forName: Constants.heartbeatUserDefaultsSuiteName)
+      #else
+
+        let applicationSupportDirectory = FileManager.default
+          .urls(for: .applicationSupportDirectory, in: .userDomainMask).first!
+
+        let heartbeatsDirectoryURL = applicationSupportDirectory
+          .appendingPathComponent(
+            Constants.heartbeatFileStorageDirectoryPath, isDirectory: true
+          )
+        do {
+          try FileManager.default.removeItem(at: heartbeatsDirectoryURL)
+        } catch CocoaError.fileNoSuchFile {
+          // Do nothing.
+        } catch {
+          throw error
+        }
+      #endif // os(tvOS)
+    }
+  }
+
+#endif // ENABLE_FIREBASE_CORE_INTERNAL_TESTING_UTILS

+ 0 - 1
FirebaseCore/Internal/Tests/Common/Assertions.swift

@@ -14,7 +14,6 @@
 
 import XCTest
 @testable import FirebaseCoreInternal
-import HeartbeatLoggingTestUtils
 
 // MARK: - Assertions
 

+ 0 - 1
FirebaseCore/Internal/Tests/Integration/HeartbeatLoggingIntegrationTests.swift

@@ -14,7 +14,6 @@
 
 import XCTest
 @testable import FirebaseCoreInternal
-import HeartbeatLoggingTestUtils
 
 class HeartbeatLoggingIntegrationTests: XCTestCase {
   // 2021-11-01 @ 00:00:00 (EST)

+ 0 - 1
FirebaseCore/Internal/Tests/Unit/HeartbeatControllerTests.swift

@@ -14,7 +14,6 @@
 
 import XCTest
 @testable import FirebaseCoreInternal
-import HeartbeatLoggingTestUtils
 
 class HeartbeatControllerTests: XCTestCase {
   // 2021-11-01 @ 00:00:00 (EST)

+ 0 - 1
FirebaseCore/Internal/Tests/Unit/HeartbeatsBundleTests.swift

@@ -14,7 +14,6 @@
 
 import XCTest
 @testable import FirebaseCoreInternal
-import HeartbeatLoggingTestUtils
 
 class HeartbeatsBundleTests: XCTestCase {
   // 2021-11-01 @ 00:00:00 (EST)

+ 0 - 1
FirebaseCore/Internal/Tests/Unit/HeartbeatsPayloadTests.swift

@@ -14,7 +14,6 @@
 
 import XCTest
 @testable import FirebaseCoreInternal
-import HeartbeatLoggingTestUtils
 
 class HeartbeatsPayloadTests: XCTestCase {
   func testPayloadCurrentVersion() throws {

+ 1 - 1
FirebaseCore/Tests/Unit/FIRHeartbeatLoggerTests.m

@@ -14,7 +14,7 @@
 
 #import <XCTest/XCTest.h>
 
-@import HeartbeatLoggingTestUtils;
+@import FirebaseCoreInternal;
 
 #import "FirebaseCore/Extension/FIRHeartbeatLogger.h"
 

+ 25 - 32
FirebaseCoreInternal.podspec

@@ -36,39 +36,32 @@ Pod::Spec.new do |s|
 
   s.dependency 'GoogleUtilities/NSData+zlib', '~> 7.8'
 
-  # Using environment variable because of the dependency on the unpublished
-  # HeartbeatLoggingTestUtils.
-  if ENV['POD_LIB_LINT_ONLY'] && ENV['POD_LIB_LINT_ONLY'] == '1' then
-    s.test_spec 'Unit' do |unit_tests|
-      unit_tests.scheme = { :code_coverage => true }
-      unit_tests.platforms = {
-        :ios => ios_deployment_target,
-        :osx => osx_deployment_target,
-        :tvos => tvos_deployment_target
-      }
-      unit_tests.source_files = [
-        'FirebaseCore/Internal/Tests/Unit/**/*.swift',
-        'FirebaseCore/Internal/Tests/Common/**/*.swift',
-      ]
-      unit_tests.requires_app_host = true
-      unit_tests.dependency 'HeartbeatLoggingTestUtils'
-    end
+  s.test_spec 'Unit' do |unit_tests|
+    unit_tests.scheme = { :code_coverage => true }
+    unit_tests.platforms = {
+      :ios => ios_deployment_target,
+      :osx => osx_deployment_target,
+      :tvos => tvos_deployment_target
+    }
+    unit_tests.source_files = [
+      'FirebaseCore/Internal/Tests/Unit/**/*.swift',
+      'FirebaseCore/Internal/Tests/Common/**/*.swift',
+    ]
+    unit_tests.requires_app_host = true
+  end
 
-    s.test_spec 'Integration' do |int_tests|
-      int_tests.scheme = { :code_coverage => true }
-      int_tests.platforms = {
-        :ios => ios_deployment_target,
-        :osx => osx_deployment_target,
-        :tvos => tvos_deployment_target
-      }
+  s.test_spec 'Integration' do |int_tests|
+    int_tests.scheme = { :code_coverage => true }
+    int_tests.platforms = {
+      :ios => ios_deployment_target,
+      :osx => osx_deployment_target,
+      :tvos => tvos_deployment_target
+    }
 
-      int_tests.source_files = [
-        'FirebaseCore/Internal/Tests/Integration/**/*.swift',
-        'FirebaseCore/Internal/Tests/Common/**/*.swift',
-      ]
-      int_tests.requires_app_host = true
-      int_tests.dependency 'HeartbeatLoggingTestUtils'
-    end
+    int_tests.source_files = [
+      'FirebaseCore/Internal/Tests/Integration/**/*.swift',
+      'FirebaseCore/Internal/Tests/Common/**/*.swift',
+    ]
+    int_tests.requires_app_host = true
   end
-
 end

+ 28 - 34
FirebaseInstallations.podspec

@@ -54,43 +54,37 @@ Pod::Spec.new do |s|
     'HEADER_SEARCH_PATHS' => '"${PODS_TARGET_SRCROOT}"'
   }
 
-  # Using environment variable because of the dependency on the unpublished
-  # HeartbeatLoggingTestUtils.
-  if ENV['POD_LIB_LINT_ONLY'] && ENV['POD_LIB_LINT_ONLY'] == '1' then
-    s.test_spec 'unit' do |unit_tests|
-      unit_tests.scheme = { :code_coverage => true }
-      unit_tests.platforms = {
-        :ios => ios_deployment_target,
-        :osx => '10.15',
-        :tvos => tvos_deployment_target
-      }
-      unit_tests.source_files = base_dir + 'Tests/Unit/*.[mh]',
-                                base_dir + 'Tests/Utils/*.[mh]',
-                                base_dir + 'Tests/Unit/Swift/*'
-      unit_tests.resources = base_dir + 'Tests/Fixture/**/*'
-      unit_tests.requires_app_host = true
-      unit_tests.dependency 'OCMock'
-      unit_tests.dependency 'HeartbeatLoggingTestUtils'
+  s.test_spec 'unit' do |unit_tests|
+    unit_tests.scheme = { :code_coverage => true }
+    unit_tests.platforms = {
+      :ios => ios_deployment_target,
+      :osx => '10.15',
+      :tvos => tvos_deployment_target
+    }
+    unit_tests.source_files = base_dir + 'Tests/Unit/*.[mh]',
+                              base_dir + 'Tests/Utils/*.[mh]',
+                              base_dir + 'Tests/Unit/Swift/*'
+    unit_tests.resources = base_dir + 'Tests/Fixture/**/*'
+    unit_tests.requires_app_host = true
+    unit_tests.dependency 'OCMock'
 
-      if ENV['FIS_IID_MIGRATION_TESTING'] && ENV['FIS_IID_MIGRATION_TESTING'] == '1' then
-        unit_tests.source_files += base_dir + 'Tests/Unit/IIDStoreTests/*.[mh]'
-      end
+    if ENV['FIS_IID_MIGRATION_TESTING'] && ENV['FIS_IID_MIGRATION_TESTING'] == '1' then
+      unit_tests.source_files += base_dir + 'Tests/Unit/IIDStoreTests/*.[mh]'
     end
+  end
 
-    s.test_spec 'integration' do |int_tests|
-      int_tests.scheme = { :code_coverage => true }
-      int_tests.platforms = {:ios => '10.0', :osx => '10.15', :tvos => '11.0'}
-      int_tests.source_files = base_dir + 'Tests/Integration/**/*.[mh]'
-      int_tests.resources = base_dir + 'Tests/Resources/**/*'
-      if ENV['FIS_INTEGRATION_TESTS_REQUIRED'] && ENV['FIS_INTEGRATION_TESTS_REQUIRED'] == '1' then
-        int_tests.pod_target_xcconfig = {
-        'GCC_PREPROCESSOR_DEFINITIONS' =>
-          'FIR_INSTALLATIONS_INTEGRATION_TESTS_REQUIRED=1'
-        }
-      end
-      int_tests.requires_app_host = true
-      int_tests.dependency 'OCMock'
-      int_tests.dependency 'HeartbeatLoggingTestUtils'
+  s.test_spec 'integration' do |int_tests|
+    int_tests.scheme = { :code_coverage => true }
+    int_tests.platforms = {:ios => '10.0', :osx => '10.15', :tvos => '11.0'}
+    int_tests.source_files = base_dir + 'Tests/Integration/**/*.[mh]'
+    int_tests.resources = base_dir + 'Tests/Resources/**/*'
+    if ENV['FIS_INTEGRATION_TESTS_REQUIRED'] && ENV['FIS_INTEGRATION_TESTS_REQUIRED'] == '1' then
+      int_tests.pod_target_xcconfig = {
+      'GCC_PREPROCESSOR_DEFINITIONS' =>
+        'FIR_INSTALLATIONS_INTEGRATION_TESTS_REQUIRED=1'
+      }
     end
+    int_tests.requires_app_host = true
+    int_tests.dependency 'OCMock'
   end
 end

+ 1 - 1
FirebaseInstallations/Source/Tests/Integration/FIRInstallationsIntegrationTests.m

@@ -26,7 +26,7 @@
 
 #import <XCTest/XCTest.h>
 
-@import HeartbeatLoggingTestUtils;
+@import FirebaseCoreInternal;
 
 #import "FirebaseCore/Extension/FirebaseCoreInternal.h"
 

+ 1 - 1
FirebaseInstallations/Source/Tests/Unit/FIRInstallationsAPIServiceTests.m

@@ -18,7 +18,7 @@
 
 #import <OCMock/OCMock.h>
 
-@import HeartbeatLoggingTestUtils;
+@import FirebaseCoreInternal;
 
 #import "FBLPromise+Testing.h"
 #import "FirebaseInstallations/Source/Tests/Utils/FIRInstallationsItem+Tests.h"

+ 0 - 38
HeartbeatLoggingTestUtils.podspec

@@ -1,38 +0,0 @@
-Pod::Spec.new do |s|
-  s.name                    = 'HeartbeatLoggingTestUtils'
-  s.version                 = '10.0.0'
-  s.summary                 = 'Testing utilities for testing the HeartbeatLogging module'
-
-  s.description             = <<-DESC
-  Type declarations and utilities needed for unit testing the HeartbeatLogging module.
-  This podspec is for internal testing only and should not be published.
-                         DESC
-
-  s.homepage                = 'https://developers.google.com/'
-  s.license                 = { :type => 'Apache-2.0', :file => 'LICENSE' }
-  s.authors                 = 'Google, Inc.'
-
-  s.source                  = {
-    :git => 'https://github.com/Firebase/firebase-ios-sdk.git',
-    :tag => 'CocoaPods-' + s.version.to_s
-  }
-
-  s.pod_target_xcconfig = {
-    'ENABLE_TESTING_SEARCH_PATHS'=>'YES'
-  }
-
-  s.swift_version           = '5.3'
-
-  s.ios.deployment_target     = '10.0'
-  s.osx.deployment_target     = '10.13'
-  s.tvos.deployment_target    = '12.0'
-  s.watchos.deployment_target = '6.0'
-
-  s.source_files = [
-    'HeartbeatLoggingTestUtils/Sources/**/*.swift',
-  ]
-
-  s.framework = 'XCTest'
-
-  s.dependency 'FirebaseCoreInternal', '~> 10.0'
-end

+ 0 - 139
HeartbeatLoggingTestUtils/Sources/HeartbeatLoggingTestUtils.swift

@@ -1,139 +0,0 @@
-// Copyright 2021 Google LLC
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//      http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-import Foundation
-import XCTest
-import FirebaseCoreInternal
-
-@objc(FIRHeartbeatLoggingTestUtils)
-@objcMembers
-public class HeartbeatLoggingTestUtils: NSObject {
-  /// This should mirror the `Constants` enum in the `HeartbeatLogging` module.
-  /// See `HeartbeatLogging/Sources/StorageFactory.swift`.
-  public enum Constants {
-    /// The name of the file system directory where heartbeat data is stored.
-    public static let heartbeatFileStorageDirectoryPath = "google-heartbeat-storage"
-    /// The name of the user defaults suite where heartbeat data is stored.
-    public static let heartbeatUserDefaultsSuiteName = "com.google.heartbeat.storage"
-  }
-
-  public static var dateFormatter: DateFormatter {
-    HeartbeatsPayload.dateFormatter
-  }
-
-  public static var emptyHeartbeatsPayload: _ObjC_HeartbeatsPayload {
-    let literalData = """
-       {
-         "version": 2,
-         "heartbeats": []
-       }
-    """
-    .data(using: .utf8)!
-
-    let decoder = JSONDecoder()
-    decoder.dateDecodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
-
-    let heartbeatsPayload = try! decoder.decode(HeartbeatsPayload.self, from: literalData)
-    return _ObjC_HeartbeatsPayload(heartbeatsPayload)
-  }
-
-  public static var nonEmptyHeartbeatsPayload: _ObjC_HeartbeatsPayload {
-    let literalData = """
-       {
-         "version": 2,
-         "heartbeats": [
-           {
-             "agent": "dummy_agent_1",
-             "dates": ["2021-11-01", "2021-11-02"]
-           },
-           {
-             "agent": "dummy_agent_2",
-             "dates": ["2021-11-03"]
-           }
-         ]
-       }
-    """
-    .data(using: .utf8)!
-
-    let decoder = JSONDecoder()
-    decoder.dateDecodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
-
-    let heartbeatsPayload = try! decoder.decode(HeartbeatsPayload.self, from: literalData)
-    return _ObjC_HeartbeatsPayload(heartbeatsPayload)
-  }
-
-  @objc(assertEncodedPayloadString:isEqualToLiteralString:withError:)
-  public static func assertEqualPayloadStrings(_ encoded: String, _ literal: String) throws {
-    var encodedData = try XCTUnwrap(Data(base64URLEncoded: encoded))
-    if encodedData.count > 0 {
-      encodedData = try! encodedData.unzipped()
-    }
-
-    let literalData = try XCTUnwrap(literal.data(using: .utf8))
-
-    let decoder = JSONDecoder()
-    decoder.dateDecodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
-
-    let payloadFromEncoded = try? decoder.decode(HeartbeatsPayload.self, from: encodedData)
-
-    let payloadFromLiteral = try? decoder.decode(HeartbeatsPayload.self, from: literalData)
-
-    let encoder = JSONEncoder()
-    encoder.dateEncodingStrategy = .formatted(HeartbeatsPayload.dateFormatter)
-    encoder.outputFormatting = .prettyPrinted
-
-    let payloadDataFromEncoded = try XCTUnwrap(encoder.encode(payloadFromEncoded))
-    let payloadDataFromLiteral = try XCTUnwrap(encoder.encode(payloadFromLiteral))
-
-    XCTAssertEqual(
-      payloadFromEncoded,
-      payloadFromLiteral,
-      """
-      Mismatched payloads!
-
-      Payload 1:
-      \(String(data: payloadDataFromEncoded, encoding: .utf8) ?? "")
-
-      Payload 2:
-      \(String(data: payloadDataFromLiteral, encoding: .utf8) ?? "")
-
-      """
-    )
-  }
-
-  /// Removes all underlying storage containers used by the module.
-  /// - Throws: An error if the storage container could not be removed.
-  public static func removeUnderlyingHeartbeatStorageContainers() throws {
-    #if os(tvOS)
-      UserDefaults().removePersistentDomain(forName: Constants.heartbeatUserDefaultsSuiteName)
-    #else
-
-      let applicationSupportDirectory = try XCTUnwrap(
-        FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first
-      )
-
-      let heartbeatsDirectoryURL = applicationSupportDirectory
-        .appendingPathComponent(
-          Constants.heartbeatFileStorageDirectoryPath, isDirectory: true
-        )
-      do {
-        try FileManager.default.removeItem(at: heartbeatsDirectoryURL)
-      } catch CocoaError.fileNoSuchFile {
-        // Do nothing.
-      } catch {
-        throw error
-      }
-    #endif // os(tvOS)
-  }
-}

+ 0 - 9
Package.swift

@@ -214,7 +214,6 @@ let package = Package(
       dependencies: [
         "FirebaseCore",
         "SharedTestUtilities",
-        "HeartbeatLoggingTestUtils",
         .product(name: "OCMock", package: "ocmock"),
       ],
       path: "FirebaseCore/Tests/Unit",
@@ -248,16 +247,10 @@ let package = Package(
       ],
       path: "FirebaseCore/Internal/Sources"
     ),
-    .target(
-      name: "HeartbeatLoggingTestUtils",
-      dependencies: ["FirebaseCoreInternal"],
-      path: "HeartbeatLoggingTestUtils/Sources"
-    ),
     .testTarget(
       name: "FirebaseCoreInternalTests",
       dependencies: [
         "FirebaseCoreInternal",
-        "HeartbeatLoggingTestUtils",
       ],
       path: "FirebaseCore/Internal/Tests"
     ),
@@ -460,7 +453,6 @@ let package = Package(
       name: "AuthUnit",
       dependencies: [
         "FirebaseAuth",
-        "HeartbeatLoggingTestUtils",
         .product(name: "OCMock", package: "ocmock"),
       ],
       path: "FirebaseAuth/Tests/Unit",
@@ -1281,7 +1273,6 @@ let package = Package(
       dependencies: [
         "FirebaseAppCheck",
         "SharedTestUtilities",
-        "HeartbeatLoggingTestUtils",
         .product(name: "OCMock", package: "ocmock"),
       ],
       path: "FirebaseAppCheck/Tests",