|
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 precense 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 }; |
|
67 |
|
68 exports.defineManualTests = function(contentEl, createActionButton) { |
|
69 var logMessage = function (message, color) { |
|
70 var log = document.getElementById('info'); |
|
71 var logLine = document.createElement('div'); |
|
72 if (color) { |
|
73 logLine.style.color = color; |
|
74 } |
|
75 logLine.innerHTML = message; |
|
76 log.appendChild(logLine); |
|
77 } |
|
78 |
|
79 var clearLog = function () { |
|
80 var log = document.getElementById('info'); |
|
81 log.innerHTML = ''; |
|
82 } |
|
83 |
|
84 var device_tests = '<h3>Press Dump Device button to get device information</h3>' + |
|
85 '<div id="dump_device"></div>' + |
|
86 'Expected result: Status box will get updated with device info. (i.e. platform, version, uuid, model, etc)'; |
|
87 |
|
88 contentEl.innerHTML = '<div id="info"></div>' + device_tests; |
|
89 |
|
90 createActionButton('Dump device', function() { |
|
91 clearLog(); |
|
92 logMessage(JSON.stringify(window.device, null, '\t')); |
|
93 }, "dump_device"); |
|
94 }; |