24
24
import com .owncloud .android .lib .resources .shares .CreateShareRemoteOperation ;
25
25
import com .owncloud .android .lib .resources .shares .ShareType ;
26
26
import com .owncloud .android .lib .resources .status .GetCapabilitiesRemoteOperation ;
27
+ import com .owncloud .android .lib .resources .status .NextcloudVersion ;
27
28
import com .owncloud .android .lib .resources .status .OCCapability ;
29
+ import com .owncloud .android .lib .resources .status .OwnCloudVersion ;
28
30
29
31
import org .junit .BeforeClass ;
30
32
import org .junit .Test ;
@@ -94,6 +96,12 @@ public void testFileSearchEmpty() throws IOException {
94
96
95
97
@ Test
96
98
public void testFileSearchEverything () throws IOException {
99
+ // on newer server we have Talk folder
100
+ int offset = 0 ;
101
+ if (capability .getVersion ().isNewerOrEqual (NextcloudVersion .nextcloud_20 )) {
102
+ offset = 1 ;
103
+ }
104
+
97
105
for (int i = 0 ; i < 10 ; i ++) {
98
106
String filePath = createFile ("image" + i );
99
107
String remotePath = "/image" + i + ".jpg" ;
@@ -108,7 +116,7 @@ public void testFileSearchEverything() throws IOException {
108
116
109
117
RemoteOperationResult <List <RemoteFile >> result = sut .execute (client );
110
118
assertTrue (result .isSuccess ());
111
- assertEquals (11 , result .getResultData ().size ());
119
+ assertEquals (offset + 10 , result .getResultData ().size ());
112
120
}
113
121
114
122
@ Test
@@ -202,14 +210,27 @@ public void favoriteFiles() throws IOException {
202
210
assertEquals (2 , result .getResultData ().size ());
203
211
204
212
assertEquals (remotePath , result .getResultData ().get (0 ).getRemotePath ());
205
- assertEquals (sharedRemotePath , result .getResultData ().get (1 ).getRemotePath ());
213
+
214
+ if (capability .getVersion ().isNewerOrEqual (OwnCloudVersion .nextcloud_17 )) {
215
+ assertEquals (sharedRemotePath , result .getResultData ().get (1 ).getRemotePath ());
216
+ } else {
217
+ // on NC16 we have a bug that each file ends with "/"
218
+ sharedRemotePath += "/" ;
219
+ assertEquals (sharedRemotePath , result .getResultData ().get (1 ).getRemotePath ());
220
+ }
206
221
}
207
222
208
223
/**
209
224
* shows just all files, but sorted by date
210
225
*/
211
226
@ Test
212
227
public void testRecentlyModifiedSearch () throws IOException {
228
+ // on newer server we have Talk folder
229
+ int offset = 0 ;
230
+ if (capability .getVersion ().isNewerOrEqual (NextcloudVersion .nextcloud_20 )) {
231
+ offset = 1 ;
232
+ }
233
+
213
234
long now = System .currentTimeMillis () / MILLI_TO_SECOND ;
214
235
String filePath = createFile ("image" );
215
236
assertTrue (new UploadFileRemoteOperation (filePath , "/image.jpg" , "image/jpg" , now - 50 )
@@ -234,7 +255,7 @@ public void testRecentlyModifiedSearch() throws IOException {
234
255
235
256
RemoteOperationResult <List <RemoteFile >> result = sut .execute (client );
236
257
assertTrue (result .isSuccess ());
237
- assertEquals (4 , result .getResultData ().size ());
258
+ assertEquals (offset + 3 , result .getResultData ().size ());
238
259
239
260
assertEquals ("/video.mp4" , result .getResultData ().get (0 ).getRemotePath ());
240
261
assertEquals ("/pdf.pdf" , result .getResultData ().get (1 ).getRemotePath ());
@@ -399,6 +420,8 @@ public void testPhotoSearchLimitAndTimestamp() throws IOException {
399
420
400
421
@ Test
401
422
public void testGallerySearch () throws IOException {
423
+ testOnlyOnServer (OwnCloudVersion .nextcloud_18 );
424
+
402
425
for (int i = 0 ; i < 10 ; i ++) {
403
426
String filePath = createFile ("image" + i );
404
427
String remotePath = "/image" + i + ".jpg" ;
@@ -425,6 +448,12 @@ public void testGallerySearch() throws IOException {
425
448
426
449
@ Test
427
450
public void showOnlyFolders () throws IOException {
451
+ // on newer server we have Talk folder
452
+ int offset = 0 ;
453
+ if (capability .getVersion ().isNewerOrEqual (NextcloudVersion .nextcloud_20 )) {
454
+ offset = 1 ;
455
+ }
456
+
428
457
for (int i = 0 ; i < 10 ; i ++) {
429
458
String filePath = createFile ("image" + i );
430
459
String remotePath = "/image" + i + ".jpg" ;
@@ -438,13 +467,13 @@ public void showOnlyFolders() throws IOException {
438
467
439
468
RemoteOperationResult <List <RemoteFile >> result = sut .execute (client );
440
469
assertTrue (result .isSuccess ());
441
- assertEquals (1 , result .getResultData ().size ());
470
+ assertEquals (0 + offset , result .getResultData ().size ());
442
471
443
472
assertTrue (new CreateFolderRemoteOperation ("/folder/" , false ).execute (client ).isSuccess ());
444
473
445
474
result = sut .execute (client );
446
475
assertTrue (result .isSuccess ());
447
- assertEquals (2 , result .getResultData ().size ());
476
+ assertEquals (1 + offset , result .getResultData ().size ());
448
477
assertEquals ("/folder/" , result .getResultData ().get (0 ).getRemotePath ());
449
478
}
450
479
0 commit comments