Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…onView

# Conflicts:
#	GLTableCollectionViewTests/GLTableCollectionViewTests.swift
  • Loading branch information
giulio92 committed Apr 24, 2017
2 parents a2454c4 + 40f88f3 commit f5f6f90
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ env:
- DESTINATION="platform=iOS Simulator,OS=latest,name=iPhone 5"

before_install:
- brew update
- brew upgrade
# - brew update
# - brew upgrade
- gem update
- gem install xcpretty
- gem install xcpretty-travis-formatter
Expand Down
52 changes: 40 additions & 12 deletions GLTableCollectionViewTests/GLTableCollectionViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
import XCTest
@testable import GLTableCollectionView

class GLTableCollectionViewTests: XCTestCase {
var tableCollectionView: GLTableCollectionViewController!
var visibleCells: [UITableViewCell]!
final class GLTableCollectionViewTests: XCTestCase {
private var tableCollectionView: GLTableCollectionViewController!
private var visibleCells: [UITableViewCell]!

override func setUp() {
super.setUp()
Expand Down Expand Up @@ -93,17 +93,29 @@ class GLTableCollectionViewTests: XCTestCase {
func testUITableViewCellClasses() {
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")

for tableViewCell in visibleCells {
XCTAssertTrue(tableViewCell is GLCollectionTableViewCell, "UITableViewCells must be GLCollectionTableViewCell")
visibleCells.forEach { cell in
if cell is GLCollectionTableViewCell {
return
} else {
XCTAssertTrue(cell is GLCollectionTableViewCell, "UITableViewCells must be GLCollectionTableViewCell")
}
}
}

func testTableViewCellIdentifiers() {
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")

for tableViewCell: GLCollectionTableViewCell in visibleCells as! [GLCollectionTableViewCell] {
XCTAssertTrue(Int(tableViewCell.reuseIdentifier!.components(separatedBy: "#").last!)! >= 0,
"GLCollectionTableViewCell cellIdentifier was: \(String(describing: tableViewCell.reuseIdentifier))\nGLCollectionTableViewCell's cellIdentifier must end with a positive integer")
visibleCells.forEach { cell in
guard let tableViewCell: GLCollectionTableViewCell = cell as? GLCollectionTableViewCell else {
fatalError("UITableViewCells must be GLCollectionTableViewCell")
}

guard let reuseID: String = tableViewCell.reuseIdentifier else {
fatalError("UITableViewCells must have a reuse identifier")
}

XCTAssertTrue(Int(reuseID.components(separatedBy: "#").last!)! >= 0,
"GLCollectionTableViewCell cellIdentifier was: \(String(describing: reuseID))\nGLCollectionTableViewCell's cellIdentifier must end with a positive integer")
}
}

Expand All @@ -112,7 +124,11 @@ class GLTableCollectionViewTests: XCTestCase {
func testCollectionViewsDelegateAndDataSource() {
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")

for collectionTableCell: GLCollectionTableViewCell in visibleCells as! [GLCollectionTableViewCell] {
visibleCells.forEach { cell in
guard let collectionTableCell: GLCollectionTableViewCell = cell as? GLCollectionTableViewCell else {
fatalError("UITableViewCells must be GLCollectionTableViewCell")
}

XCTAssertNotNil(collectionTableCell.collectionView.dataSource, "GLCollectionTableViewCell dataSource is nil")
XCTAssertNotNil(collectionTableCell.collectionView.delegate, "GLCollectionTableViewCell delegate is nil")
}
Expand All @@ -121,7 +137,11 @@ class GLTableCollectionViewTests: XCTestCase {
func testCollectionNativePaginationFlag() {
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")

for collectionTableCell: GLCollectionTableViewCell in visibleCells as! [GLCollectionTableViewCell] {
visibleCells.forEach { cell in
guard let collectionTableCell: GLCollectionTableViewCell = cell as? GLCollectionTableViewCell else {
fatalError("UITableViewCells must be GLCollectionTableViewCell")
}

if collectionTableCell.collectionViewPaginatedScroll == true {
XCTAssertFalse(collectionTableCell.collectionView.isPagingEnabled,
"Custom scrolling pagination and native UICollectionView pagination can't be enabled at the same time")
Expand All @@ -132,7 +152,11 @@ class GLTableCollectionViewTests: XCTestCase {
func testCollectionViewPaginationConsistency() {
XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")

for collectionTableCell: GLCollectionTableViewCell in visibleCells as! [GLCollectionTableViewCell] {
visibleCells.forEach { cell in
guard let collectionTableCell: GLCollectionTableViewCell = cell as? GLCollectionTableViewCell else {
fatalError("UITableViewCells must be GLCollectionTableViewCell")
}

if collectionTableCell.collectionViewPaginatedScroll == true {
XCTAssertTrue(collectionTableCell.collectionView.isScrollEnabled,
"If custom paginated scroll is enabled the UICollectionView should be scrollable")
Expand All @@ -159,7 +183,11 @@ class GLTableCollectionViewTests: XCTestCase {

XCTAssertGreaterThan(visibleCells.count, 0, "UITableView visible cells must be greater than 0")

for collectionTableCell: GLCollectionTableViewCell in visibleCells as! [GLCollectionTableViewCell] {
visibleCells.forEach { cell in
guard let collectionTableCell: GLCollectionTableViewCell = cell as? GLCollectionTableViewCell else {
fatalError("UITableViewCells must be GLCollectionTableViewCell")
}

XCTAssertTrue(collectionTableCell.collectionView.isOpaque, "The UICollectionView should be opaque for increased performances")
}
}
Expand Down

0 comments on commit f5f6f90

Please sign in to comment.