Skip to content

Commit

Permalink
Fixing test #3
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickl committed Apr 21, 2016
1 parent a515206 commit b7007a8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 23 deletions.
2 changes: 2 additions & 0 deletions DynamicButton/DynamicButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ between each style changes.
- parameter animated: If true the transition between the old style and the new one is animated.
*/
public func applyButtonStyle(buttonStyle: DynamicButtonStyle, animated: Bool) {
accessibilityValue = buttonStyle.description

for config in buttonStyle.animationConfigurations(line1Layer, layer2: line2Layer, layer3: line3Layer, layer4: line4Layer) {
if animated {
let anim = animationWithKeyPath(config.keyPath, damping: 10)
Expand Down
2 changes: 1 addition & 1 deletion DynamicButton/DynamicButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class DynamicButtonStyle: CustomStringConvertible {
public static let CaretRight = DynamicButtonStyleCaretRight.self

/// Up caret: ⌃
public static let CaretUp = DynamicButtonStyleArrowUp.self
public static let CaretUp = DynamicButtonStyleCaretUp.self

/// Check mark: ✓
public static let CheckMark = DynamicButtonStyleCheckMark.self
Expand Down
38 changes: 19 additions & 19 deletions Example/DynamicButtonExampleTests/DynamicButtonExampleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,44 @@ import XCTest
class DynamicButtonExampleTests: XCTTestCaseTemplate {
func testDefaultStyle() {
let dynamicButton = DynamicButton()
XCTAssert(dynamicButton.style == .Hamburger)
XCTAssert(dynamicButton.style == DynamicButtonStyleHamburger.self)
}

func testInitWithStyle() {
let hamburger = DynamicButton(style: .Hamburger)
XCTAssert(hamburger.style == .Hamburger)
let hamburger = DynamicButton(style: DynamicButtonStyleHamburger.self)
XCTAssert(hamburger.style == DynamicButtonStyleHamburger.self)

let arrowDown = DynamicButton(style: .ArrowDown)
XCTAssert(arrowDown.style == .ArrowDown)
let arrowDown = DynamicButton(style: DynamicButtonStyleArrowDown.self)
XCTAssert(arrowDown.style == DynamicButtonStyleArrowDown.self)

let circlePlus = DynamicButton(style: .CirclePlus)
XCTAssert(circlePlus.style == .CirclePlus)
let circlePlus = DynamicButton(style: DynamicButtonStyleCirclePlus.self)
XCTAssert(circlePlus.style == DynamicButtonStyleCirclePlus.self)
}

func testSetStyle() {
let dynamicButton = DynamicButton()

dynamicButton.style = .Close
XCTAssert(dynamicButton.style == .Close)
dynamicButton.style = DynamicButtonStyleClose.self
XCTAssert(dynamicButton.style == DynamicButtonStyleClose.self)

dynamicButton.style = .Download
XCTAssert(dynamicButton.style == .Download)
dynamicButton.style = DynamicButtonStyleDownload.self
XCTAssert(dynamicButton.style == DynamicButtonStyleDownload.self)

dynamicButton.style = .FastForward
XCTAssert(dynamicButton.style == .FastForward)
dynamicButton.style = DynamicButtonStyleFastForward.self
XCTAssert(dynamicButton.style == DynamicButtonStyleFastForward.self)
}

func testSetStyleAnimated() {
let dynamicButton = DynamicButton()

dynamicButton.setStyle(.Close, animated: true)
XCTAssert(dynamicButton.style == .Close)
dynamicButton.setStyle(DynamicButtonStyleClose.self, animated: true)
XCTAssert(dynamicButton.style == DynamicButtonStyleClose.self)

dynamicButton.setStyle(.Download, animated: false)
XCTAssert(dynamicButton.style == .Download)
dynamicButton.setStyle(DynamicButtonStyleDownload.self, animated: false)
XCTAssert(dynamicButton.style == DynamicButtonStyleDownload.self)

dynamicButton.setStyle(.FastForward, animated: true)
XCTAssert(dynamicButton.style == .FastForward)
dynamicButton.setStyle(DynamicButtonStyleFastForward.self, animated: true)
XCTAssert(dynamicButton.style == DynamicButtonStyleFastForward.self)
}

func testLineWidth() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ class DynamicButtonExampleUITests: XCTestCase {

func testStyleSelection() {
let collectionViewsQuery = XCUIApplication().collectionViews
let styles = DynamicButton.Style.allValues
let styles = DynamicButtonStyle.allStyles
XCUIDevice.sharedDevice().orientation = .LandscapeRight

for index in 0 ..< styles.count {
let dynamicButton = collectionViewsQuery.buttons[styles[index].rawValue]
let style = styles[index].init(center: .zero, size: 0, offset: .zero, lineWidth: 0)
let dynamicButton = collectionViewsQuery.buttons[style.description]
dynamicButton.tap()

XCTAssertEqual(dynamicButton.value as? String, styles[index].rawValue)
XCTAssertEqual(dynamicButton.value as? String, style.description)
}
}
}

0 comments on commit b7007a8

Please sign in to comment.