android - Testing AutoCompleteTextView with Espresso -


i using espresso test app several autocompletetextviews. 1 particular test, autocomplete popup appears, want ignore , move next textview. how can this? ideas either simulate "back" press or simulate tap in popup.

update:

i attempting following click on autocomplete popup:

onview(withid(r.id.brand_text))         .perform(scrollto(), typetext(card.getbrand())); ondata(allof(is(instanceof(string.class)), is(card.getbrand())))         .inroot(isplatformpopup())         .perform(click()); onview(withid(r.id.brand_text))         .check(matches(withtext(card.getbrand()))); 

now problem in cases, text entered doesn't have autocomplete matches no popup appears. how conditionally perform click depending on whether or not view matched?

my solution add uidevice object ui automator test:

 uidevice device = uidevice.getinstance(instrumentationregistry.getinstrumentation()); 

then call uidevice.pressenter() advance next textview.

device.pressenter(); 

the problem encountered doesn't work expected out of box. added view.onkeylistener each autocompletetextview handle enter key event. add listener each view , explicitly state view requests focus on enter key event.

@override  public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     // ...      brandtext.setonkeylistener(new view.onkeylistener() {          @override          public boolean onkey(view v, int keycode, keyevent event) {              if (event.getaction() == keyevent.action_up && keycode == keyevent.keycode_enter) {                  yeartext.requestfocus();                  return true;              }               return false;          }      });      //... } 

this isn't ideal. plan generalize this, possibly custom component inherits autocompletetextview handles enter key expect. send focus "next" view.


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -