aboutsummaryrefslogtreecommitdiffstats
path: root/tests/tst_qPrefDiveComputer.qml
blob: 55554b2df892b3a091cad96df22f6eccacda21e9 (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
// SPDX-License-Identifier: GPL-2.0
import QtQuick 2.6
import QtTest 1.2

TestCase {
	name: "qPrefDiveComputer"

	function test_variables() {
		var x1 = PrefDiveComputer.device
		PrefDiveComputer.device = "my device"
		compare(PrefDiveComputer.device, "my device")

		var x2 = PrefDiveComputer.device_name
		PrefDiveComputer.device_name = "my device name"
		compare(PrefDiveComputer.device_name, "my device name")

		var x3 = PrefDiveComputer.download_mode
		PrefDiveComputer.download_mode = 19
		compare(PrefDiveComputer.download_mode, 19)

		var x4 = PrefDiveComputer.product
		PrefDiveComputer.product = "my product"
		compare(PrefDiveComputer.product, "my product")

		var x5 = PrefDiveComputer.vendor
		PrefDiveComputer.vendor = "my vendor"
		compare(PrefDiveComputer.vendor, "my vendor")
	}

	Item {
		id: spyCatcher

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

		Connections {
			target: PrefDiveComputer
			onDeviceChanged: {spyCatcher.spy1 = true }
			onDevice_nameChanged: {spyCatcher.spy2 = true }
			onDownload_modeChanged: {spyCatcher.spy3 = true }
			onProductChanged: {spyCatcher.spy4 = true }
			onVendorChanged: {spyCatcher.spy5 = true }
		}
	}

	function test_signals() {
		PrefDiveComputer.device = "qml"
		PrefDiveComputer.device_name = "qml"
		PrefDiveComputer.download_mode = -19
		PrefDiveComputer.product = "qml"
		PrefDiveComputer.vendor = "qml"

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