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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167 |
2x
2x
2x
2x
2x
2x
2x
12x
12x
| /*!
* GPII Settings Transformer Tests
*
* Copyright 2012 OCAD University
* Copyright 2013-2014 Raising the Floor
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* The research leading to these results has received funding from the European Union's
* Seventh Framework Programme (FP7/2007-2013)
* under grant agreement no. 289016.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
/*global jqUnit */
"use strict";
var fluid = fluid || require("infusion"),
gpii = fluid.registerNamespace("gpii");
(function () {
fluid.registerNamespace("gpii.tests.contextManager.utils");
/* --------------- gpii.contextManager.utils.findActiveContexts tests -------------- */
var findActiveContextsTests = {
matchData: {
"inferredConfiguration": {
"gpii-default": {
"applications": {
"mac.test": {
"active": true,
"settings": {
"http://registry.gpii.net/common/fontSize": 12
}
}
}
},
"all-bright": {
"applications": {
"mac.test": {
"active": true,
"settings": {
"http://registry.gpii.net/common/fontSize": 13
}
}
},
"conditions": [
{
"type": "http://registry.gpii.net/conditions/inRange",
"min": 700,
"max": 1000,
"inputPath": "http://registry\\.gpii\\.net/common/environment/illuminance"
}
]
},
"really-bright": {
"applications": {
"mac.test": {
"active": true,
"settings": {
"http://registry.gpii.net/common/fontSize": 14
}
}
},
"conditions": [
{
"type": "http://registry.gpii.net/conditions/inRange",
"min": 900,
"inputPath": "http://registry\\.gpii\\.net/common/environment/illuminance"
}
]
},
"multi-condition": {
"applications": {
"mac.test": {
"active": true,
"settings": {
"http://registry.gpii.net/common/fontSize": 100
}
}
},
"conditions": [
{
"type": "http://registry.gpii.net/conditions/inRange",
"min": 10,
"inputPath": "http://registry\\.gpii\\.net/common/environment/auditory\\.noise"
}, {
"type": "http://registry.gpii.net/conditions/inRange",
"max": 20,
"inputPath": "http://registry\\.gpii\\.net/common/environment/auditory\\.noise"
}
]
},
"multi-condition2": {
"applications": {
"mac.test": {
"active": true,
"settings": {
"http://registry.gpii.net/common/fontSize": 100
}
}
},
"conditions": [
{
"type": "http://registry.gpii.net/conditions/inRange",
"min": 10,
"inputPath": "http://registry\\.gpii\\.net/common/environment/illuminance"
}, {
"type": "http://registry.gpii.net/conditions/inRange",
"min": 10,
"inputPath": "http://registry\\.gpii\\.net/common/environment/auditory\\.noise"
}
]
}
}
},
tests: {
"No current contexts": {
currentContexts: {},
expected: [ "gpii-default" ]
},
"Matching single and default": {
currentContexts: {
"http://registry.gpii.net/common/environment/illuminance": 800
},
expected: [ "all-bright", "gpii-default" ]
},
"Matching two and default": {
currentContexts: {
"http://registry.gpii.net/common/environment/illuminance": 950
},
expected: [ "really-bright", "all-bright", "gpii-default" ]
},
"multi-condition matching only matching single": {
currentContexts: {
"http://registry.gpii.net/common/environment/auditory.noise": 5
},
expected: [ "gpii-default" ]
},
"multi-condition matching all criteria in multi-condition": {
currentContexts: {
"http://registry.gpii.net/common/environment/auditory.noise": 15
},
expected: [ "multi-condition", "gpii-default" ]
},
"multi context matching everything": {
currentContexts: {
"http://registry.gpii.net/common/environment/auditory.noise": 15,
"http://registry.gpii.net/common/environment/illuminance": 950
},
expected: [ "multi-condition2", "multi-condition", "really-bright", "all-bright", "gpii-default" ]
}
}
};
jqUnit.test("gpii.contextManager.utils.findActiveContexts test", function () {
fluid.each(findActiveContextsTests.tests, function (test, testName) {
var result = gpii.contextManager.utils.findActiveContexts(test.currentContexts, findActiveContextsTests.matchData);
jqUnit.assertDeepEq("Testing: " + testName, test.expected, result);
});
});
})();
|