Code review comment for lp:~paulliu/unity/phablet_add-qmluitest1

Revision history for this message
Michael Zanetti (mzanetti) wrote :

94 + function test_mouseEvent() {
95 + indicatorMenuWindow.shown=true
96 + tryCompare(indicatorMenuWindow, "opacity", 1.0)
97 +
98 + clickedSpy.clear()
99 + mouseClick(indicatorMenuWindow, indicatorMenuWindow.width / 2,
100 + indicatorMenuWindow.height / 2)
101 + compare(clickedSpy.count, 0,
102 + "Mouse event should be eaten by indicatorMenuWindow")
103 +
104 + indicatorMenuWindow.shown=false
105 + tryCompare(indicatorMenuWindow, "opacity", 0.0)
106 +
107 + clickedSpy.clear()
108 + mouseClick(indicatorMenuWindow, indicatorMenuWindow.width / 2,
109 + indicatorMenuWindow.height / 2)
110 + compare(clickedSpy.count, 1,
111 + "Mouse event should not be eaten by indicatorMenuWindow")
112 + }

I think this would be a perfect candidate for using the _data() mechanism.

Example:

        function test_mouseEvent_data() {
            return [
                {tag: "invisible", shown: true, opacity: 1.0, mouseClicks: 0},
                {tag: "visible", shown: false, opacity: 0.0, mouseClicks: 1},
            ]
        }

        function test_mouseEvent(data) {
            indicatorMenuWindow.shown = data.shown
            tryCompare(indicatorMenuWindow, "opacity", data.opacity)

            clickedSpy.clear()
            mouseClick(indicatorMenuWindow, indicatorMenuWindow.width / 2,
                       indicatorMenuWindow.height / 2)
            compare(clickedSpy.count, data.mouseClicks,
                    "Check for Mouse event eating by indicatorMenuWindow failed")
        }

This way you don't have to copy/paste the test code and the debug output gives better feedback when a test fails.

review: Needs Fixing

« Back to merge proposal