Can you clarify? You want to simulate a long press in an edit box,
followed by a selection of the "paste" menu item?

If so, get hold of the Android 2.2 SDK documentation. In it, under the
Resources tab, there's a tutorial on unit testing an Activity:

http://developer.android.com/resources/tutorials/testing/activity_test.html

This uses the test case class ActivityInstrumentationTestCase2, which
inherits from InstrumentationTestCase.

Part of the tutorial shows how to get focus on a UI widget. In your
case, you'd get focus on the edit box.

>From there, you need to bring up the context menu. I think you could
use TouchUtils.longClickView() to do that. That puts focus on the
menu, I think. From there, send DPAD_DOWN key events to move the
highlight to the "paste" option, then DPAD_ENTER to select it.

Keep in mind that I've never tried to do this on a menu. I just
provide this as a guideline for trying to solve the problem.

Also keep in mind that Android JUnit testing is really focused on
*unit* testing. If you're really trying to test functionality, there
are better options. IMHO, the difference is that unit testing goes
method-by-method, with the assumption that all methods and classes are
independent. You inject all external dependencies, either with mocks
or actual objects. Functional testing goes from the beginning of a
user task to the end. For example, a functional test of a calculator
app would enter a 2, enter a +, enter another 2, enter an =, and check
to see that 4 is displayed.



On Nov 4, 12:41 pm, Zymurgeek <[email protected]> wrote:
> How do I go about simulating a context menu paste command using the
> Android JUnit tests?

-- 
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

Reply via email to