How do I write a Solo/Robotium testcase that uses the builtin camera to take a picture?
Asked Answered
Z

3

2

From my activity I do startActivityForResult(MediaStore.ACTION_IMAGE_CAPTURE),
and then I land in the builtin camera activity (in this case in the emulator).

When I now do:
"solo.clickOnButton(0);"
in my testcase, it does not find ANY button (null is found for index=0).

How do I write a Solo/Robotium testcase that uses the builtin camera to take a picture ?

Zarathustra answered 1/10, 2010 at 14:20 Comment(0)
C
2

according to the Robotium doc you cannot do this as this spans two applications ( your one and the default camera activity ). See http://code.google.com/p/robotium/wiki/QuestionsAndAnswers

You will either need to write your own camera implementation within your package or write two test applications

Hope this helps :)

Curtiscurtiss answered 5/4, 2011 at 13:58 Comment(1)
@Renas said "It has always worked across Activities as long as they belong to the same process." in a comment to https://mcmap.net/q/258783/-how-do-you-test-an-android-application-across-multiple-activitiesHelenehelenka
C
1

What are you trying to achieve is definitely feasible. You are trying to do that via System built-in functionality. Issue here is that user is expected to take picture and confirm that it is valid. Than, result (image URL) is brought back to your activity. So, it is not robotium.

Another approach is to use fact that Android offers you complete control over Camera via

android.hardware.Camera;

It is definitely more demanding approach. But if you use existing example from your Android installation as guideline

android-sdk-windows\samples\android-8\ApiDemos\src\com\example\android\apis\graphics\CameraPreview.java

it should be achievable. Do not forget to declare permissions in your manifest, as descibed in the Camera SDK documentation.

Coreligionist answered 2/10, 2010 at 16:28 Comment(2)
Clarification: The Camera activity is just another activity with views with id's/index. Since I get null back maybe I'm incorrect. I was hoping that someone had already figured out how to click a button inside the emulators default camera application, using Robotium/solo.Zarathustra
Shouldn't it be something like solo.clickOnButton("Done") or solo.clickOnButton("OK")? On a phone click on "Done" terminates the capture.Coreligionist
B
1

Sorry to bump this...

I've just put the camera stub i made / use on the play store... thought might be of use to you / others for testing the camera in automated tests :)

https://play.google.com/store/apps/details?id=com.hitherejoe.CameraStub&hl=en

Blowing answered 5/12, 2013 at 15:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.