2015-08-02 5 views
6

Con Espresso provo a scorrere fino a una TextView all'interno LinearLayout - ma sto ottenendo questa eccezione:scorrimento per visualizzare ha tentato di sorprendere la vista non viene visualizzato

android.support.test.espresso.PerformException: Error performing 'scroll to' on view 'with id: 

org.ligi.gobandroid_hd:id/final_points'. 
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83) 
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:70) 
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:53) 
at reporting.SpooningFailureHandler.handle(SpooningFailureHandler.java:31) 
at android.support.test.espresso.ViewInteraction.runSynchronouslyOnUiThread(ViewInteraction.java:184) 
at android.support.test.espresso.ViewInteraction.doPerform(ViewInteraction.java:115) 
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:87) 
at org.ligi.gobandroidhd.uitest.TheGameScoringActivity.testThatTapToMarkWorks(TheGameScoringActivity.java:65) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
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 android.support.test.internal.runner.junit3.DelegatingTestResult.runProtected(DelegatingTestResult.java:90) 
at junit.framework.TestResult.run(TestResult.java:118) 
at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:49) 
at junit.framework.TestCase.run(TestCase.java:124) 
at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63) 
at junit.framework.TestSuite.runTest(TestSuite.java:243) 
at junit.framework.TestSuite.run(TestSuite.java:238) 
at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103) 
at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:63) 
at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90) 
at org.junit.runners.Suite.runChild(Suite.java:128) 
at org.junit.runners.Suite.runChild(Suite.java:27) 
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) 
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) 
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) 
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) 
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) 
at org.junit.runners.ParentRunner.run(ParentRunner.java:363) 
at org.junit.runner.JUnitCore.run(JUnitCore.java:137) 
at org.junit.runner.JUnitCore.run(JUnitCore.java:115) 
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54) 
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:228) 
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853) 
Caused by: java.lang.RuntimeException: Scrolling to view was attempted, but the view is not displayed 
at android.support.test.espresso.action.ScrollToAction.perform(ScrollToAction.java:66) 
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:144) 
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:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:135) 
at android.app.ActivityThread.main(ActivityThread.java:5257) 
at java.lang.reflect.Method.invoke(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:372) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

manualmente posso scorrere fino a questo punto di vista.

+0

Se viene visualizzata la tastiera può anche causare l'errore poiché la vista che scorre a non è visibile all'utente. Ad esempio, dopo aver eseguito 'editText()' la tastiera sarà visibile. – hexicle

risposta

10

Il problema si verifica quando lo ScrollView ha un riempimento: lo ha assegnato al layout all'interno dello ScrollView e tutto funziona correttamente. Forse un bug nel calcolo delle coordinate.

Ad esempio:

code change

+1

Appare anche quando la scrollview non ce l'ha: · (Succede con questo ScrollView non imbottito: https://gist.github.com/rocboronat/a00a76c4af63d23495b6a1237ef6113b –

+0

@ligi Come risolvere questo problema? Puoi condividere un campione codice? –

Problemi correlati