Android - Video grabbing protocol

Suitest instrumentation library for Android applications can grab video properties in case your application is using Android's VideoView for playing video content. However, if you have implemented your own player or used an external that is not based on the VideoView, Suitest will not be able to recognize the video.

If this is your case, we suggest to adopting the Suitest Video protocol. You will have to ask the developer of the app to conform to the protocol.

Integration

You will need to add a link for Suitest, that will match the video View with its controller.

You can do so by calling:

SuitestInstrumentalApplication.addVideoControllerAndView(SuitestVideoController videoController, View view);

The second parameter is the View to be tested (in a typical implementation, that would be a SurfaceView). The first parameter is an interface that will help Suitest verify the state of the View. It has the following methods:

interface SuitestVideoController {
    int getDuration();
    int getCurrentPosition();
    Util.VideoInfo.State getState();
    String getUrl();
}

Feel free to implement this interface in a way that suits your implementation and coding style. Then, when the video View is created, register it with Suitest and you are ready to test your video implementation. Using SurfaceView as an example, you can register the View and controller within surfaceCreated() method of SurfaceHolder.Callback:

final SurfaceHolder surfaceHolder = getHolder();
if (surfaceHolder != null) {
    surfaceHolder.addCallback(new SurfaceHolder.Callback() {
        @Override
        public void surfaceCreated(SurfaceHolder holder) {
            SuitestInstrumentalApplication.addVideoControllerAndView(getSuitestVideoController(),getSurfaceView());
        }
        @Override
        public void surfaceDestroyed(SurfaceHolder holder) {
            SuitestInstrumentalApplication.removeVideoController(getSurfaceView());
        }
    });
}

When the View is destroyed, unregister its controller (as shown above in surfaceDestroyed), in order to prevent possible memory leaks.