D19052: Fix captions with non-BMP characters

Vlad Zagorodniy <[email protected]>
Newsgroups gmane.comp.kde.devel.kwin
Message-ID <[email protected]>
zzag added a comment.


  Oh, I see. You can do better. :-) Just create a test table, e.g.
  
    void X11ClientTest::testCaption_data()
    {
        QTest::addColumn<QByteArray>("original");
        QTest::addColumn<QByteArray>("expected):
    
       QTest::newRow("trimmed") << QByteArrayLiteral("...") << QByteArrayLiteral("...");
       QTest::newRow("emojis") << QByteArrayLiteral("...") << QByteArrayLiteral("...");
    }
    
    void X11ClientTest::testCaption
    {
        // 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());
        QFETCH(QByteArray, original);
        winInfo.setName(original);
        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);
        QFETCH(QByteArray, expected);
        QCOMPARE(client->caption(), QString::fromUtf8(expected));
    
        // and destroy the window again
        xcb_unmap_window(c.data(), w);
        xcb_destroy_window(c.data(), w);
        xcb_flush(c.data());
    
        QVERIFY(Test::waitForWindowDestroyed(client));
    }

REPOSITORY
  R108 KWin

REVISION DETAIL
  https://phabricator.kde.org/D19052

To: cfeck, #kwin
Cc: zzag, graesslin, kwin, jraleigh, GB_2, mkulinski, ragreen, jackyalcine, Pitel, iodelay, bwowk, ZrenBot, ngraham, alexeymin, lesliezhai, ali-mohamed, hardening, jensreuterberg, abetts, sebas, apol, mart
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.