Skip to content

Commit

Permalink
fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyapuchka committed Oct 26, 2018
1 parent dd20c07 commit 2245929
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 40 deletions.
4 changes: 2 additions & 2 deletions DrawerKitDemo/DrawerKitDemo/PresenterViewController.swift
Expand Up @@ -15,7 +15,7 @@ class PresenterViewController: UIViewController, DrawerCoordinating {
@IBAction func alertButtonTapped() {
let alert = UIAlertController(title: "Alert", message: "", preferredStyle: .alert)
alert.addAction(UIAlertAction.init(title: "OK", style: .default, handler: nil))
self.presentedViewController?.present(alert, animated: true, completion: nil)
(self.presentedViewController ?? self).present(alert, animated: true, completion: nil)
}
}

Expand All @@ -36,7 +36,7 @@ private extension PresenterViewController {
configuration.durationIsProportionalToDistanceTraveled = false
// default is UISpringTimingParameters()
configuration.timingCurveProvider = UISpringTimingParameters(dampingRatio: 0.8)
configuration.fullExpansionBehaviour = .leavesCustomGap(gap: 150)
configuration.fullExpansionBehaviour = .coversFullScreen
configuration.supportsPartialExpansion = true
configuration.dismissesInStages = true
configuration.isDrawerDraggable = true
Expand Down
26 changes: 9 additions & 17 deletions DrawerKitDemo/DrawerKitDemo/Storyboards/Base.lproj/Main.storyboard
Expand Up @@ -32,7 +32,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="zqC-oY-NTg">
<rect key="frame" x="0.0" y="90" width="375" height="487"/>
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<accessibility key="accessibilityConfiguration" identifier="mainCanvas"/>
<gestureRecognizers/>
<state key="normal">
Expand All @@ -41,31 +41,18 @@
<connections>
<action selector="presentButtonTapped" destination="uBw-Sr-LpF" eventType="touchUpInside" id="ROy-A5-vzk"/>
<outletCollection property="gestureRecognizers" destination="biI-9V-ig5" appends="YES" id="vSE-Uj-jCd"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="mT6-dc-gM1">
<rect key="frame" x="171" y="60" width="33" height="30"/>
<constraints>
<constraint firstAttribute="height" constant="30" id="M9V-Oy-TbX"/>
</constraints>
<state key="normal" title="Alert">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="alertButtonTapped" destination="uBw-Sr-LpF" eventType="touchUpInside" id="4Et-YI-7sK"/>
<outletCollection property="gestureRecognizers" destination="HER-mx-HJG" appends="YES" id="8lM-f4-epj"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" red="0.24548156692070328" green="0.44175364460593769" blue="0.61927218264248707" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<constraints>
<constraint firstItem="zqC-oY-NTg" firstAttribute="top" secondItem="mT6-dc-gM1" secondAttribute="bottom" id="7p9-ir-jZ2"/>
<constraint firstItem="mT6-dc-gM1" firstAttribute="centerX" secondItem="kpO-ML-Q54" secondAttribute="centerX" id="BJG-Mf-P1w"/>
<constraint firstItem="E1R-4Q-Kln" firstAttribute="centerY" secondItem="kpO-ML-Q54" secondAttribute="centerY" id="Zhb-3P-Akq"/>
<constraint firstItem="E1R-4Q-Kln" firstAttribute="centerX" secondItem="kpO-ML-Q54" secondAttribute="centerX" id="chs-2Y-Dg5"/>
<constraint firstItem="zqC-oY-NTg" firstAttribute="centerY" secondItem="kpO-ML-Q54" secondAttribute="centerY" id="g9w-F7-JVk"/>
<constraint firstItem="mT6-dc-gM1" firstAttribute="top" secondItem="eUk-bQ-xyb" secondAttribute="bottom" constant="40" id="jNZ-yF-aZ0"/>
<constraint firstAttribute="trailing" secondItem="zqC-oY-NTg" secondAttribute="trailing" id="jxk-gc-Uqa"/>
<constraint firstItem="zqC-oY-NTg" firstAttribute="leading" secondItem="kpO-ML-Q54" secondAttribute="leading" id="rnK-kU-a7Q"/>
<constraint firstItem="zqC-oY-NTg" firstAttribute="top" secondItem="eUk-bQ-xyb" secondAttribute="bottom" id="wYF-b9-gqO"/>
<constraint firstItem="ZsS-x3-G2B" firstAttribute="top" secondItem="zqC-oY-NTg" secondAttribute="bottom" id="zoo-za-lxb"/>
</constraints>
</view>
</viewController>
Expand All @@ -75,6 +62,11 @@
<action selector="presentButtonDoubleTapped" destination="uBw-Sr-LpF" id="kiH-5x-R81"/>
</connections>
</tapGestureRecognizer>
<pongPressGestureRecognizer allowableMovement="10" minimumPressDuration="0.5" id="HER-mx-HJG">
<connections>
<action selector="alertButtonTapped" destination="uBw-Sr-LpF" id="LdR-GM-qDt"/>
</connections>
</pongPressGestureRecognizer>
</objects>
<point key="canvasLocation" x="-5634.3999999999996" y="-3600.4497751124441"/>
</scene>
Expand Down
28 changes: 8 additions & 20 deletions DrawerKitDemo/DrawerKitDemoUITests/DrawerKitDemoUITests.swift
Expand Up @@ -3,7 +3,7 @@ import XCTest
class DrawerKitDemoUITests: XCTestCase {

var app: XCUIApplication!
let transitionTimeout: TimeInterval = 1.0
let transitionTimeout: TimeInterval = 2.0

enum ElementState: String {
case exists = "exists == true"
Expand Down Expand Up @@ -83,29 +83,17 @@ class DrawerKitDemoUITests: XCTestCase {
func testTouchesPassthrough() {
let mainCanvas = app.buttons[Identifiers.mainCanvas]
mainCanvas.doubleTap()
XCTAssertTrue(isDrawerOpen())

let alertButton = app.buttons["Alert"]
let alert = app.alerts["Alert"]

XCTAssertTrue(alertButton.isHittable)
alertButton.tap()

XCTAssertTrue(alert.exists)
alert.buttons.firstMatch.tap()

let drawer = app.staticTexts[Identifiers.drawerDescription].firstMatch
let start = drawer.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5))
let end = mainCanvas.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.1))
start.press(forDuration: 0.05, thenDragTo: end)

XCTAssertFalse(alertButton.isHittable)

end.press(forDuration: 0.05, thenDragTo: start)

XCTAssertTrue(alertButton.isHittable)
alertButton.tap()
if #available(iOS 12, *) {
mainCanvas.press(forDuration: 1)
} else {
app.press(forDuration: 1)
}

XCTAssertTrue(alert.exists)
XCTAssertTrue(tryWaitFor(element: alert, withState: .exists))
alert.buttons.firstMatch.tap()
}

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Expand Up @@ -14,7 +14,7 @@ test:
CODE_SIGN_IDENTITY=
PROVISIONING_PROFILE=
-sdk iphonesimulator
-destination 'platform=iOS Simulator,OS=11.1,name=iPhone 7'
-destination 'platform=iOS Simulator,OS=11.1,name=iPhone X'
-workspace DrawerKit.xcworkspace
-scheme "DrawerKitDemo"
clean build test
Expand Down

0 comments on commit 2245929

Please sign in to comment.