def add_wl(wireless, ssid, case_name, result_file):
    log.info('start add wireless profile {}'.format(ssid))
    wireless.add(ssid=ssid)
    wireless.apply_and_ok()
    icon = wait_element(wl_pic("_move_mouse"), offset=(0, 10))
    tool.click(icon[0][0], icon[0][1], num=2)
    if wait_element(wl_pic("_{}".format(ssid))):
        log.info("wireless profile {} add success".format(ssid))
        steps = {
            'step_name': 'check all the configurations could be saved -- add',
            'result': 'Pass',
            'expect': '',
            'actual': '',
            'note': ''
        }
        update_cases_result(result_file, case_name, steps)
    else:
        error_pic = os.path.join(get_current_dir(), r'Test_Report', 'img',
                                 '{}+add1.png'.format(case_name))
        capture_screen(error_pic)
        steps = {
            'step_name': 'check all the configurations could be saved -- add',
            'result': 'Fail',
            'expect': 'saved',
            'actual': 'no exists',
            'note': '{}'.format(error_pic)
        }
        update_cases_result(result_file, case_name, steps)
        wireless.wl_set_apply()
        return False
    wireless.wl_set_apply()
    time.sleep(25)
    if check_wl("add_res"):
        log.info('new wireless profile connection success')
        steps = {
            'step_name':
            'check could successful connect to specified AP -- add',
            'result': 'Pass',
            'expect': '',
            'actual': '',
            'note': ''
        }
        update_cases_result(result_file, case_name, steps)
    else:
        error_pic = os.path.join(get_current_dir(), r'Test_Report', 'img',
                                 '{}+add2.png'.format(case_name))
        capture_screen(error_pic)
        steps = {
            'step_name':
            'check could successful connect to specified AP -- add',
            'result': 'Fail',
            'expect': 'connect',
            'actual': 'disconnect',
            'note': '{}'.format(error_pic)
        }
        update_cases_result(result_file, case_name, steps)
        close_wl_statistics()
        reset_setting(wireless, ssid)
        return False
    close_wl_statistics()
def start(case_name, **kwargs):
    try:
        log.info('Begin to start test {}'.format(case_name))
        user_manager = vdi_connection.MultiUserManger()
        user = user_manager.get_a_available_key()
        rdp_server = user_manager.get_a_available_key('rdp win10')
        conn = vdi_connection.RDPLinux(user=user, rdp_server=rdp_server)
        log.info('user: {}, rdp_server: {}'.format(user, rdp_server))
        report_file = os.path.join(
            common_function.get_current_dir(), r'Test_Report',
            '{}.yaml'.format(common_function.check_ip_yaml()))
        common_function.new_cases_result(report_file, case_name)
        common_function.case_steps_run_control(steps_list,
                                               __name__,
                                               case_name=case_name,
                                               log=log,
                                               report_file=report_file,
                                               user=user,
                                               rdp_server=rdp_server,
                                               conn=conn,
                                               user_manager=user_manager)
    except:
        log.error(traceback.format_exc())
        error_pic = os.path.join(common_function.get_current_dir(),
                                 r'Test_Report', 'img',
                                 '{}.png'.format(case_name))
        picture_operator.capture_screen(error_pic)
        reset_all_settings(num=0)
        return False
def delete_wl(wireless, ssid, case_name, result_file):
    log.info('start delete wireless profile {}'.format(ssid))
    wireless.delete(ssid=ssid)
    icon = wait_element(wl_pic("_move_mouse"), offset=(0, 10))
    tool.click(icon[0][0], icon[0][1], num=2)
    if not wait_element(wl_pic("_{}".format(ssid))):
        log.info("wireless profile {} delete success".format(ssid))
        steps = {
            'step_name': 'check selected profile could be deleted',
            'result': 'Pass',
            'expect': '',
            'actual': '',
            'note': ''
        }
        update_cases_result(result_file, case_name, steps)
    else:
        error_pic = os.path.join(get_current_dir(), r'Test_Report', 'img',
                                 '{}+delete1.png'.format(case_name))
        capture_screen(error_pic)
        steps = {
            'step_name': 'check selected profile could be deleted',
            'result': 'Fail',
            'expect': 'deleted',
            'actual': 'exists',
            'note': '{}'.format(error_pic)
        }
        update_cases_result(result_file, case_name, steps)
        wireless.wl_set_apply()
        reset_setting(wireless, ssid)
        return False
    wireless.wl_set_apply()
    time.sleep(25)
    if not check_wl("edit_res"):
        log.info('deleted wireless connection disconnection success')
        steps = {
            'step_name':
            'check thinpro will disconnect from the wireless network',
            'result': 'Pass',
            'expect': '',
            'actual': '',
            'note': ''
        }
        update_cases_result(result_file, case_name, steps)
    else:
        error_pic = os.path.join(get_current_dir(), r'Test_Report', 'img',
                                 '{}+delete2.png'.format(case_name))
        capture_screen(error_pic)
        steps = {
            'step_name':
            'check thinpro will disconnect from the wireless network',
            'result': 'Fail',
            'expect': 'disconnect',
            'actual': 'connect',
            'note': '{}'.format(error_pic)
        }
        update_cases_result(result_file, case_name, steps)
        close_wl_statistics()
        reset_setting(wireless, ssid)
        return False
    close_wl_statistics()
Exemple #4
0
def restart_network():
    log.info("restart network from network systray icon")
    nw = wait_element(
        cf.get_current_dir(
            "Test_Data/td_network/wired/_wired_connect_systray"))
    if not nw:
        log.error("not found network systray icon")
        return False
    pyautogui.click(nw[0])
    stop = wait_element(
        cf.get_current_dir("Test_Data/td_network/wired/_systray_restart"))
    if not stop:
        log.error("not found network systray stop icon")
        return False
    pyautogui.click(stop[0])
    wireless = network_setting.Wireless()
    for i in range(20):
        log.info("wait network disconnect...")
        time.sleep(2)
        if not wireless.check_wireless_connected():
            log.info("network disconnected")
            break
    else:
        log.error("network disconnect fail")
        return False
    for i in range(40):
        log.info("wait network connect...")
        time.sleep(3)
        if wireless.check_wireless_connected():
            log.info("network connected success")
            log.info("restart network from network systray icon success")
            return True
    log.error("network connected fail")
    log.error("restart network from network systray icon fail")
    return False
Exemple #5
0
def start(case_name, **kwargs):
    try:
        log.info('Begin to start case {}'.format(case_name))
        result_file = os.path.join(get_current_dir(), r'Test_Report',
                                   '{}.yaml'.format(check_ip_yaml()))
        new_cases_result(result_file, case_name)
        SwitchThinProMode(switch_to='admin')
        default_method = get_connection_method()
        wired = Wired()
        if dynamic_ip_check(case_name, result_file, wired) is False:
            reset_connection_method(default_method)
            return
        if dynamic_ip_ping(case_name, result_file) is False:
            reset_connection_method(default_method)
            return
        ip = get_ip()
        mask = wired.get_mask('eth0')
        gateway = wired.gateway()
        if static_ip_check(case_name, result_file, wired, ip, mask,
                           gateway) is False:
            reset_connection_method(default_method)
            return
        if static_ip_ping(case_name, result_file) is False:
            reset_connection_method(default_method)
            return
    except:
        log.error(traceback.format_exc())
        error_pic = os.path.join(get_current_dir(), r'Test_Report', 'img',
                                 '{}.png'.format(case_name))
        capture_screen(error_pic)
        os.system("wmctrl -c 'Control Panel'")
Exemple #6
0
 def __get_src_files(self):
     static_path = os.path.join(os.getcwd(), self.__static_src)
     if os.path.exists(get_current_dir('Test_Report', 'static')):
         shutil.rmtree(get_current_dir('Test_Report', 'static'))
         log.info('Target static folder exist, remove the old folder')
     shutil.copytree(static_path, get_current_dir('Test_Report', 'static'))
     log.info('Copy static folder to report folder finished')
     return True
Exemple #7
0
 def wrapper(*args, **kwargs):
     res = func(*args, **kwargs)
     if not res:
         return False
     loc, shape = res
     checked = status.get("checkedbox", "")
     text = status.get("text", "")
     selected = status.get("selected", "")
     loc_x, loc_y = loc
     save_path = get_current_dir() + "/Test_Data/td_power_manager/temp.png"
     if checked:
         checked_path = get_current_dir("Test_Data/td_power_manager/verify_screen_saver_works/checked")
         if checked.lower() == "disabled":
             checked_path = get_current_dir("Test_Data/td_power_manager/verify_screen_saver_works/unchecked")
         pic_list = get_folder_items(checked_path)
         assert pic_list != [], "{} not exist".format(checked_path)
         off_x, off_y = -30, -15
         fil_x = loc_x + off_x if loc_x + off_x > 0 else 0
         fil_y = loc_y + off_y if loc_y + off_y > 0 else 0
         filter_dic = {"left": fil_x, "top": fil_y, "width": 30, "height": 30}
         capture_screen_by_loc(save_path, filter_dic)
         for i in pic_list:
             if compare_pic_similarity(checked_path + "/" + i, save_path):
                 break
         else:
             return False
     elif text:
         text_path = get_current_dir("Test_Data/td_power_manager/verify_screen_saver_works/text/{}".format(text))
         pic_list = get_folder_items(text_path)
         assert pic_list != [], "{} not exist".format(text_path)
         off_x, off_y = shape[1] - 10, -15
         fil_x = loc_x + off_x if loc_x + off_x > 0 else 0
         fil_y = loc_y + off_y if loc_y + off_y > 0 else 0
         filter_dic = {"left": fil_x, "top": fil_y, "width": 200, "height": 35}
         capture_screen_by_loc(save_path, filter_dic)
         for i in pic_list:
             if compare_pic_similarity(text_path + "/" + i, save_path):
                 break
         else:
             return False
     elif selected:
         text_path = get_current_dir("Test_Data/td_power_manager/verify_screen_saver_works/selected/{}".format(selected.lower()))
         pic_list = get_folder_items(text_path)
         assert pic_list != [], "{} not exist".format(text_path)
         off_x, off_y = shape[1] - 10, -15
         fil_x = loc_x + off_x if loc_x + off_x > 0 else 0
         fil_y = loc_y + off_y if loc_y + off_y > 0 else 0
         filter_dic = {"left": fil_x, "top": fil_y, "width": 200, "height": 35}
         capture_screen_by_loc(save_path, filter_dic)
         for i in pic_list:
             if compare_pic_similarity(text_path + "/" + i, save_path):
                 break
         else:
             return False
     return True
 def wrapper(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except LogonError:
         traceback.print_exc()
         white_list = None
         cs = ""
         if args:
             vdi = args[0].__class__.__name__.lower()
             if "rdp" in vdi:
                 white_list = white_list_rdp
             elif "view" in vdi:
                 white_list = white_list_view
             elif "citrix" in vdi:
                 white_list = white_list_citrix
             except_pic_path = "{}/Test_Report".format(cf.get_current_dir())
             if not os.path.exists(except_pic_path):
                 os.makedirs(except_pic_path)
             cs = capture_screen(except_pic_path + "/{}_exception.png".format(vdi))
         flag = False
         if white_list:
             self = args[0]
             for k, v in white_list.items():
                 if v and k.lower() == "pic":
                     flag = self.check_picture(v, cs)
         if flag:
             raise Continue
         else:
             raise LogonError
Exemple #9
0
 def get_website_response(self):
     log.info('get data from {}'.format(self.host_name))
     # try:
     #     data_temp = requests.get(self.host_name, timeout=5).status_code
     # except Exception:
     #     data_temp = 'Error'
     #     log.info(traceback.format_exc())
     # if data_temp == 200:
     #     data = data_temp
     # else:
     #     data = 'Error'
     # return data
     file = common_function.get_current_dir('index.html')
     if os.path.exists(file):
         os.remove(file)
     cmd = 'wget -T 5 -t 2 {}'.format(self.host_name)
     log.info(cmd)
     subprocess.run(cmd,
                    shell=True,
                    stdout=subprocess.PIPE,
                    encoding='utf-8')
     for i in range(5):
         if os.path.exists(file):
             status = 200
             time.sleep(5)
             log.info('remove {}'.format(file))
             os.remove(file)
             break
     else:
         status = 0
     return status
Exemple #10
0
def set_eth0_speed(ethernet_speed):
    try:
        cf.SwitchThinProMode("admin")
        wired = network_setting.Wired()
        wired.open_network_wired_dialog()
        wired.set_ethernet_speed(speed=ethernet_speed)
        wired.apply()
        log.info("close control panel")
        wired.close_control_panel()
        time.sleep(1)
        s = subprocess.getoutput(
            "mclient --quiet get root/Network/Wired/EthernetSpeed")
        if s == ethernet_speed:
            log.info(
                "set 'Ethernet Speed' is '{}' success".format(ethernet_speed))
            return True
        else:
            log.error(
                "set 'Ethernet Speed' is '{}' fail".format(ethernet_speed))
            return False
    except:
        log.error(traceback.format_exc())
        pyautogui.screenshot(
            cf.get_current_dir(
                "Test_Report/check_speed_{}.png".format(ethernet_speed)))
        return False
def pic_path(pic_name):
    path = os.path.join(
        common_function.get_current_dir(),
        'Test_Data/td_power_manager/verify_screensaver_diff_image'
        '/source_pic/{}'.format(pic_name))
    log.info('select the source picture:{}'.format(path))
    return path
 def __capture_part_screen(self, icon_path, position: tuple) -> tuple:
     save_path = get_current_dir("loc_demo.png")
     if not position:
         return picture_operator.wait_element(icon_path, offset=(0, 0))
     if not len(position) == 4:
         raise KeyError(
             "Position must be a tuple as: (left, top, width, height)")
     left, top, width, height = position
     current_x, current_y = self.loc
     pos = {
         "left": current_x + left,
         "top": current_y + top,
         "width": width,
         "height": height
     }
     capture_screen_by_loc(file_path=save_path, loc_dic=pos)
     items = get_folder_items(icon_path, file_only=True, filter_name=".png")
     pic_path_list = list(
         map(lambda file_name: icon_path + f"/{file_name}", items))
     for pic_item in pic_path_list:
         element_shape = compare_pic_similarity(img=pic_item, tmp=save_path)
         if element_shape:
             loc, size = element_shape
             loc_x, loc_y = loc
             current_left, current_top = current_x + left + loc_x, current_y + top + loc_y
             return (current_left, current_top), size
     return ()
def reset_settings(*args, **kwargs):
    case_name = kwargs.get('case_name')
    SwitchThinProMode(switch_to='admin')
    if not click_icon('start'):
        unlock_screen('root', '1')
    try:
        power_m = PowerManagerFactory("ScreenSaver")
        power_m.ScreenSaver.open_power_manager_from_control_panel()
        power_m.ScreenSaver.switch()
        power_m.ScreenSaver.set(
            pms=pms.ScreenSaver.Enable_Screensaver_and_Screen_Lock, radio="on")
        power_m.ScreenSaver.set(
            pms=pms.ScreenSaver.Require_password_for_general_users,
            radio="off")
        power_m.ScreenSaver.apply()
        time.sleep(5)
        power_m.ScreenSaver.close_all_power_manager()
    except:
        log.debug(
            traceback.format_exc(),
            common_function.get_current_dir(
                'Test_Report', 'img',
                '{}.png'.format(case_name.replace(' ', '_'))))
        os.system(
            "mclient --quiet set root/screensaver/lockScreenUser {}".format(0))
        os.system("mclient commit")
    os.system('hptc-control-panel --term')
    web = WebConn([])
    web.close_web_connection()
    tl = TelnetLinux()
    tl.logoff()
    if os.path.exists(path):
        os.remove(path)
def linux_check_locked(**kwargs):
    path = os.path.join(common_function.get_current_dir(), 'Test_Data', 'td_power_manager', 'locked_pic')
    path1 = kwargs.get('path', path)
    if picture_operator.wait_element(os.path.join(path1), cycle=1):
        return True
    else:
        return False
 def xml_file_path(self):
     if len(self.ports_name_list) > 6:
         print('Exceeded template length')
         raise FileNotFoundError
     xml_file_name = 'displays_template.xml'
     return get_current_dir('Test_Data/td_multiple_display/' +
                            xml_file_name)
Exemple #16
0
 def __load_uut_result(self):
     result_file = get_current_dir('Test_Report', '{}.yaml'.format(self.ip))
     if not os.path.exists(result_file):
         empty_result = [{
             'uut_name': self.ip,
             'case_name': 'No result return',
             'steps': [],
             'result': 'fail'
         }, {
             'uut_name': self.ip,
             'case_name': 'No result return',
             'steps': [],
             'result': 'pass'
         }]
         log.error('Result File {} Not Exsit'.format(result_file))
         result = empty_result
     else:
         with open(result_file, encoding='utf-8') as f:
             result = yaml.safe_load(f.read())
     try:
         self.return_to_ALM(result)
     except Exception as e:
         log.error('Fail to return result to ALM:')
         log.error(str(e))
     return result
def verify_cpu_mhz(mode, case_name, power_manager):
    try:
        if mode == 'ondemand':
            low_mhz = linux_get_cpu_mhz(mode)
            select_mode('performance', power_manager)
            time.sleep(15)
            high_mhz = linux_get_cpu_mhz('performance')
            log.info("ondemand mode:{}, performance mode:{}".format(
                low_mhz, high_mhz))
            return [high_mhz, low_mhz]
        else:
            high_mhz = linux_get_cpu_mhz(mode)
            select_mode('ondemand', power_manager)
            time.sleep(15)
            low_mhz = linux_get_cpu_mhz('ondemand')
            log.info("performance mode:{}, ondemand mode:{}".format(
                high_mhz, low_mhz))
            return [high_mhz, low_mhz]
    except:
        log.error(traceback.format_exc())
        error_pic = os.path.join(common_function.get_current_dir(),
                                 r'Test_Report', 'img',
                                 '{}.png'.format(case_name))
        capture_screen(error_pic)
        os.system("wmctrl -c 'Control Panel'")
        return '0'
def step_2_2():
    log.info("start check wireless after reboot")
    cf.SwitchThinProMode("admin")
    wireless = network_setting.Wireless()
    for i in range(24):
        log.info("wait connect wireless...")
        time.sleep(5)
        if wireless.check_wireless_connected():
            log.info("wireless is connected")
            break
    else:
        log.error("connect wireless time out")
        return [False, "connect wireless time out"]

    if not wait_element(pic("_systray_connect")):
        log.error("not found the wireless systray icon")
        pyautogui.screenshot(
            cf.get_current_dir(
                "Test_Report/ssid_disable_and_enable_wireless_error.png"))
        return [False, "not found the wireless systray icon"]
    log.info("found the wireless systray icon")

    wireless.open_network()
    wireless.switch_to_wireless_tab()
    if not wait_element(pic("_black_add_gray_edit_del"), rate=0.99):
        log.error("not found the black add and edit delete")
        return [False, "not found the black add and edit delete"]
    log.info("found the black add and edit delete")
    wireless.close_control_panel()
    restore()
    # log.info("{:+^80}".format("test case pass"))
    return [True, "success"]
 def __getattr__(self, item):
     log.info(f"-> Find Item: {item}")
     pic_path, offset, position = self.pic_settings.get(item, (None, ()))
     if not pic_path:
         raise KeyError(f"pic settings doesn't have Item: {item}")
     icon_path = get_current_dir(pic_path)
     if not os.path.exists(icon_path):
         raise PathNotFoundError(
             f"Pic Path: '{icon_path}' Not Exists, Current Path: {icon_path}"
         )
     if not self.loc:
         element_shape = picture_operator.wait_element(icon_path,
                                                       offset=(0, 0))
     else:
         element_shape = self.__capture_part_screen(icon_path=icon_path,
                                                    position=position)
     if not element_shape:
         raise PicNotFoundError(
             f"Item: '{item}' Icon not found, Current Path: {icon_path}")
     loc = self.__calculate_midpoint(loc=element_shape[0],
                                     size=element_shape[1],
                                     offset=offset)
     flow_obj = self.__class__(loc=loc, name=item, pic_path=pic_path)
     log.info(flow_obj)
     return flow_obj
    def __update_result(self):
        step = {
            'step_name': '',
            'result': 'PASS',
            'expect': '',
            'actual': '',
            'note': ''
        }
        step.update({'step_name': self.event_method_name})
        if not self.flag:
            if self.capture:
                path = get_current_dir(
                    "Test_Report/img/{}__{}_exception.png".format(
                        self.case_name, self.event_method_name))
                log.warning(f"capture path: {path}")
                capture_screen(path)
            step.update({
                'result':
                'Fail',
                'expect':
                self.error_msg.get("expect", ""),
                'actual':
                self.error_msg.get("actual", ""),
                'note':
                '{}__{}_exception.png'.format(self.case_name,
                                              self.event_method_name)
                if self.capture else ""
            })
        else:

            step.update(self.success_msg)
        update_cases_result(self.yml_path, self.case_name, step)
        return
 def wrapper(*args, **kwargs):
     self, pms, loc, shape = args
     flag = kwargs.get("radio", "")
     print(args, flag, "check_radio")
     loc_x, loc_y = loc
     print(loc_x, loc_y, "check_radio")
     off_x, off_y = 22, 5
     fil_x = loc_x - off_x if loc_x - off_x > 0 else 0
     fil_y = loc_y - off_y if loc_y - off_y > 0 else 0
     filter_dic = {"left": fil_x, "top": fil_y, "width": 30, "height": 30}
     save_path = get_current_dir() + "/Test_Data/td_power_manager/temp.png"
     capture_screen_by_loc(save_path, filter_dic)
     if flag.upper() == "ON":
         path_sel = self._file_path + "Common/Radio_selected/"
         pic_path_list = get_folder_items(path_sel, file_only=True)
         for i in pic_path_list:
             if compare_pic_similarity(path_sel + i, save_path):
                 print(self.Info.format("Status is already checked"))
                 return
         else:
             func(*args, **kwargs)
     elif flag.upper() == "OFF":
         path_sel = self._file_path + "Common/Radio_unselected/"
         pic_path_list = get_folder_items(path_sel, file_only=True)
         for i in pic_path_list:
             if compare_pic_similarity(path_sel + i, save_path):
                 print(self.Info.format("Status is already unchecked"))
                 return
         else:
             func(*args, **kwargs)
Exemple #22
0
 def __init__(self):
     self.para = common_function.load_global_parameters()
     self.target_platform = self.para['platform']
     self.current_path = common_function.get_current_dir()
     self.log = common_function.log
     self.log.info("-" * 60)
     self.log.info("case name: Verify_security_boot_enabled")
def login_domain_user(*args, **kwargs):
    case_name = kwargs.get("case_name")
    result_file = kwargs.get("report_file")
    log.info('2.1. Login with  !#$%^  Shanghai2010')
    time.sleep(10)
    domain_login(user_name='!#$%^', password="******")
    time.sleep(5)
    if check_account('start') or check_account('domain_icon'):
        steps = {
            'step_name': 'login domain account success',
            'result': 'Pass',
            'expect': 'login success',
            'actual': 'success',
            'note': ''
        }
        common_function.update_cases_result(result_file, case_name, steps)
    else:
        error_pic = os.path.join(common_function.get_current_dir(),
                                 r'Test_Report', 'img',
                                 'login_domain_user_result.png')
        picture_operator.capture_screen(error_pic)
        steps = {
            'step_name': 'login domain account success',
            'result': 'Fail',
            'expect': 'login success',
            'actual': 'fail',
            'note': '{}'.format(error_pic)
        }
        common_function.update_cases_result(result_file, case_name, steps)
        reset_all_settings(num=0)
        return False
def pic_cut(folder, name):
    pic = os.path.join(
        common_function.get_current_dir(),
        'Test_Data/td_power_manager/verify_screensaver_diff_image',
        '{}/{}.png'.format(folder, name))
    capture_screen(pic)
    return pic
Exemple #25
0
 def __init__(self):
     self.log = common_function.log
     self.path = common_function.get_current_dir()
     self.scr_save = screensaver.ScreenSaver()
     self.vdi = None
     self.user = ''
     self.rdp_server = ''
def step2(power_m):
    try:
        set_image_slideshowstretch(power_m)
        power_m.ScreenSaver.apply()
        time.sleep(5)
        lock_screen()
        img21, size21 = open_pic(pic_cut('3', '1'))
        data21 = get_pic_color(img21, get_xy(size21))
        log.info(data21)
        for _ in range(3):
            time.sleep(5)
            img22, size22 = open_pic(pic_cut('3', '2'))
            data22 = get_pic_color(img22, get_xy(size22))
            if data21 != data22:
                break
        else:
            time.sleep(5)
            img22, size22 = open_pic(pic_cut('3', '2'))
            data22 = get_pic_color(img22, get_xy(size22))
        log.info(data22)
        locked_wake_up()
        time.sleep(5)
        return data21, data22
    except:
        log.debug(
            traceback.format_exc(),
            common_function.get_current_dir(
                'Test_Report', 'img', 'different_image_slideshowstretch.png'))
        power_m.ScreenSaver.apply()
        power_m.close_all_power_manager()
        return None
def check_min_to_zero():
    path = get_current_dir(
        "Test_Data/td_power_manager/verify_sleep_mode_disabled")
    res = wait_element(path)
    if res:
        return True
    return False
 def step_unlock_result(self,
                        report_file,
                        case_name,
                        unlock_result='win10'):
     if self.check_unlock_result(unlock_result):
         step = {
             'step_name': 'Check unlock result for vdi view',
             'result': 'Pass',
             'expect': 'Unlock vdi view successfully.',
             'actual': 'Unlock vdi view successfully.',
             'note': 'none'
         }
         common_function.update_cases_result(report_file, case_name, step)
         return True
     else:
         self.log.debug(
             'Fail to unlock vdi view',
             common_function.get_current_dir("Test_Report", 'img',
                                             'unlock_vdi_view_result.png'))
         step = {
             'step_name': 'Check unlock result for vdi view',
             'result': 'Fail',
             'expect': 'Unlock vdi view successfully.',
             'actual': 'Fail to unlock vdi view.',
             'note': 'none'
         }
         common_function.update_cases_result(report_file, case_name, step)
         return False
Exemple #29
0
def check_layout(source):
    temp_pic = picture_operator.capture_screen(os.path.join(common_function.get_current_dir(), 'temp.png'), auto_fix=True)
    if temp_pic:
        flag = False
        if not os.path.exists(source):
            flag = True
        return [*picture_operator.compare_picture_auto_collect(temp_pic, source, auto_fix=True), flag]
def template_pic_path(p):
    path = os.path.join(
        common_function.get_current_dir(),
        'Test_Data/td_power_manager/verify_screensaver_diff_image'
        '/{}'.format(p))
    log.info('verify the template picture:{}'.format(path))
    return path