[autotest] Add test case for window caption need to be simplified
The test illustrates that special characters like a line break are not removed from the window caption, which results in a line break added in the window decoration. Test case uses a title from a web page triggering it in Firefox. CCBUG: 323798
This commit is contained in:
parent
9e23d20f8f
commit
55a0afca97
3 changed files with 150 additions and 0 deletions
|
@ -52,6 +52,7 @@ if (XCB_ICCCM_FOUND)
|
||||||
integrationTest(NAME testX11DesktopWindow SRCS desktop_window_x11_test.cpp LIBS XCB::ICCCM)
|
integrationTest(NAME testX11DesktopWindow SRCS desktop_window_x11_test.cpp LIBS XCB::ICCCM)
|
||||||
integrationTest(NAME testXwaylandInput SRCS xwayland_input_test.cpp LIBS XCB::ICCCM)
|
integrationTest(NAME testXwaylandInput SRCS xwayland_input_test.cpp LIBS XCB::ICCCM)
|
||||||
integrationTest(NAME testWindowRules SRCS window_rules_test.cpp LIBS XCB::ICCCM)
|
integrationTest(NAME testWindowRules SRCS window_rules_test.cpp LIBS XCB::ICCCM)
|
||||||
|
integrationTest(NAME testX11Client SRCS x11_client_test.cpp LIBS XCB::ICCCM)
|
||||||
|
|
||||||
if (KWIN_BUILD_ACTIVITIES)
|
if (KWIN_BUILD_ACTIVITIES)
|
||||||
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM)
|
integrationTest(NAME testActivities SRCS activities_test.cpp LIBS XCB::ICCCM)
|
||||||
|
|
|
@ -60,6 +60,7 @@ private Q_SLOTS:
|
||||||
void testMaximizedToFullscreen();
|
void testMaximizedToFullscreen();
|
||||||
void testWindowOpensLargerThanScreen_data();
|
void testWindowOpensLargerThanScreen_data();
|
||||||
void testWindowOpensLargerThanScreen();
|
void testWindowOpensLargerThanScreen();
|
||||||
|
void testCaptionSimplified();
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestShellClient::initTestCase()
|
void TestShellClient::initTestCase()
|
||||||
|
@ -544,5 +545,22 @@ void TestShellClient::testWindowOpensLargerThanScreen()
|
||||||
QVERIFY(sizeChangeRequestedSpy.wait());
|
QVERIFY(sizeChangeRequestedSpy.wait());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestShellClient::testCaptionSimplified()
|
||||||
|
{
|
||||||
|
// this test verifies that caption is properly trimmed
|
||||||
|
// see BUG 323798 comment #12
|
||||||
|
QScopedPointer<Surface> surface(Test::createSurface());
|
||||||
|
// only done for xdg-shell as ShellSurface misses the setter
|
||||||
|
QScopedPointer<XdgShellSurface> shellSurface(qobject_cast<XdgShellSurface*>(Test::createShellSurface(Test::ShellSurfaceType::XdgShellV5, surface.data())));
|
||||||
|
const QString origTitle = QString::fromUtf8(QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox"));
|
||||||
|
shellSurface->setTitle(origTitle);
|
||||||
|
auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue);
|
||||||
|
QVERIFY(c);
|
||||||
|
QEXPECT_FAIL("", "BUG 323798", Continue);
|
||||||
|
QVERIFY(c->caption() != origTitle);
|
||||||
|
QEXPECT_FAIL("", "BUG 323798", Continue);
|
||||||
|
QCOMPARE(c->caption(), origTitle.simplified());
|
||||||
|
}
|
||||||
|
|
||||||
WAYLANDTEST_MAIN(TestShellClient)
|
WAYLANDTEST_MAIN(TestShellClient)
|
||||||
#include "shell_client_test.moc"
|
#include "shell_client_test.moc"
|
||||||
|
|
131
autotests/integration/x11_client_test.cpp
Normal file
131
autotests/integration/x11_client_test.cpp
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
/********************************************************************
|
||||||
|
KWin - the KDE window manager
|
||||||
|
This file is part of the KDE project.
|
||||||
|
|
||||||
|
Copyright (C) 2016 Martin Gräßlin <mgraesslin@kde.org>
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*********************************************************************/
|
||||||
|
#include "kwin_wayland_test.h"
|
||||||
|
#include "composite.h"
|
||||||
|
#include "effects.h"
|
||||||
|
#include "effectloader.h"
|
||||||
|
#include "cursor.h"
|
||||||
|
#include "platform.h"
|
||||||
|
#include "scene_qpainter.h"
|
||||||
|
#include "shell_client.h"
|
||||||
|
#include "wayland_server.h"
|
||||||
|
#include "workspace.h"
|
||||||
|
|
||||||
|
#include <netwm.h>
|
||||||
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
|
using namespace KWin;
|
||||||
|
static const QString s_socketName = QStringLiteral("wayland_test_x11_client-0");
|
||||||
|
|
||||||
|
class X11ClientTest : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private Q_SLOTS:
|
||||||
|
void initTestCase();
|
||||||
|
void init();
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
void testCaptionSimplified();
|
||||||
|
};
|
||||||
|
|
||||||
|
void X11ClientTest::initTestCase()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<KWin::AbstractClient*>();
|
||||||
|
QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated);
|
||||||
|
QVERIFY(workspaceCreatedSpy.isValid());
|
||||||
|
kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024));
|
||||||
|
QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit()));
|
||||||
|
|
||||||
|
kwinApp()->start();
|
||||||
|
QVERIFY(workspaceCreatedSpy.wait());
|
||||||
|
QVERIFY(Compositor::self());
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11ClientTest::init()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void X11ClientTest::cleanup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
struct XcbConnectionDeleter
|
||||||
|
{
|
||||||
|
static inline void cleanup(xcb_connection_t *pointer)
|
||||||
|
{
|
||||||
|
xcb_disconnect(pointer);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
void X11ClientTest::testCaptionSimplified()
|
||||||
|
{
|
||||||
|
// this test verifies that caption is properly trimmed
|
||||||
|
// see BUG 323798 comment #12
|
||||||
|
QSignalSpy windowAddedSpy(effects, &EffectsHandler::windowAdded);
|
||||||
|
QVERIFY(windowAddedSpy.isValid());
|
||||||
|
|
||||||
|
// create an xcb window
|
||||||
|
QScopedPointer<xcb_connection_t, XcbConnectionDeleter> c(xcb_connect(nullptr, nullptr));
|
||||||
|
QVERIFY(!xcb_connection_has_error(c.data()));
|
||||||
|
const QRect windowGeometry(0, 0, 100, 200);
|
||||||
|
xcb_window_t w = xcb_generate_id(c.data());
|
||||||
|
xcb_create_window(c.data(), XCB_COPY_FROM_PARENT, w, rootWindow(),
|
||||||
|
windowGeometry.x(),
|
||||||
|
windowGeometry.y(),
|
||||||
|
windowGeometry.width(),
|
||||||
|
windowGeometry.height(),
|
||||||
|
0, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_COPY_FROM_PARENT, 0, nullptr);
|
||||||
|
xcb_size_hints_t hints;
|
||||||
|
memset(&hints, 0, sizeof(hints));
|
||||||
|
xcb_icccm_size_hints_set_position(&hints, 1, windowGeometry.x(), windowGeometry.y());
|
||||||
|
xcb_icccm_size_hints_set_size(&hints, 1, windowGeometry.width(), windowGeometry.height());
|
||||||
|
xcb_icccm_set_wm_normal_hints(c.data(), w, &hints);
|
||||||
|
NETWinInfo winInfo(c.data(), w, rootWindow(), NET::Properties(), NET::Properties2());
|
||||||
|
const QByteArray origTitle = QByteArrayLiteral("Was tun, wenn Schüler Autismus haben?\342\200\250\342\200\250\342\200\250 – Marlies Hübner - Mozilla Firefox");
|
||||||
|
winInfo.setName(origTitle.constData());
|
||||||
|
xcb_map_window(c.data(), w);
|
||||||
|
xcb_flush(c.data());
|
||||||
|
|
||||||
|
// we should get a client for it
|
||||||
|
QSignalSpy windowCreatedSpy(workspace(), &Workspace::clientAdded);
|
||||||
|
QVERIFY(windowCreatedSpy.isValid());
|
||||||
|
QVERIFY(windowCreatedSpy.wait());
|
||||||
|
Client *client = windowCreatedSpy.first().first().value<Client*>();
|
||||||
|
QVERIFY(client);
|
||||||
|
QCOMPARE(client->window(), w);
|
||||||
|
QEXPECT_FAIL("", "BUG 323798", Continue);
|
||||||
|
QVERIFY(client->caption() != QString::fromUtf8(origTitle));
|
||||||
|
QEXPECT_FAIL("", "BUG 323798", Continue);
|
||||||
|
QCOMPARE(client->caption(), QString::fromUtf8(origTitle).simplified());
|
||||||
|
|
||||||
|
// and destroy the window again
|
||||||
|
xcb_unmap_window(c.data(), w);
|
||||||
|
xcb_flush(c.data());
|
||||||
|
|
||||||
|
QSignalSpy windowClosedSpy(client, &Client::windowClosed);
|
||||||
|
QVERIFY(windowClosedSpy.isValid());
|
||||||
|
QVERIFY(windowClosedSpy.wait());
|
||||||
|
xcb_destroy_window(c.data(), w);
|
||||||
|
c.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
WAYLANDTEST_MAIN(X11ClientTest)
|
||||||
|
#include "x11_client_test.moc"
|
Loading…
Reference in a new issue