forked from GPII/linux
/
alsaSettingsHandlerTests.js
57 lines (43 loc) · 1.75 KB
/
alsaSettingsHandlerTests.js
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
/*
GPII Node.js ALSA Volume Bridge
Copyright 2013 Emergya
Licensed under the New BSD license. You may not use this file except in
compliance with this License.
You may obtain a copy of the License at
https://github.com/gpii/universal/LICENSE.txt
*/
var fluid = require("universal"),
gpii = fluid.registerNamespace("gpii"),
jqUnit = fluid.require("jqUnit");
require("alsa");
alsa = fluid.registerNamespace("gpii.alsa");
jqUnit.module("GPII Node.js ALSA Volume Bridge");
jqUnit.test("Running tests for ALSA Settings Handler", function () {
jqUnit.expect(6);
// Check if all required methods are available through the
// ALSA Settings Handler.
//
methods = ["getSystemVolume", "setSystemVolume", "get", "set"];
for (var method in methods) {
jqUnit.assertTrue("Checking availability of method '" + method + "'",
(methods[method] in alsa));
}
var payload = {
"org.alsa-project": [{
settings: {
"masterVolume": 1
}
}]
};
var returnPayload = alsa.set(payload);
jqUnit.assertDeepEq("The system volume is being setted well",
returnPayload["org.alsa-project"][0].settings["masterVolume"].newValue,
payload["org.alsa-project"][0].settings["masterVolume"]);
var newPayload = fluid.copy(payload);
newPayload["org.alsa-project"][0].settings["masterVolume"] =
returnPayload["org.alsa-project"][0].settings["masterVolume"].oldValue;
lastPayload = alsa.set(newPayload);
jqUnit.assertDeepEq("The system volume is being restored well",
returnPayload["org.alsa-project"][0].settings["masterVolume"].oldValue,
lastPayload["org.alsa-project"][0].settings["masterVolume"].newValue);
});