Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,11 @@ import XCTest

internal final class LoginToutViewControllerTests: TestCase {
func testLoginToutView() {
let devices = [Device.phone4_7inch, Device.phone5_8inch, Device.pad]
let intents = [LoginIntent.generic, .starProject, .messageCreator, .backProject]

orthogonalCombos(Language.allLanguages, devices, intents).forEach { language, device, intent in
withEnvironment(language: language) {
let controller = LoginToutViewController.configuredWith(loginIntent: intent)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)

self.scheduler.run()

assertSnapshot(
matching: parent.view,
as: .image,
named: "intent_\(intent)_lang_\(language)_device_\(device)"
)
}
}
}

func testDarkMode() {
let language = Language.en
let device = Device.phone5_8inch
let intent = LoginIntent.generic

withEnvironment(language: language) {
forEachScreenshotType(withData: intents) { type, intent in
let controller = LoginToutViewController.configuredWith(loginIntent: intent)
let (parent, _) = traitControllers(device: device, orientation: .portrait, child: controller)

controller.overrideUserInterfaceStyle = .dark

self.scheduler.run()

assertSnapshot(
matching: parent.view,
as: .image,
named: "intent_\(intent)_lang_\(language)_device_\(device)_dark"
)
assertSnapshot(forController: controller, withType: type)
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions Kickstarter-iOS/TestHelpers/Combos.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,52 @@ internal func orthogonalCombos<A, B, C>(_ xs: [A], _ ys: [B], _ zs: [C]) -> [(A,
}
}
}

// Combine four arrays by creating an array where each element is represented at least once.
// Result consists of `max(A.count, B.count, C.count, D.count)` tuples.
// swiftlint:disable large_tuple
internal func orthogonalCombos<A, B, C, D>(
_ xs: [A],
_ ys: [B],
_ zs: [C],
_ ws: [D]
) -> [(A, B, C, D)] {
let count = max(xs.count, ys.count, zs.count, ws.count)

guard count > 0 else { return [] }

return (0..<count).map { index in
(
xs[index % xs.count],
ys[index % ys.count],
zs[index % zs.count],
ws[index % ws.count]
)
}
}

// Combine five arrays by creating an array where each element is represented at least once.
// Result consists of `max(A.count, B.count, C.count, D.count, E.count)` tuples.
internal func orthogonalCombos<A, B, C, D, E>(
_ xs: [A],
_ ys: [B],
_ zs: [C],
_ ws: [D],
_ vs: [E]
) -> [(A, B, C, D, E)] {
let count = max(xs.count, ys.count, zs.count, ws.count, vs.count)

guard count > 0 else { return [] }

return (0..<count).map { index in
(
xs[index % xs.count],
ys[index % ys.count],
zs[index % zs.count],
ws[index % ws.count],
vs[index % vs.count]
)
}
}

// swiftlint:enable large_tuple
Loading