@@ -52,15 +52,19 @@ class CallIntentDataParserTests {
52
52
}
53
53
54
54
@Test
55
- fun `Element Call urls will be returned as is ` () {
55
+ fun `Element Call http urls returns null ` () {
56
56
val httpBaseUrl = " http://call.element.io"
57
57
val httpCallUrl = " http://call.element.io/some-actual-call?with=parameters"
58
+ assertThat(callIntentDataParser.parse(httpBaseUrl)).isNull()
59
+ assertThat(callIntentDataParser.parse(httpCallUrl)).isNull()
60
+ }
61
+
62
+ @Test
63
+ fun `Element Call urls will be returned as is` () {
58
64
val httpsBaseUrl = " https://call.element.io"
59
- val httpsCallUrl = " https://call.element.io/some-actual-call?with=parameters"
60
- assertThat(callIntentDataParser.parse(httpBaseUrl)).isEqualTo(httpBaseUrl)
61
- assertThat(callIntentDataParser.parse(httpCallUrl)).isEqualTo(httpCallUrl)
62
- assertThat(callIntentDataParser.parse(httpsBaseUrl)).isEqualTo(httpsBaseUrl)
63
- assertThat(callIntentDataParser.parse(httpsCallUrl)).isEqualTo(httpsCallUrl)
65
+ val httpsCallUrl = VALID_CALL_URL_WITH_PARAM
66
+ assertThat(callIntentDataParser.parse(httpsBaseUrl)).isEqualTo(" $httpsBaseUrl ?$EXTRA_PARAMS " )
67
+ assertThat(callIntentDataParser.parse(httpsCallUrl)).isEqualTo(" $httpsCallUrl &$EXTRA_PARAMS " )
64
68
}
65
69
66
70
@Test
@@ -76,19 +80,35 @@ class CallIntentDataParserTests {
76
80
}
77
81
78
82
@Test
79
- fun `element scheme with call host and url param gets url extracted ` () {
83
+ fun `element scheme with call host and url with http will returns null ` () {
80
84
val embeddedUrl = " http://call.element.io/some-actual-call?with=parameters"
81
85
val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
82
86
val url = " element://call?url=$encodedUrl "
83
- assertThat(callIntentDataParser.parse(url)).isEqualTo(embeddedUrl )
87
+ assertThat(callIntentDataParser.parse(url)).isNull( )
84
88
}
85
89
86
90
@Test
87
- fun `element scheme 2 with url param gets url extracted` () {
91
+ fun `element scheme with call host and url param gets url extracted` () {
92
+ val embeddedUrl = VALID_CALL_URL_WITH_PARAM
93
+ val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
94
+ val url = " element://call?url=$encodedUrl "
95
+ assertThat(callIntentDataParser.parse(url)).isEqualTo(" $VALID_CALL_URL_WITH_PARAM &$EXTRA_PARAMS " )
96
+ }
97
+
98
+ @Test
99
+ fun `element scheme 2 with url param with http returns null` () {
88
100
val embeddedUrl = " http://call.element.io/some-actual-call?with=parameters"
89
101
val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
90
102
val url = " io.element.call:/?url=$encodedUrl "
91
- assertThat(callIntentDataParser.parse(url)).isEqualTo(embeddedUrl)
103
+ assertThat(callIntentDataParser.parse(url)).isNull()
104
+ }
105
+
106
+ @Test
107
+ fun `element scheme 2 with url param gets url extracted` () {
108
+ val embeddedUrl = VALID_CALL_URL_WITH_PARAM
109
+ val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
110
+ val url = " io.element.call:/?url=$encodedUrl "
111
+ assertThat(callIntentDataParser.parse(url)).isEqualTo(" $VALID_CALL_URL_WITH_PARAM &$EXTRA_PARAMS " )
92
112
}
93
113
94
114
@Test
@@ -101,15 +121,15 @@ class CallIntentDataParserTests {
101
121
102
122
@Test
103
123
fun `element scheme 2 with no url returns null` () {
104
- val embeddedUrl = " http://call.element.io/some-actual-call?with=parameters "
124
+ val embeddedUrl = VALID_CALL_URL_WITH_PARAM
105
125
val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
106
126
val url = " io.element.call:/?no_url=$encodedUrl "
107
127
assertThat(callIntentDataParser.parse(url)).isNull()
108
128
}
109
129
110
130
@Test
111
131
fun `element scheme with no call host returns null` () {
112
- val embeddedUrl = " http://call.element.io/some-actual-call?with=parameters "
132
+ val embeddedUrl = VALID_CALL_URL_WITH_PARAM
113
133
val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
114
134
val url = " element://no-call?url=$encodedUrl "
115
135
assertThat(callIntentDataParser.parse(url)).isNull()
@@ -129,9 +149,39 @@ class CallIntentDataParserTests {
129
149
130
150
@Test
131
151
fun `element invalid scheme returns null` () {
132
- val embeddedUrl = " http://call.element.io/some-actual-call?with=parameters "
152
+ val embeddedUrl = VALID_CALL_URL_WITH_PARAM
133
153
val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
134
154
val url = " bad.scheme:/?url=$encodedUrl "
135
155
assertThat(callIntentDataParser.parse(url)).isNull()
136
156
}
157
+
158
+ @Test
159
+ fun `element scheme 2 with url extra param appPrompt gets url extracted` () {
160
+ val embeddedUrl = " ${VALID_CALL_URL_WITH_PARAM } &appPrompt=true"
161
+ val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
162
+ val url = " io.element.call:/?url=$encodedUrl "
163
+ assertThat(callIntentDataParser.parse(url)).isEqualTo(" $VALID_CALL_URL_WITH_PARAM &$EXTRA_PARAMS " )
164
+ }
165
+
166
+ @Test
167
+ fun `element scheme 2 with url extra param confineToRoom gets url extracted` () {
168
+ val embeddedUrl = " ${VALID_CALL_URL_WITH_PARAM } &confineToRoom=false"
169
+ val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
170
+ val url = " io.element.call:/?url=$encodedUrl "
171
+ assertThat(callIntentDataParser.parse(url)).isEqualTo(" $VALID_CALL_URL_WITH_PARAM &$EXTRA_PARAMS " )
172
+ }
173
+
174
+ @Test
175
+ fun `element scheme 2 with url fragment gets url extracted` () {
176
+ val embeddedUrl = " ${VALID_CALL_URL_WITH_PARAM } #fragment"
177
+ val encodedUrl = URLEncoder .encode(embeddedUrl, " utf-8" )
178
+ val url = " io.element.call:/?url=$encodedUrl "
179
+ assertThat(callIntentDataParser.parse(url)).isEqualTo(" $VALID_CALL_URL_WITH_PARAM &$EXTRA_PARAMS #fragment" )
180
+ }
181
+
182
+
183
+ companion object {
184
+ const val VALID_CALL_URL_WITH_PARAM = " https://call.element.io/some-actual-call?with=parameters"
185
+ const val EXTRA_PARAMS = " appPrompt=false&confineToRoom=true"
186
+ }
137
187
}
0 commit comments