summaryrefslogtreecommitdiffstats
path: root/tests/auto/client/shared
Commit message (Collapse)AuthorAgeFilesLines
* Add client test for data deviceJohan Klokkhammer Helsing2019-01-306-0/+163
| | | | | Change-Id: Id89ec40a3f484808385401829a09a43781a1bed7 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client tests: Add simple test for keyboard pressJohan Klokkhammer Helsing2019-01-304-4/+75
| | | | | Change-Id: Ib28be5277af9145834c7808f993c747e21845616 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client: Add wl_output testsJohan Klokkhammer Helsing2019-01-175-13/+81
| | | | | | | | | Also removes overlapping old tests and adds a (currently failing) test for QTBUG-72828. Task-number: QTBUG-72828 Change-Id: Id93d5872ed1c4f181935c1e493e9d8d0ae9cfaf3 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Client: Test for xdg surface window geometryPier Luigi Fiorini2019-01-152-0/+14
| | | | | Change-Id: I2f336a81682317b1f7dc939d911906b4db60a386 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* Client: Test for xdg toplevel min and max sizeJohan Klokkhammer Helsing2019-01-152-1/+28
| | | | | Change-Id: I60605f494eebfde9a7737911eefe69a93041ced5 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Create a new type of mock compositor for client testsJohan Klokkhammer Helsing2018-12-1123-2509/+1407
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are a number of issues with the current client testing: - Adding new compositor functionality is cumbersome (need to add compositor send method, command, implementation, not to mention creating new wrapper objects. - Customizing available globals and their versions is not possible and would be hard to implement. I.e. how to test that functionality works with old and new versions of an interface? Handle globals being destroyed. We did this with wl_output, but it was painfully cumbersome. - Hard to verify that the compositor state is clean between tests. It is currently done in some tests, but requires boiler plate code which needs to be added and maintained for each test. - In general lots of boiler-plate for new tests. (We have to have separate tests as long as Qt has global/static state. I.e. if one shell extension has been initialized, we can't deinitialize and initialize another one, so tests have to be separate.) - Dispatching server events tied to the client event loop sometimes makes it hard to write tests without deadlocks. - Abstraction, encapsulation and automatic behavior that can't be disabled makes it hard to test low-level functionality like surface exposure. So, in an attempt to mitigate these issues, I wrote a new testing framework. - Compositor dispatch is running continuously in it's own thread, access to compositor state is guarded by a mutex on the compositor, locking this will make dispatching stop, so the test can safely access internals. Although a bit cumbersome at first this makes it much easier to directly use server protocol commands from the test itself, i.e. no need to create commands for every single thing we want to test. - The CoreCompositor::exec template method can accept a lambda that will be run with dispatching stopped. It can also return a value, conveniently letting us safely extract or modify compositor state from tests. - This framework also takes full advantage of the qtwaylandscanner, using wrapper classes for everything, reducing boiler plate considerably. - The compositor parts are designed to do as little as possible automatically, but still provide easy ways to enable common functionality, like releasing buffers automatically, configuring shell surfaces etc. - Compositor globals are pluggable, use add<GlobalClass>() and remove<GlobalClass>() to add new global interfaces. I.e. easy to create a compositor with or without data_device_manager for instance. - DefaultCompositor provides a sensible default set of functionality and convenience methods for most test-cases. Custom ones can still be made by inheriting from CoreCompositor directly instead or by removing or adding globals to DefaultCompositor. - Globals have an isClean() method. Implement it to verify that the client didn't leave any objects lying around from the previous test. CoreCompositor::isClean calls isClean on the globals so a single call is all that's needed. In short, we've traded mock compositor encapsulation and thread safety guarantees for less boiler-plate, easier and more convenient access to internals. Anything accessing compositor state should go into a exec() call, or through the wrapper macros QCOMPOSITOR_VERIFY and QCOMPOSITOR_COMPARE (or the TRY versions). I've also tried to make the compositor print warnings if compositor state is accessed in an unsafe way. The mock compositor is currently built once per test due to CI limitations (same thing as with the old tests). Change-Id: Ia3feb80ce175d3814292b7f4768a0cc719f8b0e8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client: Add fullscreen shell integrationPier Luigi Fiorini2018-11-055-1/+126
| | | | | | | | | | | | | | | | [ChangeLog][QPA plugin] Added support for fullscreen-shell unstable v1. The fullscreen_shell_unstable_v1 interface displays a single surface per output and it is used for nested compositors, where each output is rendered in a surface that is then displayed by the main compositor. For example weston could be the main compositor and a QML compositor could be launched as a client using this shell integration to display it inside weston. Change-Id: I037679a283ff03cb4bdf4b3fed59945090ec9250 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
* Merge remote-tracking branch 'origin/5.12' into devQt Forward Merge Bot2018-10-304-9/+30
|\ | | | | | | Change-Id: I1d9281750b06f7584e55759994dc6fcbcc5b2455
| * Client: Don't attach buffers to unexposed windowsJohan Klokkhammer Helsing2018-10-264-9/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QBackingStore::flush is sometimes called with an unxeposed window, in that case, don't attach the buffer to the wl_surface immediately, as that causes protocol errors with xdg_shell. Flushed buffers are instead stored until we get the first configure event. [ChangeLog][QPA plugin][xdg-shell] Fixed a bug where buffers were sometimes attached and committed before the first configure event, causing protocol errors. Fixes: QTBUG-71345 Change-Id: If9409d97bd25f6b13940c56141920a664c349c8e Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: David Edmundson <davidedmundson@kde.org>
* | Don't include system versions of wayland protocolJohan Klokkhammer Helsing2018-10-031-2/+1
|/ | | | | | | | | | | | | | | | | | | | | wayland-client.h and wayland-server.h includes protocol generated for the version of wayland.xml corresponding to the libwayland version. This becomes a problem when we want to support a version of wayland.xml that's newer than the system libwayland. The solution is to include wayland-client-core.h and wayland-client-server.h instead. These headers don't include any wayland-scanner generated code, so we can safely compile and link code generated against the version of wayland.xml that we ship. [ChangeLog] Code generated by qtwaylandscanner now includes wayland-client-core.h and wayland-server-core.h instead of wayland-client.h and wayland-server.h. This might break source compatibility for code using custom wayland extensions. Fixes: QTBUG-70553 Change-Id: Ice0cdb60ecc4f936acc0e158b96f7978549f62c1 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Don't use members of wl_resourceJohan Klokkhammer Helsing2018-09-181-4/+4
| | | | | | | | | When we switch to only including core wayland headers, wl_resource will be an opaque type. Use the getters and setter functions instead. Task-number: QTBUG-70553 Change-Id: I7d84d48a4ee3586f231a331cd15716686dcee775 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Remove ifdefs for unsupported libwayland versionsJohan Klokkhammer Helsing2018-09-171-7/+0
| | | | | | | The ifdefs were for version 1.2.0. Change-Id: Ie58745c7cf4c0fba45bc5203d24e9913d3a8b8ce Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Add missing Q_UNUSEDJohan Klokkhammer Helsing2018-09-141-0/+1
| | | | | Change-Id: I7e6b4460aac92cb9669ac1d0d0f4785a8444925d Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Compositor: Fix nullptr dereferences in fromResource functionsJohan Klokkhammer Helsing2018-08-291-1/+3
| | | | | | | | | If there was no resource for the given wl_resource*, don't try to dereference it. Change-Id: I3a27a5805699148bb26029e8b4179042c3c1117a Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Client: Add tests for xdg-shell v6 window geometryJohan Klokkhammer Helsing2018-06-073-0/+10
| | | | | Change-Id: Ifb7a1d63a136349cd99d516e63732b4393967468 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client xdg-shell v6 tests: Fix dangling pointer usageJohan Klokkhammer Helsing2018-05-291-2/+2
| | | | | | | Fixes some flaky tests Change-Id: Ifac7c95d12714d61afc37f879f4c70b2a7dbe0cf Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Fix QWaylandXdgShellV6Integration::handleKeyboardFocusChangedJohan Klokkhammer Helsing2018-05-091-1/+4
| | | | | | | | | | | The implementation was broken because it: 1. Didn't activate popups. 2. Activated toplevels with keyboard focus twice. 3. Tried to cast to xdg-shell-v5 classes, so windows were never deactivated. Change-Id: If492ebdbcd10a3214424f7bf6ac01e7ba8704bbf Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Client: Add acked configure support and implement it for xdg-shell v6Johan Klokkhammer Helsing2018-05-074-5/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem: The code in QWaylandWindow::setWindowStateInternal made many assumptions about how the shell surface responded to new window states, and when and if they were applied. Particularly: - The shell integrations support different subsets of Qt::WindowStates, so it doesn't make sense to map from states to setFullscreen, setNormal, etc. in QWaylandWindow because it really depends on the shell integration how it should be handled. - Some states are not supported/unknown on some shells and should immediately be rejected. - On some shells, particularly those where the current state is unknown, flags need to be resent even though they didn't change. - Should handleWindowStatesChanged be called immediately (client decides) or should it wait for a configure event (compositor decides)? I.e. the mState variable only makes sense for some shells. Furthermore, when state changes come from the compositors, some shell integrations require that a configure event is acked by the client and that the next committed buffer's size and content matches that configure event. Previously, we would just ack immediately and still send a buffer with the old size before a correct frame was drawn. i.e. sending incorrect acks, which would lead to protocol errors on some compositors. Additionally, QWaylandWindow::createDecoration() also assumed that windows should have decorations unless they are fullscreen. This is not always the case, particularly on ivi-application and probably on future shell integrations for embedded or tiling window managers etc. The Solution: The responsibility of mapping requested window states to Wayland requests have been moved to the QWaylandShellSurface implementation. QWaylandWindow now calls a new virtual, QWaylandShellSurface::requestWindowStates(Qt::WindowStates), instead of trying to be smart about it. The virtual getters and setters for window states have now been removed from the QWaylandShellSurface interface. It's now also the shell surface implementation's responsibility to call QWaylandWindow::handleWindowStatesChanged if and when it knows a new state is effective. QWaylandWindow::configure has been replaced with QWaylandWindow::applyConfigureWhenPossible(), which causes another new virtual, QWaylandShellSurface::applyConfigure(), to be called whenever we're free to resize and change the states of the next buffer (this is when states should be acked). This means that shells that use acked states need to store the pending states themselves, call applyConfigureWhenPossible(), wait for applyConfigure() to be called, call resizeFromApplyConfigure() and handleWindowStatesChanged(), and finally ack the applied state. Acked state for xdg-shell v5 and v6 has now been implemented, which also means we've now: [ChangeLog][QPA plugin] Implemented support for maximizing, minimizing, and setting fullscreen with xdg-shell unstable v6. [ChangeLog][QPA plugin] QWindow::isActive now follows configure events on xdg-shell unstable v6 (like v5). QWaylandWindow::createDecoration queries QWaylandShellSurface::wantsDecoration before creating window decorations, instead of using the previously unreliable QWaylandWindow::isFullscreen(). [ChangeLog][QPA plugin] Window decorations are now automatically disabled for ivi-application. The refactor also removes a couple of hacks: - QWindowSystemInterface::flushWindowSystemEvents() was called in QWaylandWindow::setWindowStates. Since this hack was introduced, the events now have oldState and newState members, and their values seem to make sense (ensured in the tests). - The hack for unminimizing on xdg-shell v5 in QWaylandWindow::createDecoration was not needed anymore. Finally, tests have been added for xdg-shell v6 to ensure that the right Wayland requests are sent, that we respond to configure events from the compositor, and that the Qt events and signals emitted on the client side make sense. Task-number: QTBUG-53702 Task-number: QTBUG-63417 Task-number: QTBUG-63748 Task-number: QTBUG-66928 Change-Id: Ib4c36b69105750f9dbdcc78adcf71e2e994cc70d Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Mocking compositor: Don't leak wl_shell_surfacesJohan Klokkhammer Helsing2018-03-121-0/+4
| | | | | Change-Id: Ic133b41bdcfb98418be4a0141f382734f1d5db85 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Add client-side tests for ivi-applicationJohan Klokkhammer Helsing2018-03-125-0/+215
| | | | | | | | Tests ivi surface creation and configuration. Task-number: QTBUG-66512 Change-Id: Idff60eb99eb34b7fce1c935bd036ef18a8f97d7c Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Send configure events in shell-agnostic client testsJohan Klokkhammer Helsing2018-03-088-10/+67
| | | | | | | | | | xdg-shell >= unstable v6 requires surfaces to be configured before buffers can be attached. Make sure to send a configure event when a compositor would normally do it. Task-number: QTBUG-66510 Change-Id: Icbff6ebaa597e858d92d621849aa0df7a8a976f3 Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Client test for xdg-shell v6 configure eventsJohan Klokkhammer Helsing2018-03-084-34/+147
| | | | | | Task-number: QTBUG-66689 Change-Id: Ifdf38a9ab73357fdbe61e77f0464b227ddd2e8ac Reviewed-by: Andy Nichols <andy.nichols@qt.io>
* Fix nullptr dereference in client testsJohan Klokkhammer Helsing2018-03-081-1/+2
| | | | | Change-Id: I932cd20f17b5486a1161569c5e9a3feebabeee8e Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Use default member initialization for raw pointersJohan Klokkhammer Helsing2018-02-283-10/+10
| | | | | | | | Initialize to nullptr to prevent undefined behavior. Change-Id: I7753c0be77a886d62ecb1cd7b86fc8c98340b0b8 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Init variables where they are declared when possible (clang-tidy)Johan Klokkhammer Helsing2018-02-276-28/+14
| | | | | | | | | | | | | | | | | | | | clang-tidy -p compile_commands.json $file \ -checks='-*,modernize-use-default-member-init,readability-redundant-member-init' \ -config='{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: "1"}]}' \ -header-filter='qtwayland' \ -fix Afterwards I ran search and replace on the diff to clean up some whitespace errors: - Replaced '(\n\+[^:\n]*)(:\s+\+\s+)' with '$1: ' - Replaced '(\n\+[^,\n]*)(,\s+\+\s+)' with '$1, ' - Replaced '\n\+\s*\n' with '\n' I also had to do some manual edits, because for some reason, this particular clang-tidy check doesn't trigger for some files. Change-Id: I3b3909bac4bf20108bbe8ad1e01bcc54236dae1b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Client tests: Use generated classes for mocking shellsJohan Klokkhammer Helsing2018-02-268-237/+160
| | | | | | | | | Removes a lot of boiler-plate code and makes the two shells more similar. This also makes it easier to extend the shells with additional mocking functionality. Change-Id: I4a846b06eeda695527d7c5679df339beae983af6 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Fix crash when connecting a new screenJohan Klokkhammer Helsing2018-02-214-2/+36
| | | | | | | | | | | | | | | | | | | | | | In QWaylandWindow::virtualSiblings, don't include screens that have not been added yet. I.e. QWaylandScreens for which QPlatformIntegration::screenAdded has not yet been called. There are two reasons why this crash wasn't covered by the removePrimaryScreen() test. First of all, the mock output didn't send wl_output.done events when updating the mode/geometry. These wayland events are what causes QWindowSystemInterface::handleScreenGeometryChange() to be called (where virtualSiblings are called). Furthermore, virtualSiblings is only called when the geometry actually changes, so add a new test that changes the screen geometry of the existing screen while a new one is being added (i.e. moves it to the right). Task-number: QTBUG-62044 Change-Id: I623fbf8799d21c6b9293e7120ded301277639cc6 Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Aleix Pol Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Test that xdg_toplevel_v6s are destroyed before xdg_surface_v6sJohan Klokkhammer Helsing2018-02-011-4/+21
| | | | | | | | | Adds an assert so tst_WaylandClientXdgShellV6::createDestroyWindow verifies deletion order. Task-number: QTBUG-65568 Change-Id: I0b4dd350f811495a9c7a78811915647fb713a43a Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Merge remote-tracking branch 'qt/5.10' into devPaul Olav Tvete2018-01-312-2/+7
| | | | Change-Id: I603cbb164e6015c1bb7796bd8bb055d84dbc3b04
* Verify that the client supports the compositor removing outputsJohan Klokkhammer Helsing2017-11-153-0/+19
| | | | | Change-Id: I799d29fa43ad429b7973d7a210aca554d6b0ce26 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Client: Test that the current screen is updated by surface eventsJohan Klokkhammer Helsing2017-11-157-40/+224
| | | | | Change-Id: If96691a2d844263a1e01a86df8b0d58f23848a4c Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
* Test client side xdg shell v6Johan Klokkhammer Helsing2017-10-2010-0/+1832
Apart for some new mocking code for xdg shell v6, this is mostly a refactor of the existing test, to reuse the existing mocking code between the different shell integrations. Change-Id: I68f93ab12ac47e51a50fd69647286cab46a3c595 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>