summaryrefslogtreecommitdiff
path: root/tests/qml/tst_icon_utils.qml
blob: 4b0b67b854169081009a5e4210e2daaf9473fc8a (plain)
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
import QtQuick 6.0
import QtTest 1.0
import "../../package/contents/ui" as Ui

TestCase {
    name: "IconUtils"

    Ui.IconUtils { id: icons }

    // getBatteryIcon — boundary and edge cases
    function test_battery_undefined() {
        compare(icons.getBatteryIcon(undefined), "\uf244")
    }

    function test_battery_null() {
        compare(icons.getBatteryIcon(null), "\uf244")
    }

    function test_battery_negative() {
        compare(icons.getBatteryIcon(-1), "\uf244")
    }

    function test_battery_zero() {
        compare(icons.getBatteryIcon(0), "\uf244")
    }

    function test_battery_low_boundary() {
        compare(icons.getBatteryIcon(20), "\uf244")
    }

    function test_battery_quarter() {
        compare(icons.getBatteryIcon(21), "\uf243")
    }

    function test_battery_quarter_boundary() {
        compare(icons.getBatteryIcon(40), "\uf243")
    }

    function test_battery_half() {
        compare(icons.getBatteryIcon(41), "\uf242")
    }

    function test_battery_half_boundary() {
        compare(icons.getBatteryIcon(60), "\uf242")
    }

    function test_battery_three_quarter() {
        compare(icons.getBatteryIcon(61), "\uf241")
    }

    function test_battery_three_quarter_boundary() {
        compare(icons.getBatteryIcon(80), "\uf241")
    }

    function test_battery_full() {
        compare(icons.getBatteryIcon(81), "\uf240")
    }

    function test_battery_full_100() {
        compare(icons.getBatteryIcon(100), "\uf240")
    }

    // getDirectionIcon — all states
    function test_direction_charge() {
        compare(icons.getDirectionIcon("charge"), "\uf185")
    }

    function test_direction_discharge() {
        compare(icons.getDirectionIcon("discharge"), "\uf0e7")
    }

    function test_direction_idle() {
        compare(icons.getDirectionIcon("idle"), "\uf186")
    }

    function test_direction_unknown() {
        compare(icons.getDirectionIcon("bogus"), "")
    }

    function test_direction_empty() {
        compare(icons.getDirectionIcon(""), "")
    }

    function test_direction_null() {
        compare(icons.getDirectionIcon(null), "")
    }

    function test_direction_undefined() {
        compare(icons.getDirectionIcon(undefined), "")
    }
}