简体   繁体   中英

android unit test for verify mediaplayer

I need to write unit test for android media player, that verify that MediaPlayer's class method call or not.

@Override
public void setAssetPath(String path) throws IOException {
    if(!this.path.equals(path)){
        this.path = path;
        mediaPlayer.setDataSource(path);
    }
}

@Override
public void play() {
    if(mediaPlayer == null){
        return;
    }
    mediaPlayer.start();
}

@Override
public void pause() {
    if (mediaPlayer.isPlaying()) {
        mediaPlayer.pause();
    }
}

Based on my own research I found the solution for that. this link provides the solution of change private variable of class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM