17 function runNextTest() {
18 test_list[current_test++]();
21 function reportFail(message) {
23 document.title = "Fail";
27 document.title = "Pass";
30 var api = xwalk.experimental.system;
32 function getAVCodecs() {
33 function checkAVCodecsInfo(info) {
34 if (!info.audioCodecs)
35 reportFail("Missing AudioCodec attribute in the SystemAVCodecs object.");
37 if (!info.videoCodecs)
38 reportFail("Missing VideoCodec name in the SystemAVCodecs object.");
40 for (var i = 0; i < info.audioCodecs.length; ++i) {
41 if (info.audioCodecs[i].format == null)
42 reportFail("Missing audio encoding format in the AudioCodec object.");
44 if (typeof info.audioCodecs[i].format != "string")
45 reportFail("Audio encoding format is not a string.");
48 for (var i = 0; i < info.videoCodecs.length; ++i) {
49 if (info.videoCodecs[i].format == null)
50 reportFail("Missing video encoding format in the VideoCodec object.");
52 if (typeof info.videoCodecs[i].format != "string")
53 reportFail("Video encoding format is not a string.");
55 if (info.videoCodecs[i].hwAccel == null)
56 reportFail("Missing hwAccel in the VideoCodec object.");
58 if (typeof info.videoCodecs[i].hwAccel != "boolean")
59 reportFail("hwAccel is not a boolean.");
61 if (info.videoCodecs[i].encode == null)
62 reportFail("Missing encode in the VideoCodec object.");
64 if (typeof info.videoCodecs[i].encode != "boolean")
65 reportFail("encode is not a boolean.");
68 if (document.title != "Fail")
72 api.getAVCodecs().then(checkAVCodecsInfo);
75 function getCPUInfo() {
79 function checkCPUInfo(info) {
80 if (info.numOfProcessors < 1)
81 reportFail("What!? A computer with less than 1 CPU?");
84 reportFail("Missing archtecture name in the SystemCPU object.");
86 if (typeof info.archName != "string")
87 reportFail("Archtecture name is not a string.");
89 if (info.load < 0 || info.load > 1)
90 reportFail("Load should be in the range of 0 and 1.");
92 if (++call_count == call_max)
96 for (var i = 0; i < call_max; ++i)
97 api.getCPUInfo().then(checkCPUInfo, reportFail);
100 function getDisplayInfo() {
101 function checkDisplayInfo(info) {
102 for (var i = 0; i < info.displays.length; ++i) {
103 if (typeof info.displays[i].id != "string")
104 reportFail("Display id is not a string.");
106 if (info.displays[i].id.length == 0)
107 reportFail("Display id can't be empty.");
109 if (typeof info.displays[i].name != "string")
110 reportFail("Display name is not a string.");
112 if (typeof info.displays[i].primary != "boolean")
113 reportFail("Display type is not a boolean.");
115 if (typeof info.displays[i].external != "boolean")
116 reportFail("Display type is not a boolean.");
118 if (typeof info.displays[i].deviceXDPI != "number")
119 reportFail("Display deviceXDPI must be a number.");
121 if (typeof info.displays[i].deviceYDPI != "number")
122 reportFail("Display deviceYDPI must be a number.");
124 if (typeof info.displays[i].width != "number")
125 reportFail("Display width must be a number.");
127 if (typeof info.displays[i].height != "number")
128 reportFail("Display height must be a number.");
130 if (typeof info.displays[i].availWidth != "number")
131 reportFail("Display availWidth must be a number.");
133 if (typeof info.displays[i].availHeight != "number")
134 reportFail("Display availHeight must be a number.");
136 if (typeof info.displays[i].colorDepth != "number")
137 reportFail("Display colorDepth must be a number.");
139 if (typeof info.displays[i].pixelDepth != "number")
140 reportFail("Display pixelDepth must be a number.");
143 if (document.title != "Fail")
147 api.getDisplayInfo().then(checkDisplayInfo);
150 function getMemoryInfo() {
151 function checkMemoryInfo(info) {
152 if (info.capacity <= 0)
153 reportFail("How can we run this in a computer with no memory?");
155 if (info.availCapacity <= 0)
156 reportFail("You should have some free memory to run this test.");
158 if (info.availCapacity > info.capacity)
159 reportFail("Availiable memory cannot be more than the total memory.");
161 if (document.title != "Fail")
165 api.getMemoryInfo().then(checkMemoryInfo, reportFail);
168 function getStorageInfo() {
169 function checkStorageInfo(info) {
171 reportFail("We must have at least 1 storage device.");
173 for (var i = 0; i < info.storages.length; ++i) {
174 if (typeof info.storages[i].id != "string")
175 reportFail("Storage id is not a string.");
177 if (info.storages[i].id.length == 0)
178 reportFail("Storage id can't be empty.");
180 if (typeof info.storages[i].name != "string")
181 reportFail("Storage name is not a string.");
183 if (typeof info.storages[i].type != "string")
184 reportFail("Storage type is not a string.");
186 if (info.storages[i].type.length == 0)
187 reportFail("Storage type can't be empty.");
189 if (typeof info.storages[i].capacity != "number")
190 reportFail("Storage capacity must be a number.");
192 if (info.storages[i].capacty <= 0)
193 reportFail("Storage has to be able to store something.");
196 if (document.title != "Fail")
200 api.getStorageInfo().then(checkStorageInfo);