I figured out a way to do it.
Just loop through advancing the cursor until you are at the end using
a single key then sending the backspace until you are done:
//Now we need to delete whatever is there. No easy way to do
this in
the Instrumentation class...do it a key at a time
for(int x = 0; x < 7; x++)
{
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_DPAD_RIGHT);
instrumentation.sendCharacterSync(KeyEvent.KEYCODE_DEL);
}
On Jul 11, 12:13 pm, darrinps <[email protected]> wrote:
> I have a case where the application remembers the last text that was
> entered into it. I want to be able to replace that text with something
> else in my test but I don't see any such method in the Instrumentation
> class!
>
> What I do is something like this. See the comment for an instruction I
> need to have that I cannot find. Thanks!
>
> monitor =
> instrumentation.addMonitor(MyActivity.class.getName(),
> null, false);
>
> TouchUtils.clickView(this, currentView);
>
> currentActivity =
> getInstrumentation().waitForMonitorWithTimeout(monitor, 5);
>
> assertEquals("ADD something meaningful here to verify we are
> at the
> right place.", true, true);
>
> currentView =
> currentActivity.findViewById(com.mycompany.android.R.id.username);
> assertTrue(currentView instanceof EditText);
>
> //NEED TO CLEAR THE FIELD HERE AS WHAT I SEND DOES NOT SEEM TO
> REPLACE, BUT ADD
>
> instrumentation.sendStringSync("SOME NEW TEXT");
> ...
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en