37
37
import org .opendatakit .util .ODKMatchers ;
38
38
import org .opendatakit .util .UAUtils ;
39
39
import org .opendatakit .utilities .ODKFileUtils ;
40
+ import org .opendatakit .utilities .ODKXFileUriUtils ;
40
41
41
42
import java .io .File ;
42
43
72
73
import static org .hamcrest .Matchers .notNullValue ;
73
74
import static org .opendatakit .tables .utils .Constants .IntentKeys .TABLE_PREFERENCE_FRAGMENT_TYPE ;
74
75
import static org .opendatakit .util .TestConstants .APP_NAME ;
75
- import static org .opendatakit .util .TestConstants .OI_PICK_FILE ;
76
76
import static org .opendatakit .util .TestConstants .T_HOUSE_E_DISPLAY_NAME ;
77
77
import static org .opendatakit .util .TestConstants .T_HOUSE_E_TABLE_ID ;
78
78
import static org .opendatakit .util .TestConstants .T_HOUSE_TABLE_ID ;
@@ -237,24 +237,24 @@ public void setup() {
237
237
}
238
238
239
239
@ Test
240
- public void intents_launchOIFileManager () {
240
+ public void intents_launchFilePicker () {
241
241
//Check intent on "List View File"
242
242
EspressoUtils
243
243
.onRecyclerViewText (R .string .list_view_file )
244
244
.perform (click ());
245
- intended (hasAction (OI_PICK_FILE ), Intents .times (1 ));
245
+ intended (hasAction (Intent . ACTION_OPEN_DOCUMENT ), Intents .times (1 ));
246
246
247
247
//Check intent on "Detail View File"
248
248
EspressoUtils
249
249
.onRecyclerViewText (R .string .detail_view_file )
250
250
.perform (click ());
251
- intended (hasAction (OI_PICK_FILE ), Intents .times (2 ));
251
+ intended (hasAction (Intent . ACTION_OPEN_DOCUMENT ), Intents .times (2 ));
252
252
253
253
//Check intent on "Map List View File"
254
254
EspressoUtils
255
255
.onRecyclerViewText (R .string .map_list_view_file )
256
256
.perform (click ());
257
- intended (hasAction (OI_PICK_FILE ), Intents .times (3 ));
257
+ intended (hasAction (Intent . ACTION_OPEN_DOCUMENT ), Intents .times (3 ));
258
258
}
259
259
260
260
@ Test
@@ -375,16 +375,15 @@ public void view_rotateScreen() throws RemoteException, InterruptedException {
375
375
376
376
@ Test
377
377
public void intents_listView () {
378
- final String listViewPath =
379
- "/" + APP_NAME + "/config/tables/Tea_houses/html/Tea_houses_list.html" ;
378
+ String listViewPath = "tables/Tea_houses/html/Tea_houses_list.html" ;
379
+ Uri listViewUri = ODKXFileUriUtils . getConfigUri ( APP_NAME ). buildUpon (). appendPath ( listViewPath ). build () ;
380
380
381
381
//backup current config
382
382
String currFile = getListViewFile ();
383
383
384
384
//stub response
385
- intending (hasAction (OI_PICK_FILE )).respondWith (
386
- new Instrumentation .ActivityResult (Activity .RESULT_OK , new Intent ()
387
- .setData (Uri .fromFile (new File (ODKFileUtils .getOdkFolder () + listViewPath )))));
385
+ intending (hasAction (Intent .ACTION_OPEN_DOCUMENT )).respondWith (
386
+ new Instrumentation .ActivityResult (Activity .RESULT_OK , new Intent ().setData (listViewUri )));
388
387
389
388
//edit list view path
390
389
EspressoUtils
@@ -410,28 +409,28 @@ public void intents_listView() {
410
409
411
410
@ Test
412
411
public void intents_detailView () {
413
- final String detailViewPath =
414
- "/" + APP_NAME + "/config/ tables/Tea_houses/html/Tea_houses_detail .html" ;
415
- final String listViewPath =
416
- "/" + APP_NAME + "/config/tables/Tea_houses/html/Tea_houses_list.html" ;
412
+ String detailViewPath = "tables/Tea_houses/html/Tea_houses_detail.html" ;
413
+ String listViewPath = " tables/Tea_houses/html/Tea_houses_list .html" ;
414
+ Uri detailViewUri = ODKXFileUriUtils . getConfigUri ( APP_NAME ). buildUpon (). appendPath ( detailViewPath ). build ();
415
+ Uri listViewUri = ODKXFileUriUtils . getConfigUri ( APP_NAME ). buildUpon (). appendPath ( listViewPath ). build () ;
417
416
418
417
//back up current config
419
418
String currDetailFile = getDetailViewFile ();
420
419
String currListFile = getListViewFile ();
421
420
422
421
//stub response
423
- intending (hasAction (OI_PICK_FILE )).respondWith (
422
+ intending (hasAction (Intent . ACTION_OPEN_DOCUMENT )).respondWith (
424
423
new Instrumentation .ActivityResult (Activity .RESULT_OK , new Intent ()
425
- .setData (Uri . fromFile ( new File ( ODKFileUtils . getOdkFolder () + detailViewPath )) )));
424
+ .setData (detailViewUri )));
426
425
427
426
//edit detail view path
428
427
EspressoUtils
429
428
.onRecyclerViewText (R .string .detail_view_file )
430
429
.perform (click ());
431
430
432
- intending (hasAction (OI_PICK_FILE )).respondWith (
431
+ intending (hasAction (Intent . ACTION_OPEN_DOCUMENT )).respondWith (
433
432
new Instrumentation .ActivityResult (Activity .RESULT_OK , new Intent ()
434
- .setData (Uri . fromFile ( new File ( ODKFileUtils . getOdkFolder () + listViewPath )) )));
433
+ .setData (listViewUri )));
435
434
436
435
//edit list view path
437
436
EspressoUtils
@@ -455,8 +454,7 @@ public void intents_detailView() {
455
454
allOf (withId (R .id .webkit ), isDescendantOfA (withId (R .id .top_pane )));
456
455
457
456
//check url
458
- onView (topWebViewMatcher )
459
- .check (matches (ODKMatchers .withUrl (endsWith (detailViewPath ))));
457
+ onView (topWebViewMatcher ).check (matches (ODKMatchers .withUrl (endsWith (detailViewPath ))));
460
458
461
459
EspressoUtils
462
460
.delayedFindElement (topWebViewMatcher , Locator .ID , "TITLE" , WEB_WAIT_TIMEOUT )
@@ -528,7 +526,7 @@ public void display_outOfAppDirViewFile() {
528
526
529
527
try {
530
528
//stub intent
531
- intending (hasAction (OI_PICK_FILE )).respondWith (
529
+ intending (hasAction (Intent . ACTION_OPEN_DOCUMENT )).respondWith (
532
530
new Instrumentation .ActivityResult (Activity .RESULT_OK ,
533
531
new Intent ().setData (Uri .fromFile (new File ("/test.html" )))));
534
532
0 commit comments