java – adb touchscreen swipe fail in a call-ThrowExceptions

Exception or error:

I’m trying to simulate a auto video call with adb using touches and swipes.
The scenario:

Device1 audio calls Device2, Device2 answers, Device1 asks for video call(bidirectional), Device2 tries to answer and fails.
The wired thing is that sometimes it works but most of the it fails on that point when the device2 trying to answer via adb swipe.

here is the code:

@Test(timeout = 60000000)
    /**
     *
     */
    @TestProperties(name = "Video call / Normal video call")
    public void VT111_0011() throws InterruptedException, IOException, AWTException {
        initTestVariable("Normal_Video_Call_Test_VT111_0011");
        sleep(idleBeforeTest);
        System.out.println("Starting normal video test");
        Android.adbCommand(secondDevice.getDevice1(), "adb -s " + secondDevice.getDeviceID() + " shell input touchscreen swipe 355 858 590 858");

        for(int i=0; i<Iteration; i++) {
            moveMouse();
            Jsystem.broadCastMessage("\nIteration " + i, globalVar.nameForLogFile);
            cleanLogs();
            firstDevice.call(secondDevice);
            Thread.sleep(2000);
            if(secondDevice.isRinging())
                secondDevice.answerCall(1000);
            else{
                ringingFail();
            }

            // Start video by gui
            Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 650 380");
            Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 420 470");
            Thread.sleep(1000);
            Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 197 780"); // 197 920 Video bidirectional
            Thread.sleep(5500);
            // Device2 answers video
            Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 355 858"); // 197 920 Video bidirectional
            Android.adbCommand(secondDevice.getDevice1(), "adb -s " + secondDevice.getDeviceID() + " shell input touchscreen swipe 355 858 590 858");
            Thread.sleep(200);
            Android.adbCommand(firstDevice.getDevice1(),"adb -s " + firstDevice.getDeviceID() + " shell input tap 60 372");
            Android.adbCommand(secondDevice.getDevice1(),"adb -s " + secondDevice.getDeviceID() + " shell input tap 60 372");


        /*  Thread.sleep(5000);
            if((!firstDevice.isInCall()) || (!secondDevice.isInCall())){
                inCallFail();
                continue;
            } */
            int failsCounter = 0;
            VerifyVideo verifyVideo = new VerifyVideo(); 
            for(int j = 8; j<10; j++){
                if(verifyVideo.verrfiyVideo(firstDevice, secondDevice) == false)
                    failsCounter++;
            }
            if(failsCounter>2) {
                Jsystem.broadCastMessage("****** TEST FAILED, VIDEO DOSENT WORK GOOD ENOUGH ****** " , globalVar.nameForLogFile); 
                System.out.println("Number of fails: " + failsCounter);
                comparePhototsFail();
            }

            firstDevice.endCall();
            secondDevice.endCall();
            sleep(TimeBetweenIteration);

        }

    }

Any ideas?
Thanks.

How to solve:

Try add duration to swipe:

adb shell input touchscreen swipe <x1> <y1> <x2> <y2> [duration(ms)]

Leave a Reply

Your email address will not be published. Required fields are marked *