Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_seat.cpp
Show First 20 Lines • Show All 386 Lines • ▼ Show 20 Line(s) | 367 | { | |||
---|---|---|---|---|---|
387 | m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15)); | 387 | m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15)); | ||
388 | QCOMPARE(focusedPointerChangedSpy.count(), 1); | 388 | QCOMPARE(focusedPointerChangedSpy.count(), 1); | ||
389 | QVERIFY(!focusedPointerChangedSpy.first().first().value<PointerInterface*>()); | 389 | QVERIFY(!focusedPointerChangedSpy.first().first().value<PointerInterface*>()); | ||
390 | // no pointer yet | 390 | // no pointer yet | ||
391 | QVERIFY(m_seatInterface->focusedPointerSurface()); | 391 | QVERIFY(m_seatInterface->focusedPointerSurface()); | ||
392 | QVERIFY(!m_seatInterface->focusedPointer()); | 392 | QVERIFY(!m_seatInterface->focusedPointer()); | ||
393 | 393 | | |||
394 | Pointer *p = m_seat->createPointer(m_seat); | 394 | Pointer *p = m_seat->createPointer(m_seat); | ||
395 | QSignalSpy frameSpy(p, &Pointer::frame); | ||||
396 | QVERIFY(frameSpy.isValid()); | ||||
395 | const Pointer &cp = *p; | 397 | const Pointer &cp = *p; | ||
396 | QVERIFY(p->isValid()); | 398 | QVERIFY(p->isValid()); | ||
397 | QScopedPointer<RelativePointer> relativePointer(m_relativePointerManager->createRelativePointer(p)); | 399 | QScopedPointer<RelativePointer> relativePointer(m_relativePointerManager->createRelativePointer(p)); | ||
398 | QVERIFY(relativePointer->isValid()); | 400 | QVERIFY(relativePointer->isValid()); | ||
399 | QSignalSpy pointerCreatedSpy(m_seatInterface, SIGNAL(pointerCreated(KWayland::Server::PointerInterface*))); | 401 | QSignalSpy pointerCreatedSpy(m_seatInterface, SIGNAL(pointerCreated(KWayland::Server::PointerInterface*))); | ||
400 | QVERIFY(pointerCreatedSpy.isValid()); | 402 | QVERIFY(pointerCreatedSpy.isValid()); | ||
401 | // once the pointer is created it should be set as the focused pointer | 403 | // once the pointer is created it should be set as the focused pointer | ||
402 | QVERIFY(pointerCreatedSpy.wait()); | 404 | QVERIFY(pointerCreatedSpy.wait()); | ||
403 | QVERIFY(m_seatInterface->focusedPointer()); | 405 | QVERIFY(m_seatInterface->focusedPointer()); | ||
404 | QCOMPARE(pointerCreatedSpy.first().first().value<PointerInterface*>(), m_seatInterface->focusedPointer()); | 406 | QCOMPARE(pointerCreatedSpy.first().first().value<PointerInterface*>(), m_seatInterface->focusedPointer()); | ||
405 | QCOMPARE(focusedPointerChangedSpy.count(), 2); | 407 | QCOMPARE(focusedPointerChangedSpy.count(), 2); | ||
406 | QCOMPARE(focusedPointerChangedSpy.last().first().value<PointerInterface*>(), m_seatInterface->focusedPointer()); | 408 | QCOMPARE(focusedPointerChangedSpy.last().first().value<PointerInterface*>(), m_seatInterface->focusedPointer()); | ||
409 | QVERIFY(frameSpy.wait()); | ||||
410 | QCOMPARE(frameSpy.count(), 1); | ||||
407 | 411 | | |||
408 | m_seatInterface->setFocusedPointerSurface(nullptr); | 412 | m_seatInterface->setFocusedPointerSurface(nullptr); | ||
409 | QCOMPARE(focusedPointerChangedSpy.count(), 3); | 413 | QCOMPARE(focusedPointerChangedSpy.count(), 3); | ||
410 | QVERIFY(!focusedPointerChangedSpy.last().first().value<PointerInterface*>()); | 414 | QVERIFY(!focusedPointerChangedSpy.last().first().value<PointerInterface*>()); | ||
411 | serverSurface->client()->flush(); | 415 | serverSurface->client()->flush(); | ||
412 | QTest::qWait(100); | 416 | QVERIFY(frameSpy.wait()); | ||
417 | QCOMPARE(frameSpy.count(), 2); | ||||
413 | 418 | | |||
414 | QSignalSpy enteredSpy(p, SIGNAL(entered(quint32,QPointF))); | 419 | QSignalSpy enteredSpy(p, SIGNAL(entered(quint32,QPointF))); | ||
415 | QVERIFY(enteredSpy.isValid()); | 420 | QVERIFY(enteredSpy.isValid()); | ||
416 | 421 | | |||
417 | QSignalSpy leftSpy(p, SIGNAL(left(quint32))); | 422 | QSignalSpy leftSpy(p, SIGNAL(left(quint32))); | ||
418 | QVERIFY(leftSpy.isValid()); | 423 | QVERIFY(leftSpy.isValid()); | ||
419 | 424 | | |||
420 | QSignalSpy motionSpy(p, SIGNAL(motion(QPointF,quint32))); | 425 | QSignalSpy motionSpy(p, SIGNAL(motion(QPointF,quint32))); | ||
Show All 10 Lines | |||||
431 | 436 | | |||
432 | QVERIFY(!p->enteredSurface()); | 437 | QVERIFY(!p->enteredSurface()); | ||
433 | QVERIFY(!cp.enteredSurface()); | 438 | QVERIFY(!cp.enteredSurface()); | ||
434 | m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15)); | 439 | m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(10, 15)); | ||
435 | QCOMPARE(m_seatInterface->focusedPointerSurface(), serverSurface); | 440 | QCOMPARE(m_seatInterface->focusedPointerSurface(), serverSurface); | ||
436 | QVERIFY(enteredSpy.wait()); | 441 | QVERIFY(enteredSpy.wait()); | ||
437 | QCOMPARE(enteredSpy.first().first().value<quint32>(), m_display->serial()); | 442 | QCOMPARE(enteredSpy.first().first().value<quint32>(), m_display->serial()); | ||
438 | QCOMPARE(enteredSpy.first().last().toPoint(), QPoint(10, 3)); | 443 | QCOMPARE(enteredSpy.first().last().toPoint(), QPoint(10, 3)); | ||
444 | QCOMPARE(frameSpy.count(), 3); | ||||
439 | PointerInterface *serverPointer = m_seatInterface->focusedPointer(); | 445 | PointerInterface *serverPointer = m_seatInterface->focusedPointer(); | ||
440 | QVERIFY(serverPointer); | 446 | QVERIFY(serverPointer); | ||
441 | QCOMPARE(p->enteredSurface(), s); | 447 | QCOMPARE(p->enteredSurface(), s); | ||
442 | QCOMPARE(cp.enteredSurface(), s); | 448 | QCOMPARE(cp.enteredSurface(), s); | ||
443 | QCOMPARE(focusedPointerChangedSpy.count(), 4); | 449 | QCOMPARE(focusedPointerChangedSpy.count(), 4); | ||
444 | QCOMPARE(focusedPointerChangedSpy.last().first().value<PointerInterface*>(), serverPointer); | 450 | QCOMPARE(focusedPointerChangedSpy.last().first().value<PointerInterface*>(), serverPointer); | ||
445 | 451 | | |||
446 | // test motion | 452 | // test motion | ||
447 | m_seatInterface->setTimestamp(1); | 453 | m_seatInterface->setTimestamp(1); | ||
448 | m_seatInterface->setPointerPos(QPoint(10, 16)); | 454 | m_seatInterface->setPointerPos(QPoint(10, 16)); | ||
449 | QVERIFY(motionSpy.wait()); | 455 | QVERIFY(motionSpy.wait()); | ||
456 | QCOMPARE(frameSpy.count(), 4); | ||||
450 | QCOMPARE(motionSpy.first().first().toPoint(), QPoint(0, 1)); | 457 | QCOMPARE(motionSpy.first().first().toPoint(), QPoint(0, 1)); | ||
451 | QCOMPARE(motionSpy.first().last().value<quint32>(), quint32(1)); | 458 | QCOMPARE(motionSpy.first().last().value<quint32>(), quint32(1)); | ||
452 | 459 | | |||
453 | // test relative motion | 460 | // test relative motion | ||
454 | m_seatInterface->relativePointerMotion(QSizeF(1, 2), QSizeF(3, 4), quint64(-1)); | 461 | m_seatInterface->relativePointerMotion(QSizeF(1, 2), QSizeF(3, 4), quint64(-1)); | ||
455 | QVERIFY(relativeMotionSpy.wait()); | 462 | QVERIFY(relativeMotionSpy.wait()); | ||
456 | QCOMPARE(relativeMotionSpy.count(), 1); | 463 | QCOMPARE(relativeMotionSpy.count(), 1); | ||
457 | QCOMPARE(relativeMotionSpy.first().at(0).toSizeF(), QSizeF(1, 2)); | 464 | QCOMPARE(relativeMotionSpy.first().at(0).toSizeF(), QSizeF(1, 2)); | ||
458 | QCOMPARE(relativeMotionSpy.first().at(1).toSizeF(), QSizeF(3, 4)); | 465 | QCOMPARE(relativeMotionSpy.first().at(1).toSizeF(), QSizeF(3, 4)); | ||
459 | QCOMPARE(relativeMotionSpy.first().at(2).value<quint64>(), quint64(-1)); | 466 | QCOMPARE(relativeMotionSpy.first().at(2).value<quint64>(), quint64(-1)); | ||
460 | 467 | | |||
461 | // test axis | 468 | // test axis | ||
462 | m_seatInterface->setTimestamp(2); | 469 | m_seatInterface->setTimestamp(2); | ||
463 | m_seatInterface->pointerAxis(Qt::Horizontal, 10); | 470 | m_seatInterface->pointerAxis(Qt::Horizontal, 10); | ||
464 | QVERIFY(axisSpy.wait()); | 471 | QVERIFY(axisSpy.wait()); | ||
472 | QCOMPARE(frameSpy.count(), 5); | ||||
465 | m_seatInterface->setTimestamp(3); | 473 | m_seatInterface->setTimestamp(3); | ||
466 | m_seatInterface->pointerAxis(Qt::Vertical, 20); | 474 | m_seatInterface->pointerAxis(Qt::Vertical, 20); | ||
467 | QVERIFY(axisSpy.wait()); | 475 | QVERIFY(axisSpy.wait()); | ||
476 | QCOMPARE(frameSpy.count(), 6); | ||||
468 | QCOMPARE(axisSpy.first().at(0).value<quint32>(), quint32(2)); | 477 | QCOMPARE(axisSpy.first().at(0).value<quint32>(), quint32(2)); | ||
469 | QCOMPARE(axisSpy.first().at(1).value<Pointer::Axis>(), Pointer::Axis::Horizontal); | 478 | QCOMPARE(axisSpy.first().at(1).value<Pointer::Axis>(), Pointer::Axis::Horizontal); | ||
470 | QCOMPARE(axisSpy.first().at(2).value<qreal>(), qreal(10)); | 479 | QCOMPARE(axisSpy.first().at(2).value<qreal>(), qreal(10)); | ||
471 | 480 | | |||
472 | QCOMPARE(axisSpy.last().at(0).value<quint32>(), quint32(3)); | 481 | QCOMPARE(axisSpy.last().at(0).value<quint32>(), quint32(3)); | ||
473 | QCOMPARE(axisSpy.last().at(1).value<Pointer::Axis>(), Pointer::Axis::Vertical); | 482 | QCOMPARE(axisSpy.last().at(1).value<Pointer::Axis>(), Pointer::Axis::Vertical); | ||
474 | QCOMPARE(axisSpy.last().at(2).value<qreal>(), qreal(20)); | 483 | QCOMPARE(axisSpy.last().at(2).value<qreal>(), qreal(20)); | ||
475 | 484 | | |||
476 | // test button | 485 | // test button | ||
477 | m_seatInterface->setTimestamp(4); | 486 | m_seatInterface->setTimestamp(4); | ||
478 | m_seatInterface->pointerButtonPressed(1); | 487 | m_seatInterface->pointerButtonPressed(1); | ||
479 | QVERIFY(buttonSpy.wait()); | 488 | QVERIFY(buttonSpy.wait()); | ||
489 | QCOMPARE(frameSpy.count(), 7); | ||||
480 | QCOMPARE(buttonSpy.at(0).at(0).value<quint32>(), m_display->serial()); | 490 | QCOMPARE(buttonSpy.at(0).at(0).value<quint32>(), m_display->serial()); | ||
481 | m_seatInterface->setTimestamp(5); | 491 | m_seatInterface->setTimestamp(5); | ||
482 | m_seatInterface->pointerButtonPressed(2); | 492 | m_seatInterface->pointerButtonPressed(2); | ||
483 | QVERIFY(buttonSpy.wait()); | 493 | QVERIFY(buttonSpy.wait()); | ||
494 | QCOMPARE(frameSpy.count(), 8); | ||||
484 | QCOMPARE(buttonSpy.at(1).at(0).value<quint32>(), m_display->serial()); | 495 | QCOMPARE(buttonSpy.at(1).at(0).value<quint32>(), m_display->serial()); | ||
485 | m_seatInterface->setTimestamp(6); | 496 | m_seatInterface->setTimestamp(6); | ||
486 | m_seatInterface->pointerButtonReleased(2); | 497 | m_seatInterface->pointerButtonReleased(2); | ||
487 | QVERIFY(buttonSpy.wait()); | 498 | QVERIFY(buttonSpy.wait()); | ||
499 | QCOMPARE(frameSpy.count(), 9); | ||||
488 | QCOMPARE(buttonSpy.at(2).at(0).value<quint32>(), m_display->serial()); | 500 | QCOMPARE(buttonSpy.at(2).at(0).value<quint32>(), m_display->serial()); | ||
489 | m_seatInterface->setTimestamp(7); | 501 | m_seatInterface->setTimestamp(7); | ||
490 | m_seatInterface->pointerButtonReleased(1); | 502 | m_seatInterface->pointerButtonReleased(1); | ||
491 | QVERIFY(buttonSpy.wait()); | 503 | QVERIFY(buttonSpy.wait()); | ||
504 | QCOMPARE(frameSpy.count(), 10); | ||||
492 | QCOMPARE(buttonSpy.count(), 4); | 505 | QCOMPARE(buttonSpy.count(), 4); | ||
493 | 506 | | |||
494 | // timestamp | 507 | // timestamp | ||
495 | QCOMPARE(buttonSpy.at(0).at(1).value<quint32>(), quint32(4)); | 508 | QCOMPARE(buttonSpy.at(0).at(1).value<quint32>(), quint32(4)); | ||
496 | // button | 509 | // button | ||
497 | QCOMPARE(buttonSpy.at(0).at(2).value<quint32>(), quint32(1)); | 510 | QCOMPARE(buttonSpy.at(0).at(2).value<quint32>(), quint32(1)); | ||
498 | QCOMPARE(buttonSpy.at(0).at(3).value<KWayland::Client::Pointer::ButtonState>(), KWayland::Client::Pointer::ButtonState::Pressed); | 511 | QCOMPARE(buttonSpy.at(0).at(3).value<KWayland::Client::Pointer::ButtonState>(), KWayland::Client::Pointer::ButtonState::Pressed); | ||
499 | 512 | | |||
Show All 16 Lines | |||||
516 | // button | 529 | // button | ||
517 | QCOMPARE(buttonSpy.at(3).at(2).value<quint32>(), quint32(1)); | 530 | QCOMPARE(buttonSpy.at(3).at(2).value<quint32>(), quint32(1)); | ||
518 | QCOMPARE(buttonSpy.at(3).at(3).value<KWayland::Client::Pointer::ButtonState>(), KWayland::Client::Pointer::ButtonState::Released); | 531 | QCOMPARE(buttonSpy.at(3).at(3).value<KWayland::Client::Pointer::ButtonState>(), KWayland::Client::Pointer::ButtonState::Released); | ||
519 | 532 | | |||
520 | // leave the surface | 533 | // leave the surface | ||
521 | m_seatInterface->setFocusedPointerSurface(nullptr); | 534 | m_seatInterface->setFocusedPointerSurface(nullptr); | ||
522 | QCOMPARE(focusedPointerChangedSpy.count(), 5); | 535 | QCOMPARE(focusedPointerChangedSpy.count(), 5); | ||
523 | QVERIFY(leftSpy.wait()); | 536 | QVERIFY(leftSpy.wait()); | ||
537 | QCOMPARE(frameSpy.count(), 11); | ||||
524 | QCOMPARE(leftSpy.first().first().value<quint32>(), m_display->serial()); | 538 | QCOMPARE(leftSpy.first().first().value<quint32>(), m_display->serial()); | ||
525 | QVERIFY(!p->enteredSurface()); | 539 | QVERIFY(!p->enteredSurface()); | ||
526 | QVERIFY(!cp.enteredSurface()); | 540 | QVERIFY(!cp.enteredSurface()); | ||
527 | 541 | | |||
528 | // now a relative motion should not be sent to the relative pointer | 542 | // now a relative motion should not be sent to the relative pointer | ||
529 | m_seatInterface->relativePointerMotion(QSizeF(1, 2), QSizeF(3, 4), quint64(-1)); | 543 | m_seatInterface->relativePointerMotion(QSizeF(1, 2), QSizeF(3, 4), quint64(-1)); | ||
530 | QVERIFY(!relativeMotionSpy.wait()); | 544 | QVERIFY(!relativeMotionSpy.wait()); | ||
531 | 545 | | |||
532 | // enter it again | 546 | // enter it again | ||
533 | m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(0, 0)); | 547 | m_seatInterface->setFocusedPointerSurface(serverSurface, QPoint(0, 0)); | ||
534 | QCOMPARE(focusedPointerChangedSpy.count(), 6); | 548 | QCOMPARE(focusedPointerChangedSpy.count(), 6); | ||
535 | QVERIFY(enteredSpy.wait()); | 549 | QVERIFY(enteredSpy.wait()); | ||
550 | QCOMPARE(frameSpy.count(), 12); | ||||
536 | QCOMPARE(p->enteredSurface(), s); | 551 | QCOMPARE(p->enteredSurface(), s); | ||
537 | QCOMPARE(cp.enteredSurface(), s); | 552 | QCOMPARE(cp.enteredSurface(), s); | ||
538 | 553 | | |||
539 | // send another relative motion event | 554 | // send another relative motion event | ||
540 | m_seatInterface->relativePointerMotion(QSizeF(4, 5), QSizeF(6, 7), quint64(1)); | 555 | m_seatInterface->relativePointerMotion(QSizeF(4, 5), QSizeF(6, 7), quint64(1)); | ||
541 | QVERIFY(relativeMotionSpy.wait()); | 556 | QVERIFY(relativeMotionSpy.wait()); | ||
542 | QCOMPARE(relativeMotionSpy.count(), 2); | 557 | QCOMPARE(relativeMotionSpy.count(), 2); | ||
543 | QCOMPARE(relativeMotionSpy.last().at(0).toSizeF(), QSizeF(4, 5)); | 558 | QCOMPARE(relativeMotionSpy.last().at(0).toSizeF(), QSizeF(4, 5)); | ||
▲ Show 20 Lines • Show All 1753 Lines • Show Last 20 Lines |