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