AgtLucas / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

Espresso does not wait until next activity to be resumed to proceed to next action #55

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. In Espresso, click any view that will launch a new activity, or click back 
to go back to the previous activity
2. At the next line, do check isDisplayed() on any view in the next activity

What is the expected output? What do you see instead?
Expected: The check returned without problem
Actual: Sometimes it performs the check too quick, and the UI is still in the 
current activity. In that case, a NoMatchingViewException is thrown.

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

Please provide any additional information below.
This does not happen very often. Maybe just one out of 100 tries. That doesn't 
sound very high if this is an app, but that's very high for Continuous Delivery 
automation. For any test suite that has more than 100 test scripts doing this, 
it's almost guaranteed to fail. For automation in Continuous Delivery, we are 
looking for one out of a million tries stability, and I think that's what 
Espresso is supposed to do.

Original issue reported on code.google.com by K76...@gmail.com on 11 Feb 2014 at 7:10

GoogleCodeExporter commented 9 years ago
Log for the back problem

02-06 23:11:04.194 I/ViewInteraction( 1644): Performing 'send keyCode: 4, 
metaState: 0 key event' action on view is a root view. 

02-06 23:11:04.194 V/ESP_TRACE( 1644): EventInjector:Injecting event for 
character (À€) with key code (4) downtime: (190583) 

02-06 23:11:04.194 V/ESP_TRACE( 1644): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 }, with target: android.app.ActivityThread.H, callback: 
android.app.LoadedApk$ReceiverDispatcher$Args@b5c17150 

02-06 23:11:04.194 V/ESP_TRACE( 1644): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-1ms }, with target: android.app.ActivityThread.H, callback: 
android.app.LoadedApk$ReceiverDispatcher$Args@b5c03888 

02-06 23:11:04.194 V/ESP_TRACE( 1644): UiControllerImpl: MessageQueue.next(): { 
what=10 when=0 arg1=19212 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

02-06 23:11:04.194 V/ESP_TRACE( 1644): UiControllerImpl: MessageQueue.next(): { 
what=3 when=0 arg1=3429 }, with target: android.os.Handler, callback: no 
callback. 

02-06 23:11:04.194 V/ESP_TRACE( 1644): EventInjector:Injecting event for 
character (À€) with key code (4) downtime: (190589) 

02-06 23:11:04.204 V/ESP_TRACE( 1644): UiControllerImpl: MessageQueue.next(): { 
what=10 when=-5ms arg1=19225 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

02-06 23:11:04.204 V/Unknown Source( 1644): Default implementation of 
onFragmentResult was run, finishing activity CurrentActivity@b595aa30 

02-06 23:11:04.204 W/WindowManager( 1006): Failure taking screenshot for 
(246x410) to layer 21015 

02-06 23:11:04.224 W/ActivityManager( 1006): Duplicate finish request for 
ActivityRecord{b5b82c80 myApp/.CurrentActivity} 

02-06 23:11:04.224 V/ESP_TRACE( 1644): UiControllerImpl: MessageQueue.next(): { 
what=3 when=0 arg1=3431 }, with target: android.os.Handler, callback: no 
callback. 

02-06 23:11:04.234 E/ViewAssertions( 1644): 'is displayed on the screen to the 
user' check could not be performed because view 'is displayed on the screen to 
the user' was not found. 

02-06 23:11:04.274 D/LifecycleMonitor( 1644): Lifecycle status change: 
CurrentActivity@b595aa30 in: PAUSED 

02-06 23:11:04.285 D/LifecycleMonitor( 1644): Lifecycle status change: 
PreviousActivity@b5c15db0 in: RESTARTED 

02-06 23:11:04.285 D/LifecycleMonitor( 1644): Lifecycle status change: 
PreviousActivity@b5c15db0 in: STARTED 

02-06 23:11:04.294 D/LifecycleMonitor( 1644): Lifecycle status change: 
PreviousActivity@b5c15db0 in: RESUMED 

Original comment by K76...@gmail.com on 11 Feb 2014 at 7:11

GoogleCodeExporter commented 9 years ago
Similar problem happened to me, but this time it was not pressing back. 
Instead, it's clicking on a menu option that will enter another activity. I 
substituted the activity names with fake ones, but the CurrentActivity is the 
activity I click the menu option, and NextActivity is the target activity. Log 
shows that the check is performed before the CurrentActivity enters Paused 
state: 

03-13 04:18:49.085 I/ViewInteraction( 1685): Performing 'send keyCode: 82, 
metaState: 0 key event' action on view is a root view. 

03-13 04:18:49.085 V/ESP_TRACE( 1685): EventInjector:Injecting event for 
character (À€) with key code (82) downtime: (339278) 

03-13 04:18:49.085 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=10 when=0 arg1=27583 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.085 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=3 when=0 arg1=5778 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.085 V/ESP_TRACE( 1685): EventInjector:Injecting event for 
character (À€) with key code (82) downtime: (339281) 

03-13 04:18:49.085 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=10 when=0 arg1=27597 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.094 W/AudioPolicyManagerBase(  793): getOutput() could not find 
output for stream 1, samplingRate 0,format 0, channels 3, flags 0 

03-13 04:18:49.094 W/AudioPolicyManagerBase(  793): getOutput() could not find 
output for stream 1, samplingRate 0,format 0, channels 3, flags 0 

03-13 04:18:49.094 W/AudioPolicyManagerBase(  793): getOutput() could not find 
output for stream 1, samplingRate 44100,format 1, channels 1, flags 4 

03-13 04:18:49.094 E/AudioTrack( 1001): Could not get audio output for stream 
type 1 

03-13 04:18:49.094 E/SoundPool( 1001): Error creating AudioTrack 

03-13 04:18:49.094 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-8ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=6 when=-48ms arg1=1 arg2=1 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=3 when=-47ms arg1=5780 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-44ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-40ms }, with target: android.widget.Editor.Blink, callback: 
Handler (android.widget.Editor$Blink) {b60cb4d0} 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=5 when=-8ms arg1=399 arg2=303 
obj=android.view.ViewRootImpl$ResizedInfo@b60bc2d0 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-6ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b60bc4b8 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-6ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b5f6fe40 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-6ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6006db0 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-6ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b60086a8 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-5ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b60bbf10 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-4ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b60bc030 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-4ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b60bc088 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.144 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-5ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b60bc0e0 

03-13 04:18:49.144 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.167 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-24ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.167 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.167 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=6 when=-20ms arg2=1 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.184 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.184 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-16ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.224 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.224 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-43ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b606d5e0 

03-13 04:18:49.224 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.224 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-44ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b606d6c0 

03-13 04:18:49.224 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.224 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-44ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b606d718 

03-13 04:18:49.224 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.224 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-44ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b606d770 

03-13 04:18:49.224 I/ViewInteraction( 1685): Performing 'single click' action 
on view with string from resource id: 
<2131493091>[STR_LntEditor_AddRecipientFromNameLookup] value: Look Up Recipient 

03-13 04:18:49.224 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.AbsListView$2@b616a868 

03-13 04:18:49.234 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=4 when=0 arg1=5782 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.265 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-9ms }, with target: android.os.Handler, callback: 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$Signali
ngTask@b616baf0 

03-13 04:18:49.265 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 arg1=5784 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.284 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-5ms }, with target: android.os.Handler, callback: 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$Signali
ngTask@b616cd08 

03-13 04:18:49.284 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 arg1=5786 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.294 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-1ms }, with target: android.os.Handler, callback: 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$Signali
ngTask@b6129600 

03-13 04:18:49.294 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 arg1=5788 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.310 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-9ms }, with target: android.os.Handler, callback: 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$Signali
ngTask@b612a698 

03-13 04:18:49.310 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 arg1=5790 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.310 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-17ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.314 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=4 when=-2ms arg1=5792 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.384 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-8ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.AbsListView$1@b612bc00 

03-13 04:18:49.384 D/GoogleInstr( 1685): execStartActivity(context, ibinder, 
ibinder, activity, intent, int, bundle 

03-13 04:18:49.384 V/Unknown Source( 1685): run lookup query on background 
thread for 'null' 

03-13 04:18:49.384 V/Unknown Source( 1685): Creating results cursor for local 
'' & remote 'null' 

03-13 04:18:49.384 I/ActivityManager( 1001): START 
{act=android.intent.action.SEARCH cmp=com.test/.NextActivity (has extras) u=0} 
from pid 1685 

03-13 04:18:49.384 W/WindowManager( 1001): Failure taking screenshot for 
(246x410) to layer 21025 

03-13 04:18:49.384 D/dalvikvm( 1685): WAIT_FOR_CONCURRENT_GC blocked 0ms 

03-13 04:18:49.408 W/AudioPolicyManagerBase(  793): getOutput() could not find 
output for stream 1, samplingRate 0,format 0, channels 3, flags 0 

03-13 04:18:49.408 W/AudioPolicyManagerBase(  793): getOutput() could not find 
output for stream 1, samplingRate 0,format 0, channels 3, flags 0 

03-13 04:18:49.408 W/AudioPolicyManagerBase(  793): getOutput() could not find 
output for stream 1, samplingRate 44100,format 1, channels 1, flags 4 

03-13 04:18:49.408 E/AudioTrack( 1001): Could not get audio output for stream 
type 1 

03-13 04:18:49.408 E/SoundPool( 1001): Error creating AudioTrack 

03-13 04:18:49.408 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-29ms }, with target: android.os.Handler, callback: 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$Signali
ngTask@b612cd68 

03-13 04:18:49.414 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-4ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.414 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=3 when=-10ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: no callback. 

03-13 04:18:49.454 D/dalvikvm( 1685): GC_EXPLICIT freed 1414K, 19% free 
17814K/21767K, paused 2ms+3ms, total 75ms 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-64ms arg1=5794 }, with target: android.os.Handler, callback: no 
callback. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-59ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180a68 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-59ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180b58 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-60ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180c48 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-60ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180d38 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-59ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180850 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-60ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b61808a8 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-60ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180900 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-61ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.widget.TextView$2@b6180958 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=6 when=-4ms arg1=1 arg2=1 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.474 W/InputMethodManagerService( 1001): Window already focused, 
ignoring focus gain of: 
com.android.internal.view.IInputMethodClient$Stub$Proxy@b5a0c350 attribute=null 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=6 when=-6ms arg2=1 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=13 when=-1ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: no callback. 

03-13 04:18:49.474 V/ESP_TRACE( 1685): Barrier detected or task avaliable for 
running shortly. 

03-13 04:18:49.486 V/ESP_TRACE( 1685): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-22ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b5abd330 

03-13 04:18:49.486 I/Unknown Source( 1685): Invoked the menu item 

03-13 04:18:49.525 E/ViewAssertions( 1685): 'is displayed on the screen to the 
user' check could not be performed because view 'is displayed on the screen to 
the user' was not found. 

03-13 04:18:49.594 V/Unknown Source( 1685): ENTRY 

03-13 04:18:49.594 V/Unknown Source( 1685): ENTRY 

03-13 04:18:49.594 V/Unknown Source( 1685): EXIT: not enabled 

03-13 04:18:49.594 V/Unknown Source( 1685): ENTRY: key = 
devPAppLevelPwLastTimestamp 

03-13 04:18:49.594 V/Unknown Source( 1685): configPost = false appsChanged = 
false 

03-13 04:18:49.594 D/LifecycleMonitor( 1685): Lifecycle status change: 
com.test.CurrentActivity@b5babe30 in: PAUSED 

03-13 04:18:49.594 D/LifecycleMonitor( 1685): Lifecycle status change: 
com.test.NextActivity@b5d45d20 in: PRE_ON_CREATE 

03-13 04:18:49.604 D/LifecycleMonitor( 1685): Lifecycle status change: 
com.test.NextActivity@b5d45d20 in: CREATED 

03-13 04:18:49.604 V/Unknown Source( 1685): EXIT: timestamp = Thu Mar 13 
04:18:44 EDT 2014 

03-13 04:18:49.604 D/LifecycleMonitor( 1685): Lifecycle status change: 
com.test.NextActivity@b5d45d20 in: STARTED 

03-13 04:18:49.654 D/dalvikvm( 1685): GC_CONCURRENT freed 1685K, 18% free 
18048K/21767K, paused 14ms+2ms, total 28ms 

03-13 04:18:49.654 D/LifecycleMonitor( 1685): Lifecycle status change: 
com.test.NextActivity@b5d45d20 in: RESUMED

Original comment by K76...@gmail.com on 14 Mar 2014 at 5:01

GoogleCodeExporter commented 9 years ago
Hello.

This issue is caused by the activity management. It's very easy to reproduce 
with "Don't keep activities turned on". 

1. Start instrument test for MainActivity
2. Perform click to launch SecondActivity
3. Perform pressBack
4. Assert anything on MainActivity's views
5. It will wail with:
com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException: No 
views in hierarchy found matching: with id: is <2131230737>

The IdlingResource isn't helpful in this case, because the MainActivity under 
test is destroyed and a new activity is created. The getActivity method returns 
only the old instance.

            TestRunner  I  started: test(MainActivityTest)
# start MainActivity by getActivity
      LifecycleMonitor  D  Lifecycle status change: MainActivity@423458b8 in: PRE_ON_CREATE
                        D  Lifecycle status change: MainActivity@423458b8 in: CREATED
                        D  Lifecycle status change: MainActivity@423458b8 in: STARTED
                        D  Lifecycle status change: MainActivity@423458b8 in: RESUMED
# I've registered here the IdlingResource (on a @423458b8)
                   TAG  I  registerLoadServer MainActivity@423458b8
# perform click on a view that starts another activity
                        D  Lifecycle status change: MainActivity@423458b8 in: PAUSED
                        D  Lifecycle status change: SecondActivity@4221bfa0 in: PRE_ON_CREATE
                        D  Lifecycle status change: SecondActivity@4221bfa0 in: CREATED
                        D  Lifecycle status change: SecondActivity@4221bfa0 in: STARTED
      LifecycleMonitor  D  Lifecycle status change: SecondActivity@4221bfa0 in: RESUMED
                        D  Lifecycle status change: MainActivity@423458b8 in: STOPPED
# the activity under test is destroyed
                        D  Lifecycle status change: MainActivity@423458b8 in: DESTROYED
# finish SecondActivity with pressBack
                        D  Lifecycle status change: SecondActivity@4221bfa0 in: PAUSED
# as you can see a new MainActivity is created (@421b5428)
# the methods of IdlingResource will not be called, so my test will fail
                        D  Lifecycle status change: MainActivity@421b5428 in: PRE_ON_CREATE
                        D  Lifecycle status change: MainActivity@421b5428 in: CREATED
                        D  Lifecycle status change: MainActivity@421b5428 in: STARTED
                        D  Lifecycle status change: MainActivity@421b5428 in: RESUMED
# as I mentioned above, the test has failed
            TestRunner  I  failed: test(MainActivityTest)
                        I  ----- begin exception -----
                        I  
                        I  com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: is <2131230737>
                           ...

If you have the "Don't keep activities" turned off, this situation may happen 
in 1/100 runs. 

Any ideas how to work around this issue?

Original comment by TomR...@gmail.com on 30 Mar 2014 at 1:27

GoogleCodeExporter commented 9 years ago
Issue 48 has been merged into this issue.

Original comment by vale...@google.com on 7 May 2014 at 4:44

GoogleCodeExporter commented 9 years ago
Issue 47 has been merged into this issue.

Original comment by vale...@google.com on 7 May 2014 at 4:44

GoogleCodeExporter commented 9 years ago

Original comment by vale...@google.com on 7 May 2014 at 4:45

GoogleCodeExporter commented 9 years ago
K76154 - are you using the IdlingResource interface to synchronize your app 
with Espresso?

TomRozb - as a workaround, can you not use "Don't keep activities turned on"?

Original comment by vale...@google.com on 9 Jun 2014 at 9:36

GoogleCodeExporter commented 9 years ago
Yes, of course I can turn it off, but Android may kill activity at random so 
this is not perfect solution. But I've workaround this in another way, it is 
not a problem for me anymore.

Original comment by TomR...@gmail.com on 10 Jun 2014 at 10:02

GoogleCodeExporter commented 9 years ago
I am using IdlingResource somewhere else in my test, but not in this part of 
code or test.

Original comment by K76...@gmail.com on 10 Jun 2014 at 11:25

GoogleCodeExporter commented 9 years ago
Did you find a way to work this around?

Original comment by hulc...@gmail.com on 24 Nov 2014 at 3:46

GoogleCodeExporter commented 9 years ago
Not ideal, but I'm able to work-around this by using a rollback-action: 
.perform(click(click())); or .perform(click(longClick())). My scenario was for 
a menu action attempting to start another activity.

Original comment by p.pr...@blueesoteric.com on 16 Feb 2015 at 6:33

GoogleCodeExporter commented 9 years ago
Issue 104 has been merged into this issue.

Original comment by nkors...@google.com on 5 May 2015 at 5:53

GoogleCodeExporter commented 9 years ago

Original comment by nkors...@google.com on 5 May 2015 at 6:05

GoogleCodeExporter commented 9 years ago
Just a friendly poke on this issue. It's been over a year since it was reported.

Original comment by Paul.Tur...@gmail.com on 19 May 2015 at 5:13

GoogleCodeExporter commented 9 years ago
Just curious - do you see this issue when you have animations disabled? The 
only way we've been able to repro in our environment is to turn animations back 
on.

Original comment by vale...@google.com on 19 May 2015 at 6:36

GoogleCodeExporter commented 9 years ago
I'm getting this issue on emulator with animations disabled. 

Original comment by Paul.Tur...@gmail.com on 19 May 2015 at 6:37

GoogleCodeExporter commented 9 years ago
Here are the details of my flaky test:

Relevant logcat:
D/LifecycleMonitor( 2042): Lifecycle status change: com.app.ActivityA@b18604e8 
in: RESUMED
D/LifecycleMonitor( 2042): running callback: 
com.app.test.BaseTest$ActivityLifeCycleListener@b2f000c0
D/LifecycleMonitor( 2042): callback completes: 
com.app.test.BaseTest$ActivityLifeCycleListener@b2f000c0
I/ActivityManager( 1223): Displayed com.app/ActivtyA: +659ms
I/ViewInteraction( 2042): Performing 'CallOnClick' action on view with id: 
com.app:id/buttonWithPressedStateAnimation
I/ActivityManager( 1223): START u0 {cmp=com.app/ActivtyB (has extras)} from pid 
2042
I/WindowManager( 1223): Screenshot Window{b16c9868 u0 
com.app/com.app.ActivityA} was all black! mSurfaceLayer=21015 minLayer=21000 
maxLayer=21015
E/ViewAssertions( 2042): 'is displayed on the screen to the user' check could 
not be performed because view 'with text: is "Text that is displayed on 
ActivityB"' was not found.
D/LifecycleMonitor( 2042): Lifecycle status change: com.app.ActivityA@b18604e8 
in: PAUSED
D/LifecycleMonitor( 2042): running callback: 
com.app.test.BaseTest$ActivityLifeCycleListener@b2f000c0
D/LifecycleMonitor( 2042): callback completes: 
com.app.test.BaseTest$ActivityLifeCycleListener@b2f000c0
D/LifecycleMonitor( 2042): Lifecycle status change: com.appActivtyB@b2e0f748 
in: PRE_ON_CREATE

Scenario: 
ActivityA launches ActivityB with startActivityForResult.
I use a custom view action, "CallOnClick" to click on the button view that 
launches ActivityB
* I can provide gist link for custom view action, but basically:
* Can't use default click() because espresso bug where click becomes long 
click, which causes animation, which causes tests to stall because ui thread is 
busy. :( (https://code.google.com/p/android-test-kit/issues/detail?id=45)

Relevant test code:
test() {
        onView(withId(R.id.buttonWithPressedStateAnimation)
                .perform(new CallOnClickAction());

        onView(withText("Text that is displayed on ActivityB")).check(matches(isDisplayed()));  //Flaky
}

Let me know if there are additional details that could be helpful, if possible 
I will provide them.

Original comment by jabKnows...@gmail.com on 19 May 2015 at 8:52