32 #include <QScrollArea>
34 #include <QApplication>
36 #include <private/qhighdpiscaling_p.h>
37 #include <private/qwidget_p.h>
38 #include <private/qwidgetrepaintmanager_p.h>
39 #include <qpa/qplatformbackingstore.h>
54 const int width = qMax(200, 100 * ((screenWidth + 500) / 1000));
104 fillColor.
setBlue(paintCount % 255);
135 return QSize(100, 100);
144 top->setGeometry(10, 0,
width() - 10, 10);
151 lastPos =
e->position().toPoint();
156 pos +=
e->position().toPoint() - lastPos;
236 void opaqueChildren();
237 void staticContents();
239 #if defined(QT_BUILD_INTERNAL)
240 void scrollWithOverlap();
241 void overlappedRegion();
244 void moveInOutOverlapped();
254 if (!waitForFlush(
w)) {
255 qWarning() <<
"Widget" <<
w <<
"failed to flush";
262 QImage backingstoreContent = platformBackingStore->
toImage();
263 if (!
w->isWindow()) {
264 const qreal dpr =
w->devicePixelRatioF();
266 backingstoreContent = backingstoreContent.
copy(
offset.x(),
offset.y(),
w->width() * dpr,
w->height() * dpr);
270 const bool result = backingstoreContent == widgetRender;
295 bool m_implementsScroll =
false;
318 void tst_QWidgetRepaintManager::basic()
338 void tst_QWidgetRepaintManager::children()
341 QSKIP(
"This test fails on Android");
347 child1->
move(20, 20);
353 child1->
move(20, 30);
360 child2->
move(30, 30);
374 void tst_QWidgetRepaintManager::opaqueChildren()
377 QSKIP(
"This test fails on Android");
383 child1->
move(20, 20);
391 child1->
move(20, 30);
394 if (!m_implementsScroll)
395 QEXPECT_FAIL(
"",
"child1 shouldn't get painted, we can just move the area of the backingstore",
Continue);
403 void tst_QWidgetRepaintManager::staticContents()
421 void tst_QWidgetRepaintManager::scroll()
424 QSKIP(
"This test fails on Android");
431 if (!m_implementsScroll)
437 child->initialShow();
440 child->scroll(10, 0);
447 child->scroll(10, 0);
449 if (!m_implementsScroll)
456 #if defined(QT_BUILD_INTERNAL)
463 void tst_QWidgetRepaintManager::scrollWithOverlap()
466 QSKIP(
"This test fails on Android");
477 w->setAutoFillBackground(
true);
478 m_scrollArea->setWidget(
w);
479 m_scrollArea->resize(500, 100);
480 w->resize(5000, 600);
482 m_topWidget =
new QWidget(
this);
484 m_topWidget->setAutoFillBackground(
true);
485 m_topWidget->resize(300, 200);
500 inline QWidget *topWidget()
const {
return m_topWidget; }
512 bool result = compareWidget(
w.topWidget());
517 QSKIP(
"Cannot compare QWidget::grab with QScreen::grabWindow on this machine");
521 w.scrollArea()->horizontalScrollBar()->setValue(
w.scrollArea()->horizontalScrollBar()->maximum());
522 QVERIFY(compareWidget(
w.topWidget()));
527 w.scrollArea()->verticalScrollBar()->setValue(
w.scrollArea()->verticalScrollBar()->maximum());
528 QVERIFY(compareWidget(
w.topWidget()));
533 w.topWidget()->hide();
534 QVERIFY(compareWidget(
w.scrollArea()->viewport()));
539 w.scrollArea()->horizontalScrollBar()->setValue(
w.scrollArea()->horizontalScrollBar()->minimum());
540 QVERIFY(compareWidget(
w.scrollArea()->viewport()));
545 w.scrollArea()->verticalScrollBar()->setValue(
w.scrollArea()->verticalScrollBar()->minimum());
546 QVERIFY(compareWidget(
w.scrollArea()->viewport()));
554 void tst_QWidgetRepaintManager::overlappedRegion()
560 QSKIP(
"The screen on this system is too small for this test");
566 auto overlappedRegion = [](
QWidget *
widget,
bool breakAfterFirst =
false){
569 return priv->overlappedRegion(
widget->
geometry(), breakAfterFirst);
582 overlap = overlappedRegion(
scene.redChild);
587 scene.redChild->move(100, 0);
588 overlap = overlappedRegion(
scene.redChild);
592 scene.redChild->move(100, 100);
593 overlap = overlappedRegion(
scene.redChild);
597 scene.yellowChild->move(200, 200);
598 overlap = overlappedRegion(
scene.yellowChild);
602 void tst_QWidgetRepaintManager::fastMove()
614 if (m_implementsScroll) {
625 void tst_QWidgetRepaintManager::moveAccross()
634 for (
int i = 0;
i < 4; ++
i) {
636 waitForFlush(&
scene);
640 for (
int i = 0;
i < 16; ++
i) {
642 waitForFlush(&
scene);
648 waitForFlush(&
scene);
653 void tst_QWidgetRepaintManager::moveInOutOverlapped()
691 scene.redChild->move(
scene.greenChild->pos());
700 #include "tst_qwidgetrepaintmanager.moc"
small capitals from c petite p scientific i
[1]
void mouseMoveEvent(QMouseEvent *e) override
void mousePressEvent(QMouseEvent *e) override
Draggable(const QColor &col, QWidget *parent=nullptr)
void resizeEvent(QResizeEvent *) override
void mouseReleaseEvent(QMouseEvent *) override
QSize sizeHint() const override
Draggable(QWidget *parent=nullptr)
static QWidgetList topLevelWidgets()
The QBackingStore class provides a drawing area for QWindow.
QPlatformBackingStore * handle() const
The QBrush class defines the fill pattern of shapes drawn by QPainter.
The QColor class provides colors based on RGB, HSV or CMYK values.
static QColor fromRgb(QRgb rgb) noexcept
QGraphicsObject * parent
the parent of the item
The QGuiApplication class manages the GUI application's control flow and main settings.
QScreen * primaryScreen
the primary (or default) screen of the application.
QString platformName
The name of the underlying platform plugin.
The QImage class provides a hardware-independent image representation that allows direct access to th...
QImage copy(const QRect &rect=QRect()) const
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const &
virtual QRect geometry() const =0
bool isEmpty() const noexcept
The QMouseEvent class contains parameters that describe a mouse event.
The QObject class is the base class of all Qt objects.
void setObjectName(const QString &name)
The QPaintEvent class contains event parameters for paint events. \inmodule QtGui.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawText(const QPointF &p, const QString &s)
void fillRect(const QRectF &, const QBrush &)
The QPalette class contains color groups for each widget state.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
The QPointF class defines a point in the plane using floating point precision.
The QPoint class defines a point in the plane using integer precision.
The QRect class defines a rectangle in the plane using integer precision.
constexpr QPoint topLeft() const noexcept
constexpr int width() const noexcept
The QRegion class specifies a clip region for a painter.
QRect boundingRect() const noexcept
The QResizeEvent class contains event parameters for resize events. \inmodule QtGui.
QRect geometry
the screen's geometry in pixels
The QSize class defines the size of a two-dimensional object using integer point precision.
constexpr int width() const noexcept
static QString number(int, int base=10)
The QStringList class provides a list of strings.
QSize sizeHint() const override
void resizeEvent(QResizeEvent *) override
Q_TESTLIB_EXPORT const char * currentTestFunction()
Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout=5000)
Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout=5000)
Q_TESTLIB_EXPORT const char * currentDataTag()
QT_END_INCLUDE_NAMESPACE typedef double qreal
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble GLdouble top
GLbitfield GLuint64 timeout
[4]
GLenum GLuint GLintptr offset
#define QTEST_MAIN(TestObject)
#define QSKIP(statement,...)
#define QEXPECT_FAIL(dataIndex, comment, mode)
#define QVERIFY(statement)
#define QTRY_VERIFY(expr)