<commit_before>//
//  UIViewPropertyAnimatorTests+Rx.swift
//  RxSwiftExt
//
//  Created by <NAME> on 3/4/18.
//  Copyright © 2017 RxSwift Community. All rights reserved.
//

import XCTest
import RxSwift
import RxCocoa
import RxSwiftExt
import UIKit

class UIViewPropertyAnimatorTests: XCTestCase {
    let disposeBag = DisposeBag()

    @available(iOS 10.0, *)
    func testAnimationCompleted() {
        let expectations = expectation(description: "Animation completed")

        let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        let animator = UIViewPropertyAnimator(duration: 0.5, curve: .linear) {
            view.transform = CGAffineTransform(translationX: 100, y: 100)
        }

        animator
            .rx.animate()
            .subscribe(onCompleted: {
                XCTAssertEqual(100, view.frame.origin.x)
                XCTAssertEqual(100, view.frame.origin.y)
                expectations.fulfill()
            })
            .disposed(by: self.disposeBag)

        waitForExpectations(timeout: 1)
    }
}<commit_msg>Add UIViewPropertyAnimator fractionComplete binder tests<commit_after>//
//  UIViewPropertyAnimatorTests+Rx.swift
//  RxSwiftExt
//
//  Created by <NAME> on 3/4/18.
//  Copyright © 2017 RxSwift Community. All rights reserved.
//

import XCTest
import RxSwift
import RxCocoa
import RxSwiftExt
import RxTest
import UIKit

class UIViewPropertyAnimatorTests: XCTestCase {
    
    var disposeBag: DisposeBag!
    
    override func setUp() {
        disposeBag = DisposeBag()
    }

    @available(iOS 10.0, *)
    func testAnimationCompleted() {
        let expectations = expectation(description: "Animation completed")

        let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        let animator = UIViewPropertyAnimator(duration: 0.5, curve: .linear) {
            view.transform = CGAffineTransform(translationX: 100, y: 100)
        }

        animator
            .rx.animate()
            .subscribe(onCompleted: {
                XCTAssertEqual(100, view.frame.origin.x)
                XCTAssertEqual(100, view.frame.origin.y)
                expectations.fulfill()
            })
            .disposed(by: disposeBag)

        waitForExpectations(timeout: 1)
    }
    
    @available(iOS 10.0, *)
    func testBindToFractionCompleted() {
        let animator = UIViewPropertyAnimator(
            duration: 0, curve: .linear, animations: { }
        )
        
        let subject = PublishSubject<CGFloat>()
        
        subject
            .bind(to: animator.rx.fractionComplete)
            .disposed(by: disposeBag)
        
        subject.onNext(0.3)
        XCTAssertEqual(animator.fractionComplete, 0.3)
        
        subject.onNext(0.5)
        XCTAssertEqual(animator.fractionComplete, 0.5)
    }
}
{'fraction_non_alphanumeric': 0.10056858564321251, 'fraction_numerical': 0.028429282160625444, 'mean_word_length': 2.2581018518518516, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4548943', 'n_tokens_mistral': 935, 'n_tokens_neox': 827, 'n_words': 187}