@@ -52,6 +52,129 @@ void testBrowserVersionMatch() {
52
52
assertThat (comparator .compare ("130.0" , "131" )).isEqualTo (-1 );
53
53
}
54
54
55
+ @ Test
56
+ public void testSpecificRelayCapabilitiesAppMatch () {
57
+ Capabilities capabilitiesWithApp =
58
+ new ImmutableCapabilities (
59
+ "appium:app" ,
60
+ "link.to.apk" ,
61
+ "appium:appPackage" ,
62
+ "com.example.app" ,
63
+ "appium:platformVersion" ,
64
+ "15" ,
65
+ "platformName" ,
66
+ "Android" ,
67
+ "appium:automationName" ,
68
+ "uiautomator2" );
69
+ assertThat (DefaultSlotMatcher .matchConditionToRemoveCapability (capabilitiesWithApp )).isTrue ();
70
+ capabilitiesWithApp =
71
+ new ImmutableCapabilities (
72
+ "browserName" ,
73
+ "chrome" ,
74
+ "appium:platformVersion" ,
75
+ "15" ,
76
+ "platformName" ,
77
+ "Android" ,
78
+ "appium:automationName" ,
79
+ "uiautomator2" );
80
+ assertThat (DefaultSlotMatcher .matchConditionToRemoveCapability (capabilitiesWithApp )).isFalse ();
81
+ }
82
+
83
+ @ Test
84
+ public void testRelayNodeMatchByRemovingBrowserNameWhenAppSet () {
85
+ /*
86
+ Relay node stereotype does not have browserName (where user wants to restrict to run a native app only)
87
+ Request capabilities have both browserName (it might initialize by ChromeOptions) and app set
88
+ The browserName will be filter out when validating match
89
+ */
90
+ Capabilities stereotype =
91
+ new ImmutableCapabilities (
92
+ CapabilityType .PLATFORM_NAME , Platform .ANDROID , "appium:platformVersion" , "14" );
93
+ Capabilities capabilities =
94
+ new ImmutableCapabilities (
95
+ CapabilityType .BROWSER_NAME ,
96
+ "chrome" ,
97
+ CapabilityType .PLATFORM_NAME ,
98
+ Platform .ANDROID ,
99
+ "appium:platformVersion" ,
100
+ "14" ,
101
+ "appium:app" ,
102
+ "link.to.apk" ,
103
+ "appium:automationName" ,
104
+ "uiautomator2" );
105
+ assertThat (slotMatcher .matches (stereotype , capabilities )).isTrue ();
106
+ }
107
+
108
+ @ Test
109
+ public void testRelayNodeNotMatchHybridBrowserVersionWhenStereotypeWithoutBrowserName () {
110
+ /*
111
+ Relay node 1 has stereotype does not have browserName (where user wants to restrict to run a native app only)
112
+ Request capabilities want to run a hybrid app (browserName is set) and app isn't set
113
+ Request capabilities should not match the stereotype
114
+ Relay node 2 has stereotype with browserName set should match the request capabilities
115
+ */
116
+ Capabilities stereotype1 =
117
+ new ImmutableCapabilities (
118
+ CapabilityType .PLATFORM_NAME , Platform .ANDROID , "appium:platformVersion" , "14" );
119
+ Capabilities capabilities =
120
+ new ImmutableCapabilities (
121
+ CapabilityType .BROWSER_NAME ,
122
+ "chrome" ,
123
+ CapabilityType .PLATFORM_NAME ,
124
+ Platform .ANDROID ,
125
+ "appium:platformVersion" ,
126
+ "14" ,
127
+ "appium:automationName" ,
128
+ "uiautomator2" );
129
+ assertThat (slotMatcher .matches (stereotype1 , capabilities )).isFalse ();
130
+ Capabilities stereotype2 =
131
+ new ImmutableCapabilities (
132
+ CapabilityType .BROWSER_NAME ,
133
+ "chrome" ,
134
+ CapabilityType .PLATFORM_NAME ,
135
+ Platform .ANDROID ,
136
+ "appium:platformVersion" ,
137
+ "14" );
138
+ assertThat (slotMatcher .matches (stereotype2 , capabilities )).isTrue ();
139
+ }
140
+
141
+ @ Test
142
+ public void testRelayNodeNotMatchWhenNonW3CCompliantPlatformVersionSet () {
143
+ /*
144
+ There are Appium server plugins which allow to “fix” non W3C compliant capabilities by automatically adding `appium:` prefix to them
145
+ Relay Node 1: When `platformVersion` is set in both stereotype and capabilities, the non W3C compliant `platformVersion` should be not matched
146
+ Relay Node 2: When `platformVersion` is set in stereotype and capabilities, the non W3C compliant `platformVersion` should be matched
147
+ */
148
+ Capabilities stereotype1 =
149
+ new ImmutableCapabilities (
150
+ CapabilityType .BROWSER_NAME ,
151
+ "chrome" ,
152
+ CapabilityType .PLATFORM_NAME ,
153
+ Platform .ANDROID ,
154
+ "platformVersion" ,
155
+ "14" );
156
+ Capabilities capabilities =
157
+ new ImmutableCapabilities (
158
+ CapabilityType .BROWSER_NAME ,
159
+ "chrome" ,
160
+ CapabilityType .PLATFORM_NAME ,
161
+ Platform .ANDROID ,
162
+ "platformVersion" ,
163
+ "15" ,
164
+ "appium:automationName" ,
165
+ "uiautomator2" );
166
+ assertThat (slotMatcher .matches (stereotype1 , capabilities )).isFalse ();
167
+ Capabilities stereotype2 =
168
+ new ImmutableCapabilities (
169
+ CapabilityType .BROWSER_NAME ,
170
+ "chrome" ,
171
+ CapabilityType .PLATFORM_NAME ,
172
+ Platform .ANDROID ,
173
+ "platformVersion" ,
174
+ "15" );
175
+ assertThat (slotMatcher .matches (stereotype2 , capabilities )).isTrue ();
176
+ }
177
+
55
178
@ Test
56
179
void fullMatch () {
57
180
Capabilities stereotype =
0 commit comments