Exemple #1
0
    def __init__(self, step_id, par_dict, dev_dict1, crt, caseFolderName, all_monitor_thread_dict, stepType, platform):
        self.step_id = step_id
        self.dict = par_dict
        self.dict1 = dev_dict1
        self.crt = crt
        self.stepType = stepType
        self.platform = platform
        
        print "Parameter List: "
        for key in self.dict:
            print key , ": " , self.dict[key]
        print ""
        self.rt_dict = {}
        
        crt_list = list(crt)
        print "Pass Criterion: "
        crt_exist = 0
        for crt_no in crt_list:
            if cmp(crt_no.text,'Off'):
                print crt_no.tag, crt_no.text
                crt_exist = 1
        if crt_exist == 0:
            print "None"
        print ''

        from tools.client import adbAccessor as accessor
        self.cli = accessor(self.dict1)
        self.Clip_Path = get_clip_path()
Exemple #2
0
    def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName,
                 all_monitor_thread_dict, stepType, platform):
        self.step_id = step_id
        self.dict = par_dict
        self.dict1 = dev_dict
        self.crt = crt
        self.caseFolderName = caseFolderName
        self.stepType = stepType
        self.platform = platform
        self.all_monitor_thread_dict = all_monitor_thread_dict

        print "Parameter List: "
        for key in self.dict:
            if key == "VideoCodec":
                self.videocodec = self.dict[key]
            elif key == "Resolution":
                self.resolution = self.dict[key]
            elif key == "Duration":
                self.duration = self.dict[key]
            elif key == "Bitrate":
                self.bitrate = self.dict[key]
            elif key == "FPS":
                self.fps = self.dict[key]

            print key, ": ", self.dict[key]
            print ""
        self.rt_dict = {}

        crt_list = list(crt)
        print "Pass Criterion: "
        crt_exist = 0
        for crt_no in crt_list:
            if cmp(crt_no.text, 'Off'):
                print crt_no.tag, crt_no.text
                crt_exist = 1
        if crt_exist == 0:
            print "None"
        print ''
        if not self.dict1.get('Connect', ''):
            raise TestException(
                "Error: no Connect element found in device's profile, while running"
            )
        if not self.dict1.get('Connect', '') in ['ssh', 'adb']:
            raise TestException(
                "Error: the text of Connect element should be ssh or adb in device's profile "
            )
        if not cmp(self.dict1['Connect'], 'ssh'):
            self.prefix = ''
            from tools.client import sshAccessor as accessor

        if not cmp(self.dict1['Connect'], 'adb'):
            self.prefix = '/system/bin/'
            from tools.client import adbAccessor as accessor

        self.cli = accessor(self.dict1)
        self.Clip_Path = get_clip_path()
Exemple #3
0
    def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform):
        self.step_id = step_id
        self.dict = par_dict
        self.dict1 = dev_dict
        self.crt = crt
        self.caseFolderName = caseFolderName
        self.stepType = stepType
        self.platform = platform
        self.all_monitor_thread_dict = all_monitor_thread_dict
         
        print "Parameter List: "
        for key in self.dict:
            if key == "VideoCodec":
                self.videocodec = self.dict[key]
            elif key == "Resolution":
                self.resolution = self.dict[key]
            elif key == "Duration":
                self.duration = self.dict[key]
            elif key == "Bitrate":
                self.bitrate = self.dict[key]
            elif key == "FPS":
                self.fps = self.dict[key]

            print key , ": " , self.dict[key]
            print ""
        self.rt_dict = {}
        
        crt_list = list(crt)
        print "Pass Criterion: "
        crt_exist = 0
        for crt_no in crt_list:
            if cmp(crt_no.text,'Off'):
                print crt_no.tag, crt_no.text
                crt_exist = 1
        if crt_exist == 0:
            print "None"
        print ''
        if not self.dict1.get('Connect', ''):
            raise TestException("Error: no Connect element found in device's profile, while running")
        if not self.dict1.get('Connect', '') in ['ssh', 'adb']:
            raise TestException("Error: the text of Connect element should be ssh or adb in device's profile ")            
        if not cmp(self.dict1['Connect'], 'ssh'):
            self.prefix = ''  
            from tools.client import sshAccessor as accessor

        if not cmp(self.dict1['Connect'], 'adb'):
            self.prefix = '/system/bin/'
            from tools.client import adbAccessor as accessor

        self.cli = accessor(self.dict1)
        self.Clip_Path = get_clip_path()
Exemple #4
0
    def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform):
        self.step_id = step_id
        self.par_dict = par_dict
        self.dev_dict = dev_dict
        self.crt = crt
        self.caseFolderName = caseFolderName
        self.stepType = stepType
        self.platform = platform
        self.all_monitor_thread_dict = all_monitor_thread_dict
 
        print "Parameter List: "
        for key in self.par_dict:
            if key.strip() == 'InputFile':
                if self.par_dict[key].find('http:') != -1 or self.par_dict[key].find('rtp:') != -1:
                    new_url = self.get_http_url(self.par_dict[key])
                    print key, ': ', new_url
                else:
                    print key , ": " , self.par_dict[key]
            else:
                print key , ": " , self.par_dict[key]
        print ""
        self.rt_dict = {}
        
        crt_list = list(crt)
        print "Pass Criterion: "
        crt_exist = 0
        for crt_no in crt_list:
            if cmp(crt_no.text,'Off'):
                print crt_no.tag, crt_no.text
                crt_exist = 1
        if crt_exist == 0:
            print "None"
        print ''
        if not self.dev_dict.get('Connect', ''):
            raise TestException("Error: no Connect element found in device's profile, while running")
        if not self.dev_dict.get('Connect', '') in ['ssh', 'adb']:
            raise TestException("Error: the text of Connect element should be ssh or adb in device's profile ")            
        if not cmp(self.dev_dict['Connect'], 'ssh'):
            self.prefix = ''  
            from tools.client import sshAccessor as accessor

        if not cmp(self.dev_dict['Connect'], 'adb'):
            self.prefix = '/system/bin/'
            from tools.client import adbAccessor as accessor

        self.cli = accessor(self.dev_dict)
        self.Clip_Path = get_clip_path()
Exemple #5
0
 def __init__(self, step_id, par_dict, dev_dict, crt, caseFolderName, all_monitor_thread_dict, stepType, platform):
     self.step_id = step_id
     self.par_dict = par_dict
     self.dev_dict = dev_dict
     self.crt = crt
     self.caseFolderName = caseFolderName
     self.stepType = stepType
     self.all_monitor_thread_dict = all_monitor_thread_dict
     self.platform = platform
     
     print "Parameter List: "
     for key in self.par_dict:
         print key , ": " , self.par_dict[key]
     print ""
     
     self.rt_dict = {}
     crt_list = list(crt)
     print "Pass Criterion: "
     crt_exist = 0
     for crt_no in crt_list:
         if cmp(crt_no.text.strip().lower(),'off'):
             print crt_no.tag, crt_no.text
             crt_exist = 1
     if crt_exist == 0:
         print "None"
     print ''
     
     if not self.dev_dict.get('Connect', ''):
         raise TestException("Error: no Connect element found in device's profile, while running")
     if not self.dev_dict.get('Connect', '') in ['ssh', 'adb']:
         raise TestException("Error: the text of Connect element should be ssh or adb in device's profile ")            
     if not cmp(self.dev_dict['Connect'], 'ssh'):
         self.prefix = ''  
         from tools.client import sshAccessor as accessor
     elif not cmp(self.dev_dict['Connect'], 'adb'):
         self.prefix = '/system/bin/'
         from tools.client import adbAccessor as accessor
     self.cli = accessor(self.dev_dict)
     self.Clip_Path = get_clip_path()
Exemple #6
0
 def capture(self):
     
     SOURCE_CLIP_PATH = '/sdcard/DCIM/Camera/'
     TARGET_CLIP_PATH = get_clip_path() + self.par_dict['Format'] + '/'
     self.cli.execute("rm -rf " + SOURCE_CLIP_PATH + '*')
     self.cli.execute("mkdir -p " + TARGET_CLIP_PATH)
     sensor_flag = self.par_dict.get('Sensor', ' ')
     if sensor_flag is None or sensor_flag.strip() == '' or sensor_flag.strip().lower() not in ['front', 'back']:
         raise TestException('ERROR: No Sensor element found or the value of Sensor element should be Front or Back')
     if sensor_flag.lower() == 'front':
         sensor_resolution = FRONT_SENSOR_RESOLUTION
         script_pre = 'Default_Cam_Front_'
     else:
         sensor_resolution = BACK_SENSOR_RESOLUTION
         script_pre = 'Default_Cam_Back_'
     resolution = self.par_dict.get('Resolution', '')
     if resolution.strip() == '1080p_modified':
         self.cli.execute_on_host('root')
         self.cli.execute_on_host('remount')
         self.cli.upload('resource/settings/media_profiles.xml', '/etc/')
         self.cli.execute_on_host('reboot')
         time.sleep(120)
         self.cli.execute('svc power stayon usb')
         execute_command_on_server('./resource/settings/unlock.sh ' + self.dev_dict['serialNumber'], False)
     if resolution is None or resolution.strip() == '' or resolution.strip() not in sensor_resolution:
         raise TestException("Error:  no Resolution element found or the value of Resolution element  must be the value in " + ','.join(sensor_resolution))
     if self.platform is None:
         script_folder = 'MFLD'
     elif self.platform.lower() == 'ctp':
         script_folder = 'CTP'
     cmd = 'am start -n com.android.camera/.Camera'
     self.cli.execute(cmd)
     cmd = 'resource/monkeyrunner/scripts/monkey_playback.py ' + ' resource/video_caputure_script/' + script_folder + '/default_camera/' + script_pre + resolution.strip() + '.mr'
     print cmd
     stdout, stderr = execute_command_on_server(cmd, False)
     # press back key, and exit camera UI
     cmd = 'input keyevent 4'
     self.cli.execute(cmd)
     self.cli.execute(cmd)
     # get the clip name for mediainfo
     stdout, stderr = self.cli.execute("ls -al " + SOURCE_CLIP_PATH + ' | grep ^-')
     dirList = stdout.split('\n')
     outputName = ''
     for eachdir in dirList:
         outputName = outputName + (eachdir.split(' ')[-1])
     outputName = outputName.strip()
     #pull the clip to test_repo
     os.system("mkdir -p " + path.resultClip_path + '/' + self.caseFolderName + '/')
     self.cli.execute('mv '+ SOURCE_CLIP_PATH + outputName + ' ' + TARGET_CLIP_PATH)
     
     #rename clip
     try:
         cmd = 'mv ' + TARGET_CLIP_PATH + '/' + outputName + ' ' + TARGET_CLIP_PATH + '/' + self.par_dict['InputFile'].strip()
     except KeyError:
         raise TestException("Error: no InputFile element found.")
     self.cli.execute(cmd)
     self.cli.download(TARGET_CLIP_PATH +  self.par_dict['InputFile'].strip() + " ", path.resultClip_path + '/' + self.caseFolderName + '/')
     
     #obtain mediainfo result on result clip            
     mediainfo_dict = parseMediaInfo(path.resultClip_path + '/' + self.caseFolderName + '/' +  self.par_dict['InputFile'].strip())
     
     if mediainfo_dict.get('Resolution').strip() != RESOLUTION_DICT.get(resolution).strip():
         raise TestException("Error: recorded clip's resolution" + mediainfo_dict.get('Resolution').strip() + " isn't right with criteria: " + resolution)
Exemple #7
0
            from tools.client import adbAccessor as accessor
        self.cli = accessor(self.dict1)
        self.Clip_Path = get_clip_path()

    def jpeg_decode(self):
        try:
            inputFile = self.dict['InputFile'].strip()
        except KeyError, e:
            raise TestException(
                "Error: no InputFile element found in Parameter element")
        try:
            OutputFile = self.dict['OutputFile'].strip()
        except KeyError, e:
            raise TestException(
                "Error: no OutputFile element found in Parameter element")
        prefix = get_clip_path() + 'Image/'

        result_path = get_result_path() + 'JPEG_Decode/'
        mkdir_cmd = 'mkdir -p ' + result_path
        self.cli.execute_test(mkdir_cmd, self.step_id)
        cmd = 'djpeg -bmp ' + prefix + inputFile + ' ' + result_path + OutputFile
        self.cli.execute_test(cmd, self.step_id)
        stdout, stderr = self.cli.execute_test(
            'cksum ' + result_path + OutputFile, self.step_id)
        bmp_crc = stdout.split('/')[0].strip()
        self.rt_dict.setdefault('Image_CRC', bmp_crc)
        self.rt_dict.setdefault('cmd', cmd)

        if self.stepType == 0 or self.stepType == 30:
            if self.stepType == 30:
                return "noResult"
Exemple #8
0
            raise TestException("Error: no serialNumber element found in device profile")
        
        if self.stepType == 0 or self.stepType == 10:
            if self.stepType == 10:
                return "noResult"
        
        if self.stepType == 0 or self.stepType == 20:
            #execute
#            format = self.dict['Format']
#            try:
#                input_file_path = self.Clip_Path + self.dict['Format'] + '/' + self.dict['InputFile']
#            except KeyError:
#                raise TestException("Error: no InputFile element found in Parameter element ")
#            self.check_clip_exist_in_dut(input_file_path, serialNo)
            
            print SCRIPT_PATH + scriptName + ' ' + serialNo + ' ' + itera + ' ' + get_clip_path() + " | tee log" + str(self.step_id)
            status, output = commands.getstatusoutput(SCRIPT_PATH + scriptName + ' ' + serialNo + ' ' + itera + ' ' + get_clip_path() + " | tee log" + str(self.step_id))
                        
            #parse output
            if output.find("No such file or directory") != -1:
                print inred("Shell file not found!")
                result = 126
            elif output.find("device not found") != -1:
                print inred("Adb connection error: device not found!")
                result = 127
            else:
                result = output.split('\n')[-1].replace(' ', '').replace('\r', '')
                
            try:
                outfile = open('log' + str(self.step_id), 'r') 
            except IOError, e:
Exemple #9
0
 clips_eles = url_ele.findall('Clip')
 if len(clips_eles) == 0:
     return "No clip need to download"
 
 for each_ele in clips_eles:
     address = each_ele.text
     if address is None:
         print inred("Clip value is empty, download canceled.")
         continue
     # check if the clip exist, we should use the format in Parameter element, to keep consistent with test module
     format = root.find('Step').find('Parameter').find('Format').text
     inputFile = address.split('/')[-1]
     
     # check if the clip directory exist
     cli = accessor(dev_dict)
     stdout, stderr = cli.execute("test -d " + get_clip_path() + format + "/ && echo 'Directory exists' || echo 'Directory not found'")
     if str(stdout).strip() == 'Directory not found':
         cli.execute("mkdir -p " + get_clip_path() + format + '/')
     # check if clip exist
     stdout, stderr = cli.execute("test -f " + get_clip_path() + format + '/' + inputFile + " && echo 'File exists' || echo 'File not found'")
     if str(stdout).strip() == 'File exists':
         result = check_file_size_in_dut(dev_dict, get_clip_path() + format + '/' + inputFile)
         if result == 'pass':
             continue
         else:
             cli.execute("rm -rf " + get_clip_path() + format + '/' + inputFile)
             
     download_result = 'fail'
     download_count = 0
     while download_result == 'fail':
         download_result = download_clip(address)
Exemple #10
0
                 
 def jpeg_encode(self):
     
     for item in self.dict:
         if self.dict[item] == None:
             raise TestException("Error: No text in element '" + item + "', please check the case profile.")
         
     try:
         inputFile = self.dict['InputFile']
     except KeyError, e:
         raise TestException("Error: no InputFile element found in Parameter element")
     try:
         OutputFile = self.dict['OutputFile']
     except KeyError, e:
         raise TestException("Error: no OutputFile element found in Parameter element")
     prefix = get_clip_path() + 'Image/'
     try:
         resolution = self.dict['Resolution']
     except KeyError, e:
         raise TestException("Error: no Resolution element found in Parameter element")
     rl = self.dict['Resolution'].split("x")
     if len(rl) != 2:
         raise TestException("Error: the text of Resolution must be in the format like 120x340, 120 means width, and 340 means height ")
     width = rl[0]
     height = rl[1]
     try:
         Quality = self.dict['Quality']
     except KeyError, e:
         raise TestException("Error: no Quality element found in Parameter element")
     
     if self.dict['FrameCount'] is None or not cmp(self.dict['FrameCount'],'Off'):
Exemple #11
0
            self.prefix = '/system/bin/'
            from tools.client import adbAccessor as accessor
        self.cli = accessor(self.dict1)
        self.Clip_Path = get_clip_path()

    
    def jpeg_decode(self):
        try:
            inputFile = self.dict['InputFile'].strip()
        except KeyError, e:
            raise TestException("Error: no InputFile element found in Parameter element")
        try:
            OutputFile = self.dict['OutputFile'].strip()
        except KeyError, e:
            raise TestException("Error: no OutputFile element found in Parameter element")
        prefix = get_clip_path() + 'Image/'
        
        result_path = get_result_path() + 'JPEG_Decode/'
        mkdir_cmd = 'mkdir -p ' + result_path
        self.cli.execute_test(mkdir_cmd, self.step_id)
        cmd = 'djpeg -bmp ' + prefix + inputFile + ' ' + result_path + OutputFile
        self.cli.execute_test(cmd, self.step_id)
        stdout, stderr = self.cli.execute_test('cksum ' + result_path + OutputFile, self.step_id)
        bmp_crc = stdout.split('/')[0].strip()
        self.rt_dict.setdefault('Image_CRC', bmp_crc)
        self.rt_dict.setdefault('cmd', cmd)
            
        if self.stepType == 0 or self.stepType == 30:
            if self.stepType == 30:
                return "noResult"
            
Exemple #12
0
        for item in self.dict:
            if self.dict[item] == None:
                raise TestException("Error: No text in element '" + item +
                                    "', please check the case profile.")

        try:
            inputFile = self.dict['InputFile']
        except KeyError, e:
            raise TestException(
                "Error: no InputFile element found in Parameter element")
        try:
            OutputFile = self.dict['OutputFile']
        except KeyError, e:
            raise TestException(
                "Error: no OutputFile element found in Parameter element")
        prefix = get_clip_path() + 'Image/'
        try:
            resolution = self.dict['Resolution']
        except KeyError, e:
            raise TestException(
                "Error: no Resolution element found in Parameter element")
        rl = self.dict['Resolution'].split("x")
        if len(rl) != 2:
            raise TestException(
                "Error: the text of Resolution must be in the format like 120x340, 120 means width, and 340 means height "
            )
        width = rl[0]
        height = rl[1]
        try:
            Quality = self.dict['Quality']
        except KeyError, e: