landryshuai / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

SeekBar not working #595

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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 reported on code.google.com by kday...@gmail.com on 1 Apr 2014 at 7:19

GoogleCodeExporter commented 9 years ago
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#setProgre
ss(int)

Original comment by renasr...@gmail.com on 15 Apr 2014 at 8:02

GoogleCodeExporter commented 9 years ago
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.

Original comment by kday...@gmail.com on 15 Apr 2014 at 3:16