android-testing

Espresso NestedScrollView

三世轮回 提交于 2019-12-30 08:15:09
问题 I am trying to test EditTexts in my form that are within a NestedScrollView. I am running the following code: onView(withId(R.id.register_scroll_view)).perform(scrollTo()).perform(click()); where register_scroll_view is my NestedScrollView. However, I am getting an exception: android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: com.eazyigz.myapp:id/register_scroll_view'. Caused by: java.lang.RuntimeException: Action will not be performed because the

Instrumentation test for Android - How to receive new Activity after orientation change?

…衆ロ難τιáo~ 提交于 2019-12-30 06:48:34
问题 I'm trying to test, if newly created Activity (after orientation change) is properly reinitialized. The code below shows that activity returned from getActivity() is the one constructed in setUp(), not the newly created one. Test: public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity>{ private static final String TAG = "RAMPS"; private MyActivity mActivity; public MyActivityTest() { super("com.ramps", MyActivity.class); } protected void setUp() throws Exception {

Instrumentation test for Android - How to receive new Activity after orientation change?

梦想与她 提交于 2019-12-30 06:48:08
问题 I'm trying to test, if newly created Activity (after orientation change) is properly reinitialized. The code below shows that activity returned from getActivity() is the one constructed in setUp(), not the newly created one. Test: public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity>{ private static final String TAG = "RAMPS"; private MyActivity mActivity; public MyActivityTest() { super("com.ramps", MyActivity.class); } protected void setUp() throws Exception {

how to get text from textview using espresso

三世轮回 提交于 2019-12-30 02:45:10
问题 I want get text string shown in a textview in LinearLayout. can espresso do that? If not, is there other way to do that or can I use android api in espresso test case? I am using API 17 18 or newer, espresso 1.1(It should be the latest one.). I have no clue about this. Thanks. 回答1: The basic idea is to use a method with an internal ViewAction that retrieves the text in its perform method. Anonymous classes can only access final fields, so we cannot just let it set a local variable of getText(

How to automate the DDMS snapshot mechanism?

情到浓时终转凉″ 提交于 2019-12-29 07:09:04
问题 Does Android DDMS provide APIs ? I need to automate the snapshot mechanism for the native heap. Or is there any post processing tool for analysis DDMS native heap snapshots. 回答1: I assume by snapshot you mean a heap dump. From your app code you can call Debug.dumpHprofData() to dump the data. From a script you can call adb shell am dumpheap <process> <file> where <process> is e.g. your process id or name, and <file> is the dump file name. After that you can adb pull the dump to your computer.

Testing database on Android: ProviderTestCase2 or RenamingDelegatingContext?

本秂侑毒 提交于 2019-12-29 03:08:05
问题 I've implemented access to a database using SQLiteOpenHelper from the android.database package within some classes (with pattern DAO). I wrote some junit tests for these classes using an AndroidTestCase but this causes the tests to use the same database as the application. I read that the ProviderTestCase2 or RenamingDelegatingContext can be used to test the database separately. Unluckily I couldn't find any nice tutorial/example that shows how to test a database with ProviderTestCase2

Click by bounds / coordinates

梦想的初衷 提交于 2019-12-28 06:17:29
问题 I know it is possible for Espresso to click by bounds the way UiAutomator does. (x and y coordinates) I have read through the documentation but I can't seem to find it. Any help is appreciated. Thanks Edit I found this link, but no examples how to use it, My main concern with this is the UiController is or how to use it. 回答1: Espresso has the GeneralClickAction, this is the underlying implementation of ViewActions click() , doubleClick() , and longClick() . The GeneralClickAction 's

Espresso.onData set inAdapterView to be AlertDialog

試著忘記壹切 提交于 2019-12-25 09:22:25
问题 I have an AlertDialog that contains a list of options which is set: final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) .setTitle(args.getString(TITLE)) .setSingleChoiceItems(ARRAY_OF_CHARSEQUENCE, args.getInt(SELECTED_INDEX), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // handle click dismiss(); } }); I am trying to test clicking on each item. If I run: onView(allOf(withClassName(Matchers.equalTo

Robolectric 3.0 testing Vibrator service

ε祈祈猫儿з 提交于 2019-12-25 07:39:30
问题 I am in process of migrating my test cases to latest Robolectric 3.0. To test the viberator service in my app, earlier I used org.robolectric.shadows.ShadowVibrator but now I am not able to test it, even using custom shadow class. Even the Robolectric wesite is not updated and it shows the use Robolectric.shadowOf_() which does not exist. This is the link of the website, which is not updated version. Kindly guide. Following is code for custom implementation:-- The custom class:-- @Implements

Separate androidTest sourceSet for different buildType NOT build flavor

会有一股神秘感。 提交于 2019-12-25 02:33:16
问题 I have android library project and in it I have defined 3 build types: debug, release and integration. I would like to have additinal androidTest (instrumentation test) directory and additional source directory for integration build type. I have successfully added source directory: ' my-project/src/integration ' but have failed to add androidTestIntegration directory, android studio is not detecting it in Android project view. Project build.gradle file: android { ... debug { ... } release { .