| 15747 |
anikendra |
1 |
/*
|
|
|
2 |
*
|
|
|
3 |
* Licensed to the Apache Software Foundation (ASF) under one
|
|
|
4 |
* or more contributor license agreements. See the NOTICE file
|
|
|
5 |
* distributed with this work for additional information
|
|
|
6 |
* regarding copyright ownership. The ASF licenses this file
|
|
|
7 |
* to you under the Apache License, Version 2.0 (the
|
|
|
8 |
* "License"); you may not use this file except in compliance
|
|
|
9 |
* with the License. You may obtain a copy of the License at
|
|
|
10 |
*
|
|
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
12 |
*
|
|
|
13 |
* Unless required by applicable law or agreed to in writing,
|
|
|
14 |
* software distributed under the License is distributed on an
|
|
|
15 |
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
16 |
* KIND, either express or implied. See the License for the
|
|
|
17 |
* specific language governing permissions and limitations
|
|
|
18 |
* under the License.
|
|
|
19 |
*
|
|
|
20 |
*/
|
|
|
21 |
|
|
|
22 |
exports.defineAutoTests = function() {
|
|
|
23 |
describe('Device Information (window.device)', function () {
|
|
|
24 |
it("should exist", function() {
|
|
|
25 |
expect(window.device).toBeDefined();
|
|
|
26 |
});
|
|
|
27 |
|
|
|
28 |
it("should contain a platform specification that is a string", function() {
|
|
|
29 |
expect(window.device.platform).toBeDefined();
|
|
|
30 |
expect((new String(window.device.platform)).length > 0).toBe(true);
|
|
|
31 |
});
|
|
|
32 |
|
|
|
33 |
it("should contain a version specification that is a string", function() {
|
|
|
34 |
expect(window.device.version).toBeDefined();
|
|
|
35 |
expect((new String(window.device.version)).length > 0).toBe(true);
|
|
|
36 |
});
|
|
|
37 |
|
|
|
38 |
it("should contain a UUID specification that is a string or a number", function() {
|
|
|
39 |
expect(window.device.uuid).toBeDefined();
|
|
|
40 |
if (typeof window.device.uuid == 'string' || typeof window.device.uuid == 'object') {
|
|
|
41 |
expect((new String(window.device.uuid)).length > 0).toBe(true);
|
|
|
42 |
} else {
|
|
|
43 |
expect(window.device.uuid > 0).toBe(true);
|
|
|
44 |
}
|
|
|
45 |
});
|
|
|
46 |
|
|
|
47 |
it("should contain a cordova specification that is a string", function() {
|
|
|
48 |
expect(window.device.cordova).toBeDefined();
|
|
|
49 |
expect((new String(window.device.cordova)).length > 0).toBe(true);
|
|
|
50 |
});
|
|
|
51 |
|
|
|
52 |
it("should depend on the presence of cordova.version string", function() {
|
|
|
53 |
expect(window.cordova.version).toBeDefined();
|
|
|
54 |
expect((new String(window.cordova.version)).length > 0).toBe(true);
|
|
|
55 |
});
|
|
|
56 |
|
|
|
57 |
it("should contain device.cordova equal to cordova.version", function() {
|
|
|
58 |
expect(window.device.cordova).toBe(window.cordova.version);
|
|
|
59 |
});
|
|
|
60 |
|
|
|
61 |
it("should contain a model specification that is a string", function() {
|
|
|
62 |
expect(window.device.model).toBeDefined();
|
|
|
63 |
expect((new String(window.device.model)).length > 0).toBe(true);
|
|
|
64 |
});
|
|
|
65 |
|
|
|
66 |
it("should contain a manufacturer property that is a string", function() {
|
|
|
67 |
expect(window.device.manufacturer).toBeDefined();
|
|
|
68 |
expect((new String(window.device.manufacturer)).length > 0).toBe(true);
|
|
|
69 |
});
|
|
|
70 |
});
|
|
|
71 |
};
|
|
|
72 |
|
|
|
73 |
exports.defineManualTests = function(contentEl, createActionButton) {
|
|
|
74 |
var logMessage = function (message, color) {
|
|
|
75 |
var log = document.getElementById('info');
|
|
|
76 |
var logLine = document.createElement('div');
|
|
|
77 |
if (color) {
|
|
|
78 |
logLine.style.color = color;
|
|
|
79 |
}
|
|
|
80 |
logLine.innerHTML = message;
|
|
|
81 |
log.appendChild(logLine);
|
|
|
82 |
}
|
|
|
83 |
|
|
|
84 |
var clearLog = function () {
|
|
|
85 |
var log = document.getElementById('info');
|
|
|
86 |
log.innerHTML = '';
|
|
|
87 |
}
|
|
|
88 |
|
|
|
89 |
var device_tests = '<h3>Press Dump Device button to get device information</h3>' +
|
|
|
90 |
'<div id="dump_device"></div>' +
|
|
|
91 |
'Expected result: Status box will get updated with device info. (i.e. platform, version, uuid, model, etc)';
|
|
|
92 |
|
|
|
93 |
contentEl.innerHTML = '<div id="info"></div>' + device_tests;
|
|
|
94 |
|
|
|
95 |
createActionButton('Dump device', function() {
|
|
|
96 |
clearLog();
|
|
|
97 |
logMessage(JSON.stringify(window.device, null, '\t'));
|
|
|
98 |
}, "dump_device");
|
|
|
99 |
};
|