You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2014/05/05 17:06:24 UTC
[03/37] git commit: CB-5085 device.cordova returning wrong value
CB-5085 device.cordova returning wrong value
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/commit/633c4478
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/tree/633c4478
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/diff/633c4478
Branch: refs/heads/cdvtest
Commit: 633c4478dea8c9777b392ca78acfc467681f923c
Parents: 5af976d
Author: Carlos Santana <cs...@gmail.com>
Authored: Wed Oct 16 15:52:30 2013 -0400
Committer: Carlos Santana <cs...@gmail.com>
Committed: Wed Oct 16 17:05:38 2013 -0400
----------------------------------------------------------------------
test/autotest/tests/device.tests.js | 14 ++++++++++++++
test/index.html | 4 +++-
test/main.js | 1 +
www/device.js | 7 +++++--
4 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/633c4478/test/autotest/tests/device.tests.js
----------------------------------------------------------------------
diff --git a/test/autotest/tests/device.tests.js b/test/autotest/tests/device.tests.js
index df9d2c6..0bcd0d9 100644
--- a/test/autotest/tests/device.tests.js
+++ b/test/autotest/tests/device.tests.js
@@ -47,4 +47,18 @@ describe('Device Information (window.device)', function () {
expect(window.device.cordova).toBeDefined();
expect((new String(window.device.cordova)).length > 0).toBe(true);
});
+
+ it("should depend on the precense of cordova.version string", function() {
+ expect(window.cordova.version).toBeDefined();
+ expect((new String(window.cordova.version)).length > 0).toBe(true);
+ });
+
+ it("should contain device.cordova equal to cordova.version", function() {
+ expect(window.device.cordova).toBe(window.cordova.version);
+ });
+
+ it("should contain a model specification that is a string", function() {
+ expect(window.device.model).toBeDefined();
+ expect((new String(window.device.model)).length > 0).toBe(true);
+ });
});
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/633c4478/test/index.html
----------------------------------------------------------------------
diff --git a/test/index.html b/test/index.html
index 727c504..82f6d3b 100644
--- a/test/index.html
+++ b/test/index.html
@@ -34,11 +34,12 @@
<body onload="init();" id="stage" class="theme">
<h1>Apache Cordova Tests</h1>
<div id="info">
+ <h4>cordova.version: <span id="cordova"> </span></h4>
<h4>Platform: <span id="platform"> </span></h4>
<h4>Version: <span id="version"> </span></h4>
<h4>UUID: <span id="uuid"> </span></h4>
<h4>Model: <span id="model"> </span></h4>
- <h4>Width: <span id="width"> </span>, Height: <span id="height">
+ <h4>Width: <span id="width"> </span>, Height: <span id="height">
</span>, Color Depth: <span id="colorDepth"></span></h4>
<h4>User-Agent: <span id="user-agent"> </span></h4>
</div>
@@ -47,6 +48,7 @@
<a href="audio/index.html" class="btn large">Audio Play/Record</a>
<a href="battery/index.html" class="btn large">Battery</a>
<a href="camera/index.html" class="btn large">Camera</a>
+ <a href="capture/index.html" class="btn large">Capture</a>
<a href="compass/index.html" class="btn large">Compass</a>
<a href="contacts/index.html" class="btn large">Contacts</a>
<a href="events/index.html" class="btn large">Events</a>
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/633c4478/test/main.js
----------------------------------------------------------------------
diff --git a/test/main.js b/test/main.js
index 5f071c4..9508770 100644
--- a/test/main.js
+++ b/test/main.js
@@ -20,6 +20,7 @@
*/
var deviceInfo = function() {
+ document.getElementById("cordova").innerHTML = cordova.version;
document.getElementById("platform").innerHTML = device.platform;
document.getElementById("version").innerHTML = device.version;
document.getElementById("uuid").innerHTML = device.uuid;
http://git-wip-us.apache.org/repos/asf/cordova-plugin-device/blob/633c4478/www/device.js
----------------------------------------------------------------------
diff --git a/www/device.js b/www/device.js
index 0271b70..05f4c47 100644
--- a/www/device.js
+++ b/www/device.js
@@ -22,7 +22,8 @@
var argscheck = require('cordova/argscheck'),
channel = require('cordova/channel'),
utils = require('cordova/utils'),
- exec = require('cordova/exec');
+ exec = require('cordova/exec'),
+ cordova = require('cordova');
channel.createSticky('onCordovaInfoReady');
// Tell cordova channel to wait on the CordovaInfoReady event
@@ -45,7 +46,9 @@ function Device() {
channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
- var buildLabel = info.cordova;
+ //ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
+ //TODO: CB-5105 native implementations should not return info.cordova
+ var buildLabel = cordova.version;
me.available = true;
me.platform = info.platform;
me.version = info.version;