How to use test_wakeup method in uiautomator

Best Python code snippet using uiautomator

yuyinchangshouge.py

Source:yuyinchangshouge.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import urllib23import urllib4import cookielib5import json6import os7import sys8import string9import time10import md511import hashlib12reload(sys)13sys.setdefaultencoding('utf-8')14# first url request15def yuyinchangshouge():16 sn=" -s 1011000000111007 "17 pslogcat="adb "+ sn +"shell \"ps |grep logcat\""18 output = os.popen(pslogcat)19 output = output.read()20 if "root" not in output:21 print "There is not logcat process"22 else:23 str = output.split("root")24 val = str[1]25 val = val.lstrip()26 val = val.split(" ")27 pid = val[0]28 command="adb "+ sn + "shell kill -9 "+ pid29 print command30 os.system(command) 31 rmlog="adb "+ sn +"shell \"rm -fr /sdcard/yuyinchangshouge.log \""32 os.system(rmlog)33 cppcm="adb "+ sn +"shell \"busybox cp /sdcard/nihao.pcm /sdcard/test_wakeup.pcm \""34 os.system(cppcm)35 pidstart = 036 while(pidstart<1):37 pidlogcat="adb "+ sn +"shell \"busybox nohup logcat -v time -f /sdcard/yuyinchangshouge.log & \""38 test=os.popen(pidlogcat)39 time.sleep(3)40 test=test.read()41 if "nohup" in test:42 pidstart = 143 print 'logcat successful'44 else:45 print "logcat failed"46 time.sleep(5)47 48 wakeup = 049 while(wakeup<1):50 amcommand="adb "+ sn +"shell \"am startservice -n com.juan.voiceservice/com.juan.audio.service.TestWakeUpService\""51 os.system(amcommand)52 time.sleep(3)53 checkloghx="adb "+ sn +"shell \"cat /sdcard/yuyinchangshouge.log |grep -E '唤醒|你好'\""54 output = os.popen(checkloghx)55 res= output.read()56 print "huanxin score:",res57 if '唤醒词' in res or '你好布丁' in res:58 wakeup = 159 print 'wakeup successful'60 else:61 print 'wakeup failed'62 63 time.sleep(10) 64 cpclock="adb "+ sn +"shell \"busybox cp /sdcard/changsg.pcm /sdcard/test_wakeup.pcm \""65 os.system(cpclock)66 os.system(amcommand)67 time.sleep(10)68 69 checklogclock="adb "+ sn +"shell \"cat /sdcard/yuyinchangshouge.log |grep paramJasonStr\""70 output = os.popen(checklogclock)71 time.sleep(3)72 res= output.read()73 print "changshouge logcat",res74 if 'singer' in res:75 print 'set changshouge successful';76 else:77 print 'set changshouge failed'78 return False79 80 time.sleep(3)81 82 wakeup = 083 while(wakeup<1):84 cppcm="adb "+ sn +"shell \"busybox cp /sdcard/nihao.pcm /sdcard/test_wakeup.pcm \""85 os.system(cppcm)86 amcommand="adb "+ sn +"shell \"am startservice -n com.juan.voiceservice/com.juan.audio.service.TestWakeUpService\""87 os.system(amcommand)88 time.sleep(3)89 checkloghx="adb "+ sn +"shell \"cat /sdcard/yuyinchangshouge.log |grep score\""90 output = os.popen(checkloghx)91 res= output.read()92 print "daduan score:",res93 if 'wakeup' in res:94 wakeup = 195 print 'daduan successful'96 else:97 print 'daduan failed'98 99 time.sleep(3)100 sleep = 0101 while(sleep<1):102 cpbye="adb "+ sn +"shell \"busybox cp /sdcard/bye.pcm /sdcard/test_wakeup.pcm \""103 os.system(cpbye)104 os.system(amcommand)105 time.sleep(3)106 checklogsleep="adb "+ sn + "shell \"cat /sdcard/yuyinchangshouge.log |grep paramJasonStr\""107 sleepoutput = os.popen(checklogsleep)108 res= sleepoutput.read() 109 print "sleep logcat",res110 if 'sleep' in res:111 print 'sleep successful';112 sleep=1113 else:114 print "sleep failed"115 116 time.sleep(1)117 output = os.popen(pslogcat)118 output = output.read()119 if "root" in output:120 str = output.split("root")121 val = str[1]122 val = val.lstrip()123 val = val.split(" ")124 pid = val[0]125 killpid="adb "+ sn +"shell kill -9 "+ pid126 os.system(killpid)127 return True 128 129 ...

Full Screen

Full Screen

standby_wakeup.py

Source:standby_wakeup.py Github

copy

Full Screen

...37 if time_out_wakeup is None:38 time_out_wakeup = stbt.get_config("standby",39 "time_out_wakeup_fom_deep_standby",40 type_=int)41 assert sc_stbt.test_wakeup(sc_stbt.is_wakeup, time_out_wakeup), \42 ("PROBLEM IN WAKE_UP")43def set_wakeup_from_fake_standby():44 # SET WAKE UP AFTER FAKE_STANDBY45 """46 :param time_out_wakeup: time needed to wake up the STB47 :return: True : if wake up achieved before timeout ends48 False : if wake up not detected , or timeout ends49 """50 sc_stbt.wait(5)51 assert sc_stbt.test_wakeup(sc_stbt.is_wakeup), \52 ("PROBLEM IN WAKE_UP")53def test_set_wakeup(time_out_wakeup=None):54 """55 Funtion:set the STB on wakeup status56 :return: Fail if stb is already wakeup57 """58 sc_stbt.wait(1)59 print "iiiiiiiiiiiiiiiiiiiiiiii"60 assert sc_stbt.test_wakeup(timeout=time_out_wakeup),"WAKEUP ACTION NOT DONE"61###########################################62# #Standby63###########################################64def test_set_standby(time_out_standby=None):65 """66 Funtion:set the STB on standby status67 Precondition: STB should be on wake up to launch this test68 :return: Fail if set_standby() fail69 """70 sc_stbt.wait(1)71 if time_out_standby is None:72 time_out_standby = stbt.get_config("standby",73 "time_out_standby",74 type_=int)...

Full Screen

Full Screen

lab3-02-wakeup.py

Source:lab3-02-wakeup.py Github

copy

Full Screen

1#!/usr/bin/python2import tester3import sys4import time5def experiment(test):6 test.start_program('./test_wakeup')7 start_time = time.time()8 test.lookA('starting wakeup test', 0);9 test.lookA('initial thread returns from sleep\(NULL\)', 1);10 test.lookA('initial thread returns from sleep\(NONE\)', 1);11 result = test.lookA('wakeup test done', 4);12 if (result < 0):13 return14 end_time = time.time()15 diff_time = end_time - start_time16 if (diff_time <= 6.0):17 print 'ERROR: total run time = ' + str(diff_time) + \18 ' should be greater than 6 seconds'19 else:20 test.add_mark(2)21 if test.wait_until_end():22 test.add_mark(2) 23def main():24 mark = 1025 test = tester.Core('wakeup test', mark)26 print 'running ' + str(test.nr_times) + ' times'27 for i in range(test.nr_times):28 experiment(test)29 test.program.close()30 mark = min(mark, test.get_mark())31 test.reset_mark()32 test.add_mark(mark)33if __name__ == '__main__':34 main()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run uiautomator automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful