From b7007a8044ea305c0bc560549c88c10b62fab443 Mon Sep 17 00:00:00 2001 From: Yannick Loriot Date: Thu, 21 Apr 2016 12:18:03 +0200 Subject: [PATCH] Fixing test #3 --- DynamicButton/DynamicButton.swift | 2 + DynamicButton/DynamicButtonStyle.swift | 2 +- .../DynamicButtonExampleTests.swift | 38 +++++++++---------- .../DynamicButtonExampleUITests.swift | 7 ++-- 4 files changed, 26 insertions(+), 23 deletions(-) diff --git a/DynamicButton/DynamicButton.swift b/DynamicButton/DynamicButton.swift index 7e357a2..d0ca160 100644 --- a/DynamicButton/DynamicButton.swift +++ b/DynamicButton/DynamicButton.swift @@ -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) diff --git a/DynamicButton/DynamicButtonStyle.swift b/DynamicButton/DynamicButtonStyle.swift index 2bf4358..3169409 100644 --- a/DynamicButton/DynamicButtonStyle.swift +++ b/DynamicButton/DynamicButtonStyle.swift @@ -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 diff --git a/Example/DynamicButtonExampleTests/DynamicButtonExampleTests.swift b/Example/DynamicButtonExampleTests/DynamicButtonExampleTests.swift index 385b17e..4785b7a 100644 --- a/Example/DynamicButtonExampleTests/DynamicButtonExampleTests.swift +++ b/Example/DynamicButtonExampleTests/DynamicButtonExampleTests.swift @@ -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() { diff --git a/Example/DynamicButtonExampleUITests/DynamicButtonExampleUITests.swift b/Example/DynamicButtonExampleUITests/DynamicButtonExampleUITests.swift index f40a01a..9a32a21 100644 --- a/Example/DynamicButtonExampleUITests/DynamicButtonExampleUITests.swift +++ b/Example/DynamicButtonExampleUITests/DynamicButtonExampleUITests.swift @@ -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) } } }