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 refresh_sdcard(): """ update SDCARD img content provider """ g_common_obj.adb_cmd_common( "shell am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard" )
def setUp(self): super(Messaging, self).setUp() self.__test_name = __name__ print "Setup: %s" % self.__test_name self.d = g_common_obj.get_device() UiAutomatorUtils.unlock_screen() resource.disable_app_verification() _apk_path = resource.get_resource_from_atifactory\ ("tests.tablet.artifactory.conf", "GCM", "gcm_listener") g_common_obj.adb_cmd_common("install -r %s" % _apk_path) self._jar_path = resource.get_resource_from_atifactory\ ("tests.tablet.artifactory.conf", "GCM", "gcm_sender") self._proxy_file = resource.get_resource_from_atifactory\ ("tests.tablet.artifactory.conf", "Proxy", "http_proxy") with open(self._proxy_file) as pf: self._proxy = pf.read().strip('\n') """ Get Android version: adb shell getprop | grep ro.build.version.sdk """ cmd = 'getprop | grep ro.build.version.sdk' sdk_string = g_common_obj.adb_cmd_capture_msg(cmd) if '24' in sdk_string: self.android_version = "N" elif '23' in sdk_string: self.android_version = "M" elif '22' in sdk_string: self.android_version = "L"
def playVideoSecondDisplay(self, file_path): """ Play the video using the second display in Gallery :return: True, launch success """ g_common_obj.adb_cmd_common("logcat -c") play_cmd = 'am start --display 1 -a android.intent.action.VIEW -d "file://%s" -t "video/*" -n com.android.gallery3d/.app.MovieActivity' % file_path g_common_obj.adb_cmd_capture_msg(play_cmd) time.sleep(5) gallery_play_act = 'com.android.gallery3d/com.android.gallery3d.app.MovieActivity' display1_surface = g_common_obj.adb_cmd_capture_msg( "dumpsys SurfaceFlinger|grep -A10 'Display 0 HWC layers' ") display2_surface = g_common_obj.adb_cmd_capture_msg( "dumpsys SurfaceFlinger|grep -A10 'Display 1 HWC layers' ") logger.debug( self.tag + "Video play failed, display1_surface:\n {0},\ndisplay2_surface:\n{1}" .format(display1_surface, display2_surface)) if gallery_play_act not in display1_surface and gallery_play_act in display2_surface: logger.debug(self.tag + "Video play in the second display") else: logger.debug(self.tag + "Video play failed") return False # check video play return self.checkVideoInfoFromLogcat()
def extended_desktop_mosaic_mode_display_work_for_O(self): ''' 1. adb pull /vendor/etc/hwc_display.ini save Default setting file 2. edit the file: MOSIAC="true" CLONE="False" 3. adb push hwc_display.ini /vendor/etc/hwc_display.ini 4. adb reboot ''' self.check_car_mode_exists() self.multi_touch_screen_mode_setup() file_path = "./temp/files" file_name = "hwc_display.ini" os.system("mkdir -p {}".format(file_path)) g_common_obj.adb_cmd_common("pull /vendor/etc/hwc_display.ini {}".format(file_path)) file_path_name = os.path.join(file_path, file_name) bak_file = os.path.join(file_path, "hwc_display.ini_bak") os.system("cp {} {}".format(file_path_name, bak_file)) cmd_1 = """ sed -i 's/MOSAIC="false"/MOSAIC="true"/g' {} """.format(file_path_name) cmd_2 = """ sed -i 's/CLONE="true"/CLONE="false"/g' {} """.format(file_path_name) os.system(cmd_1) os.system(cmd_2) time.sleep(2) g_common_obj.adb_cmd_common("push {} /vendor/etc/hwc_display.ini".format(file_path_name)) self.reboot_devices() g_common_obj.adb_cmd_capture_msg("setenforce 0") self.extended_desktop_mosaic_mode_touch_work()
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 reboot_chromecast_adapter(self): """ reboot the chromecast adapter """ cmd = "-s %s reboot" % self.nexus_device g_common_obj.adb_cmd_common(cmd) print "[Wait adapter reboot]" time.sleep(100)
def sensor_log(self, cfg, delay_type, sensor_type, test_time=98): sensor_package = "com.intel.android.sensorlog" sensor_activity = "com.intel.android.sensorlog.SensorRecordFromDeviceActivity" #self.install_app(cfg, "location_apks", "sensorlog", sensor_package) self.install_artifactory_app("sensorlog", sensor_package) self.d.screen.on() self.d.press("menu") self.setSleepMode("30 minutes") g_common_obj.launch_app_am(sensor_package, sensor_activity) time.sleep(2) if self.d(resourceId="com.intel.android.sensorlog:id/sensors_list", scrollable=True).exists: self.d(resourceId="com.intel.android.sensorlog:id/sensors_list", scrollable=True).scroll.vert.to( text="Type: %s (streaming sensor)" % sensor_type) self.d(text="Type: %s (streaming sensor)" % sensor_type).click.wait() time.sleep(2) self.d(resourceId="com.intel.android.sensorlog:id/sensor_delay_spinner" ).click.wait() time.sleep(2) self.d(text="Delay %s" % delay_type).click.wait() time.sleep(2) g_common_obj.adb_cmd_common("logcat -c") self.d(text="Start").click.wait() time.sleep(test_time) if not "longlasting" in cfg: self.d(text="Stop").click.wait() else: self.logger.info("streaming running--loop")
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 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): 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 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 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 run_case(self, case_name): """ Run given test case Run given test case """ cmd = "shell /data/app/conform -r 32555 -1 %s | grep 'SUMMARY: NO tests failed at any path level'" % ( case_name) diag_output = g_common_obj.adb_cmd_common(cmd, 3000) assert diag_output.find('SUMMARY: NO tests failed at any path level' ) >= 0, "%s failed" % (case_name) cmd = "shell /data/app/conform -p 1 -r 32556 -1 %s | grep 'SUMMARY: NO tests failed at any path level'" % ( case_name) diag_output = g_common_obj.adb_cmd_common(cmd, 700) assert diag_output.find('SUMMARY: NO tests failed at any path level' ) >= 0, "%s failed" % (case_name) cmd = "shell /data/app/conform -p 2 -r 32557 -1 %s | grep 'SUMMARY: NO tests failed at any path level'" % ( case_name) diag_output = g_common_obj.adb_cmd_common(cmd, 700) assert diag_output.find('SUMMARY: NO tests failed at any path level' ) >= 0, "%s failed" % (case_name) cmd = "shell /data/app/conform -p 3 -r 32558 -1 %s | grep 'SUMMARY: NO tests failed at any path level'" % ( case_name) diag_output = g_common_obj.adb_cmd_common(cmd, 700) assert diag_output.find('SUMMARY: NO tests failed at any path level' ) >= 0, "%s failed" % (case_name)
def init_environment(self): """ Init the test environment """ 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_androidvid') self.arti = Artifactory(cfg_arti.get('location')) apk_name = cfg.get("name") file_path = self.arti.get(apk_name) print "%s" % file_path result = config_handle.check_apps(self.pkg_name) if result == 0: g_common_obj.adb_cmd_common('install ' + file_path) video_name = cfg.get("video_arti") video_path = self.arti.get(video_name) g_common_obj.adb_cmd_common('push ' + video_path + ' /sdcard/') cmd = "am broadcast -a \ android.intent.action.MEDIA_MOUNTED -d file:///sdcard/" g_common_obj.adb_cmd(cmd) self.video = cfg.get("filename") bench_files = config.read(cfg_file, 'gfxbench31_files') busybox_path = self.arti.get(bench_files.get("busybox")) busybox_tar_path = bench_files.get("busybox_path") print g_common_obj.push_file(busybox_path, busybox_tar_path) print g_common_obj.adb_cmd_capture_msg("chmod 777 " + busybox_tar_path) self.md5_id = config.read(cfg_file, 'md5_id') self.check_path = self.md5_id.get('check_path')
def imageViewCheckWithInstallApp(self, case_name, flag=1): print "run case is " + str(case_name) self.appPrepare(case_name) path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"") print path if flag != 1: self.multimedia_setting.push_file( self.video.cfg.get("push_picture_2"), self.video.cfg.get("datapath")) self.launchPhotoAPP() self.enterPhotoPath(path) self.multimedia_setting.install_apk("video_apk") self.checkPictureExist(os.path.split(path)[1]) if flag != 1: self.d(className="android.widget.ImageView").swipe.left() path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip( "\"") self.checkPictureExist(os.path.split(path_2)[1]) self.push_path = self.multimedia_setting.push_file( self.video.cfg.get("push_video_2"), self.video.cfg.get("datapath_2")) self.multimedia_handle.launchVideoApp() time.sleep(2) self.multimedia_handle.videoPlayBack(self.push_path) self.multimedia_setting.install_apk("vpg_apk") self.checkVideoPlayBack(30) adb.adb_cmd_common( 'uninstall videoplayer.app.instrument.otc.intel.com.otcvideoplayer' ) adb.adb_cmd_common('uninstall com.intel.vpg.tool') print "case " + str(case_name) + " is pass"
def diff_md5(self, id): """ diff the video's md5 """ self.id = self.arti.get(self.md5_id.get(id)) g_common_obj.adb_cmd_common('push ' + self.id + ' ' + self.check_path) cmd = '"cd /sdcard/DCIM/AndroVid/video/;/data/busybox md5sum -c %s|grep OK"' % id assert g_common_obj.adb_cmd(cmd) == 0, "The video not match"
def check_logcat(self): """ check the key word in logcat """ cmd = "logcat -d > /tmp/RsBenchmark.log" g_common_obj.adb_cmd_common(cmd) assert not os.system("cat /tmp/RsBenchmark.log|grep 'Compute Device: GPU'"),\ "The RsBenchmark not triggered well"
def pull(self, log_file): log = log_file.split('/')[4] g_common_obj.adb_cmd_common("pull %s ." % log_file) if os.path.exists(r'./' + log): return else: assert False, "log file with the format of csv failed to export!"
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 uninstall_fbreader_and_pdfplugin(): """ uninstall the fbreader and pdfplugin """ print "Uninstall the fbreader and pdfplugin" cmd = 'uninstall org.geometerplus.fbreader.plugin.pdf' g_common_obj.adb_cmd_common(cmd) cmd = 'uninstall org.geometerplus.zlibrary.ui.android' g_common_obj.adb_cmd_common(cmd)
def apk_install(self, file_path): self.cli_settings.set_key_value('global', 'package_verifier_enable', '0') self.cli_settings.set_key_value('secure', 'install_non_market_apps', '1') # pkginfo = self.dump_package(file_path) g_common_obj.adb_cmd_common('install -r -g %s' % file_path) time.sleep(10)
def clean(self): """uninstall apk""" cmd = "rm -rf %s*.json" % (self.RESULT_DIR) cmd2 = "rm -rf %s*.json" % (self.RESULT_DIR2) g_common_obj.adb_cmd_capture_msg(cmd) g_common_obj.adb_cmd_capture_msg(cmd2) cmd = "uninstall %s" % (self.PKG_NAME) g_common_obj.adb_cmd_common(cmd)
def check_chromecast_status(self): """ track aplog to check the chromecast status """ cmd = "-s %s logcat -d > /tmp/chromecast.log" % self.nexus_device g_common_obj.adb_cmd_common(cmd) assert not os.system( "cat /tmp/chromecast.log|grep 'YouTube'"\ ), "The video used chromecast didn't play"
def check_chromecast_status(self): """ track aplog to check the chromecast status """ cmd = "-s %s logcat -d > /tmp/chromecast.log" % self.nexus_device g_common_obj.adb_cmd_common(cmd) assert not os.system( "cat /tmp/chromecast.log|grep 'cast.receiver.IpcChannel'"\ ), "The video used chromecast didn't Launch" time.sleep(20)
def check_chromecast_play(self): """ check the chromecast playback """ cmd = "-s %s logcat -d > /tmp/chromecast.log" % self.nexus_device g_common_obj.adb_cmd_common(cmd) assert not os.system( "cat /tmp/chromecast.log|grep PAUSED"\ ), "The video used chromecast didn't play" time.sleep(5)
def setUp(self): super(Safe_Mode, self).setUp() self.__test_name = __name__ print "Setup: %s" % self.__test_name self.d = g_common_obj.get_device() resource.disable_app_verification() _apk_path = resource.get_resource_from_atifactory\ ("tests.tablet.artifactory.conf", "SDK_API", "api_demos") g_common_obj.adb_cmd_common("install -r %s" % _apk_path)
def root(self): g_common_obj.adb_cmd_common("root") for i in range(5): message = g_common_obj.adb_cmd_common("root") if "adbd is already running as root" in message: print "[info]--- Root success" return time.sleep(2) assert False, "Root failed!"
def push_file(self, originalName, originalPath, fileName=None, path="/sdcard/otctest"): if not fileName: fileName = originalName g_common_obj.adb_cmd_common( "push %s/%s %s/%s" % (originalPath, originalName, path, fileName))
def push_send_event_script(self, script_name): self.adb_root() rm_cmd = "rm -rf /mnt/sdcard/%s" % script_name #g_common_obj.adb_cmd_capture_msg(rm_cmd) script_path = os.path.join(os.path.dirname(__file__), "device_scripts", script_name) push_to_dir = "/mnt/sdcard/" cmd = "push %s %s" % (script_path, push_to_dir) g_common_obj.adb_cmd_common(cmd)