Skip to content

Commit b872570

Browse files
authored
Merge pull request #4681 from wix/feat/bridgeless-mode
feat(iOS): support bridgeless mode (new-arch).
2 parents 49aedb5 + ec530a8 commit b872570

File tree

85 files changed

+1382
-1039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1382
-1039
lines changed

.buildkite/jobs/pipeline.android_rn_73.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- label: ":android::detox: (Old Arch) - RN .73 + Android: Tests app"
1+
- label: ":android::detox: (Old Arch) RN .73 + Android: Tests app"
22
command:
33
- "nvm install"
44
- "./scripts/ci.android.sh"

.buildkite/jobs/pipeline.android_rn_76_old_arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- label: ":android::detox: (Old Arch) - RN .76 + Android: Tests app"
1+
- label: ":android::detox: (Old Arch) RN .76 + Android: Tests app"
22
command:
33
- "nvm install"
44
- "./scripts/ci.android.sh"

.buildkite/jobs/pipeline.ios_demo_app_rn_76_new_arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- label: ":new::ios::react: RN .76 + iOS: Demo app"
1+
- label: ":ios::react: RN .76 + iOS: Demo app"
22
command:
33
- "nvm install"
44
- "./scripts/demo-projects.ios.sh"

.buildkite/jobs/pipeline.ios_rn_73.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
- label: ":ios::detox: RN .73 + iOS: Tests app"
1+
- label: ":ios::detox: (Old Arch) RN .73 + iOS: Tests app"
22
command:
33
- "nvm install"
44
- "./scripts/ci.ios.sh"
55
env:
66
REACT_NATIVE_VERSION: 0.73.2
7+
RCT_NEW_ARCH_ENABLED: 0
78
artifact_paths:
89
- "/Users/builder/uibuilder/work/coverage/**/*.lcov"
910
- "/Users/builder/uibuilder/work/**/allure-report-*.html"

.buildkite/jobs/pipeline.ios_rn_76.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- label: ":ios::detox: RN .76 + iOS: Tests app"
1+
- label: ":ios::detox: (Old Arch) RN .76 + iOS: Tests app"
22
command:
33
- "nvm install"
44
- "./scripts/ci.ios.sh"

.buildkite/jobs/pipeline.ios_rn_76_new_arch.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
- label: ":new::ios::detox: RN .76 + New Arch + iOS: Tests app"
1+
- label: ":ios::detox: RN .76 + iOS: Tests app"
22
command:
33
- "nvm install"
44
- "./scripts/ci.ios.sh"

detox/ios/Detox/Actions/NSObject+DetoxActions.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ - (void)dtx_tapAtAccessibilityActivationPointWithNumberOfTaps:(NSUInteger)number
101101

102102
- (void)dtx_tapAtPoint:(CGPoint)point numberOfTaps:(NSUInteger)numberOfTaps
103103
{
104-
if([self isKindOfClass:UISwitch.class] && numberOfTaps == 1)
104+
if(self.dtx_switchView != nil && numberOfTaps == 1)
105105
{
106106
//Attempt a long press on the switch, rather than tap.
107-
[self dtx_longPressAtPoint:point duration:0.7];
107+
[self.dtx_switchView dtx_longPressAtPoint:point duration:0.7];
108108
return;
109109
}
110110

detox/ios/Detox/Actions/UIScrollView+DetoxActions.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ - (void)_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1;
2323

2424
@interface UIScrollView (DetoxScrolling)
2525

26-
- (BOOL)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1;
26+
- (void)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1;
2727
@property (nonatomic, assign, setter=dtx_setDisableDecelerationForScroll:) BOOL dtx_disableDecelerationForScroll;
2828

2929
@end
@@ -47,7 +47,7 @@ - (BOOL)dtx_disableDecelerationForScroll
4747
return [objc_getAssociatedObject(self, "dtx_disableDecelerationForScroll") boolValue];
4848
}
4949

50-
- (BOOL)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1
50+
- (void)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1
5151
{
5252
BOOL deceleration = arg1;
5353
if(self.dtx_disableDecelerationForScroll == YES &&
@@ -60,8 +60,8 @@ - (BOOL)_dtx_scrollViewWillEndDraggingWithDeceleration:(BOOL)arg1
6060
{
6161
deceleration = NO;
6262
}
63-
64-
return [self _dtx_scrollViewWillEndDraggingWithDeceleration:deceleration];
63+
64+
[self _dtx_scrollViewWillEndDraggingWithDeceleration:deceleration];
6565
}
6666

6767
@end

detox/ios/Detox/Invocation/Element.swift

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Element : NSObject {
8585
if ReactNativeSupport.isReactNativeApp {
8686
let className = NSStringFromClass(type(of: view))
8787
switch className {
88-
case "RCTScrollView", "RCTScrollViewComponentView":
88+
case "RCTScrollView", "RCTScrollViewComponentView", "RCTEnhancedScrollView":
8989
return (view.value(forKey: "scrollView") as! UIScrollView)
9090
default:
9191
break
@@ -189,23 +189,34 @@ class Element : NSObject {
189189
}
190190

191191
func adjust(toDate date: Date) {
192-
if let view = view as? UIDatePicker {
193-
view.dtx_adjust(to: date)
194-
} else {
195-
dtx_fatalError("View “\(view.dtx_shortDescription)” is not an instance of “UIDatePicker”", viewDescription: debugAttributes)
196-
}
192+
var didSetPicker = false
193+
194+
view.dtx_ifDatePicker { view in
195+
view.dtx_adjust(to: date)
196+
didSetPicker = true
197+
}
198+
199+
guard didSetPicker else {
200+
dtx_fatalError("View “\(view.dtx_shortDescription)” is not an instance of “UIDatePicker”", viewDescription: debugAttributes)
201+
}
202+
197203
}
198204

199205
func setComponent(_ component: Int, toValue value: Any) {
200-
if let view = view as? UIPickerView {
201-
view.dtx_setComponent(component, toValue: value)
202-
} else {
203-
dtx_fatalError("View “\(view.dtx_shortDescription)” is not an instance of “UIPickerView”", viewDescription: debugAttributes)
204-
}
206+
var didSetPicker = false
207+
208+
view.dtx_ifPicker { view in
209+
view.dtx_setComponent(component, toValue: value)
210+
didSetPicker = true
211+
}
212+
213+
guard didSetPicker else {
214+
dtx_fatalError("View “\(view.dtx_shortDescription)” is not an instance of “UIPickerView”", viewDescription: debugAttributes)
215+
}
205216
}
206217

207218
func adjust(toNormalizedSliderPosition normalizedSliderPosition: Double) {
208-
guard let slider = view as? UISlider else {
219+
guard let slider = view.dtx_sliderView else {
209220
dtx_fatalError("View \(view.dtx_shortDescription) is not instance of “UISlider”", viewDescription: debugAttributes)
210221
}
211222

@@ -267,17 +278,34 @@ class Element : NSObject {
267278
return view.accessibilityValue
268279
}
269280

270-
@objc
271-
var normalizedSliderPosition: Double {
272-
get {
273-
guard let slider = view as? UISlider else {
274-
dtx_fatalError("View \(view.dtx_shortDescription) is not instance of “UISlider”", viewDescription: debugAttributes)
275-
}
276-
277-
return slider.dtx_normalizedSliderPosition
278-
}
279-
}
280-
281+
@objc
282+
var normalizedSliderPosition: Double {
283+
get {
284+
if let slider = view.dtx_sliderView {
285+
return slider.dtx_normalizedSliderPosition
286+
}
287+
288+
dtx_fatalError(
289+
"View \(view.dtx_shortDescription) is not instance or wrapper of “UISlider”",
290+
viewDescription: debugAttributes
291+
)
292+
}
293+
}
294+
295+
@objc
296+
var toggleValue: Double {
297+
get {
298+
if let toggle = view.dtx_switchView {
299+
return toggle.isOn ? 1.0 : 0.0
300+
}
301+
302+
dtx_fatalError(
303+
"View \(view.dtx_shortDescription) is not instance or wrapper of “UISwitch”",
304+
viewDescription: debugAttributes
305+
)
306+
}
307+
}
308+
281309
@objc
282310
var attributes: [String : Any] {
283311
let views = self.views

detox/ios/Detox/Invocation/Expectation.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Expectation : CustomStringConvertible {
5757
static let toHaveValue = "toHaveValue"
5858
static let toHavePlaceholder = "toHavePlaceholder"
5959
static let toHaveSliderPosition = "toHaveSliderPosition"
60+
static let toHaveToggleValue = "toHaveToggleValue"
6061
}
6162

6263
let element : Element
@@ -81,7 +82,8 @@ class Expectation : CustomStringConvertible {
8182
Kind.toHaveId: ValueExpectation.self,
8283
Kind.toHaveValue: ValueExpectation.self,
8384
Kind.toHavePlaceholder: ValueExpectation.self,
84-
Kind.toHaveSliderPosition: SliderPositionExpectation.self
85+
Kind.toHaveSliderPosition: SliderPositionExpectation.self,
86+
Kind.toHaveToggleValue: ToggleValueExpectation.self
8587
]
8688

8789
static let keyMapping : [String: String] = [
@@ -106,7 +108,10 @@ class Expectation : CustomStringConvertible {
106108

107109
let element = try Element.with(dictionaryRepresentation: dictionaryRepresentation)
108110
let expectationClass = mapping[kind]!
109-
if expectationClass == SliderPositionExpectation.self {
111+
if expectationClass == ToggleValueExpectation.self {
112+
return ToggleValueExpectation(kind: kind, modifiers: modifiers, element: element, timeout: timeout, value: params!.first! as! Double, tolerance: params!.count > 1 ? (params![1] as! Double) : nil)
113+
114+
} else if expectationClass == SliderPositionExpectation.self {
110115
return SliderPositionExpectation(kind: kind, modifiers: modifiers, element: element, timeout: timeout, value: params!.first! as! Double, tolerance: params!.count > 1 ? (params![1] as! Double) : nil)
111116
} else if expectationClass == ValueExpectation.self {
112117
return ValueExpectation(kind: kind, modifiers: modifiers, element: element, timeout: timeout, key: keyMapping[kind]!, value: params!.first!)
@@ -312,3 +317,15 @@ class SliderPositionExpectation : DoubleExpectation {
312317
}
313318
}
314319
}
320+
321+
class ToggleValueExpectation : DoubleExpectation {
322+
override func valueToTest(from element: Element) -> Double {
323+
return element.toggleValue
324+
}
325+
326+
override var additionalDescription: String {
327+
get {
328+
return "(toggleValue \(tolerance != nil ? "(~\(tolerance!))" : "")== \(value == 1.0 ? "ON" : "OFF"))"
329+
}
330+
}
331+
}

0 commit comments

Comments
 (0)