def get_pictures(): """ download pictures tar folders from artifactory """ if not os.path.isdir("~/Pictures") is True: g_common_obj.shell_cmd("mkdir -p ~/Pictures") config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_picture') arti = Artifactory(cfg_arti.get('location')) pic_name1 = cfg.get("pngtar") file_path1 = arti.get(pic_name1) g_common_obj.shell_cmd("mv " + file_path1 + " ~/Pictures/PNG.tar.gz ") pic_name2 = cfg.get("webptar") file_path2 = arti.get(pic_name2) g_common_obj.shell_cmd("mv " + file_path2 + " ~/Pictures/WEBP.tar.gz ") # assert os.path.isdir("~/Pictures") is True os.system("cd ~/Pictures ") os.system("echo change to dir ~/pictures $?") os.system("tar xzvf ~/Pictures/PNG.tar.gz -C ~/Pictures/ ") os.system("echo unarchive png $?") os.system("tar xzvf ~/Pictures/WEBP.tar.gz -C ~/Pictures/ ") os.system("echo unarchive webp $?")
def setUp(self): super(ComposeUI, self).setUp() self._test_name = __name__ print "[Setup]: %s" % self._test_name self._docstogo = DocsToGo() config = TestConfig() cfg_file = 'tests.tablet.composeui.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg_apk = config.read(cfg_file, 'DocsToGo') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_apk.get("name") file_path = arti.get(binary_name) result = config_handle.check_apps("com.dataviz.docstogo") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) arti = Artifactory(cfg_arti.get('location')) cfg_docx = config.read(cfg_file, 'docx') docx_name = cfg_docx.get("name") docx_path = arti.get(docx_name) g_common_obj.adb_cmd_common('push ' + docx_path + ' /sdcard/') cmd = "am broadcast -a android.intent.action.MEDIA_MOUNTED\ -d file:///sdcard/" g_common_obj.adb_cmd(cmd) self.docx = cfg_docx.get("filename") print self.docx
def prepare_img(self, tag='', name=''): ''' deploy photo contents before run tests. :param tag: input config file tag name. such as: Pictures / Videos / PicturesFolder .. :param name: input head name for each content. such as: picture_001 ~ 005 / jpg_10resolution .. :return: full path of the img. ''' arti_ = TestConfig().read(section='artifactory').get('location') arti = Artifactory(arti_) if not 'Folder' in tag: photo = TestConfig().read(CONFIG_FILE, tag).get(name) return arti.get(photo) else: getPhotos = TestConfig().read(CONFIG_FILE, tag).get(name) isolatePath = getPhotos.split(';')[0] isolateConts = getPhotos.split(';')[1] repoPath = isolatePath.split('\"')[1].replace('Path:', '').strip(' ') contents = isolateConts.split('\"')[1].replace('Content:', '').strip(' ').split(',') all = [] for _ in contents: cont = _.strip(' ') contentPath = repoPath + '/' + cont localPath = arti.get(contentPath) all.append(localPath) return all
def download_file_from_artifactory(self, sub_path=None, download_file=None): """ download file from artifcatory server :param sub_path: sub location for download file in server :param download_file: file to download :return: local location of downloaded file or None """ if os.path.isfile("/etc/oat/sys.conf"): common_url = self.config.read( section='artifactory').get("location") remote_server = Artifactory(common_url + sub_path) for _ in range(5): return_file = remote_server.get(download_file) if return_file is not None and os.path.isfile(return_file): return return_file time.sleep(2) # try to download file from mirror server mirror_url = self.config.read('tests.tablet.dut_init.conf', 'download_server').get('mirror_url') mirror_server = Artifactory(mirror_url + sub_path) for _ in range(5): return_file = mirror_server.get(download_file) if return_file is not None and os.path.isfile(return_file): return return_file time.sleep(2) return None
def setUpClass(self): """ set environment """ super(ImageViewByWebBrowser, self).setUpClass() self.photos = get_photo_implement() self._qrcode = QRcode() self._chrome = ChromeExtendImpl() self.photos.rm_delete_photos() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'qrcode_marked_image') arti = Artifactory(cfg_arti.get('location')) pic_name = cfg.get("bmp01") self.pic_name1 = pic_name.split("/")[-1] self.qrcode1 = cfg.get("bmp01_qrcode") file_path = arti.get(pic_name) self.photos.deploy_photo_content(local_file=file_path) pic_name = cfg.get("bmp02") self.pic_name2 = pic_name.split("/")[-1] self.qrcode2 = cfg.get("bmp02_qrcode") file_path = arti.get(pic_name) self.photos.deploy_photo_content(local_file=file_path) self._chrome.launch() self._chrome.chrome_setup()
def setUpClass(cls): print "[setUpClass]: %s" % cls.__name__ super(DisplayAllAppsOnHomeScreen, cls).setUpClass() cls.d = g_common_obj.get_device() g_common_obj.root_on_device() g_common_obj.remount_device() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') # Change to photoGrid app since meitupic is not support for x86 cpu cfg_picasatool = config.read(cfg_file, 'content_photogrid') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_picasatool.get("name") file_path = arti.get(binary_name) print "[Setup]: install photogrid" result = config_handle.check_apps("com.roidapp.photogrid") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) cfg_picsart = config.read(cfg_file, 'content_picsart') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_picsart.get("name") file_path = arti.get(binary_name) print "[Setup]: install picsart" result = config_handle.check_apps("com.picsart.studio") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) cfg_picsay = config.read(cfg_file, 'content_picsay') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_picsay.get("name") file_path = arti.get(binary_name) print "[Setup]: install picsay" result = config_handle.check_apps("com.shinycore.picsayfree") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) cfg_sketchbook = config.read(cfg_file, 'content_sketchbook') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_sketchbook.get("name") file_path = arti.get(binary_name) print "[Setup]: install sketchbook" result = config_handle.check_apps("com.adsk.sketchbookhdexpress") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) cfg_skitch = config.read(cfg_file, 'content_skitch') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_skitch.get("name") file_path = arti.get(binary_name) print "[Setup]: install skitch" result = config_handle.check_apps("com.evernote.skitch") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path)
def setUp(self): print "[Setup]:%s" % self.__class__.__name__ super(HDMITest, self).setUp() self.photosImpl.rm_delete_photos() self.qrcode = "bmppicture" config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') self.retry_num = self.config.read( cfg_file, 'rerun_times').get("hdmi_imagedisplay_png") self.retry_num = int(self.retry_num) cfg = config.read(cfg_file, 'qrcode_marked_image') print self.qrcode self.qrcode = cfg.get("hdmi_png_qrcode") print "[Debug] qrcode:%s" % (self.qrcode) arti = Artifactory(cfg_arti.get('location')) pic_name = cfg.get("hdmi_png_image") file_path = arti.get(pic_name) g_common_obj.adb_cmd_common('push ' + file_path + ' /sdcard/Pictures') self.photosImpl.refresh_sdcard() self.systemui = SystemUiExtendImpl() self.HDMI_switch_card = HDMISwitchCardImpl() self.HDMI_capture_decode = HDMICaptureDecodeImpl() self.HDMI_switch_card.setup() self.HDMI_switch_card.switch_off() self.HDMI_capture_decode.setup() self.systemui.unlock_screen() self.d.screen.on() self.d.orientation = 'natural'
def installImageProcessor(self): ''' install from Artifactory ''' config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_imageprocessing') arti = Artifactory(cfg_arti.get('location')) version_array = osversion.get_android_version() androidversion = version_array[0] if androidversion == 7: print "osversion is N" apk_name = cfg.get("name") elif androidversion == 6: print "osversion is M" apk_name = cfg.get("name") elif androidversion == 5: print "osversion is L" apk_name = cfg.get("name_l") else: print "osversion is %s" % (androidversion) apk_name = cfg.get("name_l") file_path = arti.get(apk_name) result = config_handle.check_apps(self.pkg_name) if result == 0: g_common_obj.adb_cmd_common('install ' + str(file_path), 300)
def download_oem_content_artifactory(self, sub_path=None, download_file=None): if not os.path.isfile("/etc/oat/sys.conf"): #real_path = os.path.realpath(__file__) cmd = "cp acs_test_suites/OTC/TC/TP/support/prebuild/sys.conf /etc/oat/" os.system(cmd) common_url = self.config.read(section='artifactory').get("location") remote_server = Artifactory(common_url + sub_path) for _ in range(5): return_file = remote_server.get(download_file) print return_file if return_file is not None and os.path.isfile(return_file): break time.sleep(2) host_file_path = ConfigHandle().read_host_file_path() cmd = "mkdir %s" % (host_file_path) os.system(cmd) cmd2 = "cp %s %s" % (return_file, host_file_path) print cmd2 os.system(cmd2) tmp_file = host_file_path + "/OEM_file.zip" assert os.path.isfile(tmp_file) cmd2 = "unzip -n %s/OEM_file.zip -d %s" % (host_file_path, host_file_path) print "[INFO]: aaaa %s" % cmd2 os.system(cmd2)
def setUpClass(self): """ install apk """ super(RunImageProcessing, self).setUpClass() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_imageprocessing') arti = Artifactory(cfg_arti.get('location')) version_array = osversion.get_android_version() androidversion = version_array[0] if androidversion == 7: print "osversion is N" apk_name = cfg.get("name") elif androidversion == 6: print "osversion is M" apk_name = cfg.get("name") elif androidversion == 5: print "osversion is L" apk_name = cfg.get("name_l") else: print "osversion is %s" % (androidversion) apk_name = cfg.get("name_l") file_path = arti.get(apk_name) result = config_handle.check_apps("com.android.rs.image") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path)
def setup(self): cfg = self.config.read(self.config_file, "ChromeCast") arti = Artifactory(cfg.get('artifactory_location')) apk_path = arti.get(cfg.get("chromecast_apk")) cmd = "install -r %s" % (apk_path) print g_common_obj.adb_cmd_common(cmd)
def setUp(self): super(ComposeUI, self).setUp() self._test_name = __name__ self.device = g_common_obj.get_device() print "[Setup]: %s" % self._test_name self._composeui = ComposeUiImpl() self._imageviewer = ImageDetails() self.photos = PhotosExtendImpl() self.photosImpl = get_photo_implement() self.qrcodeImpl = QRcode() g_common_obj.root_on_device() g_common_obj.remount_device() self.photosImpl.rm_delete_photos() self.photosImpl.refresh_sdcard() self.photos.clean() self.qrcode = "GIFPICTURE" config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration('artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'qrcode_marked_image') self.qrcode = cfg.get("screenshot_edit_qrcode") print "[Debug] qrcode:%s" % (self.qrcode) arti = Artifactory(cfg_arti.get('location')) pic_name = cfg.get("screenshot_edit_image") file_path = arti.get(pic_name) g_common_obj.adb_cmd_common('push ' + file_path + ' /sdcard/Pictures') self.photosImpl.refresh_sdcard() special_actions.setup() self.photos.setup()
def setUp(self): print "[Setup]:%s" % self.__class__.__name__ super(ImageViewing, self).setUp() self.device = g_common_obj.get_device() self.photos = get_photo_implement() self.qrcodeImpl = QRcode() self.wallpaper = WallpaperImpl() self.photos.rm_delete_photos() self.photos.refresh_sdcard() self.qrcode = "GIFPICTURE" config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'qrcode_marked_image') self.qrcode = cfg.get("screenshot_imageview_qrcode") print "[Debug] qrcode:%s" % (self.qrcode) arti = Artifactory(cfg_arti.get('location')) pic_name = cfg.get("screenshot_imageview_image") file_path = arti.get(pic_name) g_common_obj.adb_cmd_common('push ' + file_path + ' /sdcard/Pictures') self.photos.refresh_sdcard()
def adb_disable_verity(self): """ M: remount /system instead of disable-verity. O: Need to flash vbmeta_img in fastboot mode. """ if self.ANDROID_VERSION == "M": g_common_obj.root_on_device() cmd = "busybox mount -o rw, remount /system" busybox_obj.setup() busybox_obj.adb_busybox_cmd(cmd) self._adb_reboot() g_common_obj.root_on_device() time.sleep(3) g_common_obj.remount_device() time.sleep(3) else: if 'remount succeeded' not in self._remount_result() or \ len(self._remount_result()) != 1: self._adb_reboot_fastboot() remote_vbmeta_path = TestConfig().read( "tests.tablet.artifactory.conf", "framebuffer_dependency_o").get("vbmeta") arti = Artifactory( TestConfig().read(section='artifactory').get('location')) vbmetaimg = arti.get(remote_vbmeta_path) self.fastboot_flash_vbmeta(vbmetaimg) time.sleep(3) assert 'remount succeeded' in self._remount_result( ), "Disable-verity failed." time.sleep(3)
def install_templerun_app(self, cfg, option="apk_name"): ''' Install Temple run 2. ''' ret = os.system( "adb -s %s shell pm list package | grep com.imangi.templerun2" % self.serial) if ret == 0: print "[Info] ---Temple run 2 already installed." return from testlib.util.repo import Artifactory config_handle = ConfigHandle() cfg["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat', 'sys.conf') arti_obj = Artifactory(cfg.get("location")) ret_file = arti_obj.get(cfg.get(option)) print "[Info] ---Install Temple run 2." assert os.path.isfile(ret_file) os.system("adb -s %s install -r %s" % (self.serial, ret_file)) time.sleep(2) ret = os.system( "adb -s %s shell pm list package | grep com.imangi.templerun2" % self.serial) assert ret == 0, "Install Temple run 2 failed!"
def init_photos(self): """ push some pictures in DUT """ config = TestConfig() cfg_file = 'tests.tablet.basic_render_script.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') arti = Artifactory(cfg_arti.get('location')) cfg_name = config.read(cfg_file, 'girls') pictures_name = cfg_name.get("name") self.floder_name = cfg_name.get('floder') pictures_path = arti.get(pictures_name) print os.system("cd " + os.path.dirname(pictures_path) + ";tar xzf " + pictures_path) unzip_photos = pictures_path.replace(".tar.gz", "/") cmd = "mkdir -p %s" % self.floder_name g_common_obj.adb_cmd_common(cmd) cmd = "push %s /sdcard/%s" % (unzip_photos, self.floder_name) g_common_obj.adb_cmd_common(cmd) cmd = "am broadcast -a android.intent.action.MEDIA_MOUNTED \ -d file:///sdcard/" g_common_obj.adb_cmd(cmd)
def check_package_download(self): art_package_root = os.path.join(self.dirname, self.art_package) if not os.path.exists(art_package_root): from testlib.util.repo import Artifactory arti_obj = Artifactory("https://mcg-depot.intel.com/artifactory/acs_test_artifacts/OTC_Android_Auto_Test_Suite/resources") ret_file = arti_obj.get("ART/%s" % self.art_package_zip) cmd = "unzip -q %s -d %s" % (ret_file, self.dirname) print cmd shell_command(cmd, 180) assert os.path.exists(art_package_root), "Download ART package failed!"
def get_resource_from_atifactory(self, conf_name, section, resource_name): #usage: et_resource_from_atifactory("tests.tablet.artifactory.conf", "content_picture", "wbmp") cfg_file = conf_name cfg_arti = self.config.read(cfg_file, 'artifactory') cfg_arti["location"] = self.config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = self.config.read(cfg_file, section) arti = Artifactory(cfg_arti.get('location')) file_name = cfg.get(resource_name) file_path = arti.get(file_name) return file_path
class APITestImpl(object): """ com.intel.test.apitests """ CONFIG_FILE = 'tests.common.apitest.conf' PACKAGE_NAME = 'com.intel.test.apitests' DisplayMetricsTestDriver_test = 'com.intel.test.apitests.tests.DisplayMetricsTestDriver#testDisplayAllFields' DisplayMetricsTestDriver_runner = 'com.intel.test.apitests/com.intel.test.apitests.runners.DisplayMetricsTestRunner' def __init__(self): super(APITestImpl, self).__init__() self.device = g_common_obj.get_device() self.configer = TestConfig() self.config = self.configer.read(self.CONFIG_FILE, "APITestImpl") config_handle = ConfigHandle() self.config["artifactory_location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat', 'sys.conf') self.arti = Artifactory(self.config.get('artifactory_location')) def setup(self): apk_path = self.arti.get(self.config.get("apk")) cmd = "install -r %s" % (apk_path) print g_common_obj.adb_cmd_common(cmd) def clean(self): cmd = "uninstall %s" % (self.PACKAGE_NAME) print g_common_obj.adb_cmd_common(cmd) def run_DisplayMetricsTest(self): time_mark = logcat.get_device_time_mark() cmd = "am instrument -e class %s -w %s"\ % (self.DisplayMetricsTestDriver_test, self.DisplayMetricsTestDriver_runner) msg = g_common_obj.adb_cmd_capture_msg(repr(cmd)) assert 'OK ' in msg,\ "[FAILURE] Failed am instrument\n%s\n%s" % (cmd, msg) logs = logcat.get_device_log(time_mark, "*:D|grep API") assert len(logs) > 0,\ "[FAILURE] Failed Catch logs" return logs def verify_screen_size(self, msg): height_pixels = re.findall(r'.* heightPixels = (\d+).*', msg, re.IGNORECASE) width_pixels = re.findall(r'.* widthPixels = (\d+).*', msg, re.IGNORECASE) print "[Debug] height_pixels=%s,width_pixels=%s"\ % (height_pixels, width_pixels) assert height_pixels and width_pixels,\ "[FAILURE] No field values, height_pixels=%s, width_pixels=%s" % (height_pixels, width_pixels) assert all([int(each) > 0 for each in height_pixels]),\ "Invalid height %s" % (height_pixels) assert all([int(each) > 0 for each in width_pixels]),\ "Invalid width %s" % (width_pixels)
def init_environment(self): """ Init the test environment """ self.config = TestConfig() self.cfg_file = 'tests.tablet.androidextensionpack.conf' cfg_arti = self.config.read(self.cfg_file, 'artifactory') cfg = self.config.read(self.cfg_file, 'binary') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg.get("name") file_path = arti.get(binary_name) print "%s" % file_path g_common_obj.adb_cmd_common('push ' + file_path + ' /data/app/') g_common_obj.adb_cmd('chmod 777 /data/app/oglconform_and_x86')
def install_apk(self, apk_name): """ Install the apk from artifactory """ config = TestConfig() cfg_file = 'tests.tablet.game.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration('artifactory', 'location', '/etc/oat/', 'sys.conf') arti = Artifactory(cfg_arti.get('location')) cfg_apk = config.read(cfg_file, apk_name) apk_name = cfg_apk.get("name") file_path = arti.get(apk_name) g_common_obj.adb_cmd_common('install ' + file_path)
def setUpClass(self): """ install apk """ super(Render, self).setUpClass() g_common_obj.root_on_device() g_common_obj.remount_device() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration('artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_grafika') arti = Artifactory(cfg_arti.get('location')) apk_name = cfg.get("name") file_path = arti.get(apk_name) result = config_handle.check_apps("grafika-debug.apk") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) video_name = cfg.get("video") self.video_file = video_name.split('/')[-1] self.video_file_path = arti.get(video_name)
def install_adobeAir(self): config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration('artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_adobeair') arti = Artifactory(cfg_arti.get('location')) apk_name = cfg.get("name") file_path = arti.get(apk_name) result = config_handle.check_apps("com.adobe.air") if result == 0: g_common_obj.adb_cmd_common('install ' + str(file_path))
def setUpClass(self): """ install apk """ super(AnTuTuTest, self).setUpClass() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') cfg = config.read(cfg_file, 'content_antutu') arti = Artifactory(cfg_arti.get('location')) apk_name = cfg.get("name") file_path = arti.get(apk_name) g_common_obj.adb_cmd_common('install ' + file_path)
class DisplayCableSwitchImpl(object): """DisplayCableSwitchImpl""" config_file = 'tests.common.display_cable_switch.conf' def __init__(self): configer = TestConfig() self.config = configer.read(self.config_file, "DisplayCableSwitch") config_handle = ConfigHandle() self.config["artifactory_location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat', 'sys.conf') self.arti = Artifactory(self.config.get('artifactory_location')) self.excuter_path = '' self.usb_vendor_product = self.config.get('usb_vendor_product') def setup(self): self.excuter_path = self.arti.get(self.config.get("bin_displayswitch")) assert self.excuter_path,\ "Download resource failed!" cmd = 'chmod 777 %s' % self.excuter_path code, msg = self.shell_command(cmd) assert code == 0,\ "[FAILURE] %s %s" % (cmd, msg) cmd = 'lsusb -d %s' % (self.usb_vendor_product) code, msg = self.shell_command(cmd) assert code == 0,\ "[FAILURE] %s %s" % (cmd, msg) assert msg,\ "[FAILURE] switch cable not connected" def switch_on(self): cmd = "%s -a" % (self.excuter_path) code, msg = self.shell_command(cmd) assert code == 0,\ "[FAILURE] %s %s" % (cmd, msg) time.sleep(5) def switch_off(self): cmd = "%s -c" % (self.excuter_path) code, msg = self.shell_command(cmd) assert code == 0,\ "[FAILURE] %s %s" % (cmd, msg) time.sleep(5) def shell_command(self, cmd): print 'Execute command: %s' % cmd exit_code, stdout_log, stderr_log = shell_command_ext(cmd) message = stdout_log + stderr_log print 'Result exit:%s\n%s' % (exit_code, message) return exit_code, message
def check_chrome_installed(self): """ Make sure chrome app is pre-installed. If no, then install it. """ result = self._config_handle.check_apps(self.pkg_name) if not result: cfgName = "tests.tablet.artifactory.conf" cfg_app = TestConfig().read(cfgName, "content_chrome").get('name') cfg_arti = TestConfig().read(section='artifactory').get('location') arti = Artifactory(cfg_arti) cmd = "adb install -r %s" % arti.get(cfg_app) print "Installing chrome app." os.system(cmd)
def setup_enviroment(cfg): """ @summary: set up gits enviroment """ if g_common_obj.adb_cmd_capture_msg("ps | grep adbd")[0:4] != "root": g_common_obj.root_on_device() # g_common_obj.remount_device() config_handle = ConfigHandle() cfg["artifactory_location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat', 'sys.conf') arti = Artifactory(cfg.get('artifactory_location')) renderscript_player_path = arti.get(cfg.get("renderscript_player")) busybox_path = arti.get(cfg.get("busybox")) gits_path = arti.get(cfg.get("gits")) busybox_tar_path = cfg.get("busybox_path") gits_tar_path = cfg.get("gits_path") g_common_obj.adb_cmd_capture_msg("mkdir -p " + os.path.dirname(gits_tar_path)) g_common_obj.push_file(busybox_path, busybox_tar_path) g_common_obj.push_file(gits_path, gits_tar_path) g_common_obj.push_file(renderscript_player_path, os.path.dirname(gits_tar_path)) print g_common_obj.adb_cmd_capture_msg("chmod 777 " + busybox_tar_path) print g_common_obj.adb_cmd_capture_msg("chmod 777 " + gits_tar_path) print g_common_obj.adb_cmd_capture_msg( "chmod 777 " + os.path.dirname(gits_tar_path) + "/" + os.path.basename(renderscript_player_path)) # install busybox to /data/bb print g_common_obj.adb_cmd_capture_msg("mkdir -p /data/bb") print g_common_obj.adb_cmd_capture_msg(busybox_tar_path + " --install -s /data/bb") # print g_common_obj.adb_cmd_capture_msg(busybox_tar_path) # install gits print g_common_obj.adb_cmd_capture_msg("\"cd " + \ os.path.dirname(gits_tar_path) + ";" + "export PATH=$PATH:/data/bb" + ";" + "sh " + gits_tar_path + "\"")
def setup(self): ''' install from Artifactory ''' config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_renderscript_N') arti = Artifactory(cfg_arti.get('location')) apk_name = cfg.get("name") file_path = arti.get(apk_name) g_common_obj.adb_cmd_common('install ' + str(file_path), 300)
def setUpClass(self): """ install apk """ super(MeituPic, self).setUpClass() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg_apk = config.read(cfg_file, 'content_meitupic') arti = Artifactory(cfg_arti.get('location')) binary_name = cfg_apk.get("name") file_path = arti.get(binary_name) result = config_handle.check_apps("com.mt.mtxx.mtxx") if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) cfg_pic = config.read(cfg_file, 'content_picture') arti = Artifactory(cfg_arti.get('location')) pic_name = cfg_pic.get("name") file_path = arti.get(pic_name) g_common_obj.adb_cmd('rm /sdcard/Pictures/*') g_common_obj.adb_cmd_common('push ' + file_path + ' /sdcard/Pictures')
def setUpClass(self): """ install apk """ super(MemTrack, self).setUpClass() config = TestConfig() cfg_file = 'tests.tablet.artifactory.conf' cfg_arti = config.read(cfg_file, 'artifactory') config_handle = ConfigHandle() cfg_arti["location"] = config_handle.read_configuration( 'artifactory', 'location', '/etc/oat/', 'sys.conf') cfg = config.read(cfg_file, 'content_graphic') arti = Artifactory(cfg_arti.get('location')) apk_name = cfg.get("name") file_path = arti.get(apk_name) os.system('adb install -r -g %s' % file_path)