on xenial help sign in
add a function to test screenshot rotation upon saving
1401a27Lukáš Tinkl
tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp+11
@@ -55,6 +55,17 @@ private Q_SLOTS:
55 QVERIFY(!args.first().toString().isEmpty());
55 QVERIFY(!args.first().toString().isEmpty());
56 }
56 }
57
57
58+ void testRotatedScreenshot()
59+ {
60+ QSignalSpy grabberSpy(m_grabber, &ScreenGrabber::screenshotSaved);
61+ m_grabber->captureAndSave(90); // rotate by 90°
62+ const QVariantList args = grabberSpy.takeFirst();
63+ const QString filename = args.first().toString();
64+ QVERIFY(!filename.isEmpty());
65+ QImage img(filename);
66+ QVERIFY(img.height() > img.width()); // verify that the image got rotated by 90° (height > width)
67+ }
68+
58private:
69private:
59 QQuickView *m_view;
70 QQuickView *m_view;
60 ScreenGrabber *m_grabber = nullptr;
71 ScreenGrabber *m_grabber = nullptr;
tests/plugins/ScreenGrabber/grabber.qml+1−1
@@ -20,7 +20,7 @@ import ScreenGrabber 0.1
20Rectangle {
20Rectangle {
21 property var grabber: screenGrabber
21 property var grabber: screenGrabber
22
22
23− width: 100
23+ width: 101 // width intentionally bigger than height to test rotation
24 height: 100
24 height: 100
25 color: "green"
25 color: "green"
26
26