def _check_dependency(self): g_common_obj.root_on_device() g_common_obj.remount_device() g_common_obj.adb_cmd_capture_msg("logcat -G 16M") g_common_obj.adb_cmd_capture_msg("logcat -c") selection = { 'L': 'apk_l', 'M': 'apk_m', 'N': 'apk_n', 'O': 'apk_o', 'P': 'apk_p' } if not pkgmgr.query_package_name(self.package_name): try: file_path = environment_utils.get_resource_file( 'tests.common.dEQP.conf', 'dEQP', selection[self.os_ver]) pkgmgr.apk_install(file_path) except KeyError as e: print("DEQP app version not match with android os: %s" % str(e)) # Need to update above when new version is released. for i in self._mustpass_list: op = g_common_obj.adb_cmd_capture_msg('ls %s%s' % (self._mustpass_path, i)) if 'No such file' in op or op == '': file_path = environment_utils.get_resource_file( 'tests.common.dEQP.conf', 'dEQP', i.split('-')[0] + '_mustpass') if not g_common_obj.push_file(file_path, self._mustpass_path): raise Exception( "Fail to push must pass list, please use script to get resource before test." )
def setup(self): """setup implement's resource file""" busybox_obj.setup() if not pkgmgr._package_installed(pkgName=self.PKG_NAME): file_path = self.config.get("apk") apk_path = self.arti.get(file_path) pkgmgr.apk_install(apk_path)
def appPrepare(self): file_path = self.config.get('file_path') + self.config.get('file_name') cache_path = artifactory.get(file_path) pkgmgr.apk_install(cache_path) # Unlock screen g_common_obj.adb_cmd_capture_msg("input keyevent 82")
def setUpClass(self): """ install apk """ super(PhotoGrid, self).setUpClass() self.photos = get_photo_implement() self.photos.rm_delete_photos() apk_path = get_resource_from_atifactory( 'tests.tablet.artifactory.conf', 'content_photogrid', 'name') pkgmgr.apk_install(apk_path) self.photos.deploy_photo_content('Pictures', 'email')
def setUp(self): print "[Setup]:%s" % self.__class__.__name__ super(CardviewRecentsTest, self).setUp() self.actor_apps = self.test_conf.get('actor_apps') self.calendar_path = get_resource_from_atifactory( self.config_file, "apps", "calendar") self.clock_path = get_resource_from_atifactory(self.config_file, "apps", "clock") pkgmgr.apk_install(self.calendar_path) pkgmgr.apk_install(self.clock_path) self.systemui = SystemUiExtendImpl() self.photos = get_photo_implement() self.photos.rm_delete_photos() self.systemui.unlock_screen() self.d.screen.on() self.d.press.menu() self.mark_time = logcat.get_device_time_mark()
def _check_dependency(self): if not pkgmgr._package_installed(pkgName=PACKAGENAME): android_version = self.env.get_android_version() selection = { 'L': 'apk_l', 'M': 'apk_m', 'N': 'apk_n', 'O-MR0': 'apk_omr0', 'O-MR1': 'apk_omr1' } try: file_path = get_resource_from_atifactory( 'tests.common.dEQP.conf', 'dEQP', selection[android_version]) pkgmgr.apk_install(file_path) except KeyError, e: print "DEQP app version not match with android os: %s" % str(e)
def _install_apk(self): if not pkgmgr._package_installed(pkgName=PACKAGE_NAME): android_version = EnvironmentUtils().get_android_version() selection = { 'L': 'apk_l', 'M': 'apk_m', 'N': 'apk_n', 'O-MR0': 'apk_omr0', 'O-MR1': 'apk_omr1' } try: file_path = get_resource_from_atifactory( 'tests.tablet.artifactory.conf', 'content_colormode', selection[android_version]) pkgmgr.apk_install(file_path) except KeyError, e: print "ColorMode app version not match with android os: %s" % str( e)
def setup(self): """setup implement's resource file""" busybox_obj.setup() if not pkgmgr._package_installed(pkgName=self.PKG_NAME): file_path = self.config.get("apk") apk_path = self.arti.get(file_path) pkgmgr.apk_install(apk_path) cmd = "cd %s || mkdir -p %s" % (self.apk_cache_dir, self.apk_cache_dir) g_common_obj.adb_cmd_capture_msg(repr(cmd)) apk_cache_files = self.arti.get(self.config.get("apk_cache_files")) ret = g_common_obj.push_file(apk_cache_files, self.dut_download) assert ret, 'Failed push %s' % (apk_cache_files) files_name = os.path.basename(apk_cache_files) cmd = "busybox tar zxf %s/%s --directory %s > /dev/null 2>&1 && print UnzipComplete"\ % (self.dut_download, files_name, self.apk_cache_dir) output = busybox_obj.adb_busybox_cmd(repr(cmd), 60 * 10) assert 'UnzipComplete' in output,\ "[FAILURE] Failed unzip: %s" % (files_name)
def test_shadow_sampleapkelevationbasic(self): """ refer TC test_Shadow_SampleAPKElevationBasic """ print "[RunTest]: %s" % self.__str__() # install apk if not exists in package list if self.basic_pkg_name not in pkgmgr.get_packages(): apk_path = get_resource_from_atifactory(self.case_cfg, 'ElevationBasic', 'apk') pkgmgr.apk_install(apk_path) # launch app run_cmd = "am start -S -n %s/%s" % (self.basic_pkg_name, self.activity_name) g_common_obj.adb_cmd_capture_msg(run_cmd) sleep(2) # screen capture before operation sx, sy, ex, ey = self.d.info["displayWidth"] / 2, \ 0, \ self.d.info["displayWidth"], \ self.d.info["displayHeight"] img_before = multi_display.get_screenshot_multidisplay_croped( 0, sx, sy, ex, ey) # define operation type def long_tap_content(): d = g_common_obj.get_device() d(resourceId="com.example.android.elevationbasic:id/floating_shape_2" ).long_click() # start test thread = threading.Timer(1.5, long_tap_content) thread.start() # screen capture after operation sleep(2) img_after = multi_display.get_screenshot_multidisplay_croped( 0, sx, sy, ex, ey) assert compare_pic.compare_pic( img_before, img_after) > 4, "No diff after operation"
def setup(self): gfb = Gfxbench() def _wait_init(timeout=60): """wait app initialize""" start_time = time.time() is_completed = False while time.time() - start_time < timeout: _, current_activity = get_current_focus_window() if current_activity == gfb.MAIN_ACTIVITY: is_completed = True break if gfb.device(text='Accept').exists: gfb.device(text='Accept').click() if gfb.device(text='OK').exists: gfb.device(text='OK').click() if gfb.device(text='Retry').exists: gfb.device(text='Retry').click() time.sleep(5) assert is_completed, \ "[FAILURE] Server timeout: %s" % (timeout) def _clean_chooses(): """check off all checkbox""" def _search_item_checkbox(name): """scroll find checkbox""" if gfb.device(resourceId="com.glbenchmark.glbenchmark27:id/main_testSelectListView")\ .scroll.vert.to(text=name): return gfb.device(text=name).right( className="android.widget.CheckBox") for each in gfb.TEST_GROUPS: checkbox = _search_item_checkbox(each) if checkbox.exists: check = checkbox.info['checked'] if check == True: checkbox.click() else: checkbox.click() checkbox.click() # install apk if not pkgmgr._package_installed(pkgName=self.PKG_NAME): pkgmgr.apk_install(self.apk_path) # Push cache files if not any([ True for i in file_sys.get_file_list(self.remote_apk_cache_path + " -type d -print") if self.PKG_NAME in i ]): busybox_obj.setup() clean_cache_cmd = "rm -rf %s%s" % (self.remote_apk_cache_path, self.PKG_NAME) push_cmd = "push %s %s" % (self.apk_cache_path, self.remote_apk_cache_path) cmd = "busybox tar xvf %s%s -C %s" % (self.remote_apk_cache_path, self.apk_cache_name, self.remote_apk_cache_path) td_cmd = "rm -rf %s%s" % (self.remote_apk_cache_path, self.apk_cache_name) g_common_obj.adb_cmd_capture_msg(clean_cache_cmd) g_common_obj.adb_cmd_common(push_cmd) busybox_obj.adb_busybox_cmd(cmd) g_common_obj.adb_cmd_capture_msg(td_cmd) # Go to main menu g_common_obj.launch_app_am(self.PKG_NAME, self.MAIN_ACTIVITY) _wait_init(240) # Log in account for i in range(4): self.device(className="android.widget.RelativeLayout").swipe.left() time.sleep(1) if not self.device(text=self.USERNAME).exists: self.device(resourceId="com.glbenchmark.glbenchmark27:id/settings_editableUserName").\ set_text(self.USERNAME) time.sleep(1) if not self.device( resourceId= "com.glbenchmark.glbenchmark27:id/settings_editableUserPassword" ).exists: self.device.press.back() time.sleep(1) self.device(resourceId="com.glbenchmark.glbenchmark27:id/settings_editableUserPassword").\ set_text(self.PASSWORD) time.sleep(1) if not self.device( resourceId="com.glbenchmark.glbenchmark27:id/settings_login" ).exists: self.device.press.back() time.sleep(1) self.device( resourceId="com.glbenchmark.glbenchmark27:id/settings_login" ).click.wait() time.sleep(1) for i in range(4): self.device( className="android.widget.RelativeLayout").swipe.right() time.sleep(1) # Show test lists if self.device( resourceId='com.glbenchmark.glbenchmark27:id/main_circleControl' ).exists: bounds = self.device( resourceId='com.glbenchmark.glbenchmark27:id/main_circleControl' ).info['visibleBounds'] for i in range(10): self.device.click( bounds['left'] + (bounds['right'] - bounds['left']) * 0.75, bounds['bottom'] - 20 * i) if self.device(text='Test selection').exists: break assert self.device(text='Test selection').exists, \ "[FAILURE] Failed skip_guide" _clean_chooses() self.device( resourceId="com.glbenchmark.glbenchmark27:id/main_testSelectListView" ).scroll.toBeginning() time.sleep(3)
def setup(self): """install apk""" if not pkgmgr._package_installed(pkgName=self.PKG_NAME): file_path = self.config.get("apk") apk_path = self.arti.get(file_path) pkgmgr.apk_install(apk_path)