mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
* Revert "Revert GDTCORStorage changes for now (#5778)" This reverts commit93eb6d8c48. * Store events and implement unit tests (#5790) Resolves many TODOs in the flat file storage system Bug fixes found by unit tests are also included. * Get rid of event iterators and add separate folders for batching (#5829) * Store events and implement unit tests (#5790) Resolves many TODOs in the flat file storage system Bug fixes found by unit tests are also included. * Change to explicit nil comparison * Address test comments - Makes all APIs async - Add thread-safety test - Comments on where files are stored - Broke up the library data get/set API into two blocks * Implement events and batch expirations (#5842) The upload coordinator will signal an expiration check whenever the app foregrounds. * Remove prioritizers, upload packages, data futures, and backwards compatibility (#5874) * Remove prioritizers, upload packages, data futures, and backwards compatibility * Update a comment and console logging * Reset the storage for every unit test, move event generation out of core init * Return a nil request if data is nil. * Fix prioritizer reference in watchOS test app * Remove unnecessary check for termination * Give more leeway for eventID generation Change the transport API to a GDTCORTarget Don't continue a long test after a failure * Return nil if an eventID couldn't be created Fix some swift in the watchOS test app * Fix all rawValue GDTCORTarget usage * Update CHANGELOGs * Remove initializer annotations (#5878) * Remove initializer designation from GDTCOREvent Change the target property to the target type * Add a couple more types * Make implicit retain explicit Nothing I do seems to get this warning to trigger locally... * Address loss of precision issue * Re-enable a disabled test Don't delete while enumerating * Additional test tweaks and hasEvents is now on the queue and async * Adjust GDTCCT to the new API * Always attempt to create a path, get rid of implicit self refs * Change all waiting for be DISPATCH_TIME_FOREVER for debugging purposes I suspect the travis machines are just overwhelmed, since the test errors don't make any sense. * Try using a different separator * Enable debug logging * Enable verbose pod lib lint output * Handle cases where the mappingID contains path components * Revert "Enable debug logging" This reverts commitb3e4a6ecc5. * Revert "Enable verbose pod lib lint output" This reverts commita5b54460f9. * Revert "Change all waiting for be DISPATCH_TIME_FOREVER for debugging purposes" This reverts commit55e4fff5dc. * Attempt to create a folder before writing * Temporarily enable verbose pod lib lint, again * Temporarily add debug logging back in * Don't double store events Also print out errors if there are any * Remove debug logging * Put debug logs back in for Crashlytics test * Update mock APIs to match and use a real target * remove debug logging * Apply nullability specifiers to Crashlytics mock class
105 lines
3.5 KiB
Swift
105 lines
3.5 KiB
Swift
/*
|
|
* Copyright 2019 Google
|
|
*
|
|
* 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 Dispatch
|
|
import GoogleDataTransport
|
|
|
|
public extension ViewController {
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
GDTCORRegistrar.sharedInstance().register(TestUploader(), target: GDTCORTarget.test)
|
|
Globals.SharedViewController = self
|
|
}
|
|
|
|
@IBAction func generateDataEvent(sender: AnyObject?) {
|
|
print("Generating data event")
|
|
let event: GDTCOREvent = transport.eventForTransport()
|
|
event.dataObject = TestDataObject()
|
|
transport.sendDataEvent(event)
|
|
}
|
|
|
|
@IBAction func generateTelemetryEvent(sender: AnyObject?) {
|
|
print("Generating telemetry event")
|
|
let event: GDTCOREvent = transport.eventForTransport()
|
|
event.dataObject = TestDataObject()
|
|
transport.sendTelemetryEvent(event)
|
|
}
|
|
|
|
@IBAction func generateHighPriorityEvent(sender: AnyObject?) {
|
|
print("Generating high priority event")
|
|
let event: GDTCOREvent = transport.eventForTransport()
|
|
event.dataObject = TestDataObject()
|
|
event.qosTier = GDTCOREventQoS.qoSFast
|
|
transport.sendDataEvent(event)
|
|
}
|
|
|
|
@IBAction func generateWifiOnlyEvent(sender: AnyObject?) {
|
|
print("Generating wifi only event")
|
|
let event: GDTCOREvent = transport.eventForTransport()
|
|
event.dataObject = TestDataObject()
|
|
event.qosTier = GDTCOREventQoS.qoSWifiOnly
|
|
transport.sendDataEvent(event)
|
|
}
|
|
|
|
@IBAction func generateDailyEvent(sender: AnyObject?) {
|
|
print("Generating daily event")
|
|
let event: GDTCOREvent = transport.eventForTransport()
|
|
event.dataObject = TestDataObject()
|
|
event.qosTier = GDTCOREventQoS.qoSDaily
|
|
transport.sendDataEvent(event)
|
|
}
|
|
|
|
func beginMonkeyTest(completion: () -> Void) {
|
|
print("Beginning monkey test")
|
|
|
|
let generateEventsQueue = DispatchQueue(label: "com.google.GDTTestApp.vc.generateEvents")
|
|
let sema: DispatchSemaphore = DispatchSemaphore(value: 0)
|
|
var generateEvents = true
|
|
DispatchQueue.global().asyncAfter(deadline: .now() + Globals.MonkeyTestLength) {
|
|
generateEventsQueue.sync {
|
|
generateEvents = false
|
|
}
|
|
sema.signal()
|
|
}
|
|
|
|
func generateEvent() {
|
|
DispatchQueue.global().asyncAfter(deadline: .now() + Double.random(in: 0 ..< 3.0)) {
|
|
let generationFunctions = [
|
|
self.generateDataEvent,
|
|
self.generateTelemetryEvent,
|
|
self.generateHighPriorityEvent,
|
|
self.generateWifiOnlyEvent,
|
|
self.generateDailyEvent,
|
|
]
|
|
let randomIndex: Int = Int.random(in: 0 ..< generationFunctions.count)
|
|
generationFunctions[randomIndex](self)
|
|
}
|
|
RunLoop.current.run(until: Date(timeIntervalSinceNow: Double.random(in: 0 ..< 1.5)))
|
|
var shouldContinueGeneratingEvents: Bool = false
|
|
generateEventsQueue.sync {
|
|
shouldContinueGeneratingEvents = generateEvents
|
|
}
|
|
if shouldContinueGeneratingEvents {
|
|
generateEvent()
|
|
}
|
|
}
|
|
generateEvent()
|
|
sema.wait()
|
|
completion()
|
|
}
|
|
}
|