Skip to content

Commit

Permalink
Merge f2d64ad into dd831cc
Browse files Browse the repository at this point in the history
  • Loading branch information
katherinekolman committed Nov 11, 2019
2 parents dd831cc + f2d64ad commit 215ecf5
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ env:
- PYTHON_VERSION=$TRAVIS_PYTHON_VERSION
- NUMPY_VERSION=stable
- MAIN_CMD='python setup.py'
- CONDA_DEPENDENCIES='hdf5 rasterio matplotlib scipy numba pyproj coveralls pytest pytest-cov pytest-xvfb vispy pyopengl netcdf4 h5py imageio imageio-ffmpeg ffmpeg pillow pyshp pyqtgraph shapely sqlalchemy pyqt appdirs pyyaml satpy eccodes'
- CONDA_DEPENDENCIES='hdf5 rasterio matplotlib scipy numba pyproj coveralls pytest pytest-mock pytest-cov pytest-qt pytest-xvfb vispy pyopengl netcdf4 h5py imageio imageio-ffmpeg ffmpeg pillow pyshp pyqtgraph shapely sqlalchemy pyqt appdirs pyyaml satpy eccodes'
- PIP_DEPENDENCIES='quamash'
- SETUP_XVFB=True
- EVENT_TYPE='push pull_request'
Expand Down
67 changes: 67 additions & 0 deletions uwsift/tests/view/test_export_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from PIL import Image
from matplotlib import pyplot as plt
from collections import namedtuple
from PyQt5.QtCore import Qt
from PyQt5.QtTest import QTest
import pytest
import datetime
import os
Expand Down Expand Up @@ -100,6 +102,9 @@ def close(self):
def window(tmp_path_factory):
d = tmp_path_factory.mktemp("tmp")
window = Main(config_dir=USER_CONFIG_DIR, workspace_dir=str(d))
window.show()
QTest.qWaitForWindowExposed(window)
QTest.qWaitForWindowActive(window)
return window


Expand Down Expand Up @@ -225,3 +230,65 @@ def test_save_screenshot(fr, fn, overwrite, exp, monkeypatch, window):
window.export_image._save_screenshot()

assert len(writer.data) == exp


def test_cmd_open_export_image_dialog(qtbot, window):
qtbot.addWidget(window)
qtbot.keyClick(window, Qt.Key_I, Qt.ControlModifier)

def check_dialog():
assert window.export_image._screenshot_dialog is not None

qtbot.waitUntil(check_dialog)


def test_export_image_dialog_info_default(qtbot, window):
window.export_image.take_screenshot()
qtbot.waitUntil(lambda: window.export_image._screenshot_dialog is not None)

res = window.export_image._screenshot_dialog.get_info()

# only look at the filename
res['filename'] = os.path.split(res['filename'])[-1]

exp = {
'frame_range': None,
'include_footer': True,
'loop': True,
'filename': export_image.ExportImageDialog.default_filename,
'fps': None,
'font_size': 11,
'colorbar': None
}

assert res == exp


def test_export_image_dialog_info(qtbot, window):
window.export_image.take_screenshot()
qtbot.waitUntil(lambda: window.export_image._screenshot_dialog is not None)

qtbot.keyClick(window.export_image._screenshot_dialog.ui.saveAsLineEdit, Qt.Key_A, Qt.ControlModifier)
qtbot.keyClick(window.export_image._screenshot_dialog.ui.saveAsLineEdit, Qt.Key_Backspace)
qtbot.keyClicks(window.export_image._screenshot_dialog.ui.saveAsLineEdit, 'test.png')
qtbot.keyClick(window.export_image._screenshot_dialog.ui.footerFontSizeSpinBox, Qt.Key_A, Qt.ControlModifier)
qtbot.keyClick(window.export_image._screenshot_dialog.ui.footerFontSizeSpinBox, Qt.Key_Backspace)
qtbot.keyClicks(window.export_image._screenshot_dialog.ui.footerFontSizeSpinBox, '20')
qtbot.mouseClick(window.export_image._screenshot_dialog.ui.frameRangeRadio, Qt.LeftButton)
qtbot.mouseClick(window.export_image._screenshot_dialog.ui.colorbarVerticalRadio, Qt.LeftButton)
qtbot.mouseClick(window.export_image._screenshot_dialog.ui.includeFooterCheckbox, Qt.LeftButton)

res = window.export_image._screenshot_dialog.get_info()
res['filename'] = os.path.split(res['filename'])[-1]

exp = {
'frame_range': [1, 1],
'include_footer': False,
'loop': True,
'filename': 'test.png',
'fps': None,
'font_size': 20,
'colorbar': 'vertical'
}

assert res == exp

0 comments on commit 215ecf5

Please sign in to comment.