This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
class FizzBuzzTDDSwiftUITests: XCTestCase { | |
override func setUp() { | |
super.setUp() | |
// Put setup code here. This method is called before the invocation of each test method in the class. | |
// In UI tests it is usually best to stop immediately when a failure occurs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func testTabButtonNumberButtonIncreased() { | |
let app = XCUIApplication() | |
let numberBtn = app.buttons["numberBtn"] | |
numberBtn.tap() | |
XCTAssertEqual(numberBtn.label, "1", "Score on button should increase") | |
} | |
func testPlayToGameOverFirstTime() { | |
let app = XCUIApplication() | |
let numberBtn = app.buttons["numberBtn"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { | |
// Override point for customization after application launch. | |
if ProcessInfo.processInfo.arguments.contains("HighSpeedAnimation") { | |
UIApplication.shared.keyWindow?.layer.speed = 100 | |
} | |
return true | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UIDevice.rx.orientation | |
.filter { value in | |
return value != .landscape | |
} | |
.map { _ in | |
return "Portrait is the best!" | |
} | |
.subscribe(onNext: { (string) in | |
showAlert(text: string) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textField | |
.rx //** <--- สำคัญมาก | |
.text | |
.orEmpty | |
.asObservable() | |
.subscribe(onNext: { (str) in | |
print("TextField1 str: [\(str)]") | |
}) | |
.disposed(by: disposeBag) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func onTextChanged() { | |
loginBtn.isEnabled = (username.length > 4) && (password.length > 4) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loginFailure() { | |
username.text = "" | |
password.text = "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func loginFailure() { | |
username.text = "" | |
password.text = "" | |
loginBtn.isEnabled = (username.length > 4) && (password.length > 4) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let usr = username.rx | |
.text | |
.orEmpty | |
.asObservable() | |
.map { (str)-> Bool in | |
return str.characters.count > 4 | |
} | |
let pwd = password.rx | |
.text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let usrObservable = username.rx | |
.text | |
.orEmpty | |
.asObservable() |
OlderNewer