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
81
82
83
84
85
86
87
88
89
90
91
92
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtTest
import Qt.labs.platform
TestCase {
id: testCase
width: 200
height: 200
visible: true
when: windowShown
name: "SystemTrayIcon"
Component {
id: systemTrayIconComponent
// Check that icon.name can be used in this Qt.labs.platform version
SystemTrayIcon {
icon.name: ""
}
}
Component {
id: signalSpyComponent
SignalSpy {}
}
function test_properties_data() {
return [
{tag: "visible", signal: "visibleChanged", init: false, value: true},
{tag: "icon.source", signal: "iconChanged", init: "", value: "qrc:/tray.png"},
{tag: "icon.name", signal: "iconChanged", init: "", value: "icon-name"},
{tag: "tooltip", signal: "tooltipChanged", init: "", value: "tooltip"},
]
}
function test_properties(data) {
let icon = createTemporaryObject(systemTrayIconComponent, testCase)
verify(icon)
let groupedProperty = data.tag.indexOf(".") !== -1
let spy = createTemporaryObject(signalSpyComponent, testCase, {
target: icon, signalName: data.signal
})
verify(spy)
verify(spy.valid)
let propertyName = groupedProperty ? data.tag.split('.')[1] : data.tag
let object = !groupedProperty ? icon : icon.icon
compare(object[propertyName], data.init)
object[propertyName] = data.value
compare(spy.count, 1)
compare(object[propertyName], data.value)
object[propertyName] = data.value
compare(spy.count, 1)
}
function test_messageIcon() {
// Q_ENUMS(QPlatformSystemTrayIcon::ActivationReason)
compare(SystemTrayIcon.NoIcon, 0)
compare(SystemTrayIcon.Information, 1)
compare(SystemTrayIcon.Warning, 2)
compare(SystemTrayIcon.Critical, 3)
}
function test_activationReason() {
// Q_ENUMS(QPlatformSystemTrayIcon::ActivationReason)
compare(SystemTrayIcon.Unknown, 0)
compare(SystemTrayIcon.Context, 1)
compare(SystemTrayIcon.DoubleClick, 2)
compare(SystemTrayIcon.Trigger, 3)
compare(SystemTrayIcon.MiddleClick, 4)
}
function test_activated() {
let icon = createTemporaryObject(systemTrayIconComponent, testCase)
verify(icon)
let spy = createTemporaryObject(signalSpyComponent, testCase, {
target: icon, signalName: "activated"
})
verify(spy)
verify(spy.valid)
icon.activated(SystemTrayIcon.Trigger)
compare(spy.count, 1)
compare(spy.signalArguments[0][0], SystemTrayIcon.Trigger)
}
}
|