Closed GoogleCodeExporter closed 9 years ago
public class ScreenshotsTaker extends
ActivityInstrumentationTestCase2<PianoFragmentActivity> {
private Solo solo;
public ScreenshotsTaker() {
super(PianoFragmentActivity.class);
}
@Override
protected void setUp() throws Exception {
Config config = new Config();
// config.screenshotFileType = ScreenshotFileType.PNG;
// config.screenshotSavePath = Environment.getExternalStorageDirectory() +
"/RobotiumTest/";
solo = new Solo(getInstrumentation(), config);
getActivity();
super.setUp();
}
public void testTakeScreenshots() throws Exception
{
View scrollbarpiano = getActivity().findViewById(R.id.scrollbar_piano);
int[] xy = new int[2];
scrollbarpiano.getLocationOnScreen(xy);
int centerx = (scrollbarpiano.getWidth() / 2) + xy[0];
int centery = (scrollbarpiano.getHeight() / 2) + xy[1];
solo.clickOnScreen(centerx, centery);
solo.sleep(1000);
solo.takeScreenshot();
}
}
Original comment by goo...@umito.nl
on 23 Feb 2014 at 2:39
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="***.test"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8" />
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="***" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="android.test.runner" />
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
</manifest>
Original comment by goo...@umito.nl
on 23 Feb 2014 at 2:41
Target package has also android.permission.WRITE_EXTERNAL_STORAGE permission
set.
Original comment by goo...@umito.nl
on 23 Feb 2014 at 2:41
It looks like I finally got it working by disabling Hardware Acceleration in
the target app. It looks like HW accel interferes with Robotium's ability to
take screenshots. Is this a known issue?
Original comment by goo...@umito.nl
on 23 Feb 2014 at 2:58
Unfortunately it still stops working after a few tries. Files just don't get
saved.
Original comment by goo...@umito.nl
on 23 Feb 2014 at 3:10
It turns out it is due to having the solo.takeScreenshot() method as last
method in the testsuite. When I add a solo.sleep(1000) after the last
screenshot call it saves ok, even with HW accel on. I guess it's due to
threading issue, where the screenshots are taken on a thread, while the test
finishes and kills the testrunner, taking the screenshot thread with it. Maybe
handle this more properly?
Original comment by goo...@umito.nl
on 23 Feb 2014 at 3:22
Thanks for reporting this. Lets see what we can do to improve it.
Original comment by renasr...@gmail.com
on 24 Feb 2014 at 3:01
Thanks again for reporting this. This has been fixed in Robotium 5.2.1.
Original comment by renasr...@gmail.com
on 18 Jun 2014 at 3:12
Ok, great! What was the solution?
Original comment by goo...@umito.nl
on 18 Jun 2014 at 6:53
We lock the instrumentation thread until the screenshot thread has finished.
Thus preventing what could happen previously.
Original comment by renasr...@gmail.com
on 19 Jun 2014 at 4:35
Original issue reported on code.google.com by
goo...@umito.nl
on 23 Feb 2014 at 2:38