Exemple #1
0
def test_maximize_restore(cartavisInstance, cleanSlate):
    """
    Test that a window can be maximized and then restored to 
    its original position
    """
    # Find and select the animation window 
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])

    # Look for the maximize button in the submenu
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is a single animator window
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Right click the context menu to restore a animator window
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there are exactly the same number of windows as there were originally and the animation window is present
    assert len(cartavisInstance.getAnimatorViews()) == 1
Exemple #2
0
    def isDiffConstant(self, f1, f2, f3):
        try:
            np1 = self.getImgNp(f1)
            np2 = self.getImgNp(f2)
            np3 = self.getImgNp(f3)

            diff_matrix_12 = ImageUtil.get_diff_matrix(np1, np2)
            #print "isDiffConstant : diff_" , f1, f2 ,

            option_diff_list = []
            for i in range(1, 7):
                option_np = self.getImgNp(str(i))
                diff_matrix_3i = ImageUtil.get_diff_matrix(np3, option_np)
                option_diff = ImageUtil.find_diff(diff_matrix_12,
                                                  diff_matrix_3i)
                option_diff_list.append(option_diff)
            min_diff = min(option_diff_list)
            min_index = option_diff_list.index(min_diff)
            #print option_diff_list
            if DEBUG:
                print "isDiffConstant : min_value = ", min_diff, "min_index =", min_index + 1

            if (min_diff * 100 < MIN_OPTION_DIFF_THRESH):
                return min_index + 1
        except BaseException:
            print "Exception in isDiffConstant: ", f1, f2, f3
            pass

        return -1
Exemple #3
0
def new_image_window():
    # Click on an existing image window
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None, 'Could not find an image window on the current display'
    pyautogui.click(x=imageWindow[0], y=imageWindow[1])
    time.sleep(3)

    # Click on the window button
    windowButton = ImageUtil.locateCenterOnScreen(
        'test_images/windowButton.png')
    assert windowButton != None, 'Could not find the window button on the menu bar'
    pyautogui.doubleClick(x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Locate the add button and click on it
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Change the plugin of the empty window to a casa image loader
    cartavisInstance.setEmptyWindowPlugin(0, 'CasaImageLoader')
Exemple #4
0
    def isRotated(self, f1, f2, f3):
        try:
            im_x = self.getImage(f1)
            im_y = self.getImage(f2)
            im_z = self.getImage(f3)

            degree = [x * 45 for x in range(1, 8)]

            for d in degree:
                rot_x = im_x.rotate(d)
                diff_xy = ImageUtil.find_image_diff(rot_x, im_y)
                #print "check rotation : diff_" , f1, f2 , " = " , diff_xy , "Degree= ", d

                if diff_xy < DIFF_THRESH + 1:
                    option_diff_list = []
                    rot_z = im_z.rotate(d)
                    for i in range(1, 7):
                        option_image = self.getImage(str(i))
                        option_diff = ImageUtil.find_image_diff(
                            rot_z, option_image)
                        option_diff_list.append(option_diff)
                    min_diff = min(option_diff_list)
                    min_index = option_diff_list.index(min_diff)

                    if DEBUG:
                        print "isRotated : diff_xy=", diff_xy, " min_value= ", min_diff, " min_index =", min_index + 1

                    if (min_diff < MIN_OPTION_DIFF_THRESH):
                        return min_index + 1
        except BaseException:
            print "Exception in isRotated: ", f1, f2, f3
            pass

        return -1
Exemple #5
0
    def xx_isDiffConstant(self, f1, f2, f3):
        try:
            im_x = self.getImage(f1)
            im_y = self.getImage(f2)
            im_z = self.getImage(f3)

            image_delta_1 = ImageChops.invert(ImageChops.difference(
                im_x, im_y))
            # Find delta between delta_1 and im_x and compare it with im_y
            image_delta_2 = ImageChops.invert(
                ImageChops.difference(im_x, image_delta_1))

            diff_xy = ImageUtil.find_image_diff(image_delta_2, im_y)
            print "x_isDiffConstant : diff_", f1, f2, " = ", diff_xy

            if diff_xy < DIFF_THRESH:
                option_diff_list = []
                for i in range(1, 7):
                    option_image = self.getImage(str(i))
                    d1 = ImageChops.invert(
                        ImageChops.difference(im_z, option_image))
                    d2 = ImageChops.invert(ImageChops.difference(im_z, d1))
                    option_diff = ImageUtil.find_image_diff(d2, option_image)
                    option_diff_list.append(option_diff)
                min_diff = min(option_diff_list)
                min_index = option_diff_list.index(min_diff)
                print option_diff_list
                print "answer is ", min_index + 1

                if (min_diff < MIN_OPTION_DIFF_THRESH):
                    return min_index + 1
        except BaseException:
            pass

        return -1
Exemple #6
0
def _saveImage(imageWindow):
    """
    Brings up the save image dialog, presses the Save button, and then
    closes the dialog.

    Parameters
    ----------
    imageWindow:
        The image window which has already been located.
    """
    pyautogui.rightClick(x=imageWindow[0], y=imageWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    saveButton = ImageUtil.locateCenterOnScreen(
        'test_images/saveImageButton.png')
    assert saveButton != None
    pyautogui.click(x=saveButton[0], y=saveButton[1])
    closeButton = ImageUtil.locateCenterOnScreen('test_images/closeButton.png')
    assert closeButton != None
    pyautogui.click(x=closeButton[0], y=closeButton[1])
Exemple #7
0
def test_maximize_restore(cartavisInstance, cleanSlate):
    """
    Test that a window can be maximized and then restored to 
    its original position
    """
    # Find and select the animation window 
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])

    # Look for the maximize button in the submenu
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is a single animator window
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Right click the context menu to restore a animator window
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there are exactly the same number of windows as there were originally and the animation window is present
    assert len(cartavisInstance.getAnimatorViews()) == 1
Exemple #8
0
    def isIdentical(self, f1, f2, f3):
        try:
            im_x = self.getImage(f1)
            im_y = self.getImage(f2)
            im_z = self.getImage(f3)

            diff_xy = ImageUtil.find_image_diff(im_x, im_y)
            #print "isIdentical : diff_" , f1, f2 , " = " , diff_xy
            if diff_xy < DIFF_THRESH:
                option_diff_list = []
                for i in range(1, 7):
                    option_image = self.getImage(str(i))
                    option_diff = ImageUtil.find_image_diff(im_z, option_image)
                    option_diff_list.append(option_diff)
                min_diff = min(option_diff_list)
                min_index = option_diff_list.index(min_diff)
                if DEBUG:
                    print "isIdentical : diff_xy=", diff_xy, " min_value= ", min_diff, " min_index =", min_index + 1

                if (min_diff < MIN_OPTION_DIFF_THRESH):
                    return min_index + 1

        except BaseException:
            print "Exception in isIdentical: ", f1, f2, f3
            pass

        return -1
Exemple #9
0
def _saveImage(imageWindow):
    """
    Brings up the save image dialog, presses the Save button, and then
    closes the dialog.

    Parameters
    ----------
    imageWindow:
        The image window which has already been located.
    """
    pyautogui.rightClick(x=imageWindow[0], y=imageWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    saveButton = ImageUtil.locateCenterOnScreen(
                    'test_images/saveImageButton.png')
    assert saveButton != None
    pyautogui.click( x=saveButton[0], y=saveButton[1] )
    closeButton = ImageUtil.locateCenterOnScreen('test_images/closeButton.png')
    assert closeButton != None
    pyautogui.click( x=closeButton[0], y=closeButton[1] )
Exemple #10
0
def process(image_file):
    tags = exifread.process_file(image_file)

    for tag in tags.keys():
        # print "key:%s, value:%s" % (tag, tags[tag])
        if tag == "Image DateTime":
            diff_str, date_str = DateUtil.get_days(tags[tag])
            ImageUtil.set_text(image_file, diff_str, date_str)
Exemple #11
0
def getTileImage(x, y):
    global MAP
    global TileData
    val = MAP[x][y]
    if (val in TileData):
        return ImageUtil.get_image(TileData[val]["image-name"])
    else:
        return ImageUtil.get_image("temp")
def render(screen):
    global buttons
    global font
    Name = ImageUtil.get_image("menu-name-black")
    Back = ImageUtil.get_image("menu-back")
    screen.blit(Back, (0,0))
    screen.blit(Name, (screen.get_width()/2-(Name.get_width()/2), 100))
    for b in buttons:
        button = buttons[b]
        pygame.draw.rect(screen, (81, 144, 184), button[2])
        text = font.render(button[0], True, (255,255,255))
        screen.blit(text, ((button[2][0] + button[2][2]/2) - (text.get_width()/2), (button[2][1] + button[2][3]/2)-(text.get_height()/2)))
Exemple #13
0
 def __init__(self):
     self.config = DeviceConfig.getDeviceConfig()
     if not cli_setup():
         auto_setup(self.filePath(),
                    logdir=True,
                    devices=[
                        self.config.DEV,
                    ])
     logging.basicConfig(
         filename="log.txt",
         filemode='w',
         level=logging.INFO,
         format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
     logging.getLogger(self.filePath())
     ImageUtil.addLocalImageRoot(os.path.dirname(self.filePath()))
Exemple #14
0
 def __init__(self, name, figure):
     #print "In rpmFrame init :  ", name, figure.visualFilename
     self.name = name
     self.image_filename = figure.visualFilename
     self.image = Image.open(figure.visualFilename)  # original image
     self.im_np = ImageUtil.binarize(self.image)  # Image bitmap in np array
     self.object_count = len(figure.objects)
Exemple #15
0
def test_animatorWrap(cartavisInstance, cleanSlate):
    """
    Test that the Animator wrap setting returns to the first channel value after animating
    the last channel.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadLocalFile(os.getcwd + '/data/N15693D.fits')

    # Get the last channel value (should be the number of channels - 1)
    lastChannel = i[0].getChannelCount() - 1
    
    # Open animator settings 
    self._openAnimatorSettings()

    # Click the wrap radio button
    wrapButton = ImageUtil.locateCenterOnScreen('test_images/wrapButton.png')
    assert wrapButton != None
    pyautogui.click( x=wrapButton[0], y=wrapButton[1])

    # Set the image to the last channel value
    a[0].setChannel( lastChannel )

    # Click the increment button and get the current channel
    self._getNextValue()
    assert a[0].getChannelIndex() == 0
    self._getNextValue()
    assert a[0].getChannelIndex() == 1

    # Close animator settings 
    self._openAnimatorSettings()
Exemple #16
0
def test_remove(cartavisInstance, cleanSlate):
    """
    Test that an existing window can be removed
    """
    windowCount = len(cartavisInstance.getPluginList())

    # Find and select the animation window
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.doubleClick(x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.rightClick(x=animWindow[0], y=animWindow[1])
    time.sleep(2)

    # Look for the window button in the submenu and remove the window
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is one animator window and no other windows
    assert len(cartavisInstance.getAnimatorViews()) == 1
    assert len(cartavisInstance.getPluginList()) == 1

    # Verify that there is one less window than there was originally and the animator window is not in the list
    assert len(cartavisInstance.getAnimatorViews()) == 0
    assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
Exemple #17
0
   def test_channelAnimatorChangeImage(cartavisInstance, cleanSlate):
    """
    Test that the Channel Animator will update when the window image is switched.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadLocalFile(os.getcwd + '/data/N15693D.fits')

    # Load a different image 
    i[0].loadLocalFile(os.getcwd + '/data/aH.fits')

    # Get the upper spinbox value of the second image
    # Go to the last value and get the channel value  
    lastValueButton = ImageUtil.locateCenterOnScreen('test_images/lastValueButton.png')
    pyautogui.click( x=lastValueButton[0], y=lastValueButton[1])
    time.sleep(2)
    upperBound = a[0].getChannelIndex()

    # Change back to the first image and get the upper spinbox value
    a[0].setImage(0)
    pyautogui.click( x=lastValueButton[0], y=lastValueButton[1])
    newUpperBound = a[0].getChannelIndex()
    assert upperBound != newUpperBound
Exemple #18
0
def test_animatorStepIncrement(cartavisInstance, cleanSlate):
    """
    Test that the Animator can be set to different step increment values.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadLocalFile(os.getcwd + '/data/N15693D.fits')

    # Open animator settings
    self._openAnimatorSettings()

    # Find the step increment spin box and change the step increment to 2
    stepIncrement = ImageUtil.locateCenterOnScreen('test_images/stepIncrement.png')
    pyautogui.click(x=stepIncrement[0]+40, y=stepIncrement[1])
    pyautogui.press('delete')
    pyautogui.typewrite('2')
    pyautougi.press('return')

    # Go to the next channel value 
    a[0].setChannel(0)
    self._getNextValue()
    assert a[0].getChannelIndex() == 2

    # Close animator settings 
    self._openAnimatorSettings()
Exemple #19
0
def test_remove(cartavisInstance, cleanSlate):
    """
    Test that an existing window can be removed
    """
    windowCount = len(cartavisInstance.getPluginList())

    # Find and select the animation window
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None 
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)

    # Look for the window button in the submenu and remove the window
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is one animator window and no other windows
    assert len(cartavisInstance.getAnimatorViews()) == 1
    assert len(cartavisInstance.getPluginList()) == 1

    # Verify that there is one less window than there was originally and the animator window is not in the list
    assert len(cartavisInstance.getAnimatorViews()) == 0
    assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
Exemple #20
0
def test_animator_to_casaimageloader(cartavisInstance, cleanSlate):
    """
    Test that we can change an animator to a CasaImageLoader
    """
    # Get the animation window count and make sure it is non-zero
    animWindowList = len(cartavisInstance.getAnimatorViews())
    assert animWindowList > 0 

    # Get the image window count 
    imageWindowList = len(cartavisInstance.getImageViews())

    # Locate an animator window and bring up the right-context menu,
    # changing to a CasaImageLoader.
    animatorWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    pyautogui.doubleClick( x=animatorWindow[0], y=animatorWindow[1])
    time.sleep(2)
    pyautogui.rightClick( x=animatorWindow[0], y=animatorWindow[1])
    pyautogui.press('right')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that the animation count has gone down by one and the image count 
    # has increased by one
    newAnimWindowCount = len(cartavisInstance.getAnimatorViews())
    newImageWindowCount = len(cartavisInstance.getImageViews())
    assert newAnimWindowCount == animWindowList - 1
    assert newImageWindowCount == imageWindowList + 1
Exemple #21
0
def test_animatorReverse(cartavisInstance, cleanSlate):
    """
    Test the Animator reverse setting.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Get the last channel value (should be the number of channels - 1)
    lastChannel = i[0].getChannelCount() - 1
    
    # Open animator settings 
    _openAnimatorSettings()

    # Click the reverse radio button
    reverseButton = ImageUtil.locateCenterOnScreen('test_images/reverseButton.png')
    assert reverseButton != None
    pyautogui.click( x=reverseButton[0], y=reverseButton[1])

    # Set the image to the last channel value
    a[0].setChannel( lastChannel )

    # Click the forward animate button on the tape deck
    _animateForward()
    time.sleep(2)
    assert a[0].getChannelIndex() < lastChannel
    _stopAnimation()

    # Close animator settings 
    _openAnimatorSettings()
Exemple #22
0
def test_animator_to_casaimageloader(cartavisInstance, cleanSlate):
    """
    Test that we can change an animator to a CasaImageLoader
    """
    # Get the animation window count and make sure it is non-zero
    animWindowList = len(cartavisInstance.getAnimatorViews())
    assert animWindowList > 0

    # Get the image window count
    imageWindowList = len(cartavisInstance.getImageViews())

    # Locate an animator window and bring up the right-context menu,
    # changing to a CasaImageLoader.
    animatorWindow = ImageUtil.locateCenterOnScreen(
        'test_images/animWindow.png')
    pyautogui.doubleClick(x=animatorWindow[0], y=animatorWindow[1])
    time.sleep(2)
    pyautogui.rightClick(x=animatorWindow[0], y=animatorWindow[1])
    pyautogui.press('right')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that the animation count has gone down by one and the image count
    # has increased by one
    newAnimWindowCount = len(cartavisInstance.getAnimatorViews())
    newImageWindowCount = len(cartavisInstance.getImageViews())
    assert newAnimWindowCount == animWindowList - 1
    assert newImageWindowCount == imageWindowList + 1
Exemple #23
0
def test_animatorWrap(cartavisInstance, cleanSlate):
    """
    Test that the Animator wrap setting returns to the first channel value after animating
    the last channel.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Get the last channel value (should be the number of channels - 1)
    lastChannel = i[0].getChannelCount() - 1
    
    # Open animator settings 
    _openAnimatorSettings()

    # Click the wrap radio button
    wrapButton = ImageUtil.locateCenterOnScreen('test_images/wrapButton.png')
    assert wrapButton != None
    pyautogui.click( x=wrapButton[0], y=wrapButton[1])

    # Set the image to the last channel value
    a[0].setChannel( lastChannel )

    # Click the increment button and get the current channel
    _getNextValue()
    assert a[0].getChannelIndex() == 0
    _getNextValue()
    assert a[0].getChannelIndex() == 1

    # Close animator settings 
    _openAnimatorSettings()
Exemple #24
0
def test_channelAnimatorChangeImage(cartavisInstance, cleanSlate):
    """
    Test that the Channel Animator will update when the window image is switched.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Load a different image 
    i[0].loadFile(os.getcwd() + '/data/aH.fits')

    # Get the upper spinbox value of the second image
    # Go to the last value and get the channel value  
    lastValueButton = ImageUtil.locateCenterOnScreen('test_images/lastValueButton.png')
    pyautogui.click( x=lastValueButton[0], y=lastValueButton[1])
    time.sleep(2)
    upperBound = a[0].getChannelIndex()

    # Change back to the first image and get the upper spinbox value
    a[0].setImage(0)
    pyautogui.click( x=lastValueButton[0], y=lastValueButton[1])
    newUpperBound = a[0].getChannelIndex()
    assert upperBound != newUpperBound
Exemple #25
0
    def isFill(self, f1, f2, f3):
        try:
            im_x = self.getImage(f1)
            im_y = self.getImage(f2)
            im_z = self.getImage(f3)

            pixel_ratio_xy = ImageUtil.get_blk_pixel_ratio(im_x, im_y)
            intx_ratio_xy = ImageUtil.get_blk_intersection_ratio(im_x, im_y)
            #print " isFill : diff_" , f1, f2 , "pixel_ratio=", pixel_ratio_xy , "intx_ratio=" , intx_ratio_xy

            option_diff_list = []
            intx_diff_list = []
            temp = []
            temp2 = []
            for i in range(1, 7):
                option_image = self.getImage(str(i))
                pixel_ratio_ci = ImageUtil.get_blk_pixel_ratio(
                    im_z, option_image)
                ratio_diff = abs(pixel_ratio_xy - pixel_ratio_ci)
                option_diff_list.append(ratio_diff)
                temp.append(pixel_ratio_ci)

                ## intx ratio
                intx_ratio_ci = ImageUtil.get_blk_intersection_ratio(
                    im_z, option_image)
                intx_diff = abs(intx_ratio_xy - intx_ratio_ci)
                intx_diff_list.append(intx_diff)
                temp2.append(intx_ratio_ci)

            min_diff = min(option_diff_list)
            min_index = option_diff_list.index(min_diff)

            #        print temp
            #        print option_diff_list
            #        print "isFill : min_value = " , min_diff , "min_index =", min_index+1
            #
            #        print temp2
            #        print intx_diff_list , intx_diff_list.index(min(intx_diff_list))+1

            if (min_diff < MIN_OPTION_DIFF_THRESH):
                return min_index + 1

        except BaseException:
            print "Exception in isFill: ", f1, f2, f3
            pass

        return -1
Exemple #26
0
def test_animator_jump(cartavisInstance, cleanSlate):
    """
    Set the channel animator to jump end behaviour. Save a preference snapshot.
    Set the channel animator to wrap end behaviour. Restore the preference snapshot.
    Check that the animator reverts back to jump behaviour.
    """
    i = cartavisInstance.getImageViews()
    a = cartavisInstance.getAnimatorViews()

    # Set the animator to jump
    settingsButton = ImageUtil.locateCenterOnScreen(
        "test_images/animatorSettingsCheckBox.png")
    assert settingsButton != None
    pyautogui.click(x=settingsButton[0], y=settingsButton[1])

    # Click the jump radio button
    jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png')
    assert jumpButton != None
    pyautogui.doubleClick(x=jumpButton[0], y=jumpButton[1])

    # Save a snapshot. Make sure preferences are checked and layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id', 'tSnapshotPreferences',
                                     False, True, False, '')
    s.save()

    # Find the wrap radio button in the animator settings and click it
    wrapButton = ImageUtil.locateCenterOnScreen('test_images/wrapButton.png')
    assert wrapButton != None
    pyautogui.click(x=wrapButton[0], y=wrapButton[1])

    # Restore the preferences
    s.restore()
    time.sleep(2)

    # Verify the animator jump end behaviour is checked by checking end behaviour
    a[0].setChannel(0)
    lastChannel = i[0].getChannelCount() - 1

    # Go to the next channel
    incrementButton = ImageUtil.locateCenterOnScreen(
        "test_images/incrementButton.png")
    assert incrementButton != None
    pyautogui.click(x=incrementButton[0], y=incrementButton[1])
    time.sleep(2)

    assert a[0].getChannelIndex() == lastChannel
    s.delete()
Exemple #27
0
def MFPBCor(inIm, err, antSize=24.5, minGain=0.05):
    """
    Apply primary beam corrections to an ImageMF

    WARNING: This routine modifies the input image;
    ONLY RUN IT ONCE.
    * inIm    = Image to be modified
    * err     = Python Obit Error/message stack
    * antSize = Antenna diameter in m.
    * minGain = Minimum antenna gain
    """
    # Check
    if not inIm.ImageIsA():
        raise TypeError("input MUST be a Python Obit Image")
    # Image info
    nterm = inIm.Desc.List.Dict['NTERM'][2][0]
    nspec = inIm.Desc.List.Dict['NSPEC'][2][0]
    freqs = []
    for i in range(1, nspec + 1):
        key = 'FREQ%4.4d' % i
        freqs.append(inIm.Desc.List.Dict[key][2][0])

    # end loop
    # Make scratch image for beam
    beam = Image.Image("PBeam")
    Image.PCloneMem(inIm, beam, err)
    OErr.printErrMsg(err, "Error with scratch beam image")
    # Loop over planes
    for i in range(1, nspec + 1):
        # Read plane
        plane = [i + nterm, 1, 1, 1, 1]
        Image.PGetPlane(inIm, None, plane, err)
        OErr.printErrMsg(err, "Error reading image")
        # Set frequency for PBCor
        d = inIm.Desc.Dict
        d['crval'][2] = freqs[i - 1]
        inIm.Desc.Dict = d
        # Make PB Image
        ImageUtil.PPBImage(beam,
                           beam,
                           err,
                           minGain=minGain,
                           antSize=antSize,
                           outPlane=plane)
        OErr.printErrMsg(err, "Error making PB image")
        # Divide
        FArray.PDivClip(inIm.FArray, beam.FArray, minGain, inIm.FArray)
        # Rewrite plane
        Image.PPutPlane(inIm, None, plane, err)
        OErr.printErrMsg(err, "Error writing image")

    # end loop
    # Add history
    outHistory = History.History("history", inIm.List, err)
    outHistory.Open(History.READWRITE, err)
    outHistory.TimeStamp(" Start Obit MFPBCor", err)
    outHistory.WriteRec(-1, "MFPBCor" + " antSize = " + str(antSize), err)
    outHistory.WriteRec(-1, "MFPBCor" + " minGain = " + str(minGain), err)
    outHistory.Close(err)
Exemple #28
0
def test_global_prefs(cartavisInstance, cleanSlate):
    """
    Test that object specific settings can also act globally.
    Set the animator to jump. Save the preferences. Open two animators. Restore the preferences.
    Check the second animator is also set to jump.
    """
    # Set the animator to jump
    settingsButton = ImageUtil.locateCenterOnScreen(
        "test_images/animatorSettingsCheckBox.png")
    assert settingsButton != None
    pyautogui.click(x=settingsButton[0], y=settingsButton[1])

    # Click the jump radio button
    jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png')
    assert jumpButton != None
    pyautogui.doubleClick(x=jumpButton[0], y=jumpButton[1])

    # Save a snapshot. Make sure preferences are checked and
    # layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id', 'tSnapshotPreferences',
                                     False, True, False, '')
    s.save()

    # Find an image window and change it into an animator
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.rightClick(x=imageWindow[0], y=imageWindow[1])
    pyautogui.press('right')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Find the settings button on the animator and click it so the jump will be visible
    settingsButton = ImageUtil.locateCenterOnScreen(
        'test_images/settingsCheckBox.png')
    assert settingsButton != None
    pyautogui.click(x=settingsButton[0], y=settingsButton[1])

    # Restore the preferences
    s.restore()

    # Check that both animators are not displaying jump
    # Verify that the animator jump end behaviour is checked in the screenshot after the tests have been run
    pyautogui.screenshot('layout_check/bothAnimatorsJump.png')
    s.delete()
Exemple #29
0
 def compensateConfig(self):
     dic = self.getMap()
     dic[apl] = (759, 627)
     dic[apr] = (1230, 653)
     dic[hq] = (1530, 542)
     dic[hqe] = (1054, 1037)
     foo = ImageUtil.getImageTemplate("foo")
     self.addCompensateTuple(foo, (1047, 590))
Exemple #30
0
    def cut(self, need_save=True):
        carbration_x = 0
        carbration_y = 0
        carbration_width = 0
        carbration_height = 0
        p = ImageUtil.ImageBinaryFunc(self.file_path)
        p.get_pic_calibration_data(p.read_pic_data())
        p.get_pic_calibration_value_data()
        if p.pic_calibration_value is None:
            return
        elif self.img.width <= 200*2:
            return
        else:
            carbration_x = p.pic_calibration_value[0]
            carbration_y = p.pic_calibration_value[1]
            carbration_width = p.pic_calibration_value[2]
            carbration_height = p.pic_calibration_value[3]
            if carbration_width == 0 or carbration_height == 0:
                return

        top = 0
        bottom = 0
        con_region_width = 200*2
        
        kind = self.train_info['kind'][1]
        if kind in ['C', 'P', 'W', 'B']:
            con_region_width = 300*2
        con_region_height = 0

        top = carbration_y - 100*2
        if top < 0:
            top = 0
        bottom = carbration_y + carbration_height + 100*2
        if bottom > self.img.height - 1:
            bottom = self.img.height - 1
        con_region_height = 960*2 if bottom - top > 960*2 else bottom - top 
        if con_region_height <= 0:
            return

        left = 0
        if left + con_region_width > self.img.width:
            left = self.img.width - con_region_width
        
        rect = (left, top, left + con_region_width, top + con_region_height)
        self.regions.append(rect)

        left = self.img.width - con_region_width
        if left < 0:
            left = 0
        if left + con_region_width > self.img.width:
            left = self.img.width - con_region_width
        
        rect = (left, top, left + con_region_width, top + con_region_height)
        self.regions.append(rect)        

        if need_save:
            self.save()
Exemple #31
0
def test_animator_jump(cartavisInstance, cleanSlate):
    """
    Set the channel animator to jump end behaviour. Save a preference snapshot.
    Set the channel animator to wrap end behaviour. Restore the preference snapshot.
    Check that the animator reverts back to jump behaviour.
    """
    i = cartavisInstance.getImageViews()
    a = cartavisInstance.getAnimatorViews()

    # Set the animator to jump 
    settingsButton = ImageUtil.locateCenterOnScreen( "test_images/animatorSettingsCheckBox.png")
    assert settingsButton != None
    pyautogui.click( x=settingsButton[0], y=settingsButton[1])

    # Click the jump radio button
    jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png')
    assert jumpButton != None
    pyautogui.doubleClick( x=jumpButton[0], y=jumpButton[1])

    # Save a snapshot. Make sure preferences are checked and layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '')
    s.save()

    # Find the wrap radio button in the animator settings and click it 
    wrapButton = ImageUtil.locateCenterOnScreen('test_images/wrapButton.png')
    assert wrapButton != None
    pyautogui.click( x=wrapButton[0], y=wrapButton[1])

    # Restore the preferences
    s[0].restore()
    time.sleep(2)

    # Verify the animator jump end behaviour is checked by checking end behaviour
    a[0].setChannel(0)
    lastChannel = i[0].getChannelCount() - 1

    # Go to the next channel 
    incrementButton = ImageUtil.locateCenterOnScreen( "test_images/incrementButton.png")
    assert incrementButton != None 
    pyautogui.click( x=incrementButton[0], y=incrementButton[1])
    time.sleep(2)

    assert a[0].getChannelIndex() == lastChannel
    s[0].delete()
Exemple #32
0
def test_global_prefs(cartavisInstance, cleanSlate):
    """
    Test that object specific settings can also act globally.
    Set the animator to jump. Save the preferences. Open two animators. Restore the preferences.
    Check the second animator is also set to jump.
    """
    # Set the animator to jump 
    settingsButton = ImageUtil.locateCenterOnScreen( "test_images/animatorSettingsCheckBox.png")
    assert settingsButton != None
    pyautogui.click( x=settingsButton[0], y=settingsButton[1])

    # Click the jump radio button
    jumpButton = ImageUtil.locateCenterOnScreen('test_images/jumpButton.png')
    assert jumpButton != None
    pyautogui.doubleClick( x=jumpButton[0], y=jumpButton[1])

    # Save a snapshot. Make sure preferences are checked and 
    # layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '')
    s.save()

    # Find an image window and change it into an animator
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.rightClick( x=imageWindow[0], y=imageWindow[1])
    pyautogui.press('right')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Find the settings button on the animator and click it so the jump will be visible 
    settingsButton = ImageUtil.locateCenterOnScreen('test_images/settingsCheckBox.png')
    assert settingsButton != None
    pyautogui.click( x=settingsButton[0], y=settingsButton[1])

    # Restore the preferences
    s[0].restore()

    # Check that both animators are not displaying jump
    # Verify that the animator jump end behaviour is checked in the screenshot after the tests have been run
    pyautogui.screenshot('layout_check/bothAnimatorsJump.png')
    s[0].delete()
Exemple #33
0
def test_add_window(cartavisInstance, cleanSlate):
    """
    Test that we can add a window and change it to a Histogram view.
    """
    # For later use, determine the number of histogram windows
    histWindowList = len(cartavisInstance.getHistogramViews())
    windowCount = len(cartavisInstance.getPluginList())
    print "Histogram Window Count=", histWindowList

    # Find a window capable of loading an image
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.click(x=imageWindow[0], y=imageWindow[1])

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen(
        'test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click(x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Look for the add button in the submenu
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    pyautogui.click(x=addButton[0], y=addButton[1])
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Check that we now have a generic empty window in the display and the window count has gone up
    emptyWindowCount = cartavisInstance.getEmptyWindowCount()
    assert emptyWindowCount == 1

    # Change the plugin of the window to a histogram
    cartavisInstance.setEmptyWindowPlugin(0, 'Histogram')

    # Verify that we have increased the number of histogram windows by one
    newHistWindowList = len(cartavisInstance.getHistogramViews())
    assert newHistWindowList == (
        1 + histWindowList), 'Histogram window count did not go up by one'
Exemple #34
0
    def cut(self, need_save=True):
        axel_y = 0
        axel_x_offset = 0
        rail_y = 0 
        carbration_x = 0
        carbration_y = 0
        carbration_width = 0
        carbration_height = 0
        p = ImageUtil.ImageBinaryFunc(self.file_path)
        data = p.read_pic_data()
        p.get_pic_calibration_data(data)
        p.get_pic_calibration_value_data()
        wheel = p.get_pic_wheel_data(data)
        if p.pic_calibration_value is None:
            return
        elif wheel is None:
            return
        else:
            axel_y = p.pic_calibration_value[4]
            axel_x_offset = p.pic_calibration_value[5]
            rail_y = p.pic_calibration_value[6]
            carbration_x = p.pic_calibration_value[0]
            carbration_y = p.pic_calibration_value[1]
            carbration_width = p.pic_calibration_value[2] - carbration_x + 1
            carbration_height = p.pic_calibration_value[3] - carbration_y + 1

        region_x = 0
        region_y = 0
        region_width = self.img.width
        region_height = 288 * 2

        if region_height > self.img.height:
            return
        
        axel_height = abs(rail_y - axel_y)
        region_y = axel_y - axel_height*1.3 - region_height
        if region_y < 0:
            region_y = 0

        if region_y + region_height > self.img.height:
            region_y = self.img.height - region_height
        
        rect = (region_x, region_y, region_width, region_height)
        region_img = self.img.crop(rect)

        last_x = 0
        while last_x < region_img.width - 200*2:
            if last_x + 1096*2 > region_img.width:
                last_x = region_img.width - 1096*2
            _rect = (last_x, 0, last_x + 1096*2, region_img.height)
            last_x += 1096*2 - 200*2
            self.regions.append(_rect)

        if need_save:
            self.save()
Exemple #35
0
    def check_reflection(self, f1, f2, f3, axis):
        try:
            im_x = self.getImage(f1)
            im_y = self.getImage(f2)
            im_z = self.getImage(f3)

            if (axis == 'y'):
                transpose_x = im_x.transpose(Image.FLIP_LEFT_RIGHT)
            else:
                transpose_x = im_x.transpose(Image.FLIP_TOP_BOTTOM)

            diff_xy = ImageUtil.find_image_diff(transpose_x, im_y)
            #print "check_reflection : diff_" , f1, f2 , " = " , diff_xy , "axis = ", axis

            if diff_xy < DIFF_THRESH:
                option_diff_list = []
                if (axis == 'y'):
                    transpose_z = im_z.transpose(Image.FLIP_LEFT_RIGHT)
                else:
                    transpose_z = im_z.transpose(Image.FLIP_TOP_BOTTOM)

                for i in range(1, 7):
                    option_image = self.getImage(str(i))
                    option_diff = ImageUtil.find_image_diff(
                        transpose_z, option_image)
                    option_diff_list.append(option_diff)
                min_diff = min(option_diff_list)
                min_index = option_diff_list.index(min_diff)

                #print option_diff_list
                if DEBUG:
                    print "isReflected : diff_xy=", diff_xy, " min_value= ", min_diff, " min_index =", min_index + 1

                if (min_diff < MIN_OPTION_DIFF_THRESH):
                    return min_index + 1

        except BaseException:
            print "Exception in check_reflection: ", f1, f2, f3, axis
            pass

        return -1
Exemple #36
0
def test_maximize_removed(cartavisInstance, cleanSlate):
    """
    Test that a window can be maximized and then removed.
    """
    windowCount = len(cartavisInstance.getPluginList())

    # Find and select the animation window
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.click(x=animWindow[0], y=animWindow[1])

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen(
        'test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click(x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Look for the maximize button in the submenu
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify there is a single animator window
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Now right click the context menu to remove the animator window
    pyautogui.doubleClick(x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.rightClick(x=animWindow[0], y=animWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is one less window than there was originally and the animation window is not in the list
    assert len(cartavisInstance.getAnimatorViews()) == 0
    assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
Exemple #37
0
def test_add_window(cartavisInstance, cleanSlate):
    """
    Test that we can add a window and change it to a Histogram view.
    """
    # For later use, determine the number of histogram windows
    histWindowList = len(cartavisInstance.getHistogramViews())
    windowCount = len(cartavisInstance.getPluginList())
    print "Histogram Window Count=", histWindowList

    # Find a window capable of loading an image
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.click( x=imageWindow[0], y=imageWindow[1])

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Look for the add button in the submenu
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    pyautogui.click( x=addButton[0], y=addButton[1])
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Check that we now have a generic empty window in the display and the window count has gone up
    emptyWindowCount = cartavisInstance.getEmptyWindowCount()
    assert emptyWindowCount == 1

    # Change the plugin of the window to a histogram
    cartavisInstance.setEmptyWindowPlugin(0, 'Histogram')

    # Verify that we have increased the number of histogram windows by one
    newHistWindowList = len(cartavisInstance.getHistogramViews())
    assert newHistWindowList == (1 + histWindowList), 'Histogram window count did not go up by one'
Exemple #38
0
def test_noCustomDialog(cartavisInstance, cleanSlate):
    """
    Test that the custom layout dialog does not appear when a custom
    layout is set from the scripted client.
    This is a regression test for issue #97.
    """
    cartavisInstance.setCustomLayout(2,1)
    time.sleep(1)
    cartavisInstance.setPlugins(['CasaImageLoader', 'Histogram'])
    dialog = ImageUtil.locateCenterOnScreen(
             'test_images/customLayoutDialog.png')
    assert dialog == None
Exemple #39
0
 def step(self):
     battle_confirm = ImageUtil.getImageTemplate("battle_confirm")
     achievement_settlement = ImageUtil.getImageTemplate(
         "achievement_settlement")
     lfz = ImageUtil.getImageTemplate("lfz")
     v = self.existsFast(lfz)
     v1 = (v[0], v[1] - 40)
     self.touch(v1)
     v2 = self.existsFast(battle_confirm)
     if not v2:
         v = self.existsFast(lfz)
         v1 = (v[0], v[1] - 40)
         self.touch(v1)
         v2 = self.existsFast(battle_confirm)
     self.touch(v2)
     self.sleep(3)
     self.begin()
     self.sleep(5)
     if exists(achievement_settlement):
         self.touchBlank()
     self.sleep(4)
Exemple #40
0
def test_maximize_removed(cartavisInstance, cleanSlate):
    """
    Test that a window can be maximized and then removed.
    """
    windowCount = len(cartavisInstance.getPluginList())

    # Find and select the animation window
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    assert animWindow != None
    pyautogui.click( x=animWindow[0], y=animWindow[1])

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Look for the maximize button in the submenu
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify there is a single animator window
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Now right click the context menu to remove the animator window
    pyautogui.doubleClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there is one less window than there was originally and the animation window is not in the list
    assert len(cartavisInstance.getAnimatorViews()) == 0
    assert len(cartavisInstance.getPluginList()) == (windowCount - 1)
Exemple #41
0
def test_minimize_restore(cartavisInstance, cleanSlate):
    """
    Test that a window can be minimized and then restored to 
    its original position. 
    """
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.click(x=imageWindow[0], y=imageWindow[1])

    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen(
        'test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click(x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Click on the minimize button in the submenu
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Find the restore buttom for the casa image loader
    restoreButton = ImageUtil.locateCenterOnScreen(
        'test_images/restoreButton.png')
    assert restoreButton != None

    # Restore the window. Verify the restore button is gone from the status bar and there is a DisplayWindowImage
    pyautogui.click(x=restoreButton[0], y=restoreButton[1])

    # Check that the clipping menu item is no longer available
    try:
        restoreLabel = ImageUtil.locateCenterOnScreen(
            'test_images/restoreButton.png')
        assert restoreButton == False
    except Exception:
        print "Test restore button was successfully removed"
    imageWindow = cartavisInstance.getImageViews()
    assert len(imageWindow) == 1
Exemple #42
0
def test_animatorFrameIncrement(cartavisInstance, cleanSlate):
    """
    Test that we can increment the channel by one.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Click the increment button 
    incrementButton = ImageUtil.locateCenterOnScreen('test_images/incrementButton.png')
    pyautogui.click( x=incrementButton[0], y=incrementButton[1])

    assert a[0].getChannelIndex() == 1
Exemple #43
0
def test_minimize_restore(cartavisInstance, cleanSlate):
    """
    Test that a window can be minimized and then restored to 
    its original position. 
    """
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    pyautogui.click( x=imageWindow[0], y=imageWindow[1])
    
    # Click the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None
    pyautogui.click( x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Click on the minimize button in the submenu
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('return')
    time.sleep(2)

    # Find the restore buttom for the casa image loader 
    restoreButton = ImageUtil.locateCenterOnScreen('test_images/restoreButton.png')
    assert restoreButton != None
    
    # Restore the window. Verify the restore button is gone from the status bar and there is a DisplayWindowImage
    pyautogui.click( x=restoreButton[0], y=restoreButton[1])

    # Check that the clipping menu item is no longer available
    try:
        restoreLabel = ImageUtil.locateCenterOnScreen('test_images/restoreButton.png')
        assert restoreButton == False
    except Exception:
        print "Test restore button was successfully removed"
    imageWindow = cartavisInstance.getImageViews()
    assert len(imageWindow) == 1
Exemple #44
0
def new_image_window():
    # Click on an existing image window 
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png') 
    assert imageWindow != None, 'Could not find an image window on the current display'
    pyautogui.click( x=imageWindow[0], y=imageWindow[1])
    time.sleep(3)

    # Click on the window button
    windowButton = ImageUtil.locateCenterOnScreen('test_images/windowButton.png')
    assert windowButton != None, 'Could not find the window button on the menu bar'
    pyautogui.doubleClick( x=windowButton[0], y=windowButton[1])
    time.sleep(2)

    # Locate the add button and click on it 
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('down')
    pyautogui.press('right')
    pyautogui.press('return')
    time.sleep(2)

    # Change the plugin of the empty window to a casa image loader
    cartavisInstance.setEmptyWindowPlugin(0, 'CasaImageLoader')
Exemple #45
0
def test_animatorFrameDecrement(cartavisInstance, cleanSlate):
    """
    Test that we can decrement the channel by one.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Get the last channel value (should be the number of channels - 1)
    lastChannel = i[0].getChannelCount() - 1

    # Click the decrement button 
    decrementButton = ImageUtil.locateCenterOnScreen('test_images/decrementButton.png')
    pyautogui.click( x=decrementButton[0], y=decrementButton[1])
    time.sleep(2)
    assert a[0].getChannelIndex() == (lastChannel - 1)
Exemple #46
0
def test_animatorReverseAnimation(cartavisInstance, cleanSlate):
    """
    Test that we can animate in the reverse directon.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Get the last channel value (should be the number of channels - 1)
    lastChannel = i[0].getChannelCount() - 1

    # Set the image to the last channel value
    a[0].setChannel( lastChannel )

    # Click the reverse animate button on the tape deck
    reverseButton = ImageUtil.locateCenterOnScreen('test_images/reverseAnimation.png')
    pyautogui.click( x=reverseButton[0], y=reverseButton[1])
    time.sleep(2)
    assert a[0].getChannelIndex() < lastChannel
    _stopAnimation()
Exemple #47
0
def test_saveImage(cartavisInstance, cleanSlate):
    """
    Test that an image can be saved from the GUI.
    """
    cartavisInstance.setImageLayout()
    i = cartavisInstance.getImageViews()
    filename = '/tmp/saveImage.png'
    imageWindow = ImageUtil.locateCenterOnScreen('test_images/imageWindow.png')
    assert imageWindow != None
    i[0].loadFile(os.getcwd() + '/data/mexinputtest.fits')
    _saveImage(imageWindow)
    # Verify that the output image is of the desired size given the save
    # parameters.
    image = Image.open(filename)
    # The default size of the saved image is 400x500, but the aspect
    # ratio mode is Keep, so the output size should be 400x400.
    assert image.size == (400,400)
    os.remove(filename)
    # This next save is a regression test for issue #101.
    zoomLevel = 0.2 
    i[0].setZoomLevel(zoomLevel)
    _saveImage(imageWindow)
    image = Image.open(filename)
    assert image.size == (400*zoomLevel, 400*zoomLevel)
Exemple #48
0
def test_restore_missing(cartavisInstance, cleanSlate):
    """
    The purpose of this test is to test that if we try to restore preferences for 
    a widget that is not present there are no problems. 
    We verify an animator is present. We save the preferences. We remove the animator
    We verify that there is not a problem by checking error status is empty and window
    count remains the same with no animator.
    """
    # Verify that there is just one animator
    assert len(cartavisInstance.getAnimatorViews()) == 1

    # Save a snapshot. Make sure preferences are checked and 
    # layout and data are not checked
    s = cartavisInstance.newSnapshot('some_session_id','tSnapshotPreferences', False, True, False, '')
    s.save()

    # Locate the animator and bring up the right-context menu,
    # changing to a CasaImageLoader.
    animWindow = ImageUtil.locateCenterOnScreen('test_images/animWindow.png')
    pyautogui.rightClick( x=animWindow[0], y=animWindow[1])
    time.sleep(2)
    pyautogui.press('down')
    pyautogui.press('right')    
    pyautogui.press('return')
    time.sleep(2)

    # Verify that there are no animation windows 
    assert len(cartavisInstance.getAnimatorViews()) == 0

    # Restore the preferences
    s[0].restore()
    time.sleep(2)

    # No way to check for errors, hence, take a screenshot
    pyautogui.screenshot('layout_check/checkNoErrors.png')
    s[0].delete()
Exemple #49
0
def _openAnimatorSettings():
    settingsButton = ImageUtil.locateCenterOnScreen( "test_images/settingsCheckBox.png")
    assert settingsButton != None, 'Could not find the animator settings checkbox on the current display'
    pyautogui.click( x=settingsButton[0], y=settingsButton[1])
Exemple #50
0
def _stopAnimation():
    stopButton = ImageUtil.get_match_coordinates( "test_images/stopButton.png", "desktop.png") 
    assert stopButton != None, 'Could not find the stop button on the current display'
    pyautogui.click( x=stopButton[0], y=stopButton[1])
Exemple #51
0
def _animateFoward():
    forwardAnimateButton = ImageUtil.locateCenterOnScreen("test_images/forwardAnimation.png")
    assert forwardAnimateButton != None, 'Could not find the forward animation button on the current display'
    pyautogui.click( x=forwardAnimateButton[0], y=forwardAnimateButton[1])
Exemple #52
0
def _getNextValue():
    incrementButton = ImageUtil.locateCenterOnScreen( "test_images/incrementButton.png")
    assert incrementButton != None, 'Could not find the incrementButton on the current display'
    pyautogui.click( x=incrementButton[0], y=incrementButton[1])
    time.sleep(2)
Exemple #53
0
def _getLastValue():
    lastValueButton = ImageUtil.locateCenterOnScreen("test_images/lastValueButton.png")
    assert lastValueButton != None, 'Could not find the lastValueButton on the current display'
    pyautogui.click( x=lastValueButton[0], y=lastValueButton[1])
    time.sleep(2)
Exemple #54
-1
def test_animatorStepIncrement(cartavisInstance, cleanSlate):
    """
    Test that the Animator can be set to different step increment values.
    """
    i = cartavisInstance.getImageViews() 
    a = cartavisInstance.getAnimatorViews()

    # Load an image
    i[0].loadFile(os.getcwd() + '/data/N15693D.fits')

    # Open animator settings
    _openAnimatorSettings()

    # Find the step increment spin box and change the step increment to 2
    stepIncrement = ImageUtil.locateCenterOnScreen('test_images/stepIncrement.png')
    pyautogui.click(x=stepIncrement[0]+40, y=stepIncrement[1])
    pyautogui.press('delete')
    pyautogui.typewrite('2')
    pyautougi.press('return')

    # Go to the next channel value 
    a[0].setChannel(0)
    _getNextValue()
    assert a[0].getChannelIndex() == 2

    # Close animator settings 
    _openAnimatorSettings()