Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiMoskvin committed Dec 17, 2018
1 parent bfc5ef9 commit 5207045
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion PlayerCore
6 changes: 5 additions & 1 deletion sources/advertisements/AdURLProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ class AdURLProviderTests: XCTestCase {
[ item ],
[ item ]
]
let response = VRMProvider.Response(transactionId: nil,
slot: "slot",
cpm: "cpm",
items:groups)

groupsContext.callbacks[0](groups)
groupsContext.callbacks[0](response)
provider.queue.sync {}

XCTAssertEqual(softTimeoutContext.callbacks.count, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class VRMRequestControllerTest: XCTestCase {

return Future(value: VRMProvider.Response(transactionId: "transactionId",
slot: "slot",
cpm: "cpm",
items: self.itemsResponse)) })


Expand Down
15 changes: 15 additions & 0 deletions sources/metrics/detectors/vrm/VRMDetectorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class VRMDetectorTests: XCTestCase {
func testEmptyDetection() {
let result = detector.process(
state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: UUID(),
timeout: .beforeSoft,
Expand All @@ -45,20 +46,23 @@ class VRMDetectorTests: XCTestCase {
func testVRMRequests() {
let id1 = UUID()
var result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id1,
timeout: .beforeSoft,
state: .ready)))
XCTAssertEqual(result.count, 0)

result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id1,
timeout: .beforeSoft,
state: .progress)))
XCTAssertEqual(result.count, 0)

result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id1,
timeout: .beforeSoft,
Expand All @@ -74,6 +78,7 @@ class VRMDetectorTests: XCTestCase {
}

result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: UUID(),
timeout: .beforeSoft,
Expand Down Expand Up @@ -113,6 +118,7 @@ class VRMDetectorTests: XCTestCase {
sut.startItems.insert(startItem1)

var result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand All @@ -128,6 +134,7 @@ class VRMDetectorTests: XCTestCase {

sut.startItems.insert(startItem1)
result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand All @@ -138,6 +145,7 @@ class VRMDetectorTests: XCTestCase {
sut.startItems.insert(startItem2)

result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand Down Expand Up @@ -170,6 +178,7 @@ class VRMDetectorTests: XCTestCase {
completeItem: nil)
sut.completeItem = completeItem1
var result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand Down Expand Up @@ -206,6 +215,7 @@ class VRMDetectorTests: XCTestCase {
completeItem: nil)
sut.timeoutItems.insert(timeoutItem1)
var result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand All @@ -219,6 +229,7 @@ class VRMDetectorTests: XCTestCase {
}

result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand All @@ -229,6 +240,7 @@ class VRMDetectorTests: XCTestCase {
sut.timeoutItems.insert(timeoutItem1)
sut.timeoutItems.insert(timeoutItem2)
result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand Down Expand Up @@ -267,6 +279,7 @@ class VRMDetectorTests: XCTestCase {
sut.otherErrorItems.insert(otherErrorItem1)

var result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand All @@ -281,6 +294,7 @@ class VRMDetectorTests: XCTestCase {

sut.otherErrorItems.insert(otherErrorItem1)
result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand All @@ -291,6 +305,7 @@ class VRMDetectorTests: XCTestCase {
sut.otherErrorItems.insert(otherErrorItem1)
sut.otherErrorItems.insert(otherErrorItem2)
result = detector.process(state: .init(timeoutBarrier: 3500,
cpm: nil,
requestsFired: 0,
request: .init(id: id,
timeout: .afterSoft,
Expand Down

0 comments on commit 5207045

Please sign in to comment.