def make_vcf_file(self, num_per_file=1, num_of_files=1): ''' Make vcf files. 1. num_per_file: The num of contacts in ech file. 2. num_of_files: The num of vcf files. ''' print "[Info] ---Make vcf file." from testlib.common.base import getTmpDir tmp_path = getTmpDir() vcf_file = tmp_path + os.sep + "test.vcf" if os.path.isfile(vcf_file): os.remove(vcf_file) file_obj = open(vcf_file, 'w') for i in range(num_per_file): vcf_contact = "BEGIN:VCARD\nVERSION:2.1\nN:;contact%03d;;;\nFN:contact%03d\nEND:VCARD\n" % ( i, i) file_obj.write(vcf_contact) file_obj.close() assert os.path.isfile(vcf_file) os.system("adb shell rm /sdcard/*.vcf >/dev/null 2>&1") push_cmd = "adb push %s /sdcard/ >/dev/null 2>&1" % vcf_file os.system(push_cmd) os.remove(vcf_file) for i in range(num_of_files): copy_cmd = "adb shell cp /sdcard/test.vcf /sdcard/test%04d.vcf" % ( i + 1) os.system(copy_cmd) os.system("adb shell rm /sdcard/test.vcf >/dev/null 2>&1") os.system("rm -rf %s >/dev/null 2>&1" % tmp_path)
def setUp(self): print "[Setup]:%s" % self.__class__.__name__ super(VsyncFPSTool, self).setUp() self.tmpdir = getTmpDir() self.systemui = SystemUiExtendImpl() self.benchmark = GLBenchmarkExtendImpl() self._glBenchmark = GLBenchmarkImpl()
def find_icon(self, filename, timeout=3, error="can not get the picture"): from testlib.common.base import getTmpDir if_getpic_succeed = False time = 0 base_path = os.path.split(os.path.realpath(__file__))[0].split(os.sep) pics_path = (os.sep).join(base_path + ['pics', '']) if timeout > 8: timeout = 3 x = self.d.info["displayWidth"] y = self.d.info["displayHeight"] mycomp = igascomparator() region = matchedregion_s() base_filename = filename next = 2 toEnd = False swipetime = 1 sleep(2) screenshotPath = getTmpDir() if not os.path.exists(screenshotPath): os.mkdir(screenshotPath) screenshotPath = os.path.join(screenshotPath, "screenshot.png") while region.center_x == 0 and region.center_y == 0 and time < timeout: verifyImage(pics_path + filename) for eachTry in range(3): try: g_common_obj.take_screenshot(screenshotPath) verifyImage(screenshotPath) sleep(2) break except BaseException, e: if eachTry == 2: raise print e print "screen shot failed, try again!" mycomp.findpattern(pics_path + filename, screenshotPath, region) sleep(1) time = time + 2 if region.center_x != 0 or region.center_y != 0: if_getpic_succeed = True if time >= timeout and region.center_x == 0 and region.center_y == 0: tempname = base_filename.split(".") next_file = tempname[0] + str(next) + "." + tempname[1] if (os.path.exists(pics_path + next_file)): filename = next_file print filename next += 1 time = 1 else: if toEnd: break swipetime += 1 #self.d.swipe(x-50,y/2,50,y/2) time = 1 filename = base_filename print filename next = 2 if swipetime > 5: toEnd = True continue
def isPass(self, loops, logdir=getTmpDir(), passRate=0.99): logFile = os.path.join(logdir, "sleep_wakup.log") self.commonObj.adb_cmd_common( "pull /data/data/com.intel.sleepwakup/files/sleep_wakup.log \"%s\"" % logFile) if not os.path.isfile(logFile): return False print logFile retMsg = os.popen("cat %s | grep PASS | wc -l" % logFile).read().strip() return int(retMsg) >= float(loops) * passRate
def __init__(self): self._device = g_common_obj.get_device() self.tmp = tempfile.gettempdir() self.tmpdir = getTmpDir() self.inside_output = "/sdcard/TestResult.qpa" self.device = g_common_obj.get_test_device() self.env = EnvironmentUtils() self._mustpass_path = '/sdcard' self._mustpass_list = [ 'vk-master.txt', 'egl-master.txt', 'gles2-master.txt', 'gles3-master.txt', 'gles31-master.txt' ] self._failure_log = os.path.join( g_common_obj.globalcontext.user_log_dir, 'deqp_failures.log') self._raw_deqp_result = os.path.join( g_common_obj.globalcontext.user_log_dir, 'deqp_test_result.log') self._extension_list = os.path.join( g_common_obj.globalcontext.user_log_dir, 'extension_list.log')
def __init__(self): self.tmpdir = getTmpDir() self.tmp = tempfile.gettempdir() self.basic_screenshot = None self.screenshot = None
def __init__(self): self._device = g_common_obj.get_device() self._locator = Locator(self._device) self.tmpdir = getTmpDir() self.systemui = SystemUiExtendImpl()
def __init__(self): self.tmpdir = getTmpDir() self.d = g_common_obj.get_device() self._locator = Locator(self.d) self.photos = get_photo_implement()
def __init__(self): self.tmpdir = getTmpDir() self.device = g_common_obj.get_device()
def saveImage(self , device , fileName = os.path.join(getTmpDir(),"savescreen.png")): print "saveImage" path = self.screenshot(fileName) print "screenshot,path is [%s]" % path return path
def __init__(self): self.tmpdir = getTmpDir() self._imageviewer = ImageDetails() self._device = g_common_obj.get_device() self._locator = Locator(self._device)