SignalSpy records TWO clicks when clicking on a Button ONCE.

Bug #1569379 reported by Tim Peeters
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-ui-toolkit (Ubuntu)
New
High
Unassigned

Bug Description

Execute the code below using qmltestrunner, and the test will fail because 'count' is 2, not 1.

import QtTest 1.0
import QtQuick 2.4
import Ubuntu.Components 1.3

Item {
    id: root
    width: units.gu(50)
    height: units.gu(80)

    Button {
        id: button
        anchors.centerIn: parent
        text: "Click me"
        onClicked: {
            print("click")
        }
    }

    TestCase {
        name: "ButtonClickedSpy"
        when: windowShown
        id: testCase

        SignalSpy {
            id: buttonSpy
            signalName: 'clicked'
            target: button
            onCountChanged: print("new count = "+count)
        }

        function test_click_button() {
            buttonSpy.clear();
            print("spy count after clearing = "+buttonSpy.count);
            mouseClick(button, button.width/2, button.height/2);
            compare(buttonSpy.count, 1, "Could not click button.");
        }
    }
}

Test results here: http://pastebin.ubuntu.com/15791843/

Tim Peeters (tpeeters)
Changed in ubuntu-ui-toolkit (Ubuntu):
importance: Undecided → High
Tim Peeters (tpeeters)
description: updated
Tim Peeters (tpeeters)
description: updated
description: updated
Revision history for this message
Andrea Bernabei (faenil) wrote :

and it seems it's not Qt's fault, since it only delivers 1 press and 1 release, as can be seen from

PASS : qmltestrunner::ButtonClickedSpy::initTestCase()
QDEBUG : qmltestrunner::ButtonClickedSpy::test_click_button() qml: spy count after clearing = 0
QDEBUG : qmltestrunner::ButtonClickedSpy::test_click_button() qt.quick.mouse: QQuickWindow::mousePressEvent() QPointF(160,304) 1 QFlags(0x1)
QDEBUG : qmltestrunner::ButtonClickedSpy::test_click_button() qt.quick.mouse: QQuickWindow::mouseReleaseEvent() QPointF(160,304) 1 QFlags()
QDEBUG : qmltestrunner::ButtonClickedSpy::test_click_button() qml: click
QDEBUG : qmltestrunner::ButtonClickedSpy::test_click_button() qml: new count = 1
QDEBUG : qmltestrunner::ButtonClickedSpy::test_click_button() qml: new count = 2
FAIL! : qmltestrunner::ButtonClickedSpy::test_click_button() Could not click button.
   Actual (): 2
   Expected (): 1

Revision history for this message
Andrea Bernabei (faenil) wrote :

fwiw, the log above was obtained using
QT_LOGGING_RULES="qt.quick.mouse.debug=true"

which is quite handy :)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.