You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ka...@apache.org on 2014/05/01 20:32:30 UTC
[45/53] [abbrv] Split out cordova-lib: move cordova-plugman files
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/amazon-fireos.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/amazon-fireos.spec.js b/cordova-lib/spec-plugman/platforms/amazon-fireos.spec.js
new file mode 100644
index 0000000..49a8b0d
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/amazon-fireos.spec.js
@@ -0,0 +1,139 @@
+var amazon_fireos = require('../../src/platforms/amazon-fireos'),
+ common = require('../../src/platforms/common'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ et = require('elementtree'),
+ os = require('osenv'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ plugins_module = require('../../src/util/plugins'),
+ dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
+ faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
+ variableplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
+ amazon_fireos_one_project = path.join(__dirname, '..', 'projects', 'android_one', '*'),
+ amazon_fireos_two_project = path.join(__dirname, '..', 'projects', 'android_two', '*');
+
+var xml_path = path.join(dummyplugin, 'plugin.xml')
+ , xml_text = fs.readFileSync(xml_path, 'utf-8')
+ , plugin_et = new et.ElementTree(et.XML(xml_text));
+
+var platformTag = plugin_et.find('./platform[@name="amazon-fireos"]');
+var dummy_id = plugin_et._root.attrib['id'];
+
+var valid_source = platformTag.findall('./source-file'),
+ valid_libs = platformTag.findall('./lib-file'),
+ assets = plugin_et.findall('./asset'),
+ configChanges = platformTag.findall('./config-file');
+
+xml_path = path.join(faultyplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8')
+plugin_et = new et.ElementTree(et.XML(xml_text));
+
+platformTag = plugin_et.find('./platform[@name="amazon-fireos"]');
+var invalid_source = platformTag.findall('./source-file');
+var faulty_id = plugin_et._root.attrib['id'];
+xml_path = path.join(variableplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8')
+plugin_et = new et.ElementTree(et.XML(xml_text));
+platformTag = plugin_et.find('./platform[@name="amazon-fireos"]');
+
+var variable_id = plugin_et._root.attrib['id'];
+var variable_configs = platformTag.findall('./config-file');
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+/*
+describe('amazon-fireos project handler', function() {
+ describe('www_dir method', function() {
+ it('should return cordova-amazon-fireos project www location using www_dir', function() {
+ expect(amazon_fireos.www_dir(path.sep)).toEqual(path.sep + path.join('assets', 'www'));
+ });
+ });
+ describe('package_name method', function() {
+ it('should return an amazon-fireos project\'s proper package name', function() {
+ expect(amazon_fireos.package_name(path.join(amazon_fireos_one_project, '..'))).toEqual('com.alunny.childapp');
+ });
+ });
+
+ describe('installation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <lib-file> elements', function() {
+ it("should copy jar files to project/libs", function () {
+ var s = spyOn(common, 'copyFile');
+
+ amazon_fireos['lib-file'].install(valid_libs[0], dummyplugin, temp);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/amazon-fireos/TestLib.jar', temp, path.join('libs', 'TestLib.jar'));
+ });
+ });
+ describe('of <source-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', amazon_fireos_one_project, temp);
+ });
+
+ it('should copy stuff from one location to another by calling common.copyFile', function() {
+ var source = copyArray(valid_source);
+ var s = spyOn(common, 'copyFile');
+ amazon_fireos['source-file'].install(source[0], dummyplugin, temp);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/amazon-fireos/DummyPlugin.java', temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
+ });
+ it('should throw if source file cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ amazon_fireos['source-file'].install(source[0], faultyplugin, temp);
+ }).toThrow('"' + path.resolve(faultyplugin, 'src/amazon-fireos/NotHere.java') + '" not found!');
+ });
+ it('should throw if target file already exists', function() {
+ // write out a file
+ var target = path.resolve(temp, 'src/com/phonegap/plugins/dummyplugin');
+ shell.mkdir('-p', target);
+ target = path.join(target, 'DummyPlugin.java');
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+
+ var source = copyArray(valid_source);
+ expect(function() {
+ amazon_fireos['source-file'].install(source[0], dummyplugin, temp);
+ }).toThrow('"' + target + '" already exists!');
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ shell.cp('-rf', amazon_fireos_two_project, temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <lib-file> elements', function(done) {
+ it('should remove jar files', function () {
+ var s = spyOn(common, 'removeFile');
+ amazon_fireos['lib-file'].install(valid_libs[0], dummyplugin, temp);
+ amazon_fireos['lib-file'].uninstall(valid_libs[0], temp, dummy_id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('libs', 'TestLib.jar'));
+ });
+ });
+ describe('of <source-file> elements', function() {
+ it('should remove stuff by calling common.deleteJava', function(done) {
+ var s = spyOn(common, 'deleteJava');
+ install('amazon-fireos', temp, dummyplugin, plugins_dir, {})
+ .then(function() {
+ var source = copyArray(valid_source);
+ amazon_fireos['source-file'].uninstall(source[0], temp);
+ expect(s).toHaveBeenCalledWith(temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
+ done();
+ });
+ });
+ });
+ });
+}); */
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/android.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/android.spec.js b/cordova-lib/spec-plugman/platforms/android.spec.js
new file mode 100644
index 0000000..57f45fe
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/android.spec.js
@@ -0,0 +1,156 @@
+var android = require('../../src/platforms/android'),
+ common = require('../../src/platforms/common'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ et = require('elementtree'),
+ os = require('osenv'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ plugins_module = require('../../src/util/plugins'),
+ dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
+ faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
+ variableplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
+ android_one_project = path.join(__dirname, '..', 'projects', 'android_one', '*'),
+ android_two_project = path.join(__dirname, '..', 'projects', 'android_two', '*');
+
+var xml_path = path.join(dummyplugin, 'plugin.xml')
+ , xml_text = fs.readFileSync(xml_path, 'utf-8')
+ , plugin_et = new et.ElementTree(et.XML(xml_text));
+
+var platformTag = plugin_et.find('./platform[@name="android"]');
+var dummy_id = plugin_et._root.attrib['id'];
+var valid_source = platformTag.findall('./source-file'),
+ valid_libs = platformTag.findall('./lib-file'),
+ valid_resources = platformTag.findall('./resource-file'),
+ assets = plugin_et.findall('./asset'),
+ configChanges = platformTag.findall('./config-file');
+
+xml_path = path.join(faultyplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8')
+plugin_et = new et.ElementTree(et.XML(xml_text));
+
+platformTag = plugin_et.find('./platform[@name="android"]');
+var invalid_source = platformTag.findall('./source-file');
+var faulty_id = plugin_et._root.attrib['id'];
+
+xml_path = path.join(variableplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8')
+plugin_et = new et.ElementTree(et.XML(xml_text));
+platformTag = plugin_et.find('./platform[@name="android"]');
+
+var variable_id = plugin_et._root.attrib['id'];
+var variable_configs = platformTag.findall('./config-file');
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+describe('android project handler', function() {
+ describe('www_dir method', function() {
+ it('should return cordova-android project www location using www_dir', function() {
+ expect(android.www_dir(path.sep)).toEqual(path.sep + path.join('assets', 'www'));
+ });
+ });
+ describe('package_name method', function() {
+ it('should return an android project\'s proper package name', function() {
+ expect(android.package_name(path.join(android_one_project, '..'))).toEqual('com.alunny.childapp');
+ });
+ });
+
+ describe('installation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <lib-file> elements', function() {
+ it("should copy jar files to project/libs", function () {
+ var s = spyOn(common, 'copyFile');
+
+ android['lib-file'].install(valid_libs[0], dummyplugin, temp);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/android/TestLib.jar', temp, path.join('libs', 'TestLib.jar'));
+ });
+ });
+ describe('of <resource-file> elements', function() {
+ it("should copy files", function () {
+ var s = spyOn(common, 'copyFile');
+
+ android['resource-file'].install(valid_resources[0], dummyplugin, temp);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'android-resource.xml', temp, path.join('res', 'xml', 'dummy.xml'));
+ });
+ });
+ describe('of <source-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', android_one_project, temp);
+ });
+
+ it('should copy stuff from one location to another by calling common.copyFile', function() {
+ var source = copyArray(valid_source);
+ var s = spyOn(common, 'copyFile');
+ android['source-file'].install(source[0], dummyplugin, temp);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/android/DummyPlugin.java', temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
+ });
+ it('should throw if source file cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ android['source-file'].install(source[0], faultyplugin, temp);
+ }).toThrow('"' + path.resolve(faultyplugin, 'src/android/NotHere.java') + '" not found!');
+ });
+ it('should throw if target file already exists', function() {
+ // write out a file
+ var target = path.resolve(temp, 'src/com/phonegap/plugins/dummyplugin');
+ shell.mkdir('-p', target);
+ target = path.join(target, 'DummyPlugin.java');
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+
+ var source = copyArray(valid_source);
+ expect(function() {
+ android['source-file'].install(source[0], dummyplugin, temp);
+ }).toThrow('"' + target + '" already exists!');
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ shell.cp('-rf', android_two_project, temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <lib-file> elements', function(done) {
+ it('should remove jar files', function () {
+ var s = spyOn(common, 'removeFile');
+ android['lib-file'].install(valid_libs[0], dummyplugin, temp);
+ android['lib-file'].uninstall(valid_libs[0], temp, dummy_id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('libs', 'TestLib.jar'));
+ });
+ });
+ describe('of <resource-file> elements', function(done) {
+ it('should remove files', function () {
+ var s = spyOn(common, 'removeFile');
+ android['resource-file'].install(valid_resources[0], dummyplugin, temp);
+ android['resource-file'].uninstall(valid_resources[0], temp, dummy_id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('res', 'xml', 'dummy.xml'));
+ });
+ });
+ describe('of <source-file> elements', function() {
+ it('should remove stuff by calling common.deleteJava', function(done) {
+ var s = spyOn(common, 'deleteJava');
+ install('android', temp, dummyplugin, plugins_dir, {})
+ .then(function() {
+ var source = copyArray(valid_source);
+ android['source-file'].uninstall(source[0], temp);
+ expect(s).toHaveBeenCalledWith(temp, path.join('src', 'com', 'phonegap', 'plugins', 'dummyplugin', 'DummyPlugin.java'));
+ done();
+ });
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/blackberry10.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/blackberry10.spec.js b/cordova-lib/spec-plugman/platforms/blackberry10.spec.js
new file mode 100644
index 0000000..bfdf926
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/blackberry10.spec.js
@@ -0,0 +1,148 @@
+var blackberry10 = require('../../src/platforms/blackberry10'),
+ common = require('../../src/platforms/common'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ et = require('elementtree'),
+ os = require('osenv'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ plugins_module = require('../../src/util/plugins'),
+ blackberry10_project = path.join(__dirname, '..', 'projects', 'blackberry10', '*'),
+ plugins = {
+ dummy: parsePlugin(path.join(__dirname, '..', 'plugins', 'DummyPlugin')),
+ faulty: parsePlugin(path.join(__dirname, '..', 'plugins', 'FaultyPlugin')),
+ echo: parsePlugin(path.join(__dirname, '..', 'plugins', 'cordova.echo'))
+ };
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+function parsePlugin (pluginPath) {
+ var pluginXML = fs.readFileSync(path.join(pluginPath, "plugin.xml"), "utf-8"),
+ pluginEt = new et.ElementTree(et.XML(pluginXML)),
+ platformTag = pluginEt.find('./platform[@name="blackberry10"]');
+
+ return {
+ path: pluginPath,
+ id: pluginEt._root.attrib.id,
+ assets: pluginEt.findall('./asset'),
+ srcFiles: platformTag.findall('./source-file'),
+ configChanges: platformTag.findall('./config-file'),
+ libFiles: platformTag.findall('./lib-file')
+ };
+}
+
+
+describe('blackberry10 project handler', function() {
+ describe('www_dir method', function() {
+ it('should return cordova-blackberry10 project www location using www_dir', function() {
+ expect(blackberry10.www_dir(path.sep)).toEqual(path.sep + 'www');
+ });
+ });
+
+ describe('package_name method', function() {
+ it('should return a blackberry10 project\'s proper package name', function() {
+ expect(blackberry10.package_name(path.join(blackberry10_project, '..'))).toEqual('cordovaExample');
+ });
+ });
+
+ describe('installation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.cp('-rf', blackberry10_project, temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <lib-file> elements', function() {
+ it("should copy so files to native/target/plugins", function () {
+ var plugin = plugins.echo,
+ libs = copyArray(plugin.libFiles),
+ s = spyOn(common, 'copyFile');
+
+ blackberry10['lib-file'].install(libs[0], plugin.path, temp);
+ expect(s).toHaveBeenCalledWith(plugin.path, 'src/blackberry10/native/device/echoJnext.so', temp, path.join('native', 'device', 'plugins', 'jnext', 'echoJnext.so'));
+ });
+ });
+ describe('of <source-file> elements', function() {
+ it('should copy stuff from one location to another by calling common.copyFile', function() {
+ var plugin = plugins.echo,
+ source = copyArray(plugin.srcFiles);
+ s = spyOn(common, 'copyFile');
+
+ blackberry10['source-file'].install(source[0], plugin.path, temp, plugin.id);
+ expect(s).toHaveBeenCalledWith(plugin.path, 'src/blackberry10/index.js', temp, path.join('native', 'device', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
+ expect(s).toHaveBeenCalledWith(plugin.path, 'src/blackberry10/index.js', temp, path.join('native', 'simulator', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
+ });
+ it('defaults to plugin id when dest is not present', function() {
+ var source = copyArray(plugins.dummy.srcFiles);
+ var s = spyOn(common, 'copyFile');
+ blackberry10['source-file'].install(source[0], plugins.dummy.path, temp, plugins.dummy.id);
+ expect(s).toHaveBeenCalledWith(plugins.dummy.path, 'src/blackberry10/index.js', temp, path.join('native', 'device', 'chrome', 'plugin', plugins.dummy.id, 'index.js'));
+ expect(s).toHaveBeenCalledWith(plugins.dummy.path, 'src/blackberry10/index.js', temp, path.join('native', 'simulator', 'chrome', 'plugin', plugins.dummy.id, 'index.js'));
+ });
+ it('should throw if source file cannot be found', function() {
+ var source = copyArray(plugins.faulty.srcFiles);
+ expect(function() {
+ blackberry10['source-file'].install(source[0], plugins.faulty.path, temp, plugins.faulty.id);
+ }).toThrow('"' + path.resolve(plugins.faulty.path, 'src/blackberry10/index.js') + '" not found!');
+ });
+ it('should throw if target file already exists', function() {
+ // write out a file
+ var target = path.resolve(temp, 'native/device/chrome/plugin/com.phonegap.plugins.dummyplugin');
+ shell.mkdir('-p', target);
+ target = path.join(target, 'index.js');
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+
+ var source = copyArray(plugins.dummy.srcFiles);
+ expect(function() {
+ blackberry10['source-file'].install(source[0], plugins.dummy.path, temp, plugins.dummy.id);
+ }).toThrow('"' + target + '" already exists!');
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.cp('-rf', blackberry10_project, temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ it('should remove stuff by calling common.removeFile', function() {
+ var s = spyOn(common, 'removeFile'),
+ plugin = plugins.echo;
+ var source = copyArray(plugin.srcFiles);
+ blackberry10['source-file'].install(source[0], plugin.path, temp, plugin.id);
+ blackberry10['source-file'].uninstall(source[0], temp, plugin.id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('native', 'device', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
+ expect(s).toHaveBeenCalledWith(temp, path.join('native', 'simulator', 'chrome', 'plugin', 'cordova.echo', 'index.js'));
+ });
+ it('should remove stuff by calling common.removeFile', function() {
+ var s = spyOn(common, 'removeFile'),
+ plugin = plugins.dummy;
+ var source = copyArray(plugin.srcFiles);
+ blackberry10['source-file'].install(source[0], plugin.path, temp, plugin.id);
+ blackberry10['source-file'].uninstall(source[0], temp, plugin.id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('native', 'device', 'chrome', 'plugin', plugin.id, 'index.js'));
+ expect(s).toHaveBeenCalledWith(temp, path.join('native', 'simulator', 'chrome', 'plugin', plugin.id, 'index.js'));
+ });
+ });
+ describe('of <lib-file> elements', function(done) {
+ it("should remove so files from www/plugins", function () {
+ var s = spyOn(common, 'removeFile'),
+ plugin = plugins.echo;
+ var source = copyArray(plugin.libFiles);
+ blackberry10['lib-file'].install(source[0], plugin.path, temp, plugin.id);
+ blackberry10['lib-file'].uninstall(source[0], temp, plugin.id);
+ expect(s).toHaveBeenCalledWith(temp, path.join('native','device','plugins','jnext','echoJnext.so'));
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/common.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/common.spec.js b/cordova-lib/spec-plugman/platforms/common.spec.js
new file mode 100644
index 0000000..dcf5f2a
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/common.spec.js
@@ -0,0 +1,130 @@
+/*
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+var common = require('../../src/platforms/common')
+ , path = require('path')
+ , fs = require('fs')
+ , osenv = require('osenv')
+ , shell = require('shelljs')
+ , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+ , project_dir = path.join(test_dir, 'project')
+ , src = path.join(project_dir, 'src')
+ , dest = path.join(project_dir, 'dest')
+ , java_dir = path.join(src, 'one', 'two', 'three')
+ , java_file = path.join(java_dir, 'test.java');
+
+describe('common platform handler', function() {
+ describe('resolveSrcPath', function() {
+ it('should not throw if path exists', function(){
+ shell.mkdir('-p', test_dir);
+ var target = path.join(test_dir, 'somefile');
+ fs.writeFileSync(target, '80085', 'utf-8');
+ expect(function(){common.resolveSrcPath(test_dir, 'somefile')}).not.toThrow();
+ shell.rm('-rf', test_dir);
+ });
+ });
+
+ describe('resolveTargetPath', function() {
+ it('should throw if path exists', function(){
+ shell.mkdir('-p', test_dir);
+ expect(function(){common.resolveTargetPath(test_dir)}).toThrow();
+ shell.rm('-rf', test_dir);
+ });
+
+ it('should not throw if path cannot be resolved', function(){
+ expect(function(){common.resolveTargetPath(test_dir, 'somefile')}).not.toThrow();
+ });
+ });
+
+ describe('copyFile', function() {
+ it('should throw if source path cannot be resolved', function(){
+ expect(function(){common.copyFile(test_dir, src, project_dir, dest)}).toThrow();
+ });
+
+ it('should throw if target path exists', function(){
+ shell.mkdir('-p', dest);
+ expect(function(){common.copyFile(test_dir, src, project_dir, dest)}).toThrow();
+ shell.rm('-rf', dest);
+ });
+
+ it('should call mkdir -p on target path', function(){
+ shell.mkdir('-p', java_dir);
+ fs.writeFileSync(java_file, 'contents', 'utf-8');
+
+ var s = spyOn(shell, 'mkdir').andCallThrough();
+ var resolvedDest = common.resolveTargetPath(project_dir, dest);
+
+ common.copyFile(test_dir, java_file, project_dir, dest);
+
+ expect(s).toHaveBeenCalled();
+ expect(s).toHaveBeenCalledWith('-p', path.dirname(resolvedDest));
+ shell.rm('-rf', project_dir);
+ });
+
+ it('should call cp source/dest paths', function(){
+ shell.mkdir('-p', java_dir);
+ fs.writeFileSync(java_file, 'contents', 'utf-8');
+
+ var s = spyOn(shell, 'cp').andCallThrough();
+ var resolvedDest = common.resolveTargetPath(project_dir, dest);
+
+ common.copyFile(test_dir, java_file, project_dir, dest);
+
+ expect(s).toHaveBeenCalled();
+ expect(s).toHaveBeenCalledWith('-f', java_file, resolvedDest);
+
+ shell.rm('-rf', project_dir);
+ });
+
+ });
+
+ describe('deleteJava', function() {
+ it('should call fs.unlinkSync on the provided paths', function(){
+ shell.mkdir('-p', java_dir);
+ fs.writeFileSync(java_file, 'contents', 'utf-8');
+
+ var s = spyOn(fs, 'unlinkSync').andCallThrough();
+ common.deleteJava(project_dir, java_file);
+ expect(s).toHaveBeenCalled();
+ expect(s).toHaveBeenCalledWith(path.resolve(project_dir, java_file));
+
+ shell.rm('-rf', java_dir);
+ });
+
+ it('should delete empty directories after removing source code in a java src path hierarchy', function(){
+ shell.mkdir('-p', java_dir);
+ fs.writeFileSync(java_file, 'contents', 'utf-8');
+
+ common.deleteJava(project_dir, java_file);
+ expect(fs.existsSync(java_file)).not.toBe(true);
+ expect(fs.existsSync(java_dir)).not.toBe(true);
+ expect(fs.existsSync(path.join(src,'one'))).not.toBe(true);
+
+ shell.rm('-rf', java_dir);
+ });
+
+ it('should never delete the top-level src directory, even if all plugins added were removed', function(){
+ shell.mkdir('-p', java_dir);
+ fs.writeFileSync(java_file, 'contents', 'utf-8');
+
+ common.deleteJava(project_dir, java_file);
+ expect(fs.existsSync(src)).toBe(true);
+
+ shell.rm('-rf', java_dir);
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/ios.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/ios.spec.js b/cordova-lib/spec-plugman/platforms/ios.spec.js
new file mode 100644
index 0000000..e2589e0
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/ios.spec.js
@@ -0,0 +1,390 @@
+var ios = require('../../src/platforms/ios'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ et = require('elementtree'),
+ shell = require('shelljs'),
+ os = require('osenv'),
+ common = require('../../src/platforms/common'),
+ xcode = require('xcode'),
+ plist = require('plist-with-patches'),
+ bplist = require('bplist-parser'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ ios_config_xml_project = path.join(__dirname, '..', 'projects', 'ios-config-xml', '*'),
+ ios_plist_project = path.join(__dirname, '..', 'projects', 'ios-plist', '*'),
+ ios_project = path.join(ios_config_xml_project, '..'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ variableplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
+ faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
+ plistplugin = path.join(__dirname, '..', 'plugins', 'PluginsPlistOnly'),
+ dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin');
+
+var xml_path = path.join(dummyplugin, 'plugin.xml'),
+ xml_test = fs.readFileSync(xml_path, 'utf-8'),
+ plugin_et = new et.ElementTree(et.XML(xml_test));
+
+var platformTag = plugin_et.find('./platform[@name="ios"]');
+var dummy_id = plugin_et._root.attrib['id'];
+var valid_source = platformTag.findall('./source-file'),
+ valid_assets = plugin_et.findall('./asset'),
+ valid_headers = platformTag.findall('./header-file'),
+ valid_resources = platformTag.findall('./resource-file'),
+ valid_custom_frameworks = platformTag.findall('./framework[@custom="true"]'),
+ valid_frameworks = platformTag.findall('./framework'),
+ plist_els = platformTag.findall('./plugins-plist'),
+ dummy_configs = platformTag.findall('./config-file');
+
+xml_path = path.join(variableplugin, 'plugin.xml');
+xml_test = fs.readFileSync(xml_path, 'utf-8');
+plugin_et = new et.ElementTree(et.XML(xml_test));
+platformTag = plugin_et.find('./platform[@name="ios"]');
+
+var variable_id = plugin_et._root.attrib['id'];
+var variable_configs = platformTag.findall('./config-file');
+
+xml_path = path.join(faultyplugin, 'plugin.xml');
+xml_test = fs.readFileSync(xml_path, 'utf-8');
+plugin_et = new et.ElementTree(et.XML(xml_test));
+platformTag = plugin_et.find('./platform[@name="ios"]');
+
+var faulty_id = plugin_et._root.attrib['id'];
+var invalid_assets = plugin_et.findall('./asset');
+var invalid_source = platformTag.findall('./source-file');
+var invalid_headers = platformTag.findall('./header-file');
+var invalid_resources = platformTag.findall('./resource-file');
+var invalid_custom_frameworks = platformTag.findall('./framework[@custom="true"]');
+var invalid_frameworks = platformTag.findall('./framework');
+
+xml_path = path.join(plistplugin, 'plugin.xml');
+xml_test = fs.readFileSync(xml_path, 'utf-8');
+plugin_et = new et.ElementTree(et.XML(xml_test));
+platformTag = plugin_et.find('./platform[@name="ios"]');
+
+var plist_id = plugin_et._root.attrib['id'];
+var plist_only_els = platformTag.findall('./plugins-plist');
+
+shell.mkdir('-p', temp);
+shell.cp('-rf', ios_config_xml_project, temp);
+var proj_files = ios.parseProjectFile(temp);
+shell.rm('-rf', temp);
+ios.purgeProjectFileCache(temp);
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+describe('ios project handler', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ ios.purgeProjectFileCache(temp);
+ });
+
+ describe('www_dir method', function() {
+ it('should return cordova-ios project www location using www_dir', function() {
+ expect(ios.www_dir(path.sep)).toEqual(path.sep + 'www');
+ });
+ });
+
+ describe('package_name method', function() {
+ it('should return the CFBundleIdentifier from the project\'s Info.plist file', function() {
+ expect(ios.package_name(ios_project)).toEqual('com.example.friendstring');
+ });
+ });
+
+ describe('parseProjectFile method', function () {
+ it('should throw if project is not an xcode project', function() {
+ expect(function() {
+ ios.parseProjectFile(temp);
+ }).toThrow('does not appear to be an xcode project (no xcode project file)');
+ });
+ it('should throw if project does not contain an appropriate PhoneGap/Cordova.plist file or config.xml file', function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ shell.rm(path.join(temp, 'SampleApp', 'config.xml'));
+
+ expect(function() {
+ ios.parseProjectFile(temp);
+ }).toThrow('could not find PhoneGap/Cordova plist file, or config.xml file.');
+ });
+ });
+
+ describe('installation', function() {
+ describe('of <source-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+
+ it('should throw if source-file src cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ ios['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files);
+ }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/FaultyPluginCommand.m') + '" ios <source-file>');
+ });
+ it('should throw if source-file target already exists', function() {
+ var source = copyArray(valid_source);
+ var target = path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'DummyPluginCommand.m');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ ios['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ }).toThrow('target destination "' + target + '" already exists');
+ });
+ it('should call into xcodeproj\'s addSourceFile appropriately when element has no target-dir', function() {
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ var spy = spyOn(proj_files.xcode, 'addSourceFile');
+ ios['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'DummyPluginCommand.m'), {});
+ });
+ it('should call into xcodeproj\'s addSourceFile appropriately when element has a target-dir', function() {
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ var spy = spyOn(proj_files.xcode, 'addSourceFile');
+ ios['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'targetDir', 'TargetDirTest.m'), {});
+ });
+ it('should cp the file to the right target location when element has no target-dir', function() {
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ var spy = spyOn(shell, 'cp');
+ ios['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join(dummyplugin, 'src', 'ios', 'DummyPluginCommand.m'), path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'DummyPluginCommand.m'));
+ });
+ it('should cp the file to the right target location when element has a target-dir', function() {
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ var spy = spyOn(shell, 'cp');
+ ios['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join(dummyplugin, 'src', 'ios', 'TargetDirTest.m'), path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'targetDir', 'TargetDirTest.m'));
+ });
+ it('should call into xcodeproj\'s addFramework appropriately when element has framework=true set', function() {
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['framework'] == "true"});
+ spyOn(proj_files.xcode, 'addSourceFile');
+ var spy = spyOn(proj_files.xcode, 'addFramework');
+ ios['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('SampleApp', 'Plugins', dummy_id, 'SourceWithFramework.m'), {weak:false});
+ });
+ });
+
+ describe('of <header-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+
+ it('should throw if header-file src cannot be found', function() {
+ var headers = copyArray(invalid_headers);
+ expect(function() {
+ ios['header-file'].install(headers[1], faultyplugin, temp, faulty_id, proj_files);
+ }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/FaultyPluginCommand.h') + '" ios <header-file>');
+ });
+ it('should throw if header-file target already exists', function() {
+ var headers = copyArray(valid_headers);
+ var target = path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'DummyPluginCommand.h');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ ios['header-file'].install(headers[0], dummyplugin, temp, dummy_id, proj_files);
+ }).toThrow('target destination "' + target + '" already exists');
+ });
+ it('should call into xcodeproj\'s addHeaderFile appropriately when element has no target-dir', function() {
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ var spy = spyOn(proj_files.xcode, 'addHeaderFile');
+ ios['header-file'].install(headers[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'DummyPluginCommand.h'));
+ });
+ it('should call into xcodeproj\'s addHeaderFile appropriately when element a target-dir', function() {
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ var spy = spyOn(proj_files.xcode, 'addHeaderFile');
+ ios['header-file'].install(headers[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'targetDir', 'TargetDirTest.h'));
+ });
+ it('should cp the file to the right target location when element has no target-dir', function() {
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ var spy = spyOn(shell, 'cp');
+ ios['header-file'].install(headers[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join(dummyplugin, 'src', 'ios', 'DummyPluginCommand.h'), path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'DummyPluginCommand.h'));
+ });
+ it('should cp the file to the right target location when element has a target-dir', function() {
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ var spy = spyOn(shell, 'cp');
+ ios['header-file'].install(headers[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join(dummyplugin, 'src', 'ios', 'TargetDirTest.h'), path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'targetDir', 'TargetDirTest.h'));
+ });
+ });
+
+ describe('of <resource-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+ it('should throw if resource-file src cannot be found', function() {
+ var resources = copyArray(invalid_resources);
+ expect(function() {
+ ios['resource-file'].install(resources[0], faultyplugin, temp, "pluginid", proj_files);
+ }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/IDontExist.bundle') + '" ios <resource-file>');
+ });
+ it('should throw if resource-file target already exists', function() {
+ var resources = copyArray(valid_resources);
+ var target = path.join(temp, 'SampleApp', 'Resources', 'DummyPlugin.bundle');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ ios['resource-file'].install(resources[0], dummyplugin, temp, "pluginid",proj_files);
+ }).toThrow('target destination "' + target + '" already exists');
+ });
+ it('should call into xcodeproj\'s addResourceFile', function() {
+ var resources = copyArray(valid_resources);
+ var spy = spyOn(proj_files.xcode, 'addResourceFile');
+ ios['resource-file'].install(resources[0], dummyplugin, temp, "pluginid", proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Resources', 'DummyPlugin.bundle'));
+ });
+ it('should cp the file to the right target location', function() {
+ var resources = copyArray(valid_resources);
+ var spy = spyOn(shell, 'cp');
+ ios['resource-file'].install(resources[0], dummyplugin, temp, "pluginid", proj_files);
+ expect(spy).toHaveBeenCalledWith('-R', path.join(dummyplugin, 'src', 'ios', 'DummyPlugin.bundle'), path.join(temp, 'SampleApp', 'Resources'));
+ });
+ });
+ describe('of <framework custom="true"> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+ it('should throw if framework src cannot be found', function() {
+ var frameworks = copyArray(invalid_custom_frameworks);
+ expect(function() {
+ ios['framework'].install(frameworks[0], faultyplugin, temp, dummy_id, proj_files);
+ }).toThrow('cannot find "' + path.resolve(faultyplugin, 'src/ios/NonExistantCustomFramework.framework') + '" ios <framework>');
+ });
+ it('should throw if framework target already exists', function() {
+ var frameworks = copyArray(valid_custom_frameworks);
+ var target = path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework');
+ shell.mkdir('-p', target);
+ expect(function() {
+ ios['framework'].install(frameworks[0], dummyplugin, temp, dummy_id, proj_files);
+ }).toThrow('target destination "' + target + '" already exists');
+ });
+ it('should call into xcodeproj\'s addFramework', function() {
+ var frameworks = copyArray(valid_custom_frameworks);
+ var spy = spyOn(proj_files.xcode, 'addFramework');
+ ios['framework'].install(frameworks[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.normalize('SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework'), {customFramework:true});
+ });
+ it('should cp the file to the right target location', function() {
+ var frameworks = copyArray(valid_custom_frameworks);
+ var spy = spyOn(shell, 'cp');
+ ios['framework'].install(frameworks[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith('-R', path.join(dummyplugin, 'src', 'ios', 'Custom.framework'),
+ path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin'));
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ describe('of <source-file> elements', function() {
+ it('should call into xcodeproj\'s removeSourceFile appropriately when element has no target-dir', function(){
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ shell.cp('-rf', ios_config_xml_project, temp);
+ var spy = spyOn(proj_files.xcode, 'removeSourceFile');
+ ios['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'DummyPluginCommand.m'));
+ });
+ it('should call into xcodeproj\'s removeSourceFile appropriately when element a target-dir', function(){
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ shell.cp('-rf', ios_config_xml_project, temp);
+ var spy = spyOn(proj_files.xcode, 'removeSourceFile');
+ ios['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'targetDir', 'TargetDirTest.m'));
+ });
+ it('should rm the file from the right target location when element has no target-dir', function(){
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ shell.cp('-rf', ios_config_xml_project, temp);
+
+ var spy = spyOn(shell, 'rm');
+ ios['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'DummyPluginCommand.m'));
+ });
+ it('should rm the file from the right target location when element has a target-dir', function(){
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ shell.cp('-rf', ios_config_xml_project, temp);
+ var spy = spyOn(shell, 'rm');
+
+ ios['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'targetDir', 'TargetDirTest.m'));
+ });
+ it('should call into xcodeproj\'s removeFramework appropriately when element framework=true set', function(){
+ var source = copyArray(valid_source).filter(function(s) { return s.attrib['framework'] == "true"});
+ shell.cp('-rf', ios_config_xml_project, temp);
+ var spy = spyOn(proj_files.xcode, 'removeFramework');
+
+ ios['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('SampleApp', 'Plugins', dummy_id, 'SourceWithFramework.m'));
+ });
+ });
+
+ describe('of <header-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+ it('should call into xcodeproj\'s removeHeaderFile appropriately when element has no target-dir', function(){
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] == undefined});
+ var spy = spyOn(proj_files.xcode, 'removeHeaderFile');
+
+ ios['header-file'].uninstall(headers[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'DummyPluginCommand.h'));
+ });
+ it('should call into xcodeproj\'s removeHeaderFile appropriately when element a target-dir', function(){
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] != undefined});
+
+ var spy = spyOn(proj_files.xcode, 'removeHeaderFile');
+
+ ios['header-file'].uninstall(headers[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Plugins', dummy_id, 'targetDir', 'TargetDirTest.h'));
+ });
+ it('should rm the file from the right target location', function(){
+ var headers = copyArray(valid_headers).filter(function(s) { return s.attrib['target-dir'] != undefined});
+ var spy = spyOn(shell, 'rm');
+
+ ios['header-file'].uninstall(headers[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp', 'Plugins', dummy_id, 'targetDir', 'TargetDirTest.h'));
+ });
+ });
+
+ describe('of <resource-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+ it('should call into xcodeproj\'s removeResourceFile', function(){
+ var resources = copyArray(valid_resources);
+ var spy = spyOn(proj_files.xcode, 'removeResourceFile');
+
+ ios['resource-file'].uninstall(resources[0], temp, "pluginid", proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join('Resources', 'DummyPlugin.bundle'));
+ });
+ it('should rm the file from the right target location', function(){
+ var resources = copyArray(valid_resources);
+ var spy = spyOn(shell, 'rm');
+
+ ios['resource-file'].uninstall(resources[0], temp, "pluginid", proj_files);
+ expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp', 'Resources', 'DummyPlugin.bundle'));
+ });
+ });
+ describe('of <framework custom="true"> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', ios_config_xml_project, temp);
+ });
+ it('should call into xcodeproj\'s removeFramework', function(){
+ var frameworks = copyArray(valid_custom_frameworks);
+ var spy = spyOn(proj_files.xcode, 'removeFramework');
+
+ ios['framework'].uninstall(frameworks[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework'), {customFramework:true});
+ });
+ it('should rm the file from the right target location', function(){
+ var frameworks = copyArray(valid_custom_frameworks);
+ var spy = spyOn(shell, 'rm');
+
+ ios['framework'].uninstall(frameworks[0], temp, dummy_id, proj_files);
+ expect(spy).toHaveBeenCalledWith('-rf', path.join(temp, 'SampleApp/Plugins/com.phonegap.plugins.dummyplugin/Custom.framework'));
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/tizen.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/tizen.spec.js b/cordova-lib/spec-plugman/platforms/tizen.spec.js
new file mode 100644
index 0000000..372e4d3
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/tizen.spec.js
@@ -0,0 +1,54 @@
+/*
+ *
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+var tizen = require('../../src/platforms/tizen'),
+ common = require('../../src/platforms/common'),
+ temp = require('temp'),
+ os = require('osenv'),
+ fs = require('fs'),
+ et = require('elementtree'),
+ path = require('path'),
+ tizen_project = path.join(__dirname, '..', 'projects', 'tizen'),
+ destination = temp.path(),
+ shell = require('shelljs'),
+ dummyPluginPath = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
+ dummyPlugin = et.XML(fs.readFileSync(
+ path.join(dummyPluginPath, 'plugin.xml'), {encoding: "utf-8"})),
+ dummySources = dummyPlugin
+ .find('./platform[@name="tizen"]')
+ .findall('./source-file');
+
+describe('Tizen project handler', function() {
+ describe('www_dir method', function() {
+ it('should append www to the directory passed in', function() {
+ expect(tizen.www_dir(path.sep)).toEqual(path.join(path.sep, 'www'));
+ });
+ });
+ describe('Manipulating project files', function() {
+ beforeEach(function() {
+ shell.cp('-rf', path.join(tizen_project, '*'), destination);
+ });
+ afterEach(function() {
+ shell.rm('-rf', destination);
+ });
+ describe('package_name method', function() {
+ it('should return the id of the config.xml root element', function() {
+ expect(tizen.package_name(destination)).toEqual("TizenTestPackage");
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/windows8.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/windows8.spec.js b/cordova-lib/spec-plugman/platforms/windows8.spec.js
new file mode 100644
index 0000000..99a5cb7
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/windows8.spec.js
@@ -0,0 +1,135 @@
+var windows8 = require('../../src/platforms/windows8'),
+ common = require('../../src/platforms/common'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ et = require('elementtree'),
+ os = require('osenv'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ plugins_module = require('../../src/util/plugins'),
+ dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
+ faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
+ windows8_project = path.join(__dirname, '..', 'projects', 'windows8');
+
+var xml_path = path.join(dummyplugin, 'plugin.xml')
+ , xml_text = fs.readFileSync(xml_path, 'utf-8')
+ , plugin_et = new et.ElementTree(et.XML(xml_text));
+
+var platformTag = plugin_et.find('./platform[@name="windows8"]');
+var dummy_id = plugin_et._root.attrib['id'];
+
+var valid_source = platformTag.findall('./source-file');
+var assets = plugin_et.findall('./asset');
+
+var configChanges = platformTag.findall('./config-file');
+
+xml_path = path.join(faultyplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8');
+
+plugin_et = new et.ElementTree(et.XML(xml_text));
+
+platformTag = plugin_et.find('./platform[@name="windows8"]');
+
+var invalid_source = platformTag.findall('./source-file');
+
+var faulty_id = plugin_et._root.attrib['id'];
+
+shell.mkdir('-p', temp);
+shell.cp('-rf', path.join(windows8_project, '*'), temp);
+var proj_files = windows8.parseProjectFile(temp);
+shell.rm('-rf', temp);
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+describe('windows8 project handler', function() {
+
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+
+ describe('www_dir method', function() {
+ it('should return cordova-windows8 project www location using www_dir', function() {
+ expect(windows8.www_dir(path.sep)).toEqual(path.sep + 'www');
+ });
+ });
+ describe('package_name method', function() {
+ it('should return a windows8 project\'s proper package name', function() {
+ expect(windows8.package_name(windows8_project)).toEqual("CordovaApp");
+ });
+ });
+
+ describe('parseProjectFile method', function() {
+ it('should throw if project is not an windows8 project', function() {
+ expect(function() {
+ windows8.parseProjectFile(temp);
+ }).toThrow(windows8.InvalidProjectPathError);
+ });
+ });
+
+ describe('installation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', path.join(windows8_project, '*'), temp);
+ });
+ it('should copy stuff from one location to another by calling common.copyFile', function() {
+ var source = copyArray(valid_source);
+ var s = spyOn(common, 'copyFile');
+ windows8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/windows8/dummer.js', temp, path.join('www', 'plugins', 'com.phonegap.plugins.dummyplugin', 'dummer.js'));
+ });
+ it('should throw if source-file src cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ windows8['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files);
+ }).toThrow('"' + path.resolve(faultyplugin, 'src/windows8/NotHere.js') + '" not found!');
+ });
+ it('should throw if source-file target already exists', function() {
+ var source = copyArray(valid_source);
+ var target = path.join(temp, 'www', 'plugins', dummy_id, 'dummer.js');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ windows8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ }).toThrow('"' + target + '" already exists!');
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ shell.cp('-rf', path.join(windows8_project, '*'), temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ it('should remove stuff by calling common.removeFile', function(done) {
+ var s = spyOn(common, 'removeFile');
+ install('windows8', temp, dummyplugin, plugins_dir, {})
+ .then(function() {
+ var source = copyArray(valid_source);
+ windows8['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(temp, path.join('www', 'plugins', 'com.phonegap.plugins.dummyplugin', 'dummer.js'));
+ done();
+ });
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/wp7.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/wp7.spec.js b/cordova-lib/spec-plugman/platforms/wp7.spec.js
new file mode 100644
index 0000000..262e851
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/wp7.spec.js
@@ -0,0 +1,129 @@
+var wp7 = require('../../src/platforms/wp7'),
+ common = require('../../src/platforms/common'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ et = require('elementtree'),
+ os = require('osenv'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ plugins_module = require('../../src/util/plugins'),
+ dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
+ faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
+ wp7_project = path.join(__dirname, '..', 'projects', 'wp7');
+
+var xml_path = path.join(dummyplugin, 'plugin.xml')
+ , xml_text = fs.readFileSync(xml_path, 'utf-8')
+ , plugin_et = new et.ElementTree(et.XML(xml_text));
+
+var platformTag = plugin_et.find('./platform[@name="wp7"]');
+var dummy_id = plugin_et._root.attrib['id'];
+var valid_source = platformTag.findall('./source-file'),
+ assets = plugin_et.findall('./asset'),
+ configChanges = platformTag.findall('./config-file');
+xml_path = path.join(faultyplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8')
+plugin_et = new et.ElementTree(et.XML(xml_text));
+
+platformTag = plugin_et.find('./platform[@name="wp7"]');
+var invalid_source = platformTag.findall('./source-file');
+var faulty_id = plugin_et._root.attrib['id'];
+
+shell.mkdir('-p', temp);
+shell.cp('-rf', path.join(wp7_project, '*'), temp);
+var proj_files = wp7.parseProjectFile(temp);
+shell.rm('-rf', temp);
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+describe('wp7 project handler', function() {
+
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+
+ describe('www_dir method', function() {
+ it('should return cordova-wp7 project www location using www_dir', function() {
+ expect(wp7.www_dir(path.sep)).toEqual(path.sep + 'www');
+ });
+ });
+ describe('package_name method', function() {
+ it('should return a wp7 project\'s proper package name', function() {
+ expect(wp7.package_name(wp7_project)).toEqual("{5FC10D78-8779-4EDB-9B61-1D04F0A755D4}");
+ });
+ });
+
+ describe('parseProjectFile method', function() {
+ it('should throw if project is not an wp7 project', function() {
+ expect(function() {
+ wp7.parseProjectFile(temp);
+ }).toThrow('does not appear to be a Windows Phone project (no .csproj file)');
+ });
+ });
+
+ describe('installation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', path.join(wp7_project, '*'), temp);
+ });
+ it('should copy stuff from one location to another by calling common.copyFile', function() {
+ var source = copyArray(valid_source);
+ var s = spyOn(common, 'copyFile');
+ wp7['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/wp7/DummyPlugin.cs', temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs'));
+ });
+ it('should throw if source-file src cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ wp7['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files);
+ }).toThrow('"' + path.resolve(faultyplugin, 'src/wp7/NotHere.cs') + '" not found!');
+ });
+ it('should throw if source-file target already exists', function() {
+ var source = copyArray(valid_source);
+ var target = path.join(temp, 'Plugins', dummy_id, 'DummyPlugin.cs');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ wp7['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ }).toThrow('"' + target + '" already exists!');
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ shell.cp('-rf', path.join(wp7_project, '*'), temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ it('should remove stuff by calling common.removeFile', function(done) {
+ var s = spyOn(common, 'removeFile');
+ install('wp7', temp, dummyplugin, plugins_dir, {})
+ .then(function() {
+ var source = copyArray(valid_source);
+ wp7['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs'));
+ done();
+ });
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/platforms/wp8.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/platforms/wp8.spec.js b/cordova-lib/spec-plugman/platforms/wp8.spec.js
new file mode 100644
index 0000000..ba9cdb4
--- /dev/null
+++ b/cordova-lib/spec-plugman/platforms/wp8.spec.js
@@ -0,0 +1,150 @@
+var wp8 = require('../../src/platforms/wp8'),
+ common = require('../../src/platforms/common'),
+ install = require('../../src/install'),
+ path = require('path'),
+ fs = require('fs'),
+ shell = require('shelljs'),
+ et = require('elementtree'),
+ os = require('osenv'),
+ temp = path.join(os.tmpdir(), 'plugman'),
+ plugins_dir = path.join(temp, 'cordova', 'plugins'),
+ xml_helpers = require('../../src/util/xml-helpers'),
+ plugins_module = require('../../src/util/plugins'),
+ dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
+ faultyplugin = path.join(__dirname, '..', 'plugins', 'FaultyPlugin'),
+ wp8_project = path.join(__dirname, '..', 'projects', 'wp8');
+
+var xml_path = path.join(dummyplugin, 'plugin.xml')
+ , xml_text = fs.readFileSync(xml_path, 'utf-8')
+ , plugin_et = new et.ElementTree(et.XML(xml_text));
+
+var platformTag = plugin_et.find('./platform[@name="wp8"]');
+var dummy_id = plugin_et._root.attrib['id'];
+var valid_source = platformTag.findall('./source-file'),
+ assets = plugin_et.findall('./asset'),
+ configChanges = platformTag.findall('./config-file');
+xml_path = path.join(faultyplugin, 'plugin.xml')
+xml_text = fs.readFileSync(xml_path, 'utf-8')
+plugin_et = new et.ElementTree(et.XML(xml_text));
+
+platformTag = plugin_et.find('./platform[@name="wp8"]');
+var invalid_source = platformTag.findall('./source-file');
+var faulty_id = plugin_et._root.attrib['id'];
+
+shell.mkdir('-p', temp);
+shell.cp('-rf', path.join(wp8_project, '*'), temp);
+var proj_files = wp8.parseProjectFile(temp);
+shell.rm('-rf', temp);
+
+function copyArray(arr) {
+ return Array.prototype.slice.call(arr, 0);
+}
+
+describe('wp8 project handler', function() {
+
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+
+ describe('www_dir method', function() {
+ it('should return cordova-wp8 project www location using www_dir', function() {
+ expect(wp8.www_dir(path.sep)).toEqual(path.sep + 'www');
+ });
+ });
+ describe('package_name method', function() {
+ it('should return a wp8 project\'s proper package name', function() {
+ expect(wp8.package_name(wp8_project)).toEqual("{F3A8197B-6B16-456D-B5F4-DD4F04AC0BEC}");
+ });
+ });
+
+ describe('parseProjectFile method', function() {
+ it('should throw if project is not an wp8 project', function() {
+ expect(function() {
+ wp8.parseProjectFile(temp);
+ }).toThrow('does not appear to be a Windows Phone project (no .csproj file)');
+ });
+ });
+
+ describe('installation', function() {
+ var done;
+ function installPromise(f) {
+ done = false;
+ f.then(function() { done = true; }, function(err) { done = err; });
+ }
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', path.join(wp8_project, '*'), temp);
+ });
+ it('should copy stuff from one location to another by calling common.copyFile', function() {
+ var source = copyArray(valid_source);
+ var s = spyOn(common, 'copyFile');
+ wp8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(dummyplugin, 'src/wp8/DummyPlugin.cs', temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs'));
+ });
+ it('should throw if source-file src cannot be found', function() {
+ var source = copyArray(invalid_source);
+ expect(function() {
+ wp8['source-file'].install(source[1], faultyplugin, temp, faulty_id, proj_files);
+ }).toThrow('"' + path.resolve(faultyplugin, 'src/wp8/NotHere.cs') + '" not found!');
+ });
+ it('should throw if source-file target already exists', function() {
+ var source = copyArray(valid_source);
+ var target = path.join(temp, 'Plugins', dummy_id, 'DummyPlugin.cs');
+ shell.mkdir('-p', path.dirname(target));
+ fs.writeFileSync(target, 'some bs', 'utf-8');
+ expect(function() {
+ wp8['source-file'].install(source[0], dummyplugin, temp, dummy_id, proj_files);
+ }).toThrow('"' + target + '" already exists!');
+ });
+ });
+ describe('of <config-changes> elements', function() {
+ beforeEach(function() {
+ shell.cp('-rf', path.join(wp8_project, '*'), temp);
+ });
+ it('should process and pass the after parameter to graftXML', function () {
+ var graftXML = spyOn(xml_helpers, 'graftXML').andCallThrough();
+
+ runs(function () { installPromise(install('wp8', temp, dummyplugin, plugins_dir, {})); });
+ waitsFor(function () { return done; }, 'install promise never resolved', 500);
+ runs(function () {
+ expect(graftXML).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), "/Deployment/App", "Tokens");
+ expect(graftXML).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), "/Deployment/App/Extensions", "Extension");
+ expect(graftXML).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Array), "/Deployment/App/Extensions", "FileTypeAssociation;Extension");
+ });
+ });
+ });
+ });
+
+ describe('uninstallation', function() {
+ beforeEach(function() {
+ shell.mkdir('-p', temp);
+ shell.mkdir('-p', plugins_dir);
+ shell.cp('-rf', path.join(wp8_project, '*'), temp);
+ });
+ afterEach(function() {
+ shell.rm('-rf', temp);
+ });
+ describe('of <source-file> elements', function() {
+ it('should remove stuff by calling common.removeFile', function(done) {
+ var s = spyOn(common, 'removeFile');
+ install('wp8', temp, dummyplugin, plugins_dir, {})
+ .then(function() {
+ var source = copyArray(valid_source);
+ wp8['source-file'].uninstall(source[0], temp, dummy_id, proj_files);
+ expect(s).toHaveBeenCalledWith(temp, path.join('Plugins', 'com.phonegap.plugins.dummyplugin', 'DummyPlugin.cs'));
+ done();
+ });
+ });
+ });
+ });
+});
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/.gitkeep
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/.gitkeep b/cordova-lib/spec-plugman/plugins/.gitkeep
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/AndroidJS/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/AndroidJS/plugin.xml b/cordova-lib/spec-plugman/plugins/AndroidJS/plugin.xml
new file mode 100644
index 0000000..1a68749
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/AndroidJS/plugin.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2013 Anis Kadri
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ id="com.phonegap.androidonly"
+ version="3.0.0">
+
+ <name>JavaScript in yo droidz</name>
+
+ <!-- android -->
+ <platform name="android">
+ <js-module src="www/android.js" name="Android">
+ <clobbers target="android" />
+ </js-module>
+ </platform>
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/AndroidJS/www/android.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/AndroidJS/www/android.js b/cordova-lib/spec-plugman/plugins/AndroidJS/www/android.js
new file mode 100644
index 0000000..d268b7d
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/AndroidJS/www/android.js
@@ -0,0 +1 @@
+{};
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/plugin.xml b/cordova-lib/spec-plugman/plugins/ChildBrowser/plugin.xml
new file mode 100644
index 0000000..2dfd692
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/ChildBrowser/plugin.xml
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Copyright 2013 Anis Kadri
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ id="com.phonegap.plugins.childbrowser"
+ version="0.6.0">
+
+ <name>Child Browser</name>
+
+ <asset src="www/childbrowser" target="childbrowser" />
+ <asset src="www/childbrowser_file.html" target="childbrowser_file.html" />
+
+ <js-module src="www/childbrowser.js" name="ChildBrowser">
+ <clobbers target="childbrowser" />
+ </js-module>
+
+ <config-file target="config.xml" parent="/*">
+ <access origin="build.phonegap.com" />
+ <access origin="s3.amazonaws.com" />
+ </config-file>
+
+ <info>No matter what platform you are installing to, this notice is very important.</info>
+
+ <!-- android -->
+ <platform name="android">
+ <config-file target="AndroidManifest.xml" parent="/manifest/application">
+ <activity android:name="com.phonegap.plugins.childBrowser.ChildBrowser"
+ android:label="@string/app_name">
+ <intent-filter>
+ </intent-filter>
+ </activity>
+ </config-file>
+
+ <!-- CDV < 2.0 -->
+ <config-file target="res/xml/plugins.xml" parent="/plugins">
+ <plugin name="ChildBrowser"
+ value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
+ </config-file>
+
+ <!-- CDV 2.0+ (for now) -->
+ <config-file target="res/xml/config.xml" parent="/cordova/plugins">
+ <plugin name="ChildBrowser"
+ value="com.phonegap.plugins.childBrowser.ChildBrowser"/>
+ </config-file>
+
+ <source-file src="src/android/ChildBrowser.java"
+ target-dir="src/com/phonegap/plugins/childBrowser" />
+ <info>Please make sure you read this because it is very important to complete the installation of your plugin.</info>
+ </platform>
+
+ <!-- ios -->
+ <platform name="ios">
+ <plugins-plist key="com.phonegap.plugins.childbrowser"
+ string="ChildBrowserCommand" />
+
+ <config-file target="config.xml" parent="/widget/plugins">
+ <plugin name="ChildBrowser"
+ value="ChildBrowserCommand" />
+ </config-file>
+
+ <resource-file src="src/ios/ChildBrowser.bundle" />
+ <resource-file src="src/ios/ChildBrowserViewController.xib" />
+
+ <config-file target="*-Info.plist" parent="AppId">
+ <string>$APP_ID</string>
+ </config-file>
+
+ <config-file target="*-Info.plist" parent="CFBundleURLTypes">
+ <array>
+ <dict>
+ <key>PackageName</key>
+ <string>$PACKAGE_NAME</string>
+ </dict>
+ </array>
+ </config-file>
+
+ <header-file src="src/ios/ChildBrowserCommand.h" />
+ <header-file src="src/ios/ChildBrowserViewController.h" />
+ <header-file src="src/ios/TargetDirTest.h" target-dir="targetDir"/>
+
+ <source-file src="src/ios/ChildBrowserCommand.m" />
+ <source-file src="src/ios/ChildBrowserViewController.m" />
+ <source-file src="src/ios/preserveDirs/PreserveDirsTest.m" preserve-dirs="true" />
+ <header-file src="src/ios/TargetDirTest.m" target-dir="targetDir"/>
+
+ <!-- framework for testing (not actual dependency of ChildBrowser -->
+ <framework src="libsqlite3.dylib" />
+ <framework src="social.framework" weak="true" />
+ <framework src="music.framework" weak="rabbit" />
+ <framework src="Custom.framework" custom="true" />
+ </platform>
+ <!-- wp7 -->
+ <platform name="wp7">
+ <resource-file src="src\wp7\Images\appbar.back.rest.png" />
+ <config-file target="config.xml" parent="/widget/plugins">
+ <plugin name="ChildBrowser"
+ value="ChildBrowser"/>
+ </config-file>
+
+ <source-file src="src\wp7\ChildBrowserCommand.cs"
+ target-dir="Plugins\" />
+
+ <!-- modify the project file to include the added files -->
+ <config-file target=".csproj" parent=".">
+ </config-file>
+
+ </platform>
+
+ <!-- wp8 -->
+ <platform name="wp8">
+ <resource-file src="src\wp7\Images\appbar.back.rest.png" />
+ <config-file target="config.xml" parent="/widget/plugins">
+ <plugin name="ChildBrowser"
+ value="ChildBrowser"/>
+ </config-file>
+
+ <source-file src="src\wp7\ChildBrowserCommand.cs"
+ target-dir="Plugins\" />
+
+ <!-- modify the project file to include the added files -->
+ <config-file target=".csproj" parent=".">
+ </config-file>
+
+ </platform>
+</plugin>
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/android/ChildBrowser.java
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/android/ChildBrowser.java b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/android/ChildBrowser.java
new file mode 100644
index 0000000..5263b0c
--- /dev/null
+++ b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/android/ChildBrowser.java
@@ -0,0 +1,19 @@
+/*
+ *
+ * Copyright 2013 Anis Kadri
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left.png
new file mode 100644
index 0000000..530e12b
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left@2x.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left@2x.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left@2x.png
new file mode 100644
index 0000000..530e12b
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_left@2x.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right.png
new file mode 100644
index 0000000..8b3d855
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right@2x.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right@2x.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right@2x.png
new file mode 100644
index 0000000..8b3d855
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/arrow_right@2x.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh.png
new file mode 100644
index 0000000..309b6bd
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh@2x.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh@2x.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh@2x.png
new file mode 100644
index 0000000..309b6bd
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/but_refresh@2x.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass.png
new file mode 100644
index 0000000..46a8901
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass.png differ
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/0318d8cd/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass@2x.png
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass@2x.png b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass@2x.png
new file mode 100644
index 0000000..46a8901
Binary files /dev/null and b/cordova-lib/spec-plugman/plugins/ChildBrowser/src/ios/ChildBrowser.bundle/compass@2x.png differ