You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/06/20 01:28:33 UTC
[2/2] android commit: updating windows create.js and creating node
test
updating windows create.js and creating node test
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/commit/32febcb8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/tree/32febcb8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/diff/32febcb8
Branch: refs/heads/master
Commit: 32febcb892c440e44d44daa1b9c190900ad9bfb2
Parents: aa45670
Author: Anis Kadri <an...@gmail.com>
Authored: Tue Jun 19 16:28:00 2012 -0700
Committer: Anis Kadri <an...@gmail.com>
Committed: Tue Jun 19 16:28:00 2012 -0700
----------------------------------------------------------------------
bin/create.js | 1 +
bin/tests/test_create_win.js | 108 +++++++++++++++++++++++++++++++++++++
2 files changed, 109 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/32febcb8/bin/create.js
----------------------------------------------------------------------
diff --git a/bin/create.js b/bin/create.js
index 46fd006..9f70443 100644
--- a/bin/create.js
+++ b/bin/create.js
@@ -149,6 +149,7 @@ exec('cmd /c copy '+ROOT+'\\framework\\assets\\www\\cordova-'+VERSION+'.js '+PRO
exec('cmd /c copy '+ROOT+'\\framework\\cordova-'+VERSION+'.jar '+PROJECT_PATH+'\\libs\\cordova-'+VERSION+'.jar /Y');
// copy in xml
+fso.CreateFolder(PROJECT_PATH + '\\res\\xml');
exec('cmd /c copy '+ROOT+'\\framework\\res\\xml\\cordova.xml ' + PROJECT_PATH + '\\res\\xml\\cordova.xml /Y');
exec('cmd /c copy '+ROOT+'\\framework\\res\\xml\\plugins.xml ' + PROJECT_PATH + '\\res\\xml\\plugins.xml /Y');
http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/32febcb8/bin/tests/test_create_win.js
----------------------------------------------------------------------
diff --git a/bin/tests/test_create_win.js b/bin/tests/test_create_win.js
new file mode 100644
index 0000000..76dd6aa
--- /dev/null
+++ b/bin/tests/test_create_win.js
@@ -0,0 +1,108 @@
+var build_path = __dirname + '/../..'
+ project_path = process.env.Temp + '\\example',
+ package_name = 'org.apache.cordova.example',
+ package_as_path = 'org/apache/cordova/example',
+ project_name = 'cordovaExample';
+
+var path = require('path'),
+ fs = require('fs'),
+ util = require('util'),
+ assert = require('assert'),
+ exec = require('child_process').exec,
+ spawn = require('child_process').spawn;
+
+var version = fs.readFileSync(build_path + '/VERSION').toString().replace('\r\n', '');
+
+assert(version !== undefined);
+assert(version !== '');
+
+process.on('uncaughtException', function (err) {
+ console.log('Caught exception: ' + err);
+ exec('rd /s /q ' + project_path);
+});
+
+var create_project = spawn('cscript',
+ [build_path + '/bin/create.js',
+ project_path,
+ package_name,
+ project_name]
+ );
+
+create_project.stderr.on('data', function (data) {
+ console.log('ps stderr: ' + data);
+});
+
+create_project.stderr.on('data', function(data) {
+ console.log(data.toString());
+});
+
+create_project.stdout.on('data', function(data) {
+ console.log(data.toString());
+});
+
+create_project.on('exit', function(code) {
+ assert.equal(code, 0, 'Project did not get created');
+
+ // make sure the project was created
+ path.exists(project_path, function(exists) {
+ assert(exists, 'Project path does not exist');
+ });
+
+ // make sure the build directory was cleaned up
+ // path.exists(build_path + '/framework/libs', function(exists) {
+ // assert(!exists, 'libs directory did not get cleaned up');
+ // });
+ path.exists(build_path + util.format('/framework/assets/cordova-%s.js', version), function(exists) {
+ assert(!exists, 'javascript file did not get cleaned up');
+ });
+ path.exists(build_path + util.format('/framework/cordova-%s.jar', version), function(exists) {
+ assert(!exists, 'jar file did not get cleaned up');
+ });
+
+ // make sure AndroidManifest.xml was added
+ path.exists(util.format('%s/AndroidManifest.xml', project_path), function(exists) {
+ assert(exists, 'AndroidManifest.xml did not get created');
+ // TODO check that the activity name was properly substituted
+ });
+
+ // make sure main Activity was added
+ path.exists(util.format('%s/src/%s/%s.java', project_path, package_as_path, project_name), function(exists) {
+ assert(exists, 'Activity did not get created');
+ // TODO check that package name and activity name were substitued properly
+ });
+
+ // make sure plugins.xml was added
+ path.exists(util.format('%s/res/xml/plugins.xml', project_path), function(exists) {
+ assert(exists, 'plugins.xml did not get created');
+ });
+
+ // make sure cordova.xml was added
+ path.exists(util.format('%s/res/xml/cordova.xml', project_path), function(exists) {
+ assert(exists, 'plugins.xml did not get created');
+ });
+
+ // make sure cordova.jar was added
+ path.exists(util.format('%s/libs/cordova-%s.jar', project_path, version), function(exists) {
+ assert(exists, 'cordova.jar did not get added');
+ });
+
+ // make sure cordova.js was added
+ path.exists(util.format('%s/assets/www/cordova-%s.js', project_path, version), function(exists) {
+ assert(exists, 'cordova.js did not get added');
+ });
+
+ // check that project compiles && creates a cordovaExample-debug.apk
+ // XXX: !@##!@# WINDOWS
+ exec('ant debug -f ' + project_path + "\\build.xml", function(error, stdout, stderr) {
+ assert(error == null, "Cordova Android Project does not compile");
+ path.exists(util.format('%s/bin/%s-debug.apk', project_path, project_name),
+ function(exists) {
+ assert(exists, 'Package did not get created');
+ // if project compiles properly just AXE it
+ exec('rd /s /q ' + project_path);
+ });
+ });
+
+
+});
+