cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drk...@apache.org
Subject git commit: CB-5761 fix recording of test to couchdb
Date Fri, 10 Jan 2014 14:33:10 GMT
Updated Branches:
  refs/heads/master f2fac4ad5 -> b62413633


CB-5761 fix recording of test to couchdb


Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/b6241363
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/b6241363
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/b6241363

Branch: refs/heads/master
Commit: b62413633bfb02b56ce21480debd864c1120062f
Parents: f2fac4a
Author: David Kemp <drkemp@chromium.org>
Authored: Fri Jan 10 09:31:39 2014 -0500
Committer: David Kemp <drkemp@chromium.org>
Committed: Fri Jan 10 09:31:39 2014 -0500

----------------------------------------------------------------------
 build_android.js                  |  2 +-
 cordova-plugin-medic/www/medic.js | 12 ++++++++--
 src/build/makers/android.js       | 41 +++++++++++-----------------------
 3 files changed, 24 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/b6241363/build_android.js
----------------------------------------------------------------------
diff --git a/build_android.js b/build_android.js
index 3d26f4a..569910d 100644
--- a/build_android.js
+++ b/build_android.js
@@ -22,7 +22,7 @@ buildinfo('Android', BRANCH, function (error, sha ) {
     if(error) {
         TEST_OK=false;
     } else {
-        android(output_location, sha,'', config.app.entry, config.couchdb.host, function(err){
+        android(output_location, sha,'', config.app.entry, config.couchdb, function(err){
             if(err) {
                 console.log('Android test prepare failed')
                 TEST_OK=false;

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/b6241363/cordova-plugin-medic/www/medic.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-medic/www/medic.js b/cordova-plugin-medic/www/medic.js
index 79966d4..01b22e4 100644
--- a/cordova-plugin-medic/www/medic.js
+++ b/cordova-plugin-medic/www/medic.js
@@ -33,8 +33,16 @@ require('./jasmine-jsreporter');
 function Medic() {
     this.couchdb = 'http://172.23.188.139:5900';
     this.sha = 'sample';
-
-
+    var medic_this = this;
+    var xhr = new XMLHttpRequest();
+    xhr.open("GET", "medic.json", false);
+    xhr.onload = xhr.onerror = function() {
+       var cfg = JSON.parse(xhr.responseText);
+       medic_this.sha = cfg.sha;
+       medic_this.couchdb = cfg.couchdb;
+       console.log('Loaded Medic Config: sha='+medic_this.sha+',couchdb='+medic_this.couchdb);
+    }
+    xhr.send();
 }
 Medic.prototype.isEnabled = function() {
     return (!!window.jasmine || !!window.jasmine.JSReporter) ;

http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/b6241363/src/build/makers/android.js
----------------------------------------------------------------------
diff --git a/src/build/makers/android.js b/src/build/makers/android.js
index a17a499..6051c90 100644
--- a/src/build/makers/android.js
+++ b/src/build/makers/android.js
@@ -7,40 +7,25 @@ var shell        = require('shelljs'),
     fs           = require('fs'),
     mspec        = require('./mobile_spec');
 
-module.exports = function(output, sha, devices, entry_point, couchdb_host, callback) {
+module.exports = function(output, sha, devices, entry_point, couchdb_cfg, callback) {
     function log(msg) {
         console.log('[ANDROID] ' + msg + ' (sha: ' + sha + ')');
     }
       try {
-          // make sure android app got created first.
-          if (!fs.existsSync(output)) {
+         // make sure android app got created first.
+         if (!fs.existsSync(output)) {
               throw new Error('create must have failed as output path does not exist.');
-          }
-          var mspec_out = path.join(output, 'assets', 'www');
-          log('Modifying Cordova Mobilespec application at:'+mspec_out);
-          mspec(mspec_out,sha,devices,entry_point, function(err){
-              if(err) {
-                  error_writer('android', sha, 'Error  modifying mobile spec application.',
'');
-                  callback(true);
-              } else {
-                  log('Modifying Cordova android application.');
-                  // add the sha to the junit reporter
-                  var tempJasmine = path.join(output, 'assets', 'www', 'jasmine-jsreporter.js');
-                  if (fs.existsSync(tempJasmine)) {
-                      fs.writeFileSync(tempJasmine, "var library_sha = '" + sha + "';\n"
+ fs.readFileSync(tempJasmine, 'utf-8'), 'utf-8');
-                  }
+         }
+         var mspec_out = path.join(output, 'assets', 'www');
+         // add the medic configuration (sha,host) to destination folder
+         var medic_config='{"sha":"'+sha+'","couchdb":"'+couchdb_cfg.host+'","couchdbext":"'+couchdb_cfg.exthost+'"}';
+         fs.writeFileSync(path.join(output, 'assets', 'www','autotest','pages', 'medic.json'),medic_config,'utf-8');
+         log('Modifying Cordova android application.');
 
-                  // modify start page in the config.xml
-                  // modify start page in the config.xml
-                  var configFile = path.join(output, 'res', 'xml', 'config.xml');
-
-
-                  var configFile = path.join(output, 'res', 'xml', 'config.xml');
-                  fs.writeFileSync(configFile, fs.readFileSync(configFile, 'utf-8').replace(/<content\s*src=".*"/gi,
'<content src="' +entry_point + '"'), 'utf-8');
-                  // make sure the couch db server is whitelisted
-                  fs.writeFileSync(configFile, fs.readFileSync(configFile, 'utf-8').replace(/<access
origin="http:..audio.ibeat.org" *.>/gi,'<access origin="http://audio.ibeat.org" /><access
origin="'+couchdb_host+'" />', 'utf-8'));
-              }
-          });
+         var configFile = path.join(output, 'res', 'xml', 'config.xml');
+         fs.writeFileSync(configFile, fs.readFileSync(configFile, 'utf-8').replace(/<content\s*src=".*"/gi,
'<content src="' +entry_point + '"'), 'utf-8');
+         // make sure the couch db server is whitelisted
+         fs.writeFileSync(configFile, fs.readFileSync(configFile, 'utf-8').replace(/<access
origin="http:..audio.ibeat.org" *.>/gi,'<access origin="http://audio.ibeat.org" /><access
origin="'+couchdb_cfg.host+'" />', 'utf-8'));
      } catch (e) {
          error_writer('android', sha, 'Exception thrown modifying Android mobile spec application.',
e.message);
          callback(true);


Mime
View raw message