def testRecordAudio(self): #Launch sound recorder d.start_activity(component='com.smartisanos.recorder/.activity.EmptyActivity') d.sleep(2) d.click(880,1545) assert d(text = '录音机').wait.exists(timeout = 5000),'Launch sound recorder failed in 5s!' #Start record for i in range(3): if i ==3: # kill recorder recorderPID = u.getPID('com.smartisanos.recorder') commands.getoutput('adb shell kill %s'%recorderPID) assert False,'Can not start recording!' d(resourceId = 'com.smartisanos.recorder:id/recorder_main_control_record').click() if d(resourceId='com.smartisanos.recorder:id/recorder_main_control_mark').enabled: break #Record 5s d.sleep(5) #Stop record and then save audio d(resourceId = 'com.smartisanos.recorder:id/recorder_main_control_stop').click.wait() if not d(text = '命名并保存').exists: recorderPID = u.getPID('com.smartisanos.recorder') commands.getoutput('adb shell kill %s'%recorderPID) assert d(text = '命名并保存').wait.exists(timeout=5000),'Save window does not pop-up in 5s!' d(text = '确定').click.wait() #Play the recorded video d(resourceId = 'com.smartisanos.recorder:id/recorder_main_title_list').click.wait() assert d(text = '录音列表').wait.exists(timeout=5000),'Switch audio list failed in 5s!' d(resourceId = 'com.smartisanos.recorder:id/list_item_arrow').click.wait() assert d(resourceId = 'com.smartisanos.recorder:id/recorder_edit_control_play').wait.exists(timeout=5000),'Switch to audio play view failed in 5s!' d(resourceId = 'com.smartisanos.recorder:id/recorder_edit_control_play').click() assert d(resourceId = 'com.smartisanos.recorder:id/recorder_edit_control_pause').wait.exists(timeout=5000),'Play audio failed in 5s!' #play audio time d.sleep(5) #Delete audio before = commands.getoutput('adb shell ls /sdcard/smartisan/Recorder/* | grep wav | wc -l') d(resourceId = 'com.smartisanos.recorder:id/recorder_edit_title_delete').click.wait() assert d(textContains = '确认要删除此音频文件').wait.exists(timeout=5000),'Delete confirmation does not pop-up in 5s!' d(text = '确认删除').click.wait() after = commands.getoutput('adb shell ls /sdcard/smartisan/Recorder/* | grep wav | wc -l') result = string.atoi(before) - string.atoi(after) assert result == 1,'Delete file failed!'
def tearDown(self): u.tearDown() # clear date self._clearDate('/sdcard/DCIM/Camera/*') self._clearDate('/sdcard/smartisan/Recorder/*') # kill recorder recorderPID = u.getPID('com.smartisanos.recorder') if recorderPID == '': pass else: commands.getoutput('adb shell kill %s'%recorderPID)