Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/buffer_size_change_test.cpp
Show All 13 Lines | |||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. | ||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "generic_scene_opengl_test.h" | 20 | #include "generic_scene_opengl_test.h" | ||
21 | 21 | | |||
22 | #include "abstract_client.h" | ||||
22 | #include "composite.h" | 23 | #include "composite.h" | ||
23 | #include "xdgshellclient.h" | | |||
24 | #include "wayland_server.h" | 24 | #include "wayland_server.h" | ||
25 | 25 | | |||
26 | #include <KWayland/Client/xdgshell.h> | 26 | #include <KWayland/Client/xdgshell.h> | ||
27 | #include <KWayland/Client/subsurface.h> | 27 | #include <KWayland/Client/subsurface.h> | ||
28 | #include <KWayland/Client/surface.h> | 28 | #include <KWayland/Client/surface.h> | ||
29 | 29 | | |||
30 | namespace KWin | 30 | namespace KWin | ||
31 | { | 31 | { | ||
Show All 24 Lines | 52 | { | |||
56 | 56 | | |||
57 | QScopedPointer<Surface> surface(Test::createSurface()); | 57 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
58 | QVERIFY(!surface.isNull()); | 58 | QVERIFY(!surface.isNull()); | ||
59 | 59 | | |||
60 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | 60 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data())); | ||
61 | QVERIFY(!shellSurface.isNull()); | 61 | QVERIFY(!shellSurface.isNull()); | ||
62 | 62 | | |||
63 | // set buffer size | 63 | // set buffer size | ||
64 | XdgShellClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | 64 | AbstractClient *client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); | ||
65 | QVERIFY(client); | 65 | QVERIFY(client); | ||
66 | 66 | | |||
67 | // add a first repaint | 67 | // add a first repaint | ||
68 | QSignalSpy swapSpy(Compositor::self(), &Compositor::bufferSwapCompleted); | 68 | QSignalSpy swapSpy(Compositor::self(), &Compositor::bufferSwapCompleted); | ||
69 | QVERIFY(swapSpy.isValid()); | 69 | QVERIFY(swapSpy.isValid()); | ||
70 | Compositor::self()->addRepaintFull(); | 70 | Compositor::self()->addRepaintFull(); | ||
71 | QVERIFY(swapSpy.wait()); | 71 | QVERIFY(swapSpy.wait()); | ||
72 | 72 | | |||
73 | // now change buffer size | 73 | // now change buffer size | ||
74 | Test::render(surface.data(), QSize(30, 10), Qt::red); | 74 | Test::render(surface.data(), QSize(30, 10), Qt::red); | ||
75 | 75 | | |||
76 | QSignalSpy damagedSpy(client, &XdgShellClient::damaged); | 76 | QSignalSpy damagedSpy(client, &AbstractClient::damaged); | ||
77 | QVERIFY(damagedSpy.isValid()); | 77 | QVERIFY(damagedSpy.isValid()); | ||
78 | QVERIFY(damagedSpy.wait()); | 78 | QVERIFY(damagedSpy.wait()); | ||
79 | KWin::Compositor::self()->addRepaintFull(); | 79 | KWin::Compositor::self()->addRepaintFull(); | ||
80 | QVERIFY(swapSpy.wait()); | 80 | QVERIFY(swapSpy.wait()); | ||
81 | } | 81 | } | ||
82 | 82 | | |||
83 | void BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface() | 83 | void BufferSizeChangeTest::testShmBufferSizeChangeOnSubSurface() | ||
84 | { | 84 | { | ||
85 | using namespace KWayland::Client; | 85 | using namespace KWayland::Client; | ||
86 | 86 | | |||
87 | // setup parent surface | 87 | // setup parent surface | ||
88 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | 88 | QScopedPointer<Surface> parentSurface(Test::createSurface()); | ||
89 | QVERIFY(!parentSurface.isNull()); | 89 | QVERIFY(!parentSurface.isNull()); | ||
90 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(parentSurface.data())); | 90 | QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(parentSurface.data())); | ||
91 | QVERIFY(!shellSurface.isNull()); | 91 | QVERIFY(!shellSurface.isNull()); | ||
92 | 92 | | |||
93 | // setup sub surface | 93 | // setup sub surface | ||
94 | QScopedPointer<Surface> surface(Test::createSurface()); | 94 | QScopedPointer<Surface> surface(Test::createSurface()); | ||
95 | QVERIFY(!surface.isNull()); | 95 | QVERIFY(!surface.isNull()); | ||
96 | QScopedPointer<SubSurface> subSurface(Test::createSubSurface(surface.data(), parentSurface.data())); | 96 | QScopedPointer<SubSurface> subSurface(Test::createSubSurface(surface.data(), parentSurface.data())); | ||
97 | QVERIFY(!subSurface.isNull()); | 97 | QVERIFY(!subSurface.isNull()); | ||
98 | 98 | | |||
99 | // set buffer sizes | 99 | // set buffer sizes | ||
100 | Test::render(surface.data(), QSize(30, 10), Qt::red); | 100 | Test::render(surface.data(), QSize(30, 10), Qt::red); | ||
101 | XdgShellClient *parent = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue); | 101 | AbstractClient *parent = Test::renderAndWaitForShown(parentSurface.data(), QSize(100, 50), Qt::blue); | ||
102 | QVERIFY(parent); | 102 | QVERIFY(parent); | ||
103 | 103 | | |||
104 | // add a first repaint | 104 | // add a first repaint | ||
105 | QSignalSpy swapSpy(Compositor::self(), &Compositor::bufferSwapCompleted); | 105 | QSignalSpy swapSpy(Compositor::self(), &Compositor::bufferSwapCompleted); | ||
106 | QVERIFY(swapSpy.isValid()); | 106 | QVERIFY(swapSpy.isValid()); | ||
107 | Compositor::self()->addRepaintFull(); | 107 | Compositor::self()->addRepaintFull(); | ||
108 | QVERIFY(swapSpy.wait()); | 108 | QVERIFY(swapSpy.wait()); | ||
109 | 109 | | |||
110 | // change buffer size of sub surface | 110 | // change buffer size of sub surface | ||
111 | QSignalSpy damagedParentSpy(parent, &XdgShellClient::damaged); | 111 | QSignalSpy damagedParentSpy(parent, &AbstractClient::damaged); | ||
112 | QVERIFY(damagedParentSpy.isValid()); | 112 | QVERIFY(damagedParentSpy.isValid()); | ||
113 | Test::render(surface.data(), QSize(20, 10), Qt::red); | 113 | Test::render(surface.data(), QSize(20, 10), Qt::red); | ||
114 | parentSurface->commit(Surface::CommitFlag::None); | 114 | parentSurface->commit(Surface::CommitFlag::None); | ||
115 | 115 | | |||
116 | QVERIFY(damagedParentSpy.wait()); | 116 | QVERIFY(damagedParentSpy.wait()); | ||
117 | 117 | | |||
118 | // add a second repaint | 118 | // add a second repaint | ||
119 | KWin::Compositor::self()->addRepaintFull(); | 119 | KWin::Compositor::self()->addRepaintFull(); | ||
120 | QVERIFY(swapSpy.wait()); | 120 | QVERIFY(swapSpy.wait()); | ||
121 | } | 121 | } | ||
122 | 122 | | |||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | WAYLANDTEST_MAIN(KWin::BufferSizeChangeTest) | 125 | WAYLANDTEST_MAIN(KWin::BufferSizeChangeTest) | ||
126 | #include "buffer_size_change_test.moc" | 126 | #include "buffer_size_change_test.moc" |