@craft-native/ios 0.0.250 → 0.0.251
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -139,6 +139,30 @@ final class DriverTests: XCTestCase {
|
|
|
139
139
|
return nil
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
+
/// About a third of a screen of scrolling, as a held drag.
|
|
143
|
+
///
|
|
144
|
+
/// `app.swipeUp()` is a flick, and how far a flick throws a scroll view
|
|
145
|
+
/// depends on how its touches arrive: on a loaded machine, with a map
|
|
146
|
+
/// keeping the app busy, eight of them moved a trail page less than one
|
|
147
|
+
/// screen. A drag that stops before it lifts moves the content by its
|
|
148
|
+
/// own length every time. It runs between the middle of the screen and
|
|
149
|
+
/// the upper part, where a flick began too, so it stays off the keys when
|
|
150
|
+
/// a keyboard is up - an iOS 27 simulator reports its keyboard's frame
|
|
151
|
+
/// below the screen while drawing it over the lower half - and it stops
|
|
152
|
+
/// short of a keyboard whose frame is known.
|
|
153
|
+
func scrollPage(towardTop: Bool) {
|
|
154
|
+
let frame = app.frame
|
|
155
|
+
var lower = frame.minY + frame.height * 0.55
|
|
156
|
+
let keyboard = app.keyboards.firstMatch
|
|
157
|
+
if keyboard.exists, !keyboard.frame.isEmpty, keyboard.frame.minY < frame.maxY {
|
|
158
|
+
lower = min(lower, keyboard.frame.minY - 24)
|
|
159
|
+
}
|
|
160
|
+
let upper = max(frame.minY + frame.height * 0.15, lower - frame.height * 0.4)
|
|
161
|
+
let point = { (y: CGFloat) in self.app.coordinate(withNormalizedOffset: .zero).withOffset(CGVector(dx: frame.midX, dy: y)) }
|
|
162
|
+
let (from, to) = towardTop ? (point(upper), point(lower)) : (point(lower), point(upper))
|
|
163
|
+
from.press(forDuration: 0.05, thenDragTo: to, withVelocity: .default, thenHoldForDuration: 0.2)
|
|
164
|
+
}
|
|
165
|
+
|
|
142
166
|
/// Whether `target`, or a field inside it, holds the keyboard.
|
|
143
167
|
func hasKeyboardFocus(_ target: XCUIElement) -> Bool {
|
|
144
168
|
if (target.value(forKey: "hasKeyboardFocus") as? Bool) == true { return true }
|
|
@@ -478,14 +502,11 @@ final class DriverTests: XCTestCase {
|
|
|
478
502
|
else { XCTFail("Element not found"); note("FAIL tab \(arg): NOT FOUND") }
|
|
479
503
|
case "scrollto":
|
|
480
504
|
var found = element(containing: arg)
|
|
481
|
-
var
|
|
482
|
-
while (found == nil || !(found!.isHittable)) &&
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
app.swipeUp()
|
|
487
|
-
}
|
|
488
|
-
swipes += 1
|
|
505
|
+
var drags = 0
|
|
506
|
+
while (found == nil || !(found!.isHittable)) && drags < 12 {
|
|
507
|
+
let towardTop = found.map { !$0.frame.isEmpty && $0.frame.midY < app.frame.midY } ?? false
|
|
508
|
+
scrollPage(towardTop: towardTop)
|
|
509
|
+
drags += 1
|
|
489
510
|
found = element(containing: arg)
|
|
490
511
|
}
|
|
491
512
|
check(found != nil && found!.isHittable, "scrollto \(arg)")
|