forked from matomo-org/matomo-sdk-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the AutoTracker to the tests to make them iOS 9.3 compatible (m…
- Loading branch information
Showing
3 changed files
with
46 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// | ||
// AutoTracker.swift | ||
// PiwikTracker | ||
// | ||
// Created by Cornelius Horstmann on 04.09.17. | ||
// Copyright © 2017 PIWIK. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
@testable import PiwikTracker | ||
|
||
extension TrackerSpec { | ||
|
||
internal final class AutoTracker { | ||
|
||
let tracker: PiwikTracker | ||
let interval: TimeInterval | ||
var timer: Timer? | ||
|
||
init(tracker: PiwikTracker, trackingInterval: TimeInterval) { | ||
self.tracker = tracker | ||
self.interval = trackingInterval | ||
} | ||
|
||
@objc private func track() { | ||
tracker.queue(event: EventFixture.event()) | ||
} | ||
|
||
func start() { | ||
self.timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(track), userInfo: nil, repeats: true) | ||
} | ||
|
||
func stop() { | ||
self.timer?.invalidate() | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters