def postprocess(self) :
        if self.requestResult.status_code != 200 :
            print 'Failing test because HTTP status code for main ' + \
                'application url was other than 200: ' + \
                str(self.requestResult.status_code)
            testing.test_fail(self.testname);

        # These are some vtk and paraview scripts that should appear in index.html
        # of the WebVisualizer application.
        baseUrl = 'http://' + self.host + ':' + str(self.port) + '/'
        requiredJavascriptLibs = [ baseUrl + 'lib/core/vtkweb-all.js',
                                   baseUrl + 'lib/js/paraview.ui.pipeline.js',
                                   baseUrl + 'lib/js/paraview.ui.toolbar.js',
                                   baseUrl + 'lib/js/paraview.ui.toolbar.vcr.js',
                                   baseUrl + 'lib/js/paraview.ui.toolbar.viewport.js' ]

        failedTest = False
        failMessage = "Unable to load the following modules: "

        # Iterate through the above Javascript include files and make sure
        # they are each included somewhere in the returned html text.
        for urlPath in requiredJavascriptLibs :
            r = requests.get(urlPath)

            if r.status_code != 200 :
                failMessage += '\n   ' + urlPath
                failedTest = True

        if failedTest is False :
            testing.test_pass(self.testname)
        else :
            print failMessage
            testing.test_fail(self.testname)
Example #2
0
    def postprocess(self):
        if self.requestResult.status_code != 200:
            print 'Failing test because HTTP status code for main ' + \
                'application url was other than 200: ' + \
                str(self.requestResult.status_code)
            testing.test_fail(self.testname)

        # These are some vtk and paraview scripts that should appear in index.html
        # of the WebVisualizer application.
        baseUrl = 'http://' + self.host + ':' + str(self.port) + '/'
        requiredJavascriptLibs = [
            baseUrl + 'lib/core/vtkweb-all.js',
            baseUrl + 'lib/js/paraview.ui.pipeline.js',
            baseUrl + 'lib/js/paraview.ui.toolbar.js',
            baseUrl + 'lib/js/paraview.ui.toolbar.vcr.js',
            baseUrl + 'lib/js/paraview.ui.toolbar.viewport.js'
        ]

        failedTest = False
        failMessage = "Unable to load the following modules: "

        # Iterate through the above Javascript include files and make sure
        # they are each included somewhere in the returned html text.
        for urlPath in requiredJavascriptLibs:
            r = requests.get(urlPath)

            if r.status_code != 200:
                failMessage += '\n   ' + urlPath
                failedTest = True

        if failedTest is False:
            testing.test_pass(self.testname)
        else:
            print failMessage
            testing.test_fail(self.testname)
def runTest(args) :

    # This name is used in error reporting
    testName = 'open_browser_and_click_renderer.py'

    # Request the WebVisualizer index.html
    urlToRetrieve = 'http://localhost:' + str(args.port) + '/apps/Visualizer'

    # print 'The args parameter contains: ' + str(args)

    # The author of pv_web_visualizer.py grabbed the --data-dir argument
    # from the command line and put it in a variable called "path" in the
    # arguments object, so that's where we look for the ParaViewData dir
    # inside this test script.
    baselineImgDir = args.baselineImgDir

    # Create a Chrome window driver.
    browser = webdriver.Chrome()
    browser.set_window_size(720, 480)
    browser.get(urlToRetrieve)

    sleepSeconds = 8
    time.sleep(sleepSeconds)

    clickPanel = browser.find_element_by_css_selector(".mouse-listener")
    clickPanel.click()
    time.sleep(1)

    # Now grab the renderer image and write it to disk
    imgdata = testing.get_image_data(browser, ".image.active>img")
    filename = 'test_pv_web_visualizer_renderer_click.jpg'
    testing.write_image_to_disk(imgdata, filename)

    knownGoodFileName = testing.concat_paths(baselineImgDir,
                                             'test_pv_web_visualizer_renderer_click_known_good.jpg')

    compareResult = -1

    try :
        compareResult = testing.compare_images(knownGoodFileName, filename)
        print 'Images compared with diff = ' + str(compareResult)
    except Exception as inst :
        print 'Caught exception in compareImages:'
        print inst
        testing.test_fail(testName)

    browser.quit()

    if compareResult != 0 :
        print "Images were different, diffsum was: " + str(compareResult)
        testing.test_fail(testName)

    testing.test_pass(testName)
def runTest(args) :
    """
    This function uses Selenium library to open a browser window and load the
    ParaView TestApp appliction.  Then it interacts with the application by
    making Javascript calls to verify that modules are registered and that
    protocols are working.
    """

    # print 'We were passed the following args: ' + str(args)

    # This name is used in error reporting
    testName = 'pv_web_test_app_all.py'

    # Request the WebVisualizer index.html
    urlToRetrieve = 'http://localhost:' + str(args.port) + '/apps/TestApp'

    # Create a Chrome window driver.
    browser = webdriver.Chrome()
    browser.set_window_size(1024, 768)
    browser.get(urlToRetrieve)

    sleepSeconds = 8
    print "Going to sleep for " + str(sleepSeconds) + " seconds to let browser load page"
    time.sleep(sleepSeconds)
    print "Ok, page should be loaded by now...continuing."

    startButton = browser.find_element_by_css_selector(".run-tests")
    startButton.click()

    # Loop until the javascript-side tests are finished
    while True :
        # Perform the check to see if tests are finished yet
        currentResults = browser.execute_script("return vtkWeb.testing.getCurrentTestResults();")

        if currentResults['finished'] is True :
            # Done with tests, check results
            testsSucceeded = currentResults['failures'] == 0

            if testsSucceeded :
                testing.test_pass(testName)
            else :
                testing.test_fail(testName)
                messageLog = browser.execute_script("return vtkWeb.testing.getTestLog();");
                print "Following is the message log from the tests:"
                print messageLog
                print

            break;

    # Don't forget to close the browser when we're done
    browser.quit()
def runTest(args) :

    # print 'Here is info on the supplied args: ' + str(dir(args))
    # print 'And here are the values: ' + str(args)

    # This name is used in error reporting
    testName = 'retrieve_index_and_check_includes.py'

    # Request the WebVisualizer index.html
    urlToRetrieve = 'http://localhost:' + str(args.port) + '/apps/TestApp'
    r = requests.get(urlToRetrieve)

    print "Status code: " + str(r.status_code)
    print "Content-Type: " + str(r.headers['content-type'])
    print "Encoding: " + str(r.encoding)

    if r.status_code != 200 :
        print 'Failing test because HTTP status code for main ' + \
            'application url was other than 200: ' + str(r.status_code)
        testing.test_fail(testName);

    # These are some vtk and paraview scripts that should appear in index.html
    # of the WebVisualizer application.
    baseUrl = 'http://localhost:' + str(args.port) + '/'
    requiredJavascriptLibs = [ baseUrl + 'lib/core/vtkweb-all.js',
                               baseUrl + 'lib/js/paraview.ui.pipeline.js',
                               baseUrl + 'lib/js/paraview.ui.toolbar.js',
                               baseUrl + 'lib/js/paraview.ui.toolbar.vcr.js',
                               baseUrl + 'lib/js/paraview.ui.toolbar.viewport.js' ]

    failedTest = False
    failMessage = "Unable to load the following modules: "

    # Iterate through the above Javascript include files and make sure
    # they are each included somewhere in the returned html text.
    for urlPath in requiredJavascriptLibs :
        r = requests.get(urlPath)

        if r.status_code != 200 :
            failMessage += '\n   ' + urlPath
            failedTest = True

    if failedTest is False :
        testing.test_pass(testName)
    else :
        print failMessage
        testing.test_fail(testName)
    def postprocess(self) :
        # Loop until the javascript-side tests are finished
        while True :
            # Perform the check to see if tests are finished yet
            currentResults = self.window.execute_script("return vtkWeb.testing.getCurrentTestResults();")

            if currentResults['finished'] is True :
                # Done with tests, check results
                testsSucceeded = currentResults['failures'] == 0

                if testsSucceeded :
                    testing.test_pass(self.testname)
                else :
                    testing.test_fail(self.testname)
                    messageLog = self.window.execute_script("return vtkWeb.testing.getTestLog();");
                    print "Following is the message log from the tests:"
                    print messageLog
                    print

                break;
Example #7
0
    def postprocess(self):
        # Loop until the javascript-side tests are finished
        while True:
            # Perform the check to see if tests are finished yet
            currentResults = self.window.execute_script(
                "return vtkWeb.testing.getCurrentTestResults();")

            if currentResults['finished'] is True:
                # Done with tests, check results
                testsSucceeded = currentResults['failures'] == 0

                if testsSucceeded:
                    testing.test_pass(self.testname)
                else:
                    testing.test_fail(self.testname)
                    messageLog = self.window.execute_script(
                        "return vtkWeb.testing.getTestLog();")
                    print "Following is the message log from the tests:"
                    print messageLog
                    print

                break
def runTest(args) :

    # print 'We were passed the following args: ' + str(args)

    if dependencies_met == False:
        raise testing.DependencyError("One of python modules 'selenium' or 'Image' is missing or deficient")

    # This name is used in error reporting
    testName = 'pv_web_file_loader_open_browser_and_click_renderer.py'

    # Request the WebVisualizer index.html
    urlToRetrieve = 'http://localhost:' + str(args.port) + '/apps/FileViewer'

    # The author of pv_web_visualizer.py grabbed the --data-dir argument
    # from the command line and put it in a variable called "path" in the
    # arguments object, so that's where we look for the ParaViewData dir
    # inside this test script.
    baselineImgDir = args.baselineImgDir
    print 'The baseline images are located here: ' + baselineImgDir

    # Create a Chrome window driver.
    browser = webdriver.Chrome()
    browser.set_window_size(720, 480)
    browser.get(urlToRetrieve)

    sleepSeconds = 8
    print "Going to sleep for " + str(sleepSeconds) + " seconds to let browser load page"
    time.sleep(sleepSeconds)
    print "Ok, page should be loaded by now...continuing."

    # First we need to hit the enter key to make the modal pop-up go away
    browser.switch_to_alert().accept()
    time.sleep(3)

    sphereDataLi = browser.execute_script("return $('.jstree-leaf:contains(dualSphereAnimation_P00T0003.vtp)')[0]")
    sphereDataLi.click()
    time.sleep(1)

    # Now click the resetCamera icon so that we change the center of
    # rotation
    resetCameraIcon = browser.find_element_by_css_selector("[action=resetCamera]");
    resetCameraIcon.click()
    time.sleep(1)

    # Now grab the renderer image and write it to disk
    imgdata = testing.get_image_data(browser, ".image.active>img")
    filename = 'image_sphere_part.jpg'
    testing.write_image_to_disk(imgdata, filename)

    print 'About to compare images...'

    knownGoodFileName = testing.concat_paths(baselineImgDir,
                                             'image_sphere_part_known_good.jpg')

    compareResult = -1

    try :
        compareResult = testing.compare_images(knownGoodFileName, filename)
        print 'Images compared with diff = ' + str(compareResult)
    except Exception as inst :
        print 'Caught exception in compareImages:'
        print inst
        testing.test_fail(testName)

    browser.quit()

    if compareResult != 0 :
        print "Images were different, diffsum was: " + str(compareResult)
        testing.test_fail(testName)

    testing.test_pass(testName)
Example #9
0
def runTest(args):

    # print 'We were passed the following args: ' + str(args)

    # This name is used in error reporting
    testName = 'pv_web_file_loader_open_browser_and_click_renderer.py'

    # Request the WebVisualizer index.html
    urlToRetrieve = 'http://localhost:' + str(args.port) + '/apps/FileViewer'

    # The author of pv_web_visualizer.py grabbed the --data-dir argument
    # from the command line and put it in a variable called "path" in the
    # arguments object, so that's where we look for the ParaViewData dir
    # inside this test script.
    baselineImgDir = args.baselineImgDir
    print 'The baseline images are located here: ' + baselineImgDir

    # Create a Chrome window driver.
    browser = webdriver.Chrome()
    browser.set_window_size(720, 480)
    browser.get(urlToRetrieve)

    sleepSeconds = 8
    print "Going to sleep for " + str(
        sleepSeconds) + " seconds to let browser load page"
    time.sleep(sleepSeconds)
    print "Ok, page should be loaded by now...continuing."

    # First we need to hit the enter key to make the modal pop-up go away
    browser.switch_to_alert().accept()
    time.sleep(3)

    sphereDataLi = browser.execute_script(
        "return $('.jstree-leaf:contains(dualSphereAnimation_P00T0003.vtp)')[0]"
    )
    sphereDataLi.click()
    time.sleep(1)

    # Now click the resetCamera icon so that we change the center of
    # rotation
    resetCameraIcon = browser.find_element_by_css_selector(
        "[action=resetCamera]")
    resetCameraIcon.click()
    time.sleep(1)

    # Now grab the renderer image and write it to disk
    imgdata = testing.get_image_data(browser, ".image.active>img")
    filename = 'image_sphere_part.jpg'
    testing.write_image_to_disk(imgdata, filename)

    print 'About to compare images...'

    knownGoodFileName = testing.concat_paths(
        baselineImgDir, 'image_sphere_part_known_good.jpg')

    compareResult = -1

    try:
        compareResult = testing.compare_images(knownGoodFileName, filename)
        print 'Images compared with diff = ' + str(compareResult)
    except Exception as inst:
        print 'Caught exception in compareImages:'
        print inst
        testing.test_fail(testName)

    browser.quit()

    if compareResult != 0:
        print "Images were different, diffsum was: " + str(compareResult)
        testing.test_fail(testName)

    testing.test_pass(testName)
def runTest(args) :

    # print 'We were passed the following args: ' + str(args)

    # This name is used in error reporting
    testName = 'pv_web_visualizer_open_browser_and_click_renderer.py'

    # Request the WebVisualizer index.html
    urlToRetrieve = 'http://localhost:' + str(args.port) + '/apps/Visualizer'

    # The author of pv_web_visualizer.py grabbed the --data-dir argument
    # from the command line and put it in a variable called "path" in the
    # arguments object, so that's where we look for the ParaViewData dir
    # inside this test script.
    baselineImgDir = args.baselineImgDir

    # Create a Chrome window driver.
    browser = webdriver.Chrome()
    browser.set_window_size(720, 480)
    browser.get(urlToRetrieve)

    sleepSeconds = 8
    time.sleep(sleepSeconds)

    # Click on the "Open file" icon to start the process of loading a file
    filesDiv = browser.find_element_by_css_selector(".action.files")
    filesDiv.click()
    time.sleep(1)

    # Click on the "can" link to load some paraview data.  We have the
    # expectation here that the paraview data dir with which we started the
    # server points to the "Data" folder in the standard ParaViewData git
    # repo.
    canLi = browser.execute_script("return $('.open-file:contains(can.ex2)')[0]")
    canLi.click()
    time.sleep(3)

    # Now choose how to color the object
    colorByLink = browser.find_element_by_css_selector(".colorBy.color")
    colorByLink.click()
    time.sleep(1)

    colorByDispLi = browser.find_element_by_css_selector(".points[name=DISPL]")
    colorByDispLi.click()
    time.sleep(1)

    endTimeLi = browser.find_element_by_css_selector(".action[action=last]")
    endTimeLi.click()
    time.sleep(1)

    rescaleIcon = browser.find_element_by_css_selector(".rescale-data")
    rescaleIcon.click()
    time.sleep(1)

    # Now click the resetCamera icon so that we change the center of
    # rotation
    resetCameraIcon = browser.find_element_by_css_selector("[action=resetCamera]");
    resetCameraIcon.click()
    time.sleep(1)

    '''
    # Click-and-drag on the cone to change its orientation a bit.
    listenerDiv = browser.find_element_by_css_selector(".mouse-listener")
    drag = ActionChains(browser)
    drag.move_to_element(listenerDiv)
    drag.click_and_hold()
    drag.move_by_offset(100, 0)
    drag.release()
    drag.perform()
    time.sleep(1)
    '''

    # Now grab the renderer image and write it to disk
    imgdata = testing.get_image_data(browser, ".image.active>img")
    filename = 'test_pv_web_visualizer_can_test.jpg'
    testing.write_image_to_disk(imgdata, filename)

    knownGoodFileName = testing.concat_paths(baselineImgDir,
                                             'test_pv_web_visualizer_can_test_known_good.jpg')

    compareResult = -1

    try :
        compareResult = testing.compare_images(knownGoodFileName, filename)
        print 'Images compared with diff = ' + str(compareResult)
    except Exception as inst :
        print 'Caught exception in compareImages:'
        print inst
        testing.test_fail(testName)

    browser.quit()

    if compareResult != 0 :
        print "Images were different, diffsum was: " + str(compareResult)
        testing.test_fail(testName)

    testing.test_pass(testName)