1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
import QtQuick 2.0
import QtTest 1.0
import QtWebKit 3.0
import "../common"
TestWebView {
id: webView
width: 200
height: 400
focus: true
property string lastUrl
property string lastTitle
SignalSpy {
id: spy
target: webView
signalName: "linkHovered"
}
onLinkHovered: {
webView.lastUrl = hoveredUrl
webView.lastTitle = hoveredTitle
}
TestCase {
name: "DesktopWebViewLinkHovered"
// Delayed windowShown to workaround problems with Qt5 in debug mode.
when: false
Timer {
running: parent.windowShown
repeat: false
interval: 1
onTriggered: parent.when = true
}
function init() {
webView.lastUrl = ""
webView.lastTitle = ""
spy.clear()
}
function test_linkHovered() {
compare(spy.count, 0)
webView.url = Qt.resolvedUrl("../common/test2.html")
verify(webView.waitForLoadSucceeded())
mouseMove(webView, 100, 100)
spy.wait()
compare(spy.count, 1)
compare(webView.lastUrl, Qt.resolvedUrl("../common/test1.html"))
compare(webView.lastTitle, "A title")
mouseMove(webView, 100, 300)
spy.wait()
compare(spy.count, 2)
compare(webView.lastUrl, "")
compare(webView.lastTitle, "")
}
function test_linkHoveredDoesntEmitRepeated() {
compare(spy.count, 0)
webView.url = Qt.resolvedUrl("../common/test2.html")
verify(webView.waitForLoadSucceeded())
for (var i = 0; i < 100; i += 10)
mouseMove(webView, 100, 100 + i)
spy.wait()
compare(spy.count, 1)
compare(webView.lastUrl, Qt.resolvedUrl("../common/test1.html"))
for (var i = 0; i < 100; i += 10)
mouseMove(webView, 100, 300 + i)
spy.wait()
compare(spy.count, 2)
compare(webView.lastUrl, "")
}
}
}
|