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 2013/04/03 05:09:00 UTC
[04/16] git commit: updating iOS tests to use either plist or
config.xml approach
updating iOS tests to use either plist or config.xml approach
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugman/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugman/commit/19bea13a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugman/tree/19bea13a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugman/diff/19bea13a
Branch: refs/heads/master
Commit: 19bea13a49e9cd27564276acd42c1a8644a1406e
Parents: 2283374
Author: Anis Kadri <an...@apache.org>
Authored: Mon Apr 1 15:24:57 2013 -0700
Committer: Anis Kadri <an...@apache.org>
Committed: Mon Apr 1 15:24:57 2013 -0700
----------------------------------------------------------------------
test/ios-config-xml-install.js | 261 +++++++++++++++++++++++++++++++++
test/ios-config-xml-uninstall.js | 227 ++++++++++++++++++++++++++++
test/ios-install.js | 260 --------------------------------
test/ios-plist-install.js | 232 +++++++++++++++++++++++++++++
test/ios-plist-uninstall.js | 219 +++++++++++++++++++++++++++
test/ios-uninstall.js | 238 ------------------------------
6 files changed, 939 insertions(+), 498 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/19bea13a/test/ios-config-xml-install.js
----------------------------------------------------------------------
diff --git a/test/ios-config-xml-install.js b/test/ios-config-xml-install.js
new file mode 100644
index 0000000..fde9de3
--- /dev/null
+++ b/test/ios-config-xml-install.js
@@ -0,0 +1,261 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+var fs = require('fs')
+ , path = require('path')
+ , xcode = require('xcode')
+ , osenv = require('osenv')
+ , shell = require('shelljs')
+ , et = require('elementtree')
+ , ios = require(path.join(__dirname, '..', 'platforms', 'ios'))
+
+ , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+ , test_project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+ , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
+ , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml')
+ , xml_text, plugin_et
+
+ //, assetsDir = path.resolve(config.projectPath, 'www')
+ , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins')
+ , resDir = path.resolve(test_project_dir, 'SampleApp/Resources');
+
+exports.setUp = function(callback) {
+ shell.mkdir('-p', test_dir);
+
+ // copy the ios test project to a temp directory
+ shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
+
+ // copy the ios test plugin to a temp directory
+ shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
+
+ // parse the plugin.xml into an elementtree object
+ xml_text = fs.readFileSync(xml_path, 'utf-8')
+ plugin_et = new et.ElementTree(et.XML(xml_text));
+
+ callback();
+}
+
+exports.tearDown = function(callback) {
+ // remove the temp files (projects and plugins)
+ shell.rm('-rf', test_dir);
+ callback();
+}
+
+exports['should install webless plugin'] = function (test) {
+
+ // setting up a DummyPlugin
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et, { APP_ID: 12345 });
+
+ test.done();
+}
+
+exports['should move the js file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ var jsPath = path.join(test_dir, 'projects', 'ios-config-xml', 'www', 'childbrowser.js');
+ test.ok(fs.existsSync(jsPath));
+ test.done();
+}
+
+exports['should move the source files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.ok(fs.existsSync(srcDir + '/ChildBrowserCommand.m'))
+ test.ok(fs.existsSync(srcDir + '/ChildBrowserViewController.m'))
+ test.ok(fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.m'))
+ test.ok(fs.existsSync(srcDir + '/targetDir/TargetDirTest.m'))
+ test.done();
+}
+
+exports['should move the header files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.ok(fs.statSync(srcDir + '/ChildBrowserCommand.h'));
+ test.ok(fs.statSync(srcDir + '/ChildBrowserViewController.h'));
+ test.ok(fs.statSync(srcDir + '/preserveDirs/PreserveDirsTest.h'));
+ test.ok(fs.statSync(srcDir + '/targetDir/TargetDirTest.h'));
+ test.done();
+}
+
+exports['should move the xib file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.ok(fs.statSync(resDir + '/ChildBrowserViewController.xib'));
+ test.done();
+}
+
+exports['should move the bundle'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ var bundle = fs.statSync(resDir + '/ChildBrowser.bundle');
+
+ test.ok(bundle.isDirectory());
+ test.done();
+}
+
+exports['should edit config.xml'] = function (test) {
+ // setting up WebNotification (with config.xml)
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
+
+ // overriding some params
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ var configXmlPath = path.join(test_project_dir, 'SampleApp', 'config.xml');
+ var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+ pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+ expected = 'plugins/plugin[@name="WebNotifications"]' +
+ '[@value="WebNotifications"]';
+
+ test.ok(pluginsDoc.find(expected));
+ test.equal(pluginsDoc.findall("access").length, 3, "/access");
+ test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "build.phonegap.com")
+ test.equal(pluginsDoc.findall("access")[2].attrib["origin"], "s3.amazonaws.com")
+ test.done();
+}
+
+exports['should edit config.xml even when using old <plugins-plist> approach'] = function (test) {
+ // setting up PGSQLitePlugin (with config.xml)
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
+ var dummy_xml_path = path.join(dummy_plugin_dir, 'plugin-old.xml')
+
+ // overriding some params
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et, { APP_ID: 12345 });
+
+ var configXmlPath = path.join(test_project_dir, 'SampleApp', 'config.xml');
+ var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+ pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+ expected = 'plugins/plugin[@name="com.phonegap.plugins.childbrowser"]' +
+ '[@value="ChildBrowserCommand"]';
+
+ test.ok(pluginsDoc.find(expected));
+ test.equal(pluginsDoc.findall("access").length, 3, "/access");
+ test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "build.phonegap.com")
+ test.equal(pluginsDoc.findall("access")[2].attrib["origin"], "12345.s3.amazonaws.com")
+
+ test.done();
+}
+
+exports['should edit the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
+
+ obj = xcode.project(projPath).parseSync();
+ var fileRefSection = obj.hash.project.objects['PBXFileReference'],
+ fileRefLength = Object.keys(fileRefSection).length,
+ EXPECTED_TOTAL_REFERENCES = 96; // magic number ahoy!
+
+ test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
+ test.done();
+}
+
+exports['should add the framework references to the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+ projContents = fs.readFileSync(projPath, 'utf8'),
+ projLines = projContents.split("\n"),
+ weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
+ references;
+
+ references = projLines.filter(function (line) {
+ return !!(line.match("libsqlite3.dylib"));
+ })
+
+ // should be four libsqlite3 reference lines added
+ // pretty low-rent test eh
+ test.equal(references.length, 4);
+ test.ok(references[0].indexOf(weak_linked) == -1);
+ test.done();
+}
+
+exports['should add the framework references with weak option to the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+ projContents = fs.readFileSync(projPath, 'utf8'),
+ projLines = projContents.split("\n"),
+ weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
+ references;
+
+ weak_references = projLines.filter(function (line) {
+ return !!(line.match("social.framework"));
+ })
+
+ non_weak_references = projLines.filter(function (line) {
+ return !!(line.match("music.framework"));
+ })
+
+ // should be four libsqlite3 reference lines added
+ // pretty low-rent test eh
+ test.equal(weak_references.length, 4);
+ test.ok(weak_references[0].indexOf(weak_linked) != -1);
+
+ test.equal(non_weak_references.length, 4);
+ test.ok(non_weak_references[0].indexOf(weak_linked) == -1);
+ test.done();
+}
+
+exports['should not install a plugin that is already installed'] = function (test) {
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.throws(function(){ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et); },
+ /already installed/
+ );
+ test.done();
+}
+
+exports['should skip collision check when installation is forced'] = function (test) {
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ test.doesNotThrow(function(){ios.handlePlugin('force-install', test_project_dir, test_plugin_dir, plugin_et); },
+ /already installed/
+ );
+ test.done();
+}
+
+//exports['should revert changes when an error occurs'] = function (test) {
+// var faulty_plugin_dir = path.join(test_dir, 'plugins', 'FaultyPlugin')
+// var faulty_xml_path = path.join(test_dir, 'plugins', 'FaultyPlugin', 'plugin.xml')
+// var faulty_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(faulty_xml_path, 'utf-8')));
+//
+// var project_dir = path.join(test_dir, 'projects', 'ios-new-config-xml')
+//
+// ios.handlePlugin('install', project_dir, faulty_plugin_dir, faulty_plugin_et, { APP_ID: 12345 });
+//
+// test.throws(function(){ios.handlePlugin('install', project_dir, test_plugin_dir, plugin_et); },
+// /already installed/
+// );
+// test.done();
+//}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/19bea13a/test/ios-config-xml-uninstall.js
----------------------------------------------------------------------
diff --git a/test/ios-config-xml-uninstall.js b/test/ios-config-xml-uninstall.js
new file mode 100644
index 0000000..a2b5885
--- /dev/null
+++ b/test/ios-config-xml-uninstall.js
@@ -0,0 +1,227 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+var fs = require('fs')
+ , path = require('path')
+ , plist = require('plist')
+ , xcode = require('xcode')
+ , osenv = require('osenv')
+ , shell = require('shelljs')
+ , et = require('elementtree')
+ , ios = require(path.join(__dirname, '..', 'platforms', 'ios'))
+
+ , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+ , test_project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+ , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
+ , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml')
+ , xml_text, plugin_et
+
+ //, assetsDir = path.resolve(config.projectPath, 'www')
+ , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins')
+ , resDir = path.resolve(test_project_dir, 'SampleApp/Resources');
+
+exports.setUp = function(callback) {
+ shell.mkdir('-p', test_dir);
+
+ // copy the ios test project to a temp directory
+ shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
+
+ // copy the ios test plugin to a temp directory
+ shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
+
+ // parse the plugin.xml into an elementtree object
+ xml_text = fs.readFileSync(xml_path, 'utf-8')
+ plugin_et = new et.ElementTree(et.XML(xml_text));
+
+ callback();
+}
+
+exports.tearDown = function(callback) {
+ // remove the temp files (projects and plugins)
+ shell.rm('-rf', test_dir);
+ callback();
+}
+
+exports['should remove webless plugin'] = function (test) {
+
+ // setting up a DummyPlugin
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ test.done();
+}
+
+exports['should remove the js file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var jsPath = path.join(test_dir, 'projects', 'ios-config-xml', 'www', 'childbrowser.js');
+ test.ok(!fs.existsSync(jsPath))
+ test.done();
+}
+
+exports['should remove the source files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserCommand.m'))
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserViewController.m'))
+ test.ok(!fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.m'))
+ test.ok(!fs.existsSync(srcDir + '/targetDir/TargetDirTest.m'))
+ test.done();
+}
+
+exports['should remove the header files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserCommand.h'))
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserViewController.h'))
+ test.ok(!fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.h'))
+ test.ok(!fs.existsSync(srcDir + '/targetDir/TargetDirTest.h'))
+ test.done();
+}
+
+exports['should remove the xib file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(resDir + '/ChildBrowserViewController.xib'))
+ test.done();
+}
+
+exports['should remove the bundle'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(resDir + '/ChildBrowser.bundle'))
+ test.done();
+}
+
+exports['should edit config.xml even when using old <plugins-plist> approach'] = function (test) {
+ // setting up PGSQLitePlugin (with config.xml)
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'PGSQLitePlugin')
+ var dummy_xml_path = path.join(dummy_plugin_dir, 'plugin.xml')
+
+ // overriding some params
+ var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ // run the platform-specific function
+ ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ ios.handlePlugin('uninstall', project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
+ var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+ pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+ expected = 'plugins/plugin[@name="PGSQLitePlugin"]' +
+ '[@value="PGSQLitePlugin"]';
+
+ test.ok(!pluginsDoc.find(expected));
+ test.equal(pluginsDoc.findall("access").length, 1, "/access");
+
+ test.done();
+}
+
+exports['should edit config.xml'] = function (test) {
+ // setting up WebNotification (with config.xml)
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
+
+ // overriding some params
+ var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ // run the platform-specific function
+ ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ ios.handlePlugin('uninstall', project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
+ var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+ pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+ expected = 'plugins/plugin[@name="WebNotifications"]' +
+ '[@value="WebNotifications"]';
+
+ test.ok(!pluginsDoc.find(expected));
+ test.equal(pluginsDoc.findall("access").length, 1, "/access");
+
+ test.done();
+}
+
+exports['should edit the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
+
+ obj = xcode.project(projPath).parseSync();
+ var fileRefSection = obj.hash.project.objects['PBXFileReference'],
+ fileRefLength = Object.keys(fileRefSection).length,
+ EXPECTED_TOTAL_REFERENCES = 70; // magic number ahoy!
+
+ test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
+ test.done();
+}
+
+exports['should remove the framework references from the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+ projContents = fs.readFileSync(projPath, 'utf8'),
+ projLines = projContents.split("\n"),
+ references;
+
+ references = projLines.filter(function (line) {
+ return !!(line.match("libsqlite3.dylib"));
+ })
+
+ // should be four libsqlite3 reference lines added
+ // pretty low-rent test eh
+ test.equal(references.length, 0);
+ test.done();
+}
+
+exports['should not uninstall a plugin that is not installed'] = function (test) {
+ test.throws(function(){ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et); },
+ /not installed/
+ );
+ test.done();
+}
+
+exports['should skip collision check when installation is forced'] = function (test) {
+ test.doesNotThrow(function(){ios.handlePlugin('uninstall-force', test_project_dir, test_plugin_dir, plugin_et); },
+ /already installed/
+ );
+ test.done();
+}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/19bea13a/test/ios-install.js
----------------------------------------------------------------------
diff --git a/test/ios-install.js b/test/ios-install.js
deleted file mode 100644
index 438f48f..0000000
--- a/test/ios-install.js
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-var fs = require('fs')
- , path = require('path')
- , plist = require('plist')
- , xcode = require('xcode')
- , osenv = require('osenv')
- , shell = require('shelljs')
- , et = require('elementtree')
- , ios = require(path.join(__dirname, '..', 'platforms', 'ios'))
-
- , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
- , test_project_dir = path.join(test_dir, 'projects', 'ios')
- , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
- , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml')
- , xml_text, plugin_et
-
- //, assetsDir = path.resolve(config.projectPath, 'www')
- , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins')
- , resDir = path.resolve(test_project_dir, 'SampleApp/Resources');
-
-exports.setUp = function(callback) {
- shell.mkdir('-p', test_dir);
-
- // copy the ios test project to a temp directory
- shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
-
- // copy the ios test plugin to a temp directory
- shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
-
- // parse the plugin.xml into an elementtree object
- xml_text = fs.readFileSync(xml_path, 'utf-8')
- plugin_et = new et.ElementTree(et.XML(xml_text));
-
- callback();
-}
-
-exports.tearDown = function(callback) {
- // remove the temp files (projects and plugins)
- shell.rm('-rf', test_dir);
- callback();
-}
-
-exports['should install webless plugin'] = function (test) {
-
- // setting up a DummyPlugin
- var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
- var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
- var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
-
- ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et, { APP_ID: 12345 });
-
- test.done();
-}
-
-exports['should move the js file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- var jsPath = path.join(test_dir, 'projects', 'ios', 'www', 'childbrowser.js');
- test.ok(fs.existsSync(jsPath));
- test.done();
-}
-
-exports['should move the source files'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- test.ok(fs.existsSync(srcDir + '/ChildBrowserCommand.m'))
- test.ok(fs.existsSync(srcDir + '/ChildBrowserViewController.m'))
- test.ok(fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.m'))
- test.ok(fs.existsSync(srcDir + '/targetDir/TargetDirTest.m'))
- test.done();
-}
-
-exports['should move the header files'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- test.ok(fs.statSync(srcDir + '/ChildBrowserCommand.h'));
- test.ok(fs.statSync(srcDir + '/ChildBrowserViewController.h'));
- test.ok(fs.statSync(srcDir + '/preserveDirs/PreserveDirsTest.h'));
- test.ok(fs.statSync(srcDir + '/targetDir/TargetDirTest.h'));
- test.done();
-}
-
-exports['should move the xib file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- test.ok(fs.statSync(resDir + '/ChildBrowserViewController.xib'));
- test.done();
-}
-
-exports['should move the bundle'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- var bundle = fs.statSync(resDir + '/ChildBrowser.bundle');
-
- test.ok(bundle.isDirectory());
- test.done();
-}
-
-
-exports['should edit PhoneGap.plist'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- var plistPath = test_project_dir + '/SampleApp/PhoneGap.plist';
- var obj = plist.parseFileSync(plistPath);
-
- test.equal(obj.Plugins['com.phonegap.plugins.childbrowser'],
- 'ChildBrowserCommand');
-
- test.equal(obj.ExternalHosts.length, 2)
- test.equal(obj.ExternalHosts[0], "build.phonegap.com")
- test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")
-
- test.done();
-}
-
-exports['should edit config.xml'] = function (test) {
- // setting up WebNotification (with config.xml)
- var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
- var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
-
- // overriding some params
- var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
- var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
-
- // run the platform-specific function
- ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
-
- var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
- var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
- pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
- expected = 'plugins/plugin[@name="WebNotifications"]' +
- '[@value="WebNotifications"]';
-
- test.ok(pluginsDoc.find(expected));
- test.equal(pluginsDoc.findall("access").length, 3, "/access");
- test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "build.phonegap.com")
- test.equal(pluginsDoc.findall("access")[2].attrib["origin"], "s3.amazonaws.com")
- test.done();
-}
-
-exports['should edit config.xml even when using old <plugins-plist> approach'] = function (test) {
- // setting up PGSQLitePlugin (with config.xml)
- var dummy_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
- var dummy_xml_path = path.join(dummy_plugin_dir, 'plugin.xml')
-
- // overriding some params
- var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
- var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
-
- // run the platform-specific function
- ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et, { APP_ID: 12345 });
-
- var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
- var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
- pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
- expected = 'plugins/plugin[@name="com.phonegap.plugins.childbrowser"]' +
- '[@value="ChildBrowserCommand"]';
-
- test.ok(pluginsDoc.find(expected));
- test.equal(pluginsDoc.findall("access").length, 3, "/access");
- test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "build.phonegap.com")
- test.equal(pluginsDoc.findall("access")[2].attrib["origin"], "12345.s3.amazonaws.com")
-
- test.done();
-}
-
-exports['should edit the pbxproj file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
-
- obj = xcode.project(projPath).parseSync();
- var fileRefSection = obj.hash.project.objects['PBXFileReference'],
- fileRefLength = Object.keys(fileRefSection).length,
- EXPECTED_TOTAL_REFERENCES = 96; // magic number ahoy!
-
- test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
- test.done();
-}
-
-exports['should add the framework references to the pbxproj file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
- var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
- projContents = fs.readFileSync(projPath, 'utf8'),
- projLines = projContents.split("\n"),
- weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
- references;
-
- references = projLines.filter(function (line) {
- return !!(line.match("libsqlite3.dylib"));
- })
-
- // should be four libsqlite3 reference lines added
- // pretty low-rent test eh
- test.equal(references.length, 4);
- test.ok(references[0].indexOf(weak_linked) == -1);
- test.done();
-}
-
-exports['should add the framework references with weak option to the pbxproj file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
- var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
- projContents = fs.readFileSync(projPath, 'utf8'),
- projLines = projContents.split("\n"),
- weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
- references;
-
- weak_references = projLines.filter(function (line) {
- return !!(line.match("social.framework"));
- })
-
- non_weak_references = projLines.filter(function (line) {
- return !!(line.match("music.framework"));
- })
-
- // should be four libsqlite3 reference lines added
- // pretty low-rent test eh
- test.equal(weak_references.length, 4);
- test.ok(weak_references[0].indexOf(weak_linked) != -1);
-
- test.equal(non_weak_references.length, 4);
- test.ok(non_weak_references[0].indexOf(weak_linked) == -1);
- test.done();
-}
-
-exports['should not install a plugin that is already installed'] = function (test) {
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
-
- test.throws(function(){ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et); },
- /already installed/
- );
- test.done();
-}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/19bea13a/test/ios-plist-install.js
----------------------------------------------------------------------
diff --git a/test/ios-plist-install.js b/test/ios-plist-install.js
new file mode 100644
index 0000000..0c524d5
--- /dev/null
+++ b/test/ios-plist-install.js
@@ -0,0 +1,232 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+var fs = require('fs')
+ , path = require('path')
+ , plist = require('plist')
+ , xcode = require('xcode')
+ , osenv = require('osenv')
+ , shell = require('shelljs')
+ , et = require('elementtree')
+ , ios = require(path.join(__dirname, '..', 'platforms', 'ios'))
+
+ , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+ , test_project_dir = path.join(test_dir, 'projects', 'ios-plist')
+ , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
+ , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml')
+ , xml_text, plugin_et
+
+ //, assetsDir = path.resolve(config.projectPath, 'www')
+ , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins')
+ , resDir = path.resolve(test_project_dir, 'SampleApp/Resources');
+
+exports.setUp = function(callback) {
+ shell.mkdir('-p', test_dir);
+
+ // copy the ios test project to a temp directory
+ shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
+
+ // copy the ios test plugin to a temp directory
+ shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
+
+ // parse the plugin.xml into an elementtree object
+ xml_text = fs.readFileSync(xml_path, 'utf-8')
+ plugin_et = new et.ElementTree(et.XML(xml_text));
+
+ callback();
+}
+
+exports.tearDown = function(callback) {
+ // remove the temp files (projects and plugins)
+ shell.rm('-rf', test_dir);
+ callback();
+}
+
+exports['should install webless plugin'] = function (test) {
+
+ // setting up a DummyPlugin
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et, { APP_ID: 12345 });
+
+ test.done();
+}
+
+exports['should move the js file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ var jsPath = path.join(test_dir, 'projects', 'ios-plist', 'www', 'childbrowser.js');
+ test.ok(fs.existsSync(jsPath));
+ test.done();
+}
+
+exports['should move the source files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.ok(fs.existsSync(srcDir + '/ChildBrowserCommand.m'))
+ test.ok(fs.existsSync(srcDir + '/ChildBrowserViewController.m'))
+ test.ok(fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.m'))
+ test.ok(fs.existsSync(srcDir + '/targetDir/TargetDirTest.m'))
+ test.done();
+}
+
+exports['should move the header files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.ok(fs.statSync(srcDir + '/ChildBrowserCommand.h'));
+ test.ok(fs.statSync(srcDir + '/ChildBrowserViewController.h'));
+ test.ok(fs.statSync(srcDir + '/preserveDirs/PreserveDirsTest.h'));
+ test.ok(fs.statSync(srcDir + '/targetDir/TargetDirTest.h'));
+ test.done();
+}
+
+exports['should move the xib file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.ok(fs.statSync(resDir + '/ChildBrowserViewController.xib'));
+ test.done();
+}
+
+exports['should move the bundle'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ var bundle = fs.statSync(resDir + '/ChildBrowser.bundle');
+
+ test.ok(bundle.isDirectory());
+ test.done();
+}
+
+
+exports['should edit PhoneGap.plist'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ var plistPath = test_project_dir + '/SampleApp/PhoneGap.plist';
+ var obj = plist.parseFileSync(plistPath);
+
+ test.equal(obj.Plugins['com.phonegap.plugins.childbrowser'],
+ 'ChildBrowserCommand');
+
+ test.equal(obj.ExternalHosts.length, 2)
+ test.equal(obj.ExternalHosts[0], "build.phonegap.com")
+ test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")
+
+ test.done();
+}
+
+exports['should edit the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
+
+ obj = xcode.project(projPath).parseSync();
+ var fileRefSection = obj.hash.project.objects['PBXFileReference'],
+ fileRefLength = Object.keys(fileRefSection).length,
+ EXPECTED_TOTAL_REFERENCES = 96; // magic number ahoy!
+
+ test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
+ test.done();
+}
+
+exports['should add the framework references to the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+ projContents = fs.readFileSync(projPath, 'utf8'),
+ projLines = projContents.split("\n"),
+ weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
+ references;
+
+ references = projLines.filter(function (line) {
+ return !!(line.match("libsqlite3.dylib"));
+ })
+
+ // should be four libsqlite3 reference lines added
+ // pretty low-rent test eh
+ test.equal(references.length, 4);
+ test.ok(references[0].indexOf(weak_linked) == -1);
+ test.done();
+}
+
+exports['should add the framework references with weak option to the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+ projContents = fs.readFileSync(projPath, 'utf8'),
+ projLines = projContents.split("\n"),
+ weak_linked = "settings = {ATTRIBUTES = (Weak, ); };",
+ references;
+
+ weak_references = projLines.filter(function (line) {
+ return !!(line.match("social.framework"));
+ })
+
+ non_weak_references = projLines.filter(function (line) {
+ return !!(line.match("music.framework"));
+ })
+
+ // should be four libsqlite3 reference lines added
+ // pretty low-rent test eh
+ test.equal(weak_references.length, 4);
+ test.ok(weak_references[0].indexOf(weak_linked) != -1);
+
+ test.equal(non_weak_references.length, 4);
+ test.ok(non_weak_references[0].indexOf(weak_linked) == -1);
+ test.done();
+}
+
+exports['should not install a plugin that is already installed'] = function (test) {
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+
+ test.throws(function(){ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et); },
+ /already installed/
+ );
+ test.done();
+}
+
+exports['should skip collision check when installation is forced'] = function (test) {
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ test.doesNotThrow(function(){ios.handlePlugin('force-install', test_project_dir, test_plugin_dir, plugin_et); },
+ /already installed/
+ );
+ test.done();
+}
+
+//exports['should revert changes when an error occurs'] = function (test) {
+// var faulty_plugin_dir = path.join(test_dir, 'plugins', 'FaultyPlugin')
+// var faulty_xml_path = path.join(test_dir, 'plugins', 'FaultyPlugin', 'plugin.xml')
+// var faulty_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(faulty_xml_path, 'utf-8')));
+//
+// var project_dir = path.join(test_dir, 'projects', 'ios-new-config-xml')
+//
+// ios.handlePlugin('install', project_dir, faulty_plugin_dir, faulty_plugin_et, { APP_ID: 12345 });
+//
+// test.throws(function(){ios.handlePlugin('install', project_dir, test_plugin_dir, plugin_et); },
+// /already installed/
+// );
+// test.done();
+//}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/19bea13a/test/ios-plist-uninstall.js
----------------------------------------------------------------------
diff --git a/test/ios-plist-uninstall.js b/test/ios-plist-uninstall.js
new file mode 100644
index 0000000..fd6ed9e
--- /dev/null
+++ b/test/ios-plist-uninstall.js
@@ -0,0 +1,219 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+var fs = require('fs')
+ , path = require('path')
+ , plist = require('plist')
+ , xcode = require('xcode')
+ , osenv = require('osenv')
+ , shell = require('shelljs')
+ , et = require('elementtree')
+ , ios = require(path.join(__dirname, '..', 'platforms', 'ios'))
+
+ , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+ , test_project_dir = path.join(test_dir, 'projects', 'ios-plist')
+ , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
+ , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml')
+ , xml_text, plugin_et
+
+ //, assetsDir = path.resolve(config.projectPath, 'www')
+ , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins')
+ , resDir = path.resolve(test_project_dir, 'SampleApp/Resources');
+
+exports.setUp = function(callback) {
+ shell.mkdir('-p', test_dir);
+
+ // copy the ios test project to a temp directory
+ shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
+
+ // copy the ios test plugin to a temp directory
+ shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
+
+ // parse the plugin.xml into an elementtree object
+ xml_text = fs.readFileSync(xml_path, 'utf-8')
+ plugin_et = new et.ElementTree(et.XML(xml_text));
+
+ callback();
+}
+
+exports.tearDown = function(callback) {
+ // remove the temp files (projects and plugins)
+ shell.rm('-rf', test_dir);
+ callback();
+}
+
+exports['should remove webless plugin'] = function (test) {
+
+ // setting up a DummyPlugin
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ test.done();
+}
+
+exports['should remove the js file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var jsPath = path.join(test_dir, 'projects', 'ios', 'www', 'childbrowser.js');
+ test.ok(!fs.existsSync(jsPath))
+ test.done();
+}
+
+exports['should remove the source files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserCommand.m'))
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserViewController.m'))
+ test.ok(!fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.m'))
+ test.ok(!fs.existsSync(srcDir + '/targetDir/TargetDirTest.m'))
+ test.done();
+}
+
+exports['should remove the header files'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserCommand.h'))
+ test.ok(!fs.existsSync(srcDir + '/ChildBrowserViewController.h'))
+ test.ok(!fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.h'))
+ test.ok(!fs.existsSync(srcDir + '/targetDir/TargetDirTest.h'))
+ test.done();
+}
+
+exports['should remove the xib file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(resDir + '/ChildBrowserViewController.xib'))
+ test.done();
+}
+
+exports['should remove the bundle'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ test.ok(!fs.existsSync(resDir + '/ChildBrowser.bundle'))
+ test.done();
+}
+
+exports['should edit PhoneGap.plist'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var plistPath = test_project_dir + '/SampleApp/PhoneGap.plist';
+ obj = plist.parseFileSync(plistPath);
+
+ test.notEqual(obj.Plugins['com.phonegap.plugins.childbrowser'],
+ 'ChildBrowserCommand');
+
+ test.equal(obj.ExternalHosts.length, 2)
+ test.equal(obj.ExternalHosts[0], "build.phonegap.com")
+ test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")
+
+ test.done();
+}
+
+exports['should edit config.xml'] = function (test) {
+ // setting up WebNotification (with config.xml)
+ var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
+ var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
+
+ // overriding some params
+ var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
+ var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
+
+ // run the platform-specific function
+ ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ ios.handlePlugin('uninstall', project_dir, dummy_plugin_dir, dummy_plugin_et);
+
+ var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
+ var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
+ pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
+ expected = 'plugins/plugin[@name="WebNotifications"]' +
+ '[@value="WebNotifications"]';
+
+ test.ok(!pluginsDoc.find(expected));
+ test.equal(pluginsDoc.findall("access").length, 1, "/access");
+
+ test.done();
+}
+
+exports['should edit the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
+
+ obj = xcode.project(projPath).parseSync();
+ var fileRefSection = obj.hash.project.objects['PBXFileReference'],
+ fileRefLength = Object.keys(fileRefSection).length,
+ EXPECTED_TOTAL_REFERENCES = 70; // magic number ahoy!
+
+ test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
+ test.done();
+}
+
+exports['should remove the framework references from the pbxproj file'] = function (test) {
+ // run the platform-specific function
+ ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+ ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
+
+
+ var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
+ projContents = fs.readFileSync(projPath, 'utf8'),
+ projLines = projContents.split("\n"),
+ references;
+
+ references = projLines.filter(function (line) {
+ return !!(line.match("libsqlite3.dylib"));
+ })
+
+ // should be four libsqlite3 reference lines added
+ // pretty low-rent test eh
+ test.equal(references.length, 0);
+ test.done();
+}
+
+exports['should not uninstall a plugin that is not installed'] = function (test) {
+ test.throws(function(){ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et); },
+ /not installed/
+ );
+ test.done();
+}
+
+exports['should skip collision check when installation is forced'] = function (test) {
+ test.doesNotThrow(function(){ios.handlePlugin('uninstall-force', test_project_dir, test_plugin_dir, plugin_et); },
+ /already installed/
+ );
+ test.done();
+}
http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/19bea13a/test/ios-uninstall.js
----------------------------------------------------------------------
diff --git a/test/ios-uninstall.js b/test/ios-uninstall.js
deleted file mode 100644
index 8d7692e..0000000
--- a/test/ios-uninstall.js
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-var fs = require('fs')
- , path = require('path')
- , plist = require('plist')
- , xcode = require('xcode')
- , osenv = require('osenv')
- , shell = require('shelljs')
- , et = require('elementtree')
- , ios = require(path.join(__dirname, '..', 'platforms', 'ios'))
-
- , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
- , test_project_dir = path.join(test_dir, 'projects', 'ios')
- , test_plugin_dir = path.join(test_dir, 'plugins', 'ChildBrowser')
- , xml_path = path.join(test_dir, 'plugins', 'ChildBrowser', 'plugin.xml')
- , xml_text, plugin_et
-
- //, assetsDir = path.resolve(config.projectPath, 'www')
- , srcDir = path.resolve(test_project_dir, 'SampleApp/Plugins')
- , resDir = path.resolve(test_project_dir, 'SampleApp/Resources');
-
-exports.setUp = function(callback) {
- shell.mkdir('-p', test_dir);
-
- // copy the ios test project to a temp directory
- shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
-
- // copy the ios test plugin to a temp directory
- shell.cp('-r', path.join(__dirname, 'plugins'), test_dir);
-
- // parse the plugin.xml into an elementtree object
- xml_text = fs.readFileSync(xml_path, 'utf-8')
- plugin_et = new et.ElementTree(et.XML(xml_text));
-
- callback();
-}
-
-exports.tearDown = function(callback) {
- // remove the temp files (projects and plugins)
- shell.rm('-rf', test_dir);
- callback();
-}
-
-exports['should remove webless plugin'] = function (test) {
-
- // setting up a DummyPlugin
- var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WeblessPlugin')
- var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
- var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
-
- ios.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
-
- test.done();
-}
-
-exports['should remove the js file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- var jsPath = path.join(test_dir, 'projects', 'ios', 'www', 'childbrowser.js');
- test.ok(!fs.existsSync(jsPath))
- test.done();
-}
-
-exports['should remove the source files'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- test.ok(!fs.existsSync(srcDir + '/ChildBrowserCommand.m'))
- test.ok(!fs.existsSync(srcDir + '/ChildBrowserViewController.m'))
- test.ok(!fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.m'))
- test.ok(!fs.existsSync(srcDir + '/targetDir/TargetDirTest.m'))
- test.done();
-}
-
-exports['should remove the header files'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- test.ok(!fs.existsSync(srcDir + '/ChildBrowserCommand.h'))
- test.ok(!fs.existsSync(srcDir + '/ChildBrowserViewController.h'))
- test.ok(!fs.existsSync(srcDir + '/preserveDirs/PreserveDirsTest.h'))
- test.ok(!fs.existsSync(srcDir + '/targetDir/TargetDirTest.h'))
- test.done();
-}
-
-exports['should remove the xib file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- test.ok(!fs.existsSync(resDir + '/ChildBrowserViewController.xib'))
- test.done();
-}
-
-exports['should remove the bundle'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- test.ok(!fs.existsSync(resDir + '/ChildBrowser.bundle'))
- test.done();
-}
-
-exports['should edit PhoneGap.plist'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345 });
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- var plistPath = test_project_dir + '/SampleApp/PhoneGap.plist';
- obj = plist.parseFileSync(plistPath);
-
- test.notEqual(obj.Plugins['com.phonegap.plugins.childbrowser'],
- 'ChildBrowserCommand');
-
- test.equal(obj.ExternalHosts.length, 2)
- test.equal(obj.ExternalHosts[0], "build.phonegap.com")
- test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")
-
- test.done();
-}
-
-exports['should edit config.xml even when using old <plugins-plist> approach'] = function (test) {
- // setting up PGSQLitePlugin (with config.xml)
- var dummy_plugin_dir = path.join(test_dir, 'plugins', 'PGSQLitePlugin')
- var dummy_xml_path = path.join(dummy_plugin_dir, 'plugin.xml')
-
- // overriding some params
- var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
- var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
-
- // run the platform-specific function
- ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
-
- ios.handlePlugin('uninstall', project_dir, dummy_plugin_dir, dummy_plugin_et);
-
- var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
- var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
- pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
- expected = 'plugins/plugin[@name="PGSQLitePlugin"]' +
- '[@value="PGSQLitePlugin"]';
-
- test.ok(!pluginsDoc.find(expected));
- test.equal(pluginsDoc.findall("access").length, 1, "/access");
-
- test.done();
-}
-
-exports['should edit config.xml'] = function (test) {
- // setting up WebNotification (with config.xml)
- var dummy_plugin_dir = path.join(test_dir, 'plugins', 'WebNotifications')
- var dummy_xml_path = path.join(test_dir, 'plugins', 'WebNotifications', 'plugin.xml')
-
- // overriding some params
- var project_dir = path.join(test_dir, 'projects', 'ios-config-xml')
- var dummy_plugin_et = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
-
- // run the platform-specific function
- ios.handlePlugin('install', project_dir, dummy_plugin_dir, dummy_plugin_et);
-
- ios.handlePlugin('uninstall', project_dir, dummy_plugin_dir, dummy_plugin_et);
-
- var configXmlPath = path.join(project_dir, 'SampleApp', 'config.xml');
- var pluginsTxt = fs.readFileSync(configXmlPath, 'utf-8'),
- pluginsDoc = new et.ElementTree(et.XML(pluginsTxt)),
- expected = 'plugins/plugin[@name="WebNotifications"]' +
- '[@value="WebNotifications"]';
-
- test.ok(!pluginsDoc.find(expected));
- test.equal(pluginsDoc.findall("access").length, 1, "/access");
-
- test.done();
-}
-
-exports['should edit the pbxproj file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
- var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
-
- obj = xcode.project(projPath).parseSync();
- var fileRefSection = obj.hash.project.objects['PBXFileReference'],
- fileRefLength = Object.keys(fileRefSection).length,
- EXPECTED_TOTAL_REFERENCES = 70; // magic number ahoy!
-
- test.equal(fileRefLength, EXPECTED_TOTAL_REFERENCES);
- test.done();
-}
-
-exports['should remove the framework references from the pbxproj file'] = function (test) {
- // run the platform-specific function
- ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
- ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et);
-
-
- var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj',
- projContents = fs.readFileSync(projPath, 'utf8'),
- projLines = projContents.split("\n"),
- references;
-
- references = projLines.filter(function (line) {
- return !!(line.match("libsqlite3.dylib"));
- })
-
- // should be four libsqlite3 reference lines added
- // pretty low-rent test eh
- test.equal(references.length, 0);
- test.done();
-}
-
-exports['should not uninstall a plugin that is not installed'] = function (test) {
- test.throws(function(){ios.handlePlugin('uninstall', test_project_dir, test_plugin_dir, plugin_et); },
- /not installed/
- );
- test.done();
-}