From 599e38f371abfbe62a7ec7ae73854317d19150b5 Mon Sep 17 00:00:00 2001 From: Pierre Raybaut Date: Thu, 2 May 2024 10:08:05 +0200 Subject: [PATCH] Add High DPI performance test for reproducing #83 --- qwt/tests/test_highdpi.py | 35 +++++++++++++++++++++++++++++++++++ qwt/tests/test_simple.py | 5 ++--- 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 qwt/tests/test_highdpi.py diff --git a/qwt/tests/test_highdpi.py b/qwt/tests/test_highdpi.py new file mode 100644 index 0000000..c12fc9a --- /dev/null +++ b/qwt/tests/test_highdpi.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8 -*- +# +# Licensed under the terms of the PyQwt License +# Copyright (C) 2003-2009 Gerard Vermeulen, for the original PyQwt example +# Copyright (c) 2015 Pierre Raybaut, for the PyQt5/PySide port and further +# developments (e.g. ported to PythonQwt API) +# (see LICENSE file for more details) + +SHOW = True # Show test in GUI-based test launcher + +import os + +import pytest + +from qwt.tests import utils +from qwt.tests.test_simple import SimplePlot + +# Performance should be the same with "1" and "2" scale factors: +# (as of today, this is not the case, but it has to be fixed in the future: +# https://github.com/PlotPyStack/PythonQwt/issues/83) +os.environ["QT_SCALE_FACTOR"] = "2" + + +class HighDPIPlot(SimplePlot): + NUM_POINTS = 5000000 # 5 million points needed to test high DPI support + + +@pytest.mark.skip(reason="This test is not relevant for the automated test suite") +def test_highdpi(): + """Test high DPI support""" + utils.test_widget(HighDPIPlot, (800, 480)) + + +if __name__ == "__main__": + test_highdpi() diff --git a/qwt/tests/test_simple.py b/qwt/tests/test_simple.py index a7a6fd0..00968ab 100644 --- a/qwt/tests/test_simple.py +++ b/qwt/tests/test_simple.py @@ -20,6 +20,7 @@ class SimplePlot(qwt.QwtPlot): + NUM_POINTS = 100 TEST_EXPORT = True def __init__(self): @@ -30,13 +31,11 @@ def __init__(self): self.setAxisTitle(qwt.QwtPlot.yLeft, "Y-axis") self.enableAxis(self.xBottom) self.setCanvasBackground(Qt.white) - canvas = self.canvas() - canvas.setBorderRadius(50) qwt.QwtPlotGrid.make(self, color=Qt.lightGray, width=0, style=Qt.DotLine) # insert a few curves - x = np.arange(0.0, 10.0, 0.1) + x = np.linspace(0.0, 10.0, self.NUM_POINTS) qwt.QwtPlotCurve.make(x, np.sin(x), "y = sin(x)", self, linecolor="red") qwt.QwtPlotCurve.make(x, np.cos(x), "y = cos(x)", self, linecolor="blue")