Files
facebook-ios-sdk/TestTools/TestTools/TestBundle.swift
Sam Odom bb29366ee2 Make InfoDictionaryProviding protocol less likely to produce conflicts
Summary: The NSBundle basis for this protocol creates a risk of conflict if we make any of the referenced symbols more abstract

Reviewed By: joesus

Differential Revision: D37358716

fbshipit-source-id: 2ca5885075e89bddbab664a1e6b785772577f6cd
2022-06-23 13:40:22 -07:00

55 lines
1.3 KiB
Swift

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
import FBSDKCoreKit
import FBSDKCoreKit_Basics
import Foundation
@objcMembers
public final class TestBundle: NSObject, InfoDictionaryProviding {
private var stubbedInfoDictionary: [String: Any]?
var lastCapturedKey: String?
public var capturedKeys = [String]()
public var didAccessInfoDictionary = false
// swiftlint:disable:next identifier_name
public var fb_infoDictionary: [String: Any]? {
get {
didAccessInfoDictionary = true
return stubbedInfoDictionary
}
set {
stubbedInfoDictionary = newValue
}
}
public override convenience init() {
self.init(infoDictionary: [:])
}
public init(infoDictionary: [String: Any] = [:]) {
stubbedInfoDictionary = infoDictionary
}
// swiftlint:disable:next identifier_name
public var fb_bundleIdentifier: String?
public func fb_object(forInfoDictionaryKey key: String) -> Any? {
lastCapturedKey = key
capturedKeys.append(key)
return fb_infoDictionary?[key] as Any?
}
public func reset() {
capturedKeys = []
lastCapturedKey = nil
stubbedInfoDictionary = nil
didAccessInfoDictionary = false
}
}