aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tst_qPrefProxy.qml
blob: 55d814a158907f303c657153ccdc0fb374f93d37 (plain) (blame)
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
// SPDX-License-Identifier: GPL-2.0
import QtQuick 2.6
import QtTest 1.2

TestCase {
	name: "qPrefProxy"

	function test_variables() {
		var x1 = PrefProxy.proxy_auth
		PrefProxy.proxy_auth = true
		compare(PrefProxy.proxy_auth, true)

		var x2 = PrefProxy.proxy_host
		PrefProxy.proxy_host = "my host"
		compare(PrefProxy.proxy_host, "my host")

		var x3 = PrefProxy.proxy_pass
		PrefProxy.proxy_pass = "my pass"
		compare(PrefProxy.proxy_pass, "my pass")

		var x4 = PrefProxy.proxy_port
		PrefProxy.proxy_port = 544
		compare(PrefProxy.proxy_port, 544)

		var x5 = PrefProxy.proxy_type
		PrefProxy.proxy_type = 3
		compare(PrefProxy.proxy_type, 3)

		var x6 = PrefProxy.proxy_user
		PrefProxy.proxy_user = "my user"
		compare(PrefProxy.proxy_user, "my user")
	}

	Item {
		id: spyCatcher

		property bool spy1 : false
		property bool spy2 : false
		property bool spy3 : false
		property bool spy4 : false
		property bool spy5 : false
		property bool spy6 : false

		Connections {
			target: PrefProxy
			onProxy_authChanged: {spyCatcher.spy1 = true }
			onProxy_hostChanged: {spyCatcher.spy2 = true }
			onProxy_passChanged: {spyCatcher.spy3 = true }
			onProxy_portChanged: {spyCatcher.spy4 = true }
			onProxy_typeChanged: {spyCatcher.spy5 = true }
			onProxy_userChanged: {spyCatcher.spy6 = true }
		}
	}

	function test_signals() {
		PrefProxy.proxy_auth = ! PrefProxy.proxy_auth
		PrefProxy.proxy_host = "qml"
		PrefProxy.proxy_pass = "qml"
		PrefProxy.proxy_port = -544
		PrefProxy.proxy_type = -3
		PrefProxy.proxy_user = "qml"

		compare(spyCatcher.spy1, true)
		compare(spyCatcher.spy2, true)
		compare(spyCatcher.spy3, true)
		compare(spyCatcher.spy4, true)
		compare(spyCatcher.spy5, true)
		compare(spyCatcher.spy6, true)
	}
}