Coder Social home page Coder Social logo

android-test-kit's People

Contributors

slinzner avatar thomaswk avatar

Watchers

 avatar

android-test-kit's Issues

scrollTo requires only ScrollView parent. not scroll-able ones like HorizontalScrollView

What steps will reproduce the problem?
1. Build up view hierarch with HorizontalScrollView and several child views in 
it.
2. in test, onView(withId(id_of_child_view)).perform(scrollTo())
3. failed to perform scrollTo action

What is the expected output? What do you see instead?

HorizontalScrollView should scrolls to the view. But it failed. (It checks if 
view is descendent of 'ScrollView' but it isn't)

What version of the product are you using? On what operating system?

KitKat/Nexus4

Please provide any additional information below.

I tried to extend ScrollToAction and override getConstraints() in vain because 
ScrollToAction is final class.
So I copied it into a new name 'ScrollToAciton2' and then used it in test. This 
worked.


Original issue reported on code.google.com by [email protected] on 22 Nov 2013 at 1:12

Espresso is unable to run it's own unit tests

What steps will reproduce the problem?
1. mvn package
2. adb install ./testapp/target/testapp.apk
3. adb install ./espresso/libtests/target/espresso-tests.apk
4. adb shell am instrument -w 
com.google.android.apps.common.testing.ui.espresso.tests/com.google.android.apps
.common.testing.testrunner.GoogleInstrumentationTestRunner

What is the expected output? What do you see instead?

I expect the tests to run. I see this instead:
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test:...
com.google.android.apps.common.testing.ui.espresso.AppNotIdleExceptionTest:INSTR
UMENTATION_RESULT: shortMsg=java.lang.IllegalAccessError
INSTRUMENTATION_RESULT: longMsg=java.lang.IllegalAccessError: Class ref in 
pre-verified class resolved to unexpected implementation
INSTRUMENTATION_CODE: 0

What version of the product are you using? On what operating system?

I'm using this rev on OS X 10.9.
https://code.google.com/p/android-test-kit/source/detail?r=b49a13f06e5e832fa4569
00345ba47cb739637f7

Please provide any additional information below.

The details are on the mailing list.
https://groups.google.com/forum/#!topic/android-test-kit-discuss/03NHPOZRdq4

Espresso's build scripts produce code that doesn't run which makes running the 
unit tests impossible.

Original issue reported on code.google.com by [email protected] on 23 Oct 2013 at 3:13

scrollTo() and isDisplayingAtLeast() has problem for views with paddings on 4.1.2 phone emulators

What steps will reproduce the problem?
do onView(withId(id)).perform(scrollTo()) on a TextView with paddings

What is the expected output? What do you see instead?
Exception is thrown saying that the view is scrolled but not displayed after 
scroll

What version of the product are you using? On what operating system?
4.1.2 phone emulator

Please provide any additional information below.
This does not happen in 4.3. My view has 5dp padding at the bottom. The 
resulting width and height are:
View: width 590, height 102
Displaying area: width 590, height 89

The end result is that Espresso thinks it is displaying only 88%, and it asks 
for 90%, so it fails the check. It looks like in Android 4.1.2, the API you use 
considers padding as invisible part of the view.

There are several options to fix this:
1. Lower the threshold to something like 85%. But this is not guaranteed to fix 
all problems
2. Provide another method scrollTo(int displayingAreaAfterScroll), and let the 
user decide.
3. Remove the paddings before you calculate the displaying area in older 
version of Android OS, so the user won't need to handle this. I like this most.

Original issue reported on code.google.com by [email protected] on 26 Dec 2013 at 5:51

Can Espresso work when we have only apk and not the source code of the application?

I do have only the apk to write the test cases. Can I use Espresso for this? 
You can find the attached java file that just invokes the target application on 
Android Device.
I have changed the signature of the target application to be same as my test 
application.
Since I further want to perform UI events on Buttons, how can I use 
"R.id.englishBtn" in the test application as I don't have the source code. The 
test application will not recognize 'R' here. 
In other words, how can I access a particular view on screen without using 'Id'?
The application is being executed on Android 4.1.2/Samsung S3.


Original issue reported on code.google.com by [email protected] on 2 Dec 2013 at 7:56

Attachments:

There is no speedup execution between GoogleInstrumentationTestRunner and InstrumentationTestRunner.

The total execution time  cost about 1 minute:

C:\Users\brightzheng>adb shell am instrument -w com.bright.hello.test/com.google
.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner

com.bright.espresso.test.MainActivityTest:.
Test results for GoogleInstrumentationTestRunner$BridgeTestRunner=.
Time: 11.333

OK (1 test)


BTW: how to stat many emulators which contain different RAM or SCREEN at once? 


Original issue reported on code.google.com by [email protected] on 7 Nov 2013 at 6:51

Using hamcrest 1.1 causes dexing problems

What steps will reproduce the problem?
1. Dependencies:
instrumentTestCompile "com.squareup.dagger:dagger-compiler:1.1.0"
    instrumentTestCompile "com.squareup.dagger:dagger:1.1.0"
    instrumentTestCompile "com.google.code.findbugs:jsr305:2.0.1"
    instrumentTestCompile "javax.annotation:javax.annotation-api:1.2"
    instrumentTestCompile "com.google.guava:guava:14.0.1"
    instrumentTestCompile fileTree(dir: 'src/instrumentTest/libs', include: '*.jar') <- espresso library
    instrumentTestCompile "org.hamcrest:hamcrest-all:1.1"
2. ./gradlew clean connectedInstrumentTest

Causes:
EXCEPTION FROM SIMULATION:
local variable type mismatch: attempt to set or access a value of type 
java.lang.Object using a local variable of type int. This is symptomatic of 
.class transformation tools that ignore local variable information.

...at bytecode offset 0000001b
locals[0000]: Lorg/hamcrest/generator/qdox/parser/impl/JFlexLexer;
locals[0001]: I
locals[0002]: [C
locals[0003]: [C
locals[0004]: [I
locals[0005]: [I
locals[0006]: <invalid>
locals[0007]: <invalid>
locals[0008]: <invalid>
locals[0009]: <invalid>
locals[000a]: <invalid>
locals[000b]: <invalid>
locals[000c]: <invalid>
locals[000d]: <invalid>
locals[000e]: <invalid>
locals[000f]: <invalid>
locals[0010]: <invalid>
stack[top0]: [B
...while working on block 001b
...while working on method yylex:()I
...while processing yylex ()I
...while processing org/hamcrest/generator/qdox/parser/impl/JFlexLexer.class



What is the expected output? What do you see instead?
Should sucess


What version of the product are you using? On what operating system?
1. Gradle with plugin: 0.6.+
2. buildToolsVersion "18.1.1"

Please provide any additional information below.
Upgrading hamcrest to 1.3 resolving this issue but espresso change is required:
You can look at: 
https://github.com/jacek-marchwicki/AndroidTestKit/commits/master

You can use this patch if you would like I have signed Google CLA

Original issue reported on code.google.com by [email protected] on 29 Oct 2013 at 10:44

Non-View actions (device rotation, Home key, Menu key, status bar notifications)?

I am aware that this is might not be strictly an espresso-specific 
functionality. One can use getActivity() as part of 
ActivityInstrumentationTestCase and from there, use setRequestedOrientation.

However, this method is asynchronous and currently, one is forced to use 
Thread.sleep() and other such to "Wait" until the rotation is complete before 
continuing with asserts. This is the exact sort of flaky code that espresso 
aims to avoid.

Is it probable that espresso will provide actions for non-view actions?

Original issue reported on code.google.com by [email protected] on 26 Nov 2013 at 12:48

Test failer on 2.3 intel emulator

What steps will reproduce the problem?
1. Download source version: b49a13f06e5e
2. mvn install
3.  Build fails
[INFO] Reactor Summary:
[INFO] 
[INFO] TestKit ........................................... SUCCESS [0.143s]
[INFO] Google Instrumentation TestRunner ................. SUCCESS [3.262s]
[INFO] Google Instrumentation TestRunner-Runtime ......... SUCCESS [0.551s]
[INFO] Espresso Parent Project ........................... SUCCESS [0.029s]
[INFO] Espresso Testing Framework ........................ SUCCESS [12.136s]
[INFO] Test App For Espresso ............................. SUCCESS [28.286s]
[INFO] Tests For the Espresso Test Framework ............. FAILURE [46.253s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE


What is the expected output? What do you see instead?

Build Success

What version of the product are you using? On what operating system?

git hash b49a13f06e5e on mac OS X on a MDPI  API 10 Intel image in an emulator.

Please provide any additional information below.

From Maven:


[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :   Running 
instrumentation tests in 
com.google.android.apps.common.testing.ui.espresso.tests
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :     Run 
started: com.google.android.apps.common.testing.ui.espresso.tests, 165 tests:
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       
Start [1/165]: 
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test#testAndroidTestCaseSetupProperly
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       End 
[1/165]: 
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test#testAndroidTestCaseSetupProperly
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       
Start [2/165]: 
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test#testExceptionContainsMatcherDescription
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       End 
[2/165]: 
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test#testExceptionContainsMatcherDescription
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       
Start [3/165]: 
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test#testExceptionContainsView
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       End 
[3/165]: 
com.google.android.apps.common.testing.ui.espresso.AmbiguousViewMatcherException
Test#testExceptionContainsView
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       
Start [4/165]: 
com.google.android.apps.common.testing.ui.espresso.AppNotIdleExceptionTest#testA
ppIdleException
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       
ERROR:com.google.android.apps.common.testing.ui.espresso.AppNotIdleExceptionTest
#testAppIdleException
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       Test 
failed to run to completion. Reason: 'Instrumentation run failed due to 
'java.lang.IllegalAccessError''. Check device logcat for details
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :       End 
[4/165]: 
com.google.android.apps.common.testing.ui.espresso.AppNotIdleExceptionTest#testA
ppIdleException
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :     Run 
failed: Instrumentation run failed due to 'java.lang.IllegalAccessError'
[INFO] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :     Run 
ended: 0 ms
[ERROR] emulator-5554_mdpi2.3intel_unknown_FullAndroidonx86Emulator :     
FAILURES!!!



From Logcat:


I/ActivityManager(  854): Starting: Intent { act=android.intent.action.MAIN 
flg=0x14000000 
cmp=com.google.android.apps.common.testing.ui.testapp/.SyncActivity } from pid 
2380
D/LifecycleMonitor( 2380): Lifecycle status change: 
com.google.android.apps.common.testing.ui.testapp.SyncActivity@b4571318 in: 
PRE_ON_CREATE
W/dalvikvm( 2380): Class resolved by unexpected DEX: 
Lcom/google/android/apps/common/testing/ui/testapp/SyncActivity;(0xb450e5a0):0x9
7a8298 ref [Lcom/google/common/base/Preconditions;] 
Lcom/google/common/base/Preconditions;(0xb450e5a0):0x96d7800
W/dalvikvm( 2380): 
(Lcom/google/android/apps/common/testing/ui/testapp/SyncActivity; had used a 
different Lcom/google/common/base/Preconditions; during pre-verification)
D/AndroidRuntime( 2380): Shutting down VM
W/dalvikvm( 2380): threadid=1: thread exiting with uncaught exception 
(group=0xb400e4f0)
E/AndroidRuntime( 2380): FATAL EXCEPTION: main
E/AndroidRuntime( 2380): java.lang.IllegalAccessError: Class ref in 
pre-verified class resolved to unexpected implementation
E/AndroidRuntime( 2380):    at 
com.google.android.apps.common.testing.ui.testapp.SyncActivity.onCreate(SyncActi
vity.java:38)
E/AndroidRuntime( 2380):    at 
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime( 2380):    at 
com.google.android.apps.common.testing.testrunner.GoogleInstrumentation.callActi
vityOnCreate(GoogleInstrumentation.java:424)
E/AndroidRuntime( 2380):    at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime( 2380):    at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 2380):    at 
android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 2380):    at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 2380):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 2380):    at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 2380):    at 
android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 2380):    at java.lang.reflect.Method.invokeNative(Native 
Method)
E/AndroidRuntime( 2380):    at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 2380):    at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 2380):    at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 2380):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(  854): Error in app 
com.google.android.apps.common.testing.ui.testapp running instrumentation 
ComponentInfo{com.google.android.apps.common.testing.ui.espresso.tests/com.googl
e.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner}:
W/ActivityManager(  854):   java.lang.IllegalAccessError
W/ActivityManager(  854):   java.lang.IllegalAccessError: Class ref in 
pre-verified class resolved to unexpected implementation
D/AndroidRuntime( 2372): Shutting down VM

From adb shell getprop:

( I have VM heap at 64MB )

[ro.secure]: [0]
[ro.allow.mock.location]: [1]
[ro.debuggable]: [1]
[persist.service.adb.enable]: [1]
[ro.kernel.qemu.gles]: [0]
[ro.kernel.qemu]: [1]
[ro.kernel.console]: [ttyS0]
[ro.kernel.android.qemud]: [ttyS1]
[ro.kernel.androidboot.hardware]: [goldfish]
[ro.kernel.clocksource]: [pit]
[ro.kernel.android.checkjni]: [1]
[ro.kernel.ndns]: [2]
[ro.factorytest]: [0]
[ro.serialno]: []
[ro.bootmode]: [unknown]
[ro.baseband]: [unknown]
[ro.carrier]: [unknown]
[ro.bootloader]: [unknown]
[ro.hardware]: [goldfish]
[ro.revision]: [0]
[ro.build.id]: [GINGERBREAD]
[ro.build.display.id]: [full_x86-eng 2.3.7 GINGERBREAD 
eng.juntian.20111231.141301 test-keys]
[ro.build.version.incremental]: [eng.juntian.20111231.141301]
[ro.build.version.sdk]: [10]
[ro.build.version.codename]: [REL]
[ro.build.version.release]: [2.3.7]
[ro.build.date]: [Sat Dec 31 14:14:01 CST 2011]
[ro.build.date.utc]: [1325312041]
[ro.build.type]: [eng]
[ro.build.user]: [juntian]
[ro.build.host]: [sdk02]
[ro.build.tags]: [test-keys]
[ro.product.model]: [Full Android on x86 Emulator]
[ro.product.brand]: [Android]
[ro.product.name]: [full_x86]
[ro.product.device]: [generic_x86]
[ro.product.board]: []
[ro.product.cpu.abi]: [x86]
[ro.product.manufacturer]: [unknown]
[ro.product.locale.language]: [en]
[ro.product.locale.region]: [US]
[ro.wifi.channels]: []
[ro.board.platform]: []
[ro.build.product]: [generic_x86]
[ro.build.description]: [full_x86-eng 2.3.7 GINGERBREAD 
eng.juntian.20111231.141301 test-keys]
[ro.build.fingerprint]: 
[Android/full_x86/generic_x86:2.3.7/GINGERBREAD/eng.juntian.20111231.141301:eng/
test-keys]
[rild.libpath]: [/system/lib/libreference-ril.so]
[rild.libargs]: [-d /dev/ttyS0]
[keyguard.no_require_sim]: [true]
[ro.com.android.dateformat]: [MM-dd-yyyy]
[ro.com.android.dataroaming]: [true]
[ro.config.notification_sound]: [OnTheHunt.ogg]
[ro.config.alarm_alert]: [Alarm_Classic.ogg]
[ro.ril.hsxpa]: [1]
[ro.ril.gprsclass]: [10]
[ro.setupwizard.mode]: [OPTIONAL]
[net.bt.name]: [Android]
[net.change]: [net.dnschange]
[dalvik.vm.stack-trace-file]: [/data/anr/traces.txt]
[ro.FOREGROUND_APP_ADJ]: [0]
[ro.VISIBLE_APP_ADJ]: [1]
[ro.PERCEPTIBLE_APP_ADJ]: [2]
[ro.HEAVY_WEIGHT_APP_ADJ]: [3]
[ro.SECONDARY_SERVER_ADJ]: [4]
[ro.BACKUP_APP_ADJ]: [5]
[ro.HOME_APP_ADJ]: [6]
[ro.HIDDEN_APP_MIN_ADJ]: [7]
[ro.EMPTY_APP_ADJ]: [15]
[ro.FOREGROUND_APP_MEM]: [2048]
[ro.VISIBLE_APP_MEM]: [3072]
[ro.PERCEPTIBLE_APP_MEM]: [4096]
[ro.HEAVY_WEIGHT_APP_MEM]: [4096]
[ro.SECONDARY_SERVER_MEM]: [6144]
[ro.BACKUP_APP_MEM]: [6144]
[ro.HOME_APP_MEM]: [6144]
[ro.HIDDEN_APP_MEM]: [7168]
[ro.EMPTY_APP_MEM]: [8192]
[net.tcp.buffersize.default]: [4096,87380,110208,4096,16384,110208]
[net.tcp.buffersize.wifi]: [4095,87380,110208,4096,16384,110208]
[net.tcp.buffersize.umts]: [4094,87380,110208,4096,16384,110208]
[net.tcp.buffersize.edge]: [4093,26280,35040,4096,16384,35040]
[net.tcp.buffersize.gprs]: [4092,8760,11680,4096,8760,11680]
[init.svc.servicemanager]: [running]
[init.svc.vold]: [running]
[init.svc.netd]: [running]
[init.svc.debuggerd]: [running]
[init.svc.ril-daemon]: [running]
[init.svc.zygote]: [running]
[init.svc.media]: [running]
[init.svc.dbus]: [running]
[init.svc.installd]: [running]
[init.svc.keystore]: [running]
[init.svc.goldfish-setup]: [stopped]
[init.svc.qemud]: [running]
[init.svc.goldfish-logcat]: [stopped]
[ARGH]: [ARGH]
[net.eth0.dns1]: [10.0.2.3]
[net.gprs.local-ip]: [10.0.2.15]
[ro.radio.use-ppp]: [no]
[status.battery.state]: [Slow]
[status.battery.level]: [5]
[status.battery.level_raw]: [50]
[status.battery.level_scale]: [9]
[ro.com.google.locationfeatures]: [1]
[init.svc.console]: [running]
[init.svc.adbd]: [running]
[dalvik.vm.heapsize]: [64m]
[qemu.sf.lcd_density]: [160]
[qemu.hw.mainkeys]: [1]
[qemu.sf.fake_camera]: [none]
[ro.qemu.init.completed]: [1]
[init.svc.bootanim]: [stopped]
[sys.settings_secure_version]: [9]
[hw.keyboards.65536.devname]: [qwerty2]
[hw.keyboards.65537.devname]: [AT Translated Set 2 keyboard]
[net.hostname]: [android_8341c9974c49f30f]
[dev.bootcomplete]: [1]
[gsm.version.ril-impl]: [android reference-ril 1.0]
[gsm.sim.operator.numeric]: [310260]
[gsm.sim.operator.alpha]: [Android]
[gsm.sim.operator.iso-country]: [us]
[gsm.sim.state]: [READY]
[gsm.current.phone-type]: [1]
[gsm.operator.alpha]: [Android]
[gsm.operator.numeric]: [310260]
[gsm.operator.iso-country]: [us]
[gsm.operator.isroaming]: [false]
[persist.sys.timezone]: [America/Phoenix]
[gsm.nitz.time]: [1383693262968]
[gsm.network.type]: [UMTS]
[persist.sys.language]: [en]
[persist.sys.country]: [US]
[persist.sys.localevar]: []
[sys.boot_completed]: [1]
[net.gprs.http-proxy]: []
[sys.settings_system_version]: [5]
[gsm.defaultpdpcontext.active]: [true]
[net.dns1]: [10.0.2.3]
[net.dnschange]: [2]
[ro.runtime.firstboot]: [1383693265175]




Original issue reported on code.google.com by [email protected] on 5 Nov 2013 at 11:19

  • Merged into: #4

java.lang.RuntimeException: No activities found if calling check right after getActivity when test starts

What steps will reproduce the problem?
1. In the very first step of the test, call getActivity()
2. Call something like onView(withId(xxx)).check(matches(xxx)) right in the 
next line
3. Sometimes the following error happens:
java.lang.RuntimeException: No activities found. Did you forget to launch the 
activity by calling getActivity() or startActivitySync or similar? 

What is the expected output? What do you see instead?
The error does not happen. The check is executed when the activity finishes its 
lifecycle to an idle state

What version of the product are you using? On what operating system?
On Android 4.1.2 tablet (Samsung Galaxy Note 10.1) and emulators

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 18 Dec 2013 at 6:31

Can not set date in calendar view.

HI Guys,
I am using this test library in my project. And i have used calendar view in my 
project. I want to change date in calendar view. But i can not change date. I 
have tried this to set date :
Espresso.onData(Matchers.allOf(Matchers.is(Matchers.instanceOf(Long.class)), 
Matchers.is(1407816000000)))
                .perform(ViewActions.click());
Thanks.

Original issue reported on code.google.com by [email protected] on 20 Dec 2013 at 12:15

scrollTo() causes a full freeze of thread

What steps will reproduce the problem?
Use a scrollTo() as part of a ViewAction in a perform() method.

What is the expected output? What do you see instead?
I would expect the execution to move onto the next ViewAction, but instead it 
locks up, and the thread continually waits.

What version of the product are you using? On what operating system?
Running on Nexus 4, 4.3 JellyBean

Please provide any additional information below.


The view *is* in the layout, and is a descendant of a ScrollView. There is 
nothing special about the layout. The text is non-null. The view is View.VISIBLE

Sample line causing issues: 
onView(ViewMatchers.withId(R.id.prescription_remarks_edit)).perform(ViewActions.
scrollTo(), ViewActions.typeText(mMedication.getRemarks()));

Stack trace: (application package obscured by #'s)
com.###.###.###.test.CZInstrumentationRunner@831725150536, prio=5, in group 
'main', status: 'WAIT'
      at java.lang.Object.wait(Object.java:-1)
      at java.lang.Thread.parkFor(Thread.java:1231)
      at sun.misc.Unsafe.park(Unsafe.java:323)
      at java.util.concurrent.locks.LockSupport.park(LockSupport.java:159)
      at java.util.concurrent.FutureTask.awaitDone(FutureTask.java:396)
      at java.util.concurrent.FutureTask.get(FutureTask.java:159)
      at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:142)
      at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(ViewInteraction.java:77)
      at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewInteraction.java:69)
      at com.###.###.###.test.D_MedicationTest.testAdd(D_MedicationTest.java:69)
      at com.###.###.###.test.BaseModuleTest.testModule(BaseModuleTest.java:62)
      at java.lang.reflect.Method.invokeNative(Method.java:-1)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
      at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
      at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
      at junit.framework.TestCase.runBare(TestCase.java:134)
      at junit.framework.TestResult$1.protect(TestResult.java:115)
      at junit.framework.TestResult.runProtected(TestResult.java:133)
      at junit.framework.TestResult.run(TestResult.java:118)
      at junit.framework.TestCase.run(TestCase.java:124)
      at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
      at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
      at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
      at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:119)
      at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661)





Original issue reported on code.google.com by [email protected] on 25 Oct 2013 at 11:03

Unable to pressImeActionButton() if text field displays suggestions

What steps will reproduce the problem?
1. enter text (typeText) in a field that triggers suggestions
2. try to pressImeActionButton() while suggestions are visible
3.

What is the expected output? What do you see instead?
expect to be able to pressImeActionButton()

error:
java.lang.RuntimeException: Waited for the root of the view hierarchy to have 
window focus and not be requesting layout for over 10 seconds. If you specified 
a non default root matcher, it may be picking a root that never takes focus. 
Otherwise, something is seriously wrong.

What version of the product are you using? On what operating system?
same on Mac & Win7 using Android Studio/IntelliJ

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 14 Nov 2013 at 4:16

  • Merged into: #7

Maven 3.1.1 not supported - Update Android-maven-plugin to 3.8.0+

What steps will reproduce the problem?
1. Install Maven 3.1.1
2. android-test-kit> mvn clean install

What is the expected output? What do you see instead?
Successful build

It fails on aether which has been moved to eclipse project instead of sonatype.


android-maven-plugin 3.6.0 does not support maven 3.1.1.

in order to fix this issue you simply need to update android-maven-plugin to 
3.8.2 or later

Original issue reported on code.google.com by [email protected] on 7 Jan 2014 at 12:47

Espresso.pressBack() sometimes throw "Pressed back and killed the app" while it actually didn't

What steps will reproduce the problem?
Write Espresso.pressBack() on the activity where pressing back once doesn't 
exit the app.

What is the expected output? What do you see instead?
Expected: The app does what it is expected to do when back is pressed
Actual: 
com.google.android.apps.common.testing.ui.espresso.NoActivityResumedException: 
Pressed back and killed the app

What version of the product are you using? On what operating system?
Espresso 1.1

Please provide any additional information below.
This is a very rare problem, but it happens. I know know how UiController 
handles activity lifecycle, but it seems like it doesn't wait until activity to 
be resumed to continue. As a result, the following codes at the end of 
pressBack() can sometimes get no activity, because it's in the middle of 
switching activity:

    if (this.key.getKeyCode() == KeyEvent.KEYCODE_BACK) {
      controller.loopMainThreadUntilIdle();
      boolean activeActivities = !ActivityLifecycleMonitorRegistry.getInstance()
          .getActivitiesInStage(Stage.RESUMED)
          .isEmpty();
      if (!activeActivities) {
        Throwable cause = new PerformException.Builder()
          .withActionDescription(this.getDescription())
          .withViewDescription(HumanReadables.describe(view))
          .build();
        throw new NoActivityResumedException("Pressed back and killed the app", cause);
      }
    }

I checked my error log and found that it calls 
getActivitiesInStage(Stage.RESUMED) when my previous activity is in pause and 
the next activity which should show up after the back was still on its way to 
resumed.

Original issue reported on code.google.com by [email protected] on 17 Jan 2014 at 5:53

Test App For Espresso fails to build with maven 3.1

What steps will reproduce the problem?
1. mvn package

What is the expected output? What do you see instead?
Expected:
[INFO] Test App For Espresso ............................. SUCCESS

Actual:
[INFO] Test App For Espresso ............................. FAILURE

What version of the product are you using? On what operating system?

I'm using this rev on OS X 10.9.
https://code.google.com/p/android-test-kit/source/detail?r=b49a13f06e5e832fa4569
00345ba47cb739637f7

Please provide any additional information below.
Stack trace is here:
https://gist.github.com/bootstraponline/7120504

Original issue reported on code.google.com by [email protected] on 23 Oct 2013 at 3:06

Cannot build

What steps will reproduce the problem?
1. Clone project
2. Run "maven verify"

What is the expected output? What do you see instead?
[ERROR] Failed to execute goal on project testapp: Could not resolve 
dependencies for project 
com.google.android.apps.common.testing:testapp:apk:1.0-SNAPSHOT: The following 
artifacts could not be resolved: android.support:compatibility-v4:jar:18, 
android.support:compatibility-v7-appcompat:jar:18, 
android.support:compatibility-v7-appcompat:apklib:18: Could not find artifact 
android.support:compatibility-v4:jar:18 in android-local-repo 
(file://C:/Java/adt/sdk/extras/android/m2r
epository) -> [Help 1]


What version of the product are you using? On what operating system?
Source checked out today.


Please provide any additional information below.
The local repo offers this:
  <groupId>com.android.support</groupId>
  <artifactId>appcompat-v7</artifactId>

But espresso is missing the "com." in the group

Original issue reported on code.google.com by [email protected] on 15 Nov 2013 at 10:48

Typing in an AutoCompleteTextView will hang Espresso

What steps will reproduce the problem?
1. In espresso run:

onView(withId(R.id.search))
        .perform(typeText("Text"))

where the view with Id is an AutoCompleteTextView. I get an error:

                        I  ----- begin exception -----
                        I  java.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesting layout for over 10 seconds. If you spe
                           cified a non default root matcher, it may be picking a root that never takes focus. Otherwise, something is seriously wrong. Selected Root:
                        I  Root{application-window-token=android.view.ViewRootImpl$W@42082240, window-token=android.view.ViewRootImpl$W@4221f450, has-window-focus=false, layout-p
                           arams-type=1000, layout-params-string=WM.LayoutParams{(36,788)(648x322) gr=#10800053 sim=#10 ty=1000 fl=#1860208 fmt=-3 wanim=0x10301ec}, decor-view-st
                           ring=PopupViewContainer{id=-1, visibility=VISIBLE, width=648, height=322, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=fals
                           e, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-conne
                           ction=false, x=0.0, y=0.0, child-count=1}}
                        I  . All Roots:
                        I  Root{application-window-token=android.view.ViewRootImpl$W@42082240, window-token=android.view.ViewRootImpl$W@4221f450, has-window-focus=false, layout-p
                           arams-type=1000, layout-params-string=WM.LayoutParams{(36,788)(648x322) gr=#10800053 sim=#10 ty=1000 fl=#1860208 fmt=-3 wanim=0x10301ec}, decor-view-st
                           ring=PopupViewContainer{id=-1, visibility=VISIBLE, width=648, height=322, has-focus=true, has-focusable=true, has-window-focus=false, is-clickable=fals
                           e, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-conne
                           ction=false, x=0.0, y=0.0, child-count=1}}
                        I  Root{application-window-token=android.view.ViewRootImpl$W@42082240, window-token=android.view.ViewRootImpl$W@42082240, has-window-focus=true, layout-pa
                           rams-type=1, layout-params-string=WM.LayoutParams{(0,0)(fillxfill) sim=#20 ty=1 fl=#1810100 pfl=0x8 wanim=0x1030299}, decor-view-string=DecorView{id=-1
                           , visibility=VISIBLE, width=720, height=1184, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, is-focuse
                           d=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, ch
                           ild-count=1}}
                        I      at com.google.android.apps.common.testing.ui.espresso.base.RootViewPicker.get(RootViewPicker.java:80)
                        I      at com.google.android.apps.common.testing.ui.espresso.base.BaseLayerModule.provideRootView(BaseLayerModule.java:100)
                        I      at com.google.android.apps.common.testing.ui.espresso.base.BaseLayerModule$$ModuleAdapter$ProvideRootViewProvidesAdapter.get(BaseLayerModule$$Modul
                           eAdapter.java:428)
                        I      at com.google.android.apps.common.testing.ui.espresso.base.BaseLayerModule$$ModuleAdapter$ProvideRootViewProvidesAdapter.get(BaseLayerModule$$Modul
                           eAdapter.java:392)
                        I      at com.google.android.apps.common.testing.ui.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:50)
                        I      at com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInteraction.java:82)
                        I      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
                        I      at java.util.concurrent.FutureTask.run(FutureTask.java:234)
                        I      at android.os.Handler.handleCallback(Handler.java:730)
                        I      at android.os.Handler.dispatchMessage(Handler.java:92)
                        I      at android.os.Looper.loop(Looper.java:137)
                        I      at android.app.ActivityThread.main(ActivityThread.java:5103)
                        I      at java.lang.reflect.Method.invokeNative(Native Method)
                        I      at java.lang.reflect.Method.invoke(Method.java:525)
                        I      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
                        I      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                        I      at dalvik.system.NativeStart.main(Native Method)
                        I  ----- end exception -----


What is the expected output? What do you see instead?
Espresso will carry on an allow more code to be run

What version of the product are you using? On what operating system?
espresso-1.0-SNAPSHOT-bundled on OS X 10.9

Original issue reported on code.google.com by oakesm9 on 12 Nov 2013 at 11:02

  • Merged into: #7

Inaccurate click on Android 4.1.2 phone emulator for small views

What steps will reproduce the problem?
On android 4.1.2 phone emulator, do onView(withId(id)).perform(click()) on a 
view that is small. My view is just a small triangle with about 4~5 pixels 
height and width, and it is used to show/hide more details.

What is the expected output? What do you see instead?
Sometimes it fails to click on that view. But sometimes it can click 
successfully.

What version of the product are you using? On what operating system?
4.1.2 phone emulator

Please provide any additional information below.

Same problem also happens when clicking on the ok button of a dialog on real 
phones. This does not happen on tablets. It looks like the accuracy of the 
click has some problems on phones.

Original issue reported on code.google.com by [email protected] on 26 Dec 2013 at 5:38

Unregister idling resource after each test.

Here what my test cases looks like:

public class TestPager extends ActivityInstrumentationTestCase2<TestActivity> {

    public void setup() {
         Espresso.registerIdlingResources(new PageIdlingResource());
    }

    public void testA() {
    }

    public void testB() {
    }

}


----

The problem comes from the fact that setup() is called twice during the test 
run: once before testA() and once before testB(). As such, Espresso instanciate 
and keeps the IdlingResource of each test. Let's say I have 20 tests. After 20 
tests I have 20 PageIdlingResource registered. 

So we need a way to unregister any IdlingResource when a test is complete. 
Either automatically, or in the tearDown() method.

Original issue reported on code.google.com by [email protected] on 7 Dec 2013 at 12:21

typeText enters wrong special characters

What steps will reproduce the problem?
1. Write a test for an activity which has a text input field
2. call onView(withId(R.id.input_field)).perform(typeText("@{!_)")); in your 
text to populate the field

What is the expected output?
The field should be filled with the string: @{!_)

What do you see instead?
The field is filled with the text "`!=

What version of the product are you using? On what operating system?
Newly released espresso build with custom dependencies
espresso-1.0-SNAPSHOT.jar etc

Test device is Android 4.1.1 Galaxy Note 2 for the Japanese market.

Please provide any additional information below.

Keyboard layout differs from the default android keyboard

the relevant part of the test code:

public LoginTest() {
        super(Login.class);
    }

    @Override
    public void setUp() throws Exception {
        super.setUp();
        getActivity();
    }

    @Test
    public void testLogin() {
        onView(withId(R.id.edit_login)).perform(typeText("@{!_)"));
...
}

Original issue reported on code.google.com by [email protected] on 23 Oct 2013 at 7:16

Attachments:

Add scrollUp/Down actions to ViewActions

I am currently writing tests for an android app that has actions implemented 
when the user scrolls over the top and bottom of the main view. 

It would be great if a scrollBy(pixels) action would be implemented (using a 
positive number for instance to move down and a negative one to move up.

Original issue reported on code.google.com by [email protected] on 13 Jan 2014 at 1:35

typeText not working

What steps will reproduce the problem?
see: http://stackoverflow.com/questions/20436968/espresso-typetext-not-working

What is the expected output? What do you see instead?
Expected that I see text in the EditText. Instead, no text appears.

What version of the product are you using? On what operating system?
espresso-1.0.SNAPSHOT-bundled.
Eclipse ADT 22.0.5 on Windows 7 Pro.

Please provide any additional information below.
Tried in an emulator with soft or hard keyboard, tried on the phone too. Same 
issue. Seems to be a focus issue

Original issue reported on code.google.com by [email protected] on 13 Dec 2013 at 10:54

Click() becomes longClick()

What steps will reproduce the problem?
onView(withId(R.id.abc)).perform(click()) sometimes does long click instead

What is the expected output? What do you see instead?
It should always do click. Doing long click sometimes makes the test flaky.

What version of the product are you using? On what operating system?
All versions of Android OS. Espresso 1.1 test kit

Please provide any additional information below.
I understand that you put a comment there saying that there's no perfect way to 
do this, but I remember that I didn't see this problem when I was using 
Robotium. Here is what Robotium does:


long downTime = SystemClock.uptimeMillis();
                        long eventTime = SystemClock.uptimeMillis();
                        MotionEvent event = MotionEvent.obtain(downTime, eventTime,
                                        MotionEvent.ACTION_DOWN, x, y, 0);
                        MotionEvent event2 = MotionEvent.obtain(downTime, eventTime,
                                        MotionEvent.ACTION_UP, x, y, 0);
                        try{
                                inst.sendPointerSync(event);
                                inst.sendPointerSync(event2);
                                successfull = true;
                        }

Espresso is using the UiController, so it may not be able to send motion event 
like Robotium does. But, the downtime and event time is also different between 
Espresso and Robotium. Maybe it can improve this problem by making this part of 
code as close as Robotium.

Original issue reported on code.google.com by [email protected] on 15 Jan 2014 at 8:56

isDisplayed() is not implemented with the way it should

What steps will reproduce the problem?
This is what ViewMatchers.withEffectiveVisibility says in its comment:

Note: Contrary to what the name may imply, view visibility does not directly 
translate into whether the view is displayed on screen (use isDisplayed() for 
that). For example, the view and all of its ancestors can have 
visibility=VISIBLE, but the view may need to be scrolled to in order to be 
actually visible to the user. Unless you're specifically targeting the 
visibility
value with your test, use isDisplayed.

However, if you look at isDisplayed's code, you'll see that it still uses 
withEffectiveVisibility as its way to determine visibility, not simple 
View.VISIBLE:

      public boolean matchesSafely(View view) {
        return view.getGlobalVisibleRect(new Rect()) &&
            withEffectiveVisibility(Visibility.VISIBLE).matches(view);
      }

What is the expected output? What do you see instead?
This should be changed to a simple integer matching like:

is(Visibility.VISIBLE).matches(view.getVisibility())

What version of the product are you using? On what operating system?
4.1.2 emulator

Please provide any additional information below.
I met a rare problem today after running my tests without problem in almost 50 
tries. A view that should be visible says its visibility=GONE and threw an 
exception because of that. Since it's the 7th or 8th check of the same UI page, 
all views in that page should have already loaded, so this should not be the 
case where the view hasn't been loaded yet. And from the underlying data(I 
check that in the previous step) and the codes in my app, I can't find any 
possibility for that view being not visible at that moment. And in last 50 
tries, this view was visible with the same data and codes. So the only 
possibility for this to fail because of visibility=GONE is that Espresso thinks 
one of its parent has visibility=GONE. But that should not happen if I am 
calling isDisplayed().

Original issue reported on code.google.com by [email protected] on 26 Dec 2013 at 3:34

GoogleInstrumentationTestRunner needs to provide access to AndroidTestRunner

Feature Request for GoogleInstrumentationTestRunner:

The GoogleInstrumentationTestRunner needs to provide access to 
AndroidTestRunner in order to be able to add TestListeners. When extending from 
the GoogleInstrumentationTestRunner, a custom TestRunner has no way of adding 
own listeners to the AndroidTestRunner.

The only way I was able to do it as a workaround was to use reflection in my 
custom TestRunner:

@Override
    public void start() {
        mListener = new JUnitReportListener(getContext(), getTargetContext(), mReportFile, mReportDir, mFilterTraces, mMultiFile);
        try {
            Class<?> c = getClass();
            Field bridgeTestRunner = c.getSuperclass().getDeclaredField("bridgeTestRunner");
            bridgeTestRunner.setAccessible(true);
            Object obj = bridgeTestRunner.get(this);
            Method m = obj.getClass().getDeclaredMethod("getAndroidTestRunner", null);
            AndroidTestRunner androidTestRunner = (AndroidTestRunner)m.invoke(obj);
            androidTestRunner.addTestListener(mListener);
        } catch (NoSuchFieldException x) {
            Log.e(LOG_TAG, x.toString());
        } catch (SecurityException e) {
            Log.e(LOG_TAG, e.toString());
          } catch (NoSuchMethodException e) {
              Log.e(LOG_TAG, e.toString());
        } catch (IllegalAccessException x) {
            Log.e(LOG_TAG, x.toString());
        } catch (InvocationTargetException e) {
            Log.e(LOG_TAG, e.toString());
        }
      super.start();
    }

Please see thread in discussion group:
https://groups.google.com/forum/#!topic/android-test-kit-discuss/_Lu3odqITj0

Original issue reported on code.google.com by [email protected] on 12 Nov 2013 at 9:59

No way to click outside of a dialog

What steps will reproduce the problem?
1. Create an app that contains

        AlertDialog.Builder builder = new AlertDialog.Builder(this);

        // Get the list of possible periods from game.
        final String[] names = new String[0];

        final int[] checkedItem = {0};


        // Set the dialog title
        builder.setTitle("")
                .setSingleChoiceItems(names, checkedItem[0],
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                checkedItem[0] = i;
                            }
                        })
                .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                })
                .setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                    }
                })
                .setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialogInterface) {
// This is what we want to test
                    }
                });
        AlertDialog dialog = builder.create();
        dialog.show();

2. Execute the app to have the dialog show.
3.  Try to write an espresso test case that clicks outside of the Dialog to 
have it be dismissed.
onView(withId(...)) and onView(withText(....)) that match outside of the dialog 
the view that brought up the dialog do not match.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 2 Nov 2013 at 10:58

Can't write espresso test case to swipe from right to left

What steps will reproduce the problem?
1. Create an app that contains tabs that are swipe able.
2. Execute the app to have the tabs showing.
3. Try to write an espresso test case that emulates the right to left swiping 
to move from tab to tab.

Sample Activity below:

public class TestEspressoActivity extends FragmentActivity implements
        ActionBar.TabListener {

    SectionsPagerAdapter mSectionsPagerAdapter;

    ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_espresso);

        // Set up the action bar.
        final ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Create the adapter that will return a fragment for each of the three
        // primary sections of the app.
        mSectionsPagerAdapter = new SectionsPagerAdapter(
                getSupportFragmentManager());

        // Set up the ViewPager with the sections adapter.
        mViewPager = (ViewPager) findViewById(R.id.pager);
        mViewPager.setAdapter(mSectionsPagerAdapter);

        // When swiping between different sections, select the corresponding
        // tab. We can also use ActionBar.Tab#select() to do this if we have
        // a reference to the Tab.
        mViewPager
                .setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
                    @Override
                    public void onPageSelected(int position) {
                        actionBar.setSelectedNavigationItem(position);
                    }
                });

        // For each of the sections in the app, add a tab to the action bar.
        for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
            // Create a tab with text corresponding to the page title defined by
            // the adapter. Also specify this Activity object, which implements
            // the TabListener interface, as the callback (listener) for when
            // this tab is selected.
            actionBar.addTab(actionBar.newTab()
                    .setText(mSectionsPagerAdapter.getPageTitle(i))
                    .setTabListener(this));
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.test_espresso, menu);
        return true;
    }

    @Override
    public void onTabSelected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
        // When the given tab is selected, switch to the corresponding page in
        // the ViewPager.
        mViewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
    }

    @Override
    public void onTabReselected(ActionBar.Tab tab,
            FragmentTransaction fragmentTransaction) {
    }

    /**
     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
     * one of the sections/tabs/pages.
     */
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int position) {
            // getItem is called to instantiate the fragment for the given page.
            // Return a DummySectionFragment (defined as a static inner class
            // below) with the page number as its lone argument.
            Fragment fragment = new DummySectionFragment();
            Bundle args = new Bundle();
            args.putInt(DummySectionFragment.ARG_SECTION_NUMBER, position + 1);
            fragment.setArguments(args);
            return fragment;
        }

        @Override
        public int getCount() {
            // Show 3 total pages.
            return 3;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            Locale l = Locale.getDefault();
            switch (position) {
            case 0:
                return getString(R.string.title_section1).toUpperCase(l);
            case 1:
                return getString(R.string.title_section2).toUpperCase(l);
            case 2:
                return getString(R.string.title_section3).toUpperCase(l);
            }
            return null;
        }
    }

    /**
     * A dummy fragment representing a section of the app, but that simply
     * displays dummy text.
     */
    public static class DummySectionFragment extends Fragment {
        /**
         * The fragment argument representing the section number for this
         * fragment.
         */
        public static final String ARG_SECTION_NUMBER = "section_number";

        public DummySectionFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(
                    R.layout.fragment_test_espresso_dummy, container, false);
            TextView dummyTextView = (TextView) rootView
                    .findViewById(R.id.section_label);
            dummyTextView.setText(Integer.toString(getArguments().getInt(
                    ARG_SECTION_NUMBER)));
            return rootView;
        }
    }

}



What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 8 Nov 2013 at 9:18

TypeText Show IME Control dialog by Calling GeneralClickAction without no callback

What steps will reproduce the problem?
1. Run these Esspresso Test with EditText

onView(withId(R.id.editText)).perform(typeText("sample"));
onView(withId(R.id.editText)).perform(pressImeActionButton());


2. occur sometime


What is the expected output? What do you see instead?

I want to succeed pressImeActionButton()

but I sometimes see below error.

--------------------------------------------------------------------------------
com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException: No 
views in hierarchy found matching: with id: is <2131361805>
If the target view is not part of the view hierarchy, you may need to use 
Espresso.onData to load it from one of the following 
AdapterViews:com.android.internal.app.AlertController$RecycleListView@406085d8

View Hierarchy:
+>DecorView{id=-1, visibility=VISIBLE, width=768, height=304, has-focus=true, 
has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, 
is-focused=false, is-focusable=false, is-layout-requested=false, 
is-selected=false, root-is-layout-requested=false, has-input-connection=false, 
child-count=1}
|
+->FrameLayout{id=16908290, res-name=content, visibility=VISIBLE, width=768, 
height=304, has-focus=true, has-focusable=true, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=false, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=1}
|
+-->WeightedLinearLayout{id=16908666, res-name=parentPanel, visibility=VISIBLE, 
width=768, height=304, has-focus=true, has-focusable=true, 
has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, 
is-focusable=false, is-layout-requested=false, is-selected=false, 
root-is-layout-requested=false, has-input-connection=false, child-count=4}
|
+--->LinearLayout{id=16908667, res-name=topPanel, visibility=VISIBLE, 
width=760, height=121, has-focus=false, has-focusable=false, 
has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, 
is-focusable=false, is-layout-requested=false, is-selected=false, 
root-is-layout-requested=false, has-input-connection=false, child-count=2}
|
+---->LinearLayout{id=16908668, res-name=title_template, visibility=VISIBLE, 
width=670, height=71, has-focus=false, has-focusable=false, 
has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, 
is-focusable=false, is-layout-requested=false, is-selected=false, 
root-is-layout-requested=false, has-input-connection=false, child-count=2}
|
+----->ImageView{id=16908294, res-name=icon, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false}
|
+----->DialogTitle{id=16908669, res-name=alertTitle, visibility=VISIBLE, 
width=670, height=71, has-focus=false, has-focusable=false, 
has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, 
is-focusable=false, is-layout-requested=false, is-selected=false, 
root-is-layout-requested=false, has-input-connection=false, text=Edit text, 
input-type=0, ime-target=false}
|
+---->ImageView{id=16908670, res-name=titleDivider, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false}
|
+--->LinearLayout{id=16908671, res-name=contentPanel, visibility=VISIBLE, 
width=760, height=159, has-focus=true, has-focusable=true, 
has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, 
is-focusable=false, is-layout-requested=false, is-selected=false, 
root-is-layout-requested=false, has-input-connection=false, child-count=1}
|
+---->RecycleListView{id=16908823, res-name=select_dialog_listview, 
visibility=VISIBLE, width=710, height=128, has-focus=true, has-focusable=true, 
has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=true, 
is-focusable=true, is-layout-requested=false, is-selected=false, 
root-is-layout-requested=false, has-input-connection=false, child-count=1}
|
+----->ListMenuItemView{id=-1, visibility=VISIBLE, width=710, height=128, 
has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=false, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=1}
|
+------>RelativeLayout{id=-1, visibility=VISIBLE, width=686, height=59, 
has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=false, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=2}
|
+------->TextView{id=16908310, res-name=title, visibility=VISIBLE, width=686, 
height=59, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=false, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, text=Input method, input-type=0, ime-target=false}
|
+------->TextView{id=16908783, res-name=shortcut, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, text=, input-type=0, ime-target=false}
|
+--->FrameLayout{id=16908673, res-name=customPanel, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=1}
|
+---->FrameLayout{id=16908331, res-name=custom, visibility=VISIBLE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=0}
|
+--->LinearLayout{id=16908674, res-name=buttonPanel, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=1}
|
+---->LinearLayout{id=-1, visibility=VISIBLE, width=0, height=0, 
has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=5}
|
+----->LinearLayout{id=16908675, res-name=leftSpacer, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=0}
|
+----->Button{id=16908313, res-name=button1, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, text=, input-type=0, ime-target=false}
|
+----->Button{id=16908315, res-name=button3, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, text=, input-type=0, ime-target=false}
|
+----->Button{id=16908314, res-name=button2, visibility=GONE, width=0, 
height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, text=, input-type=0, ime-target=false}
|
+----->LinearLayout{id=16908676, res-name=rightSpacer, visibility=GONE, 
width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, 
is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, 
is-layout-requested=true, is-selected=false, root-is-layout-requested=false, 
has-input-connection=false, child-count=0}
|
at dalvik.system.VMStack.getThreadStackTrace(Native Method)
at java.lang.Thread.getStackTrace(Thread.java:737)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ge
tUserFriendlyError(DefaultFailureHandler.java:69)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ha
ndle(DefaultFailureHandler.java:40)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronou
slyOnUiThread(ViewInteraction.java:146)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(Vie
wInteraction.java:77)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewI
nteraction.java:69)
at xxxxxxxxxxxxxxxxxxx(our test application source)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:204)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:194)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:186)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:52
9)
at 
com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunne
r.onStart(GoogleInstrumentationTestRunner.java:119)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)
--------------------------------------------------------------------------------




What version of the product are you using? On what operating system?

espresso-1.0.jar

windows 7 / run Android 2.3.3 emulator



Please provide any additional information below.

When I got error, I also see IME Control dialog.
in normally, i can see this dialog when i longclick empty editbox.
so, I think here code is cause.

----------------------------------------
package com.google.android.apps.common.testing.ui.espresso.action;

public final class TypeTextAction implements ViewAction {

  @Override
  public void perform(UiController uiController, View view) {

    // Perform a click.
    new GeneralClickAction(Tap.SINGLE, GeneralLocation.CENTER, Press.PINPOINT)
        .perform(uiController, view);
    uiController.loopMainThreadUntilIdle();


----------------------------------------

when I use very very slow emulator, 
I have to set pressback  callback with click like below.

onView(withId(R.id.editView)).perform(click(pressBack()));

without callback, the dialog sometimes will be shown.
(its depends on emulator speed)

but click called without callback in TypeText.

what should i do for stable Test success ?

if you need more infromation, please ask me.







Original issue reported on code.google.com by [email protected] on 14 Nov 2013 at 3:23

Open source clearDatabaseAndRecreateApp

clearDatabaseAndRecreateApp seems like it'd be nice for open source people.

https://code.google.com/p/android-test-kit/source/detail?r=5d1754fec571b3c6c3035
3182ba99c9e677fd817&name=master

Original issue reported on code.google.com by [email protected] on 9 Jan 2014 at 7:20

Improve the startup time

What steps will reproduce the problem?
1. Run Espresso with a very simple test in Eclipse

What is the expected output? What do you see instead?
Expected: The test starts in few seconds
Actual: It took almost a minute to start the test. If I run 60 times a day 
during my development, I waste an hour a day just to wait it to start!

What version of the product are you using? On what operating system?
1.0-SNAPSHOT

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 26 Nov 2013 at 3:13

License/Copyright

Some files such as GoogleInstrumentationTestRunner, GoogleInstrumentation 
contain a header with "// Copyright 2012 Google Inc. All Rights Reserved."

This is unusual for OSS Apache 2. Is all the code in the repo supposed to be 
Apache 2? 

Original issue reported on code.google.com by [email protected] on 6 Nov 2013 at 3:12

upgrade to dagger 1.2

Please upgrade to dagger 1.2
Even with the unbundled jars it does not seem to be possible to test with 
espresso when an android app already is using Dagger 1.2. itself

What steps will reproduce the problem?
1. build an android app with dagger 1.2
2. build with gradle with the unbundled jars as shown here
http://stackoverflow.com/questions/19646529/using-android-gradle-dagger-to-run-i
nstrumenttests
(except for dagger 1.2 instead of dagger 1.1)

What is the expected output? What do you see instead?

You will get IllegalAccessErrors on device when the application tries to create 
the dagger object graph

It works with normal instrumentation tests (without Espresso) so it is related 
to Espresso

When building the app with older Dagger 1.1 everything works fine


What version of the product are you using? On what operating system?
espresso 1.1
dagger 1.2

Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 14 Jan 2014 at 9:53

Doesn't compile with java 6

What steps will reproduce the problem?
Try to build with Java 6.

At a minimum, it might be good to document the version of Java required and 
specify it in the pom. Thanks.

What is the expected output? What do you see instead?

Env:

Apache Maven 3.0.4 (r1232337; 2012-01-17 01:44:56-0700)
Maven home: /usr/share/maven
Java version: 1.6.0_51, vendor: Apple Inc.
Java home: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Default locale: en_US, platform encoding: MacRoman
OS name: "mac os x", version: "10.8.5", arch: "x86_64", family: "mac"

You get this:

[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on 
project espresso: Compilation failure: Compilation failure:
[ERROR] 
android-test-kit/espresso/lib/src/main/java/com/google/android/apps/common/testi
ng/ui/espresso/matcher/ViewMatchers.java:[433,29] type parameters of 
<E>org.hamcrest.Matcher<android.view.View> cannot be determined; no unique 
maximal instance exists for type variable E with upper bounds 
android.view.View,android.widget.Checkable
[ERROR]  
android-test-kit/espresso/lib/src/main/java/com/google/android/apps/common/testi
ng/ui/espresso/matcher/ViewMatchers.java:[441,29] type parameters of 
<E>org.hamcrest.Matcher<android.view.View> cannot be determined; no unique 
maximal instance exists for type variable E with upper bounds 
android.view.View,android.widget.Checkable





Original issue reported on code.google.com by [email protected] on 6 Nov 2013 at 2:18

  • Merged into: #1

Compilation error in ViewMatchers.java

What steps will reproduce the problem?
1. git clone
2. mvn install
3. compiler error:

[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Espresso Testing Framework 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-shade-plugin/2.1/ma
ven-shade-plugin-2.1.pom
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-shade-plugin/2.1/ma
ven-shade-plugin-2.1.pom (8 KB at 81.7 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-shade-plugin/2.1/ma
ven-shade-plugin-2.1.jar
Downloaded: 
http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-shade-plugin/2.1/ma
ven-shade-plugin-2.1.jar (98 KB at 344.4 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-library/1.1/hamcrest-library
-1.1.pom
Downloaded: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-library/1.1/hamcrest-library
-1.1.pom (683 B at 8.0 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-integration/1.1/hamcrest-int
egration-1.1.pom
Downloaded: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-integration/1.1/hamcrest-int
egration-1.1.pom (691 B at 8.2 KB/sec)
Downloading: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-library/1.1/hamcrest-library
-1.1.jar
Downloading: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-integration/1.1/hamcrest-int
egration-1.1.jar
Downloaded: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-integration/1.1/hamcrest-int
egration-1.1.jar (15 KB at 109.5 KB/sec)
Downloaded: 
http://repo1.maven.org/maven2/org/hamcrest/hamcrest-library/1.1/hamcrest-library
-1.1.jar (109 KB at 465.3 KB/sec)
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ 
espresso ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory 
/Users/rguion/dev/android-test-kit/espresso/lib/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ espresso ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 62 source files to 
/Users/rguion/dev/android-test-kit/espresso/lib/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] 
/Users/rguion/dev/android-test-kit/espresso/lib/src/main/java/com/google/android
/apps/common/testing/ui/espresso/matcher/ViewMatchers.java:[433,29] type 
parameters of <E>org.hamcrest.Matcher<android.view.View> cannot be determined; 
no unique maximal instance exists for type variable E with upper bounds 
android.view.View,android.widget.Checkable
[ERROR] 
/Users/rguion/dev/android-test-kit/espresso/lib/src/main/java/com/google/android
/apps/common/testing/ui/espresso/matcher/ViewMatchers.java:[441,29] type 
parameters of <E>org.hamcrest.Matcher<android.view.View> cannot be determined; 
no unique maximal instance exists for type variable E with upper bounds 
android.view.View,android.widget.Checkable
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] TestKit ........................................... SUCCESS [0.883s]
[INFO] Google Instrumentation TestRunner ................. SUCCESS [22.898s]
[INFO] Google Instrumentation TestRunner-Runtime ......... SUCCESS [0.467s]
[INFO] Espresso Parent Project ........................... SUCCESS [0.003s]
[INFO] Espresso Testing Framework ........................ FAILURE [2.622s]
[INFO] Test App For Espresso ............................. SKIPPED
[INFO] Tests For the Espresso Test Framework ............. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 47.117s
[INFO] Finished at: Fri Oct 18 11:27:09 PDT 2013
[INFO] Final Memory: 17M/81M
[INFO] ------------------------------------------------------------------------

What is the expected output? What do you see instead?

Expected clean compile.


What version of the product are you using? On what operating system?

On Mac, JDK 1.6.



Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 18 Oct 2013 at 6:30

Expose a generic PoolMonitor class

We use our own ThreadPoolExecutor instead of AsyncTask, so we call 
registerIdlingResources on setUp to monitor the pool for changes. We found that 
most of the logic needed was already implemented in AsyncTaskPoolMonitor, so we 
simply copied the class, made it implement IdlingResource and it worked out of 
the box.

Is there any reason why a generic PoolMonitor class has not been made public 
and AsyncTaskPoolMonitor is package private? Are we doing something wrong?

Original issue reported on code.google.com by [email protected] on 19 Nov 2013 at 12:54

<Enhancement> Add support for DatePicker objects

What steps will reproduce the problem?
1. Create and Activity with a DatePicker
2. Go to said activity and Check through DDMS the selectable views 
3. I am unable to select an individual day for selection and espresso is unable 
to pick up the dates via onView(withText(dayAsString)).perform(click());

What is the expected output? What do you see instead?
I would expect to be able to select an individual date either via an ID or a 
text value.

What version of the product are you using? On what operating system?
Espresso Version 1.1; Mac OSX

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 14 Jan 2014 at 11:12

Changing activity and the calling onView failed

What steps will reproduce the problem?
1.  Press the up button on the activity bar.
onView(Matchers.allOf(
                withContentDescription("Navigate up"),
                isDisplayed(),
                Matchers.not(
                        ViewMatchers.hasDescendant(
                                withContentDescription("Navigate up")
                        )
                )))..perform(click());

2. Wait for the root activity of the view to show.
onView(withId(viewId)).check(matches(isDisplayed()));.

What is the expected output? What do you see instead?


Sometimes the code works, sometime it does not.
java.lang.RuntimeException: No activities found. Did you forget to launch the 
activity by calling getActivity() or startActivitySync or similar?
at 
com.google.android.apps.common.testing.ui.espresso.base.RootViewPicker.waitForAt
LeastOneActivityToBeResumed(RootViewPicker.java:164)
at 
com.google.android.apps.common.testing.ui.espresso.base.RootViewPicker.findRoot(
RootViewPicker.java:109)
at 
com.google.android.apps.common.testing.ui.espresso.base.RootViewPicker.get(RootV
iewPicker.java:65)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteractionModule.provide
RootView(ViewInteractionModule.java:51)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteractionModule$$Module
Adapter$ProvideRootViewProvidesAdapter.get(ViewInteractionModule$$ModuleAdapter.
java:187)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteractionModule$$Module
Adapter$ProvideRootViewProvidesAdapter.get(ViewInteractionModule$$ModuleAdapter.
java:151)
at 
com.google.android.apps.common.testing.ui.espresso.base.ViewFinderImpl.getView(V
iewFinderImpl.java:52)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction$2.run(ViewInt
eraction.java:141)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)



What version of the product are you using? On what operating system?

espresso-1.1
Mac OS X 10.9.1:
-- Emulator Google API's 4.4 API 19 7.68 x 1020
-- GennyMotion 2.03 (gennymotion.com) with WXGA tablet 10.1 4.2.2 API 17.

The problem did not occur as often with espresso-1.0


Workaround:

    public static void waitForView(int viewId) {
        long startTime = (new Date()).getTime();
        long endTime = startTime + 15000;
        do {
            try {
                onView(withId(viewId)).check(matches(isDisplayed()));
                return;
            } catch(Throwable ex) {
                Log.d(TAG,  "trying again waiting for view "
                        + viewId + " " + ex);
                Thread.yield();
            }
        } while (((new Date()).getTime()) < endTime);
      onView(withId(viewId)).check(matches(isDisplayed()));
    }

Use the resource id of the view that matches the outermost layout of the 
activities view.


Maybe similar to issue #33

Original issue reported on code.google.com by [email protected] on 17 Jan 2014 at 2:16

  • Merged into: #55

MotionEvents.sendCancel should not be fatal

What steps will reproduce the problem?
1.        
Espresso.onView(ViewMatchers.withId(R.id.action_new_game)).perform(ViewActions.c
lick());
where R.id.action_new_game is a action bar item that will switch to a new 
activity.

The exception below is s



What is the expected output? What do you see instead?

On slow devices there is no problem.  
On GennyMotion 2.0.3 (http://www.genymotion.com)
 using Galaxy Nexus 4.2.2 API 17, periodically we get


com.google.android.apps.common.testing.ui.espresso.PerformException: Error 
performing 'single click' on view 'with id: is <2131296376>'.
at 
com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.buil
d(PerformException.java:67)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ge
tUserFriendlyError(DefaultFailureHandler.java:57)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ha
ndle(DefaultFailureHandler.java:40)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronou
slyOnUiThread(ViewInteraction.java:159)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(Vie
wInteraction.java:90)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewI
nteraction.java:73)
at 
com.agileteer.futsalcounter.activity.CountingActivity2Test.test300OnNewGameActiv
ityBringsUpTheNewGameActivity(CountingActivity2Test.java:179)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
5)
at 
com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunne
r.onStart(GoogleInstrumentationTestRunner.java:167)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661)
Caused by: com.google.android.apps.common.testing.ui.espresso.PerformException: 
Error performing 'inject cancel event (corresponding down event: MotionEvent { 
action=ACTION_DOWN, id[0]=0, x[0]=328.0, y[0]=98.0, 
toolType[0]=TOOL_TYPE_UNKNOWN, buttonState=0, metaState=0, flags=0x0, 
edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=12204894, 
downTime=12204894, deviceId=0, source=0x1002 })' on view 'unknown'.
at 
com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.buil
d(PerformException.java:67)
at 
com.google.android.apps.common.testing.ui.espresso.action.MotionEvents.sendCance
l(MotionEvents.java:160)
at 
com.google.android.apps.common.testing.ui.espresso.action.Tap$1.sendTap(Tap.java
:28)
at 
com.google.android.apps.common.testing.ui.espresso.action.GeneralClickAction.per
form(GeneralClickAction.java:82)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInt
eraction.java:119)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5041)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
at dalvik.system.NativeStart.main(Native Method)

If we set a break point on the click statement, and then step through makes the 
problem not visible.

What version of the product are you using? On what operating system?
android test kit 1.1, with android studio 0.42 on OS X 10.9.1

Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 16 Jan 2014 at 10:13

GITR cannot be configured in Eclipse with ADT 22.3

What steps will reproduce the problem?
1. Setup a test project using the GITR
2. Go to Eclipse > Run configuration and create a new configuration
3. Select 
com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunne
r

Expected:
No error

Got:
The instrumentation runner must be of type 
android.test.InstrumentationTestRunner

Versions:
Windows XP SP3, Maven 3.0, m2e, TestKit git version b49a13f0

Original issue reported on code.google.com by [email protected] on 13 Nov 2013 at 12:34

WebView support

It'd be nice to have WebView support.
https://groups.google.com/forum/#!searchin/android-test-kit-discuss/webview/andr
oid-test-kit-discuss/KO42yKXYk00/lbPJyzZndvUJ

Original issue reported on code.google.com by [email protected] on 14 Nov 2013 at 6:50

Unable to type non-English words with typeText()

What steps will reproduce the problem?
Do ViewActions.typeText() with other languages.

What is the expected output? What do you see instead?
Expected: The text is typed at the right view
Actual: NullPointerException is thrown

What version of the product are you using? On what operating system?
Espresso 1.1

Please provide any additional information below.
It may be hard for Espresso to switch IME keyboard and do the type, so maybe 
the fix for this is to use view.setText() when it sees non-English text.

Original issue reported on code.google.com by [email protected] on 18 Jan 2014 at 7:34

SecurityException performing 'single click' on view

What steps will reproduce the problem?

1. mvn package
(I wasn't able to run the tests without following 
https://code.google.com/p/android-test-kit/issues/detail?id=4)
2. adb shell setprop dalvik.vm.dexopt-flags v=n,o=v
3. adb shell stop installd
4. adb shell start installd
5. adb shell am instrument -w -e class 
com.google.android.apps.common.testing.ui.espresso.tests.BasicTest#testTypingAnd
PressBack 
com.google.android.apps.common.testing.ui.espresso.tests/com.google.android.apps
.common.testing.testrunner.GoogleInstrumentationTestRunner

What is the expected output?

Test passes

What do you see instead?

com.google.android.apps.common.testing.ui.espresso.tests.BasicTest:
Error in testTypingAndPressBack:
com.google.android.apps.common.testing.ui.espresso.PerformException: Error 
performing 'single click' on view 'with id: is <2131034239>'.
    at com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.build(PerformException.java:67)
    at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:57)
    at com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:40)
    at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:146)
    at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(ViewInteraction.java:77)
    at com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewInteraction.java:69)
    at com.google.android.apps.common.testing.ui.espresso.tests.BasicTest.testTypingAndPressBack(BasicTest.java:57)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
    at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
    at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
    at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
    at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:554)
    at com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner.onStart(GoogleInstrumentationTestRunner.java:119)
    at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: com.google.android.apps.common.testing.ui.espresso.PerformException: 
Error performing 'Send down montion event' on view 'unknown'.
    at com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.build(PerformException.java:67)
    at com.google.android.apps.common.testing.ui.espresso.action.Tap.sendDown(Tap.java:154)
    at com.google.android.apps.common.testing.ui.espresso.action.Tap.access$100(Tap.java:19)
    at com.google.android.apps.common.testing.ui.espresso.action.Tap$1.sendTap(Tap.java:27)
    at com.google.android.apps.common.testing.ui.espresso.action.GeneralClickAction.perform(GeneralClickAction.java:81)
    at com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInteraction.java:106)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    at android.os.Handler.handleCallback(Handler.java:730)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5103)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: 
com.google.android.apps.common.testing.ui.espresso.InjectEventSecurityException:
 java.lang.SecurityException: Injecting to another application requires 
INJECT_EVENTS permission
    at com.google.android.apps.common.testing.ui.espresso.base.InputManagerEventInjectionStrategy.injectMotionEvent(InputManagerEventInjectionStrategy.java:131)
    at com.google.android.apps.common.testing.ui.espresso.base.EventInjector.injectMotionEvent(EventInjector.java:80)
    at com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$3.call(UiControllerImpl.java:199)
    at com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$3.call(UiControllerImpl.java:196)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:390)
    at java.util.concurrent.FutureTask.run(FutureTask.java:234)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
    at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Injecting to another application 
requires INJECT_EVENTS permission
    at android.os.Parcel.readException(Parcel.java:1431)
    at android.os.Parcel.readException(Parcel.java:1385)
    at android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.java:356)
    at android.hardware.input.InputManager.injectInputEvent(InputManager.java:623)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at com.google.android.apps.common.testing.ui.espresso.base.InputManagerEventInjectionStrategy.injectMotionEvent(InputManagerEventInjectionStrategy.java:122)
    ... 9 more

Test results for GoogleInstrumentationTestRunner$BridgeTestRunner=.E
Time: 2.552

FAILURES!!!
Tests run: 1,  Failures: 0,  Errors: 1

What version of the product are you using? On what operating system?

espresso-standalone/espresso-1.0-SNAPSHOT-bundled.jar
Nexus 4
Nexus 4 emulator image

Please provide any additional information below.

The problem was first observed running tests on an LG Nexus 4. The error was 
then reproduced in an emulator running the Nexus 4 preset (hardware keyboard 
not enabled).
Turning on the hardware keyboard option works around the crash (in the 
emulator). Using a different resolution emulator image (ex. 480x854) also seems 
to avoid the problem.

It appears that Espresso is not waiting for the completion of the 
closeSoftKeyboard() and the perform(click()) is being sent to the system UI 
view (soft keyboard) instead of the Button, as desired. 

Original issue reported on code.google.com by [email protected] on 28 Nov 2013 at 5:32

instrumentTestCompile dependency doesn't work

What steps will reproduce the problem?
1. build.gradle

dependencies {
    compile ... // compile dependencies

    instrumentTestCompile 'com.google.android.apps.common.testing:espresso:1.0-SNAPSHOT'
    instrumentTestCompile 'com.google.android.apps.common.testing:testrunner:1.0-SNAPSHOT'
    instrumentTestCompile 'com.google.android.apps.common.testing:testrunner-runtime:1.0-SNAPSHOT'
    instrumentTestCompile 'org.hamcrest:hamcrest-core:1.1'
    instrumentTestCompile 'org.hamcrest:hamcrest-library:1.1'
    instrumentTestCompile 'org.hamcrest:hamcrest-integration:1.1'
    instrumentTestCompile 'com.squareup.dagger:dagger:+'
    instrumentTestCompile 'com.squareup.dagger:dagger-compiler:+'
}

2.
                        I  Could not find method com.google.android.apps.common.testing.testrunner.ExposedInstrumentationApi.execStartActivity, referenced from method com.google.android.apps.common.testing.testrunner.GoogleInstrumentation.
                           execStartActivity
                        W  VFY: unable to resolve virtual method 222: Lcom/google/android/apps/common/testing/testrunner/ExposedInstrumentationApi;.execStartActivity (Landroid/content/Context;Landroid/os/IBinder;Landroid/os/IBinder;Landroi
                           d/app/Activity;Landroid/content/Intent;I)Landroid/app/Instrumentation$ActivityResult;

What is the expected output? What do you see instead?
I have the libs in local maven repo, but they are not bundled with apk.

What version of the product are you using? On what operating system?
1.0-SNAPSHOT

Please provide any additional information below.
I have to replace "instrumentTestCompile" with "compile", otherwise the classes 
are not bundled into apk.

Original issue reported on code.google.com by [email protected] on 3 Dec 2013 at 12:31

espresso's dependencies pull hamcrest libs separately

What steps will reproduce the problem?
1. clone the git repo
2. change to the project directory and hit mvn install
3. configure a test project with

<dependency>
    <groupId>com.google.android.apps.common.testing</groupId>
    <artifactId>espresso</artifactId>
    <version>${testkit.version}</version>
</dependency>
<dependency>
    <groupId>com.google.android.apps.common.testing</groupId>
    <artifactId>testrunner</artifactId>
    <version>${testkit.version}</version>
</dependency>
<dependency>
    <groupId>com.google.android.apps.common.testing</groupId>
    <artifactId>testrunner-runtime</artifactId>
    <version>${testkit.version}</version>
</dependency>

where ${testkit.version} expands to the current 1.0-SNAPSHOT.

Expected:
No build errors

Got:
Error generating final archive: Found duplicate file for APK: LICENSE.txt
Origin 1: 
path\to\.m2\repository\org\hamcrest\hamcrest-core\1.1\hamcrest-core-1.1.jar
Origin 2: 
path\to\.m2\repository\org\hamcrest\hamcrest-integration\1.1\hamcrest-integratio
n-1.1.jar

Workaround:

To get it using the -all library, I temporarily added some exclusions like this:

<dependency>
    <groupId>org.hamcrest</groupId>
    <artifactId>hamcrest-all</artifactId>
    <version>${hamcrest.version}</version>
</dependency>
<dependency>
    <groupId>com.google.android.apps.common.testing</groupId>
    <artifactId>espresso</artifactId>
    <version>${testkit.version}</version>
    <exclusions>
        <exclusion>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
    </exclusion>
        <exclusion>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-library</artifactId>
    </exclusion>
        <exclusion>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-integration</artifactId>
    </exclusion>
   </exclusions> 
</dependency>
...

I guess this is actually a bug with hamcrest, but given the fact that it can be 
circumvented by just depending on -all it might be fixable here.

Original issue reported on code.google.com by [email protected] on 13 Nov 2013 at 12:41

PerformException: Error performing 'single click' on view

What steps will reproduce the problem?

1. Create an Android application that uses Espresso as its test runner.
2. Place an EditText in the middle of an Activity
3. Place a Button below the EditText
4. Write a test which calls 
onView(withId(R.id.testEdit)).perform(typeText("Have a cup of Espresso."), 
closeSoftKeyboard()); from your test
5. Call onView(withId(R.id.button)).perform(click());

What is the expected output? 

- Test should pass

What do you see instead?

- The test fails/crashes as the "click" is not sent to the Button, but 
seemingly to the SystemUI.
- Crash log:
com.google.android.apps.common.testing.ui.espresso.PerformException: Error 
performing 'single click' on view 'with id: is <2131165246>'.
at 
com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.buil
d(PerformException.java:67)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ge
tUserFriendlyError(DefaultFailureHandler.java:57)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ha
ndle(DefaultFailureHandler.java:40)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronou
slyOnUiThread(ViewInteraction.java:159)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(Vie
wInteraction.java:90)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewI
nteraction.java:73)
at com.example.tests.FailingTest.testTypingAndPressBack(FailingTest.java:36)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
4)
at 
com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunne
r.onStart(GoogleInstrumentationTestRunner.java:167)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: com.google.android.apps.common.testing.ui.espresso.PerformException: 
Error performing 'Send down montion event' on view 'unknown'.
at 
com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.buil
d(PerformException.java:67)
at 
com.google.android.apps.common.testing.ui.espresso.action.MotionEvents.sendDown(
MotionEvents.java:90)
at 
com.google.android.apps.common.testing.ui.espresso.action.Tap$1.sendTap(Tap.java
:24)
at 
com.google.android.apps.common.testing.ui.espresso.action.GeneralClickAction.per
form(GeneralClickAction.java:82)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInt
eraction.java:119)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: 
com.google.android.apps.common.testing.ui.espresso.InjectEventSecurityException:
 java.lang.SecurityException: Injecting to another application requires 
INJECT_EVENTS permission
at 
com.google.android.apps.common.testing.ui.espresso.base.InputManagerEventInjecti
onStrategy.injectMotionEvent(InputManagerEventInjectionStrategy.java:131)
at 
com.google.android.apps.common.testing.ui.espresso.base.EventInjector.injectMoti
onEvent(EventInjector.java:80)
at 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$3.call(
UiControllerImpl.java:201)
at 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$3.call(
UiControllerImpl.java:198)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Injecting to another application 
requires INJECT_EVENTS permission
at android.os.Parcel.readException(Parcel.java:1465)
at android.os.Parcel.readException(Parcel.java:1419)
at 
android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.j
ava:356)
at android.hardware.input.InputManager.injectInputEvent(InputManager.java:641)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.google.android.apps.common.testing.ui.espresso.base.InputManagerEventInjecti
onStrategy.injectMotionEvent(InputManagerEventInjectionStrategy.java:122)
... 9 more




What version of the product are you using? On what operating system?

- Issues observed with Espresso 1.1

Please provide any additional information below.

- All animations disabled in AVD
- AVD Settings: Nexus 4, Google APIs Level 19, ARM, 1907 RAM, 64 VM, Use Host 
GPU, no hardware keyboard (screenshot attached)
- Attached animated gif of failure
- Attached sample code displaying the issue

Original issue reported on code.google.com by [email protected] on 14 Jan 2014 at 7:11

Attachments:

enhancement waitForView and onView waiting for idle

When pressing a button that drastically changes the view, e.g. taking widgets 
down or adding new widgets (e.g. dialogues) if onView is called immediately 
after the action perform(click()) then the onView will fail since the new 
widget is not yet visible.

I have found two helper methods solve my problems, and I think something like 
them should be built into the framework.

onView should wait until the UI thread is idle.  I have seen that perform does 
that, but have not found a location where onView does that.

Below is my workaround that I place before onView.

    public static void settleUiThread(Activity activity)
            throws InterruptedException {
        final Semaphore uiThreadSettled = new Semaphore(0);
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                uiThreadSettled.release();
            }
        });
        boolean acquired = uiThreadSettled.tryAcquire(1, TimeUnit.MINUTES);
        if (!acquired) {
            throw new Error("ui thread settling semaphore not acquired.");
        }
    }

The second workaround is to give the code a chance to bring up the dialogs.

    public static void waitForView(int viewId) {
        long startTime = (new Date()).getTime();
        long endTime = startTime + 15000;
        do {
            try {
                onView(withId(viewId)).check(matches(isDisplayed()));
                return;
            } catch (Throwable ex) {
                Log.d(TAG, "trying again waiting for view "
                        + viewId + " " + ex);
                Thread.yield();
            }
        } while (((new Date()).getTime()) < endTime);
        onView(withId(viewId)).check(matches(isDisplayed()));
    }

I have only seen this problem consistently when running on very fast emulators. 
 Real hardware seems to slow things down enough that the it happens only 
occasionally; enough so that I have added the above calls to my test cases to 
make the reliable.

Original issue reported on code.google.com by [email protected] on 20 Jan 2014 at 8:36

Enhancement: Please add support for XML output

Because your system has a hard requirement to use the new test runner, it will 
be unusable in our Continuous Integration environment without having to go back 
and write a custom parser or merging something like the Polidea test runner in 
and then building your project myself (once you fix the build problems that is).

Please save me and countless others who use Jenkins for their build server a 
lot of time by baking it in directly.

Here's a reference of the XML test runner I called out above:
https://code.google.com/p/the-missing-android-xml-junit-test-runner/source/brows
e/

Original issue reported on code.google.com by [email protected] on 14 Nov 2013 at 7:08

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.