def test_ST_SYST_SWUPD_MT_036(self): hh, mm, ss = Calendar.get_current_dut_time() try: alarm_time = Clock.set_new_alarm(hh, mm) hh, mm, ss = Calendar.get_current_dut_time() current_time = datetime.datetime(1, 1, 1, int(hh), int(mm), int(ss)) time_delta = alarm_time - current_time time.sleep(time_delta.seconds + 15) self.d.open.notification() self.assertTrue(self.d(text="Alarm").wait.exists(timeout=3000)) if EnvironmentUtils.get_android_version() == "N": self.assertTrue( self.d(text=CLOCK_SNOOZE_ALARM_TXT_N).wait.exists( timeout=3000)) self.assertTrue( self.d(textContains=CLOCK_DISMISS_ALARM_TXT_N).wait.exists( timeout=3000)) self.d(text=CLOCK_DISMISS_ALARM_TXT_N).click() else: self.assertTrue( self.d(text=CLOCK_SNOOZE_ALARM_TXT).wait.exists( timeout=3000)) self.assertTrue( self.d(textContains=CLOCK_DISMISS_ALARM_TXT).wait.exists( timeout=3000)) self.d(text=CLOCK_DISMISS_ALARM_TXT).click() finally: pass
def set_input_options(self, switch='ON'): """set Show taps & Pointer location""" if EnvironmentUtils.get_android_version() == "M": _opts = ['Show touches', 'Pointer location'] else: _opts = ['Show taps', 'Pointer location'] self.launch() for op in _opts: self._set_switch_option(op, switch) time.sleep(1) self.device.press.back()
def setUp(self): super(Animation, self).setUp() self.__test_name = __name__ print "Setup: %s" % self.__test_name self._cts_test = CTS_Impl() resource.disable_app_verification() if EnvironmentUtils.get_android_version() == 'N': _apk_path = resource.get_resource_from_atifactory\ ("tests.tablet.artifactory.conf", "CTS_APKS", "animation_n") else: _apk_path = resource.get_resource_from_atifactory\ ("tests.tablet.artifactory.conf", "CTS_APKS", "animation") g_common_obj.adb_cmd_common("install -r %s" % _apk_path)
def test_alarm_after_reboot(self): hh, mm, ss = Calendar.get_current_dut_time() result = SystemApiTestsInterface.run_instrumentation( class_name="CommonTestsDriver", method_name="testDisableAutoTime", instrumentation_args=None, runner_name="GenericArgumentPassingTestRunner") self.assertTrue( SystemApiTestsInterface.was_instrumentation_test_successful( result), "Could not disable auto time sync") try: # set an alarm at least 250 seconds into the future alarm_time = Clock.set_new_alarm(hh, mm, offset=120) hh, mm, ss = Calendar.get_current_dut_time() current_time = datetime.datetime(1, 1, 1, int(hh), int(mm), int(ss)) time.sleep(5) reboot_time = UiAutomatorUtils.reboot_device() UiAutomatorUtils.unlock_screen() time_delta = alarm_time - current_time sleep_time = time_delta.seconds - reboot_time if sleep_time > 0: LOG.info("sleeping for %s seconds" % time_delta.seconds) time.sleep(sleep_time) self.d.open.notification() self.assertTrue(self.d(text="Alarm").wait.exists(timeout=3000)) if EnvironmentUtils.get_android_version() == "N": self.assertTrue( self.d(text=CLOCK_SNOOZE_ALARM_TXT_N).wait.exists( timeout=3000)) self.assertTrue( self.d(textContains=CLOCK_DISMISS_ALARM_TXT_N).wait.exists( timeout=3000)) self.d(text=CLOCK_DISMISS_ALARM_TXT_N).click() else: self.assertTrue( self.d(text=CLOCK_SNOOZE_ALARM_TXT).wait.exists( timeout=3000)) self.assertTrue( self.d(textContains=CLOCK_DISMISS_ALARM_TXT).wait.exists( timeout=3000)) self.d(text=CLOCK_DISMISS_ALARM_TXT).click() finally: Clock.delete_all_alarms()
def test_android_animation(self): if EnvironmentUtils.get_android_version() == 'N': self._cts_test.run_cts_test_animation_n("animation") else: self._cts_test.run_cts_test_animation("animation")
def test_take_bug_report(self): GPS_Common().check_if_wifi_connected() ga_st = EnvironmentUtils.check_if_google_account_added() if not ga_st: self.func.add_google_account_mr1(self.username, self.passwd) Settings.turn_on_account_auto_sync() Settings.take_bug_report() # a popup for taking a bug report should appear if EnvironmentUtils.get_android_version() == "N": self.assertTrue( self.d(text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT_N ).wait.exists(timeout=3000)) self.d(text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT_N ).click() else: self.assertTrue( self.d(text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT). wait.exists(timeout=3000)) self.d( text=SETTINGS_TAKE_BUG_REPORT_POPUP_REPORT_BUTTON_TXT).click() poll_waiting_tries_for_notification = 30 found_bug_report_notification = False while poll_waiting_tries_for_notification > 0: self.d.open.notification() time.sleep(10) while self.d(textContains="is being generated").exists: LOG.info("Waiting for bug report to be generated.") time.sleep(10) # if self.d(text=SETTINGS_TAKE_BUG_REPORT_NOTIFICATION_TXT).wait.exists(timeout=3000): if self.d(textStartsWith="Bug report").wait.exists(timeout=3000): # bug report was completed found_bug_report_notification = True break self.d.press.home() # close notifications poll_waiting_tries_for_notification -= 1 self.assertTrue( found_bug_report_notification, "a notification for the bugreport should have appeared") # StatusBar.open_notifications() # notifications already opened after break in for # self.assertTrue(self.d(text=SETTINGS_TAKE_BUG_REPORT_NOTIFICATION_TXT).wait.exists(timeout=3000), self.assertTrue( self.d(textStartsWith="Bug report").wait.exists(timeout=3000), "a bug report notification should exist in the notifications bar") # self.d(text=SETTINGS_TAKE_BUG_REPORT_NOTIFICATION_TXT).click() self.d(textStartsWith="Bug report").click() # popup to warn not to share sensitive data with untrusted parties SystemPopupsAndDialogs.popup_ok() # popup for choosing wich app will handle the bugreport # there are different types of popup for different Android versions and devices SystemPopupsAndDialogs.open_resource_with(GMAIL_APP_NAME) time.sleep(15) # gmail application must open with attached bug report information self.assertTrue( self.d(packageName=GMAIL_PACKAGE_NAME).wait.exists(timeout=5000), "gmail should have opened displaying the send bug report mail") time.sleep(5) SystemPopupsAndDialogs.popup_skip() # Gmail app setup time.sleep(5) if self.d(resourceId="com.google.android.gm:id/welcome_tour_skip" ).exists: self.d(resourceId="com.google.android.gm:id/welcome_tour_skip" ).click.wait() if self.d(resourceId="com.google.android.gm:id/action_done").exists: self.d(resourceId="com.google.android.gm:id/action_done" ).click.wait() self.d.press.back() Gmail.select_sync_account_now() time.sleep(20) self.assertTrue( self.d(textStartsWith=GMAIL_TAKE_BUG_REPORT_ATTACHEMENT_PREFIX_TXT ).wait.exists(timeout=50000), "mail should have an attachement containing bugreport details")
class dEQPImpl(object): 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 setup(self): g_common_obj.root_on_device() g_common_obj.remount_device() g_common_obj.adb_cmd_capture_msg("logcat -c") self._check_dependency() def run_case(self, case_name, check_extensions=False, extension_name=''): _inside_output = self.inside_output # Add inside function for further check extension tests. def _get_extension_list(): inside_content = g_common_obj.adb_cmd_capture_msg('cat %s' % _inside_output) return re.findall(r'\ +?<Text>(.+)</Text>', inside_content) # Start run deqp test. _results = { 'Passed': 0, 'Failed': 0, 'Not supported': 0, 'Warnings': 0 } LOG.debug("Testcase: %s" % (case_name)) setlog_cmd = "setprop log.tag.dEQP DEBUG" cmd = "am start -S -n com.drawelements.deqp/android.app.NativeActivity -e cmdLine \"" \ "deqp --deqp-log-filename=%s --deqp-case=%s\"" % (self.inside_output, case_name) self.device.adb_cmd_capture_msg_ext(repr(setlog_cmd)) self.device.adb_cmd_capture_msg_ext(repr(cmd)) # failures = ['Fail', 'ResourceError', 'Crash', 'Timeout', 'InternalError'] s_time = time.time() while time.time() - s_time < 900: cur_window = get_current_focus_window() time.sleep(2) if PACKAGENAME not in cur_window: LOG.debug("Test finished.") # Save deqp results to log. g_common_obj.adb_cmd_capture_msg('logcat -d -s dEQP > %s' % self._raw_deqp_result) # Handle results. logs = Popen('cat %s' % self._raw_deqp_result, shell=True, stdout=PIPE, stderr=PIPE).communicate()[0] for i in _results.keys(): chk_log = r"logcat -d -s dEQP | grep -oe '%s:\ \+[0-9]\+/[0-9]\+'" % i try: output = g_common_obj.adb_cmd_capture_msg(chk_log) num = output.split(' ')[-1].split('/')[0] _results[i] = int(num) except ValueError as e: raise Exception("Got error when running tests: %s" % e) assert sum(_results.values()) != 0, LOG.debug("Test not run.") LOG.debug("Raw summary: %s" % _results) if _results['Failed'] > 0: raw_failures = re.findall( r'Test case .(dEQP-.*[\d|\w]).+\n.+?dEQP +: +Fail.+?.', logs) head_name = raw_failures[0].split('.')[0].split( '-')[-1].lower() real_failures = [] for i in raw_failures: _is_mustpass = "******" % ( self._mustpass_path, head_name, i) chk = g_common_obj.adb_cmd_capture_msg(_is_mustpass) if chk == '': _results['Failed'] -= 1 _results['Not supported'] += 1 else: real_failures.append(i) if len(real_failures) > 0: f = open(self._failure_log, 'w') for i in real_failures: f.write(i + '\n') f.close() LOG.debug("Final summary: %s" % _results) # Handle event for extension list check. if check_extensions: ext_list = _get_extension_list() f = open(self._extension_list, 'w') # Save extension list to logfile. for el in ext_list: f.write(el + '\n') f.close() LOG.info("Extension list saved in: %s" % self._extension_list) assert extension_name in ext_list, "%s is not in this test." % extension_name LOG.info("%s is found in this test." % extension_name) return True else: if _results['Failed'] == 0: LOG.info("All tests passed.") return True else: raise Exception( "dEQP test failed, details refer to log file: %s" % self._failure_log) else: time.sleep(3) raise Exception("Test timeout.") 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) # 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: file_path = get_resource_from_atifactory( 'tests.common.dEQP.conf', 'dEQP', i.split('-')[0] + '_mustpass') g_common_obj.push_file(file_path, self._mustpass_path + '/')