示例#1
0
def loading_time():

    progressbarWindow = ":_PersistentProgressDialog"
    progressBarLabelBiLAX = ":LAX4ch Contour detection is in progress..._QLabel"
    progressBarBiLAX = ":LAX4ch Contour detection is in progress..._QProgressBar"

    start = time.time()

    counter = 0
    while True:
        # If progress r exists, restart cycle
        if object.exists(progressbarWindow) is True or object.exists(
                progressBarBiLAX) is True:
            pass
    #             test.log("NOT BAD")
        else:
            # If dialog exists after initial pass, restart cycle and reset counter
            if object.exists(progressbarWindow) is True or object.exists(
                    progressBarBiLAX) is True:
                pass
                counter = 0

            # If dialog doesn't exist for three consecutive iterations, break and time.
            else:
                counter += 1
                if counter > 3:
                    break
    end = time.time()

    return end - start
示例#2
0
def load_series(window_given, series_num):

    series = ":scrollArea.frame-%s_SeriesThumbPreview" % (series_num - 1)

    window, x, y = find_window(window_given)

    # if series needed is bigger than 8, check if scrolling is needed to reach the series
    if object.exists(cvi42Objects.series_scrollbar):
        squish.scrollTo(squish.waitForObject(cvi42Objects.series_scrollbar),
                        -505)

        if series_num > 8:
            squish.scrollTo(
                squish.waitForObject(cvi42Objects.series_scrollbar), 855)

    # Load series into window requested

    squish.mouseMove(squish.waitForObject(series), 5, 5)
    squish.mousePress(squish.waitForObject(series))
    #     squish.snooze(1)
    squish.mouseRelease(squish.waitForObject(window))
    squish.snooze(0.2)

    if object.exists(":Load Volume.Yes_QPushButton"):
        squish.clickButton(
            squish.waitForObject(":Load Volume.Yes_QPushButton"))

    # Wait for progress bar
    time = loading_time()

    if time > 10:
        test.log("Time to load series: %.2f" % time)

    return
示例#3
0
def check_report42():

    reportTab = ":tabBar.Report_TabItem"
    greenStatusbar = ":webEngView.Save in progress_HTML_Object"
    reportLoading = "{container=':mCentralStack.stackWidget_QStackedWidget' name='webEndView' "
    "type='QWebEngineView' visible='1'}id='loader' tagName='DIV' type='HTML_Object' visible='true'}"
    feedbackMessage = ":webEngView.study-update-feeback_HTML_Object"

    counter = 0
    start = time.time()

    # Select the Report module to check progress, wait one second to allow the system to catch up
    studyFunctions.click_module("Report")
    #     squish.snooze(1)

    # Wait for the green progress bar to disappear
    while True:
        if object.exists(feedbackMessage):
            if object.exists(greenStatusbar) is True:
                pass

            else:
                if object.exists(greenStatusbar) is True or object.exists(
                        reportLoading) is True:
                    pass
                    counter = 0

                # If dialog doesn't exist for three consecutive iterations, break and time.
                else:
                    counter += 1
                    if counter > 2:
                        break
        else:
            pass
            counter += 1
            if counter > 100:
                test.log("Can't check report42")
                squish.mouseClick(squish.waitForObject(reportTab))
                return

    end = time.time()
    test.log("Added to report42 %.2f" % (end - start))
    #     squish.snooze(1)

    return
示例#4
0
    def startCura(self):

        # Get registered AUT name from conf file
        suite_conf = os.path.join(squishinfo.testCase, "..", "suite.conf")
        aut = None

        with open(suite_conf) as file:
            line = file.readline()
            while line:
                if line.startswith("AUT="):
                    aut = (line.split("AUT=")[1]).rstrip()
                    break

        startApplication(aut)

        waitForObject(names.mwi, 50000)
        if object.exists(names.mwi_changelog):
            self.click(names.mwi_changelog_btn_close)
示例#5
0
    def objectWithTextExists(self,
                             object_template,
                             value,
                             property="text",
                             lang=None,
                             exact_match=False,
                             pause=0):
        squish.snooze(
            pause /
            1000.0)  #Possibly we need to wait for the interface to update.
        if lang is not None:
            value = self.getTranslatedText(value, lang)

        obj = object_template.copy()
        if exact_match:
            obj[property] = value
        else:
            obj[property] = Wildcard("*" + value + "*")
        return object.exists(obj)
示例#6
0
def close_study():

    squish.activateItem(
        squish.waitForObjectItem(cvi42Objects.menuBar, "Workspace"))
    squish.snooze(0.5)
    squish.activateItem(
        squish.waitForObjectItem(cvi42Objects.workspaceButton, "Close Study"))
    start = time.time()

    while True:
        if object.exists(cvi42Objects.patientlistEditBox) is True:
            break
        else:
            pass
    end = time.time()

    test.log("Time to close study: %.2f" % (end - start))

    return
示例#7
0
def close_cvi42():

    while True:
        process_id = [
            item.split()[1]
            for item in os.popen('tasklist').read().splitlines()[4:]
            if "cvi42.exe" in item.split()
        ]

        if len(process_id) >= 1:
            os.system("taskkill /im cvi42.exe")

            if object.exists(cvi42Objects.QuitOkButton):
                squish.clickButton(
                    squish.waitForObject(cvi42Objects.QuitOkButton))

        else:
            break

    return
示例#8
0
def anonymize_study(study, anon_name):

    # If user is not in patient list page condition
    if object.exists(cvi42Objects.returnPatientlistButton) is True:
        squish.clickButton(
            squish.waitForObject(cvi42Objects.returnPatientlistButton))

    # Grabs the status bar object to check current message
    status = squish.waitForObject(cvi42Objects.statusBar)

    if "\\" in study:
        studyUpdated = study.replace("\\", "")
    else:
        studyUpdated = study

    # Searches for study, and anonymizes
    squish.waitForObject(cvi42Objects.patientlistEditBox).setText(studyUpdated)

    squish.openContextMenu(
        squish.waitForObjectItem(cvi42Objects.studyTreeitem, study), 50, 5, 0)

    squish.activateItem(
        squish.waitForObjectItem(cvi42Objects.contextMenu, "Anonymize Study"))
    squish.waitForObject(cvi42Objects.anonymizeEditBox).setText(anon_name)
    squish.clickButton(squish.waitForObject(cvi42Objects.anonymizeOkButton))

    start = time.time()
    #     squish.snooze(4)

    while True:
        if status.currentMessage() == "Import Study done":
            break
        else:
            pass
    end = time.time()

    test.log("Anonymizing %s time: %.2f" % (study, (end - start)))

    return anon_name
示例#9
0
def delete_study(study_name):

    squish.waitForObject(cvi42Objects.patientlistEditBox).setText(study_name)
    squish.openContextMenu(
        squish.waitForObjectItem(cvi42Objects.studyTreeitem, study_name), 50,
        13, 0)
    squish.activateItem(
        squish.waitForObjectItem(cvi42Objects.contextMenu, "Delete Study"))
    #     squish.snooze(1)
    squish.clickButton(squish.waitForObject(cvi42Objects.DeleteStudyOkButton))
    start = time.time()

    while True:
        if object.exists(cvi42Objects.UpdatingStudyListMessage):
            break
        else:
            pass
    end = time.time()

    #     test.log("Time to delete study: %.2f" %(end-start))

    squish.waitForObject(cvi42Objects.patientlistEditBox).setText("")

    return
示例#10
0
def load(study, ct=False):

    studyWindow = "{text='%s' type='QAction' unnamed='1' visible='true'}" % study

    # If study is already loaded condition
    if object.exists(studyWindow) is True:
        return

    # If user is not in patient list page condition
    if object.exists(cvi42Objects.returnPatientlistButton) is True:
        squish.clickButton(
            squish.waitForObject(cvi42Objects.returnPatientlistButton))

    # Grabs the status bar object to check current message
    status = squish.waitForObject(cvi42Objects.statusBar)

    if "\\" in study:
        studyUpdated = study.replace("\\", "")
    else:
        studyUpdated = study

    # Search for study in patient list
    squish.waitForObject(cvi42Objects.patientlistEditBox).setText(studyUpdated)
    squish.doubleClick(
        squish.waitForObjectItem(cvi42Objects.studyTreeitem, study), 22, 7, 0,
        squish.Qt.LeftButton)
    start = time.time()

    if ct == False:
        while True:
            # Wait until 'Loading Study done' message appears on statusbar
            if status.currentMessage() == "Loading Study done":
                end = time.time()
                test.log("Loading Study time: %.2f" % (end - start))
                break

            # If study already opened by another user condition
            if object.exists(cvi42Objects.studyOpenWindow) is True:
                squish.clickButton(
                    squish.waitForObject(cvi42Objects.studyOpenOK))

            # If study already opened, exit patient list window
            if status.currentMessage() == "Study Already Open":
                squish.clickButton(
                    squish.waitForObject(cvi42Objects.returnStudyButton))
                break

            # If study already loaded, exit patient list window
            if status.currentMessage() == "Study is already loaded.":
                squish.clickButton(
                    squish.waitForObject(cvi42Objects.returnStudyButton))
                break

        # If indication prompt is present
        if object.exists(cvi42Objects.SelectIndicationHeader) is True:
            squish.doubleClick(
                squish.waitForObject(cvi42Objects.NoIndicationButton))

    else:
        while True:
            # Wait until 'Select indication is on the screen'
            if object.exists(cvi42Objects.SelectIndicationHeader) is True:
                end = time.time()
                test.log("Loading Study time: %.2f" % (end - start))

                squish.doubleClick(
                    squish.waitForObject(cvi42Objects.NoIndicationButton))

                break

            # If study already opened by another user condition
            if object.exists(cvi42Objects.studyOpenWindow) is True:
                squish.clickButton(
                    squish.waitForObject(cvi42Objects.studyOpenOK))

            # If study already opened, exit patient list window
            if status.currentMessage() == "Study Already Open":
                squish.clickButton(
                    squish.waitForObject(cvi42Objects.returnStudyButton))
                break

            if object.exists(
                    ":mWorkflowDockWidget.mIndicationLabel_QLabel") is True:
                end = time.time()
                test.log("Loading Study time: %.2f" % (end - start))
                break
    return
示例#11
0
def click_module(module, ct=False):

    counter = 0
    moduleListItem = "{container=':mWorkflowDockWidget.protocolSteps_Workflow::ProtocolStepListWidget' text='%s' type='QModelIndex'}" % module

    # If the study is MR, the icon of the selected module is available in the toolbar. Checks if module already selected
    if ct == False:
        if object.exists(cvi42Objects.toolbarModuleButton) is True:
            if squish.waitForObject(
                    cvi42Objects.toolbarModuleButton).text == module:
                #                 test.log("Module Already Loaded")
                return

    while True:
        # If module not in the module list, search for it
        if object.exists(moduleListItem) is False:

            if counter == 0:
                # If module list scroll bar available, mouse scroll to try and find module
                if object.exists(cvi42Objects.moduleListScrollbar):
                    # Mouse scrolls up all the way to see top of visible module list
                    squish.sendEvent(
                        "QWheelEvent",
                        squish.waitForObject(cvi42Objects.moduleListScrollbar),
                        103, 527, 540, 0, 2)

                    # If module is visible, click it, and exit loop
                    if object.exists(moduleListItem) is True:
                        squish.mouseClick(squish.waitForObject(moduleListItem))

                        time = loading_time()
                        if time > 10:
                            test.log("Time to load module: %.2f" % time)
                        break

                    # If scroll bar available, scroll down a little bit each iteration
                    squish.sendEvent(
                        "QWheelEvent",
                        squish.waitForObject(cvi42Objects.moduleListScrollbar),
                        3, 307, -340, 0, 2)

                # If mouse scroll bar not available, pass each time
                else:
                    pass

            counter += 1

            # After four attempts, if module is not found, select it from the protocol list and click the module
            if counter == 4:
                squish.mouseClick(
                    squish.waitForObject(cvi42Objects.addProtocolButton))
                squish.activateItem(
                    squish.waitForObjectItem(cvi42Objects.addProtocolWindow,
                                             module))

                squish.mouseClick(squish.waitForObject(moduleListItem))

                time = loading_time()
                if time > 10:
                    test.log("Time to load module: %.2f" % time)

                return

        # If module exists from the beginning, select it and exit
        else:
            squish.mouseClick(squish.waitForObject(moduleListItem))

            time = loading_time()
            if time > 10:
                test.log("Time to load module: %.2f" % time)

            return

    return
示例#12
0
def login(user, server):
    
    # If cvi42 already running dialog popup
    if object.exists(cvi42Objects.cviAlreadyRunning):
        squish.mouseClick(squish.waitForObject(cvi42Objects.cviAlreadyRunningOk))
    
    # If cvi42 disconnected
    if object.exists(cvi42Objects.mainDialog):
        if object.exists(cvi42Objects.LoginDialog) is False:
            test.log("Already Logged In")
            return
    
    # Grabs desired server name
    squish.mouseClick(squish.waitForObject(cvi42Objects.serverBox), 164, 7, 0, squish.Qt.LeftButton)
    squish.mouseClick(squish.waitForObjectItem(cvi42Objects.serverBox, server), 105, 8, 0, squish.Qt.LeftButton)

    # Populates username and password boxes and clicks login
    squish.mouseClick(squish.waitForObject(cvi42Objects.usernameBox))
    squish.waitForObject(cvi42Objects.usernameBox).setText(user)
    squish.waitForObject(cvi42Objects.passwordBox).setText(user)
    
    squish.clickButton(squish.waitForObject(cvi42Objects.LoginButton))   
    start = time.time()
    start2 = time.time()
        
    # If user already logged on dialog
    if object.exists(cvi42Objects.userAlreadyLoggedOn):
        squish.mouseClick(squish.waitForObject(cvi42Objects.userAlreadyLoggedOnOk))
        
    # Benchmark splash screen measurements
    splash = squish.waitForObject(cvi42Objects.splash)
    message = splash.message()
    
    counter = 0
    while True:
        try:
            if object.exists(cvi42Objects.splash):
                if message == splash.message():
                    pass
                else:
                    splash_end = time.time()
                    test.log("Time for %s: %.2f" %(message, (splash_end-start2)))
                    message = splash.message()
                    start2 = time.time()
                    
            else:
                break
        except:
            break
            
    status = squish.waitForObject(cvi42Objects.statusBar);
        
    while True:
        if status.currentMessage() == "Load image previews done":
            break
        else:
            pass

    end = time.time()
    test.log("Time to Login: %.2f" % (end-start))
    
    return