RobotiumTech / robotium

Android UI Testing
http://www.robotium.org
Apache License 2.0
2.86k stars 786 forks source link

SeekBar not working #674

Closed renas closed 9 years ago

renas commented 9 years ago

From kday...@gmail.com on April 01, 2014 12:19:28

Im trying to control the seekbar using robotium. but not having any luck. I can control it using the drag function but the problem is that i have to change the x,y coordinate for each phone.

Here is the Main code that I'm using.

@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { // update current location as seek bar is dragged. if (bIsSeeking) mTxtCurrent.setText(DateUtils.formatElapsedTime(progress / 1000)); }

@Override
public void onStartTrackingTouch(SeekBar seekBar)
{       
    SMLog.d(logtitle, "Start Tracking.");

    if( seekBar == mSeekVideo )
        bIsSeeking = true;
    else if( seekBar == mSeekVolume )
        bSeekingVolume = true;
}

@Override
public void onStopTrackingTouch(SeekBar seekBar)
{       
    SMLog.d(logtitle, "Stop Tracking.");
    if( seekBar == mSeekVideo )
    {
        bIsSeeking = false;
        int SeekTo = mSeekVideo.getProgress();
        if( SeekTo == mDuration )
        {
            if (IsVideoLooping())
                DoSeek(SeekTo, false);
            else
            {
                bPlayComplete = true;
                getActivity().finish();
            }
        }
        else
            DoSeek( SeekTo, false );
    }
    else if( seekBar == mSeekVolume )
    {
        int vol = mSeekVolume.getProgress();

        if( vol == 0 )
            MuteVolume(true);
        else
        {
            MuteVolume(false);
            audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
        }

        audioManager.setStreamVolume( AudioManager.STREAM_MUSIC, vol , 0 );
        bSeekingVolume = false;
    }
}

And on the robotium side, this is what im calling

SeekBar seek = (SeekBar) solo.getView(com.securemedia.SMHLSVOD.R.id.seekVideo); NativePlayerFragment Missile = new NativePlayerFragment();

            for (int i=1; i<5; i++) {

                // click on screen so that the seek bar shows    

                // set forward
                Missile.onStartTrackingTouch(seek);
                seek.setProgress(i*3); 
                Missile.onStopTrackingTouch(seek);
                solo.sleep(10000);

                //click on screen so that the seek bar shows
                solo.clickOnScreen(100f, 100f);

                // set back 

                Missile.onStartTrackingTouch(seek);
                seek.setProgress(i*2); 
                Missile.onStopTrackingTouch(seek);
                solo.sleep(10000);
            }

any idea of what I'm doing wrong ?

Original issue: http://code.google.com/p/robotium/issues/detail?id=595

renas commented 9 years ago

From renasr...@gmail.com on April 15, 2014 01:02:10

I'm not sure why your experiencing this issue. Robotium sets the progress directly by using the API setProgress() found here: http://developer.android.com/reference/android/widget/ProgressBar.html#setProgress(int)

Status: Invalid
Owner: renasr...@gmail.com

renas commented 9 years ago

From kday...@gmail.com on April 15, 2014 08:16:34

Thanks renas. The drag command works great but im dealing with different size screen so I will just create a class that has the different size screen and once the the device is sensed, pick the right coordinate.