on xenial help sign in
add a function to test screenshot rotation upon saving
commit1401a2759cf0badb5a0f548735267bf479ca1fe6 authorLukáš Tinkl <lukas.tinkl@canonical.com> dateMon 12 Oct 2015, 14:55 (11 years ago) parent2183d59
2 files changed+12−1
tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp+11 tests/plugins/ScreenGrabber/grabber.qml+1−1
tests/plugins/ScreenGrabber/ScreenGrabberTest.cpp+11
@@ -55,6 +55,17 @@ private Q_SLOTS:
5555 QVERIFY(!args.first().toString().isEmpty());
5656 }
5757
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+
5869private:
5970 QQuickView *m_view;
6071 ScreenGrabber *m_grabber = nullptr;
tests/plugins/ScreenGrabber/grabber.qml+1−1
@@ -20,7 +20,7 @@ import ScreenGrabber 0.1
2020Rectangle {
2121 property var grabber: screenGrabber
2222
23− width: 100
23+ width: 101 // width intentionally bigger than height to test rotation
2424 height: 100
2525 color: "green"
2626