You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/04/29 20:51:29 UTC

git commit: finished config-handler uninstall specs

Updated Branches:
  refs/heads/master a4184091d -> 6ee050398


finished config-handler uninstall specs


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

Branch: refs/heads/master
Commit: 6ee050398223d34fc3fd72e1cd0dc8061f1fb3fd
Parents: a418409
Author: Fil Maj <ma...@gmail.com>
Authored: Mon Apr 29 11:51:24 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Apr 29 11:51:24 2013 -0700

----------------------------------------------------------------------
 spec/plugins/shared-deps-multi-child/plugin.xml    |   35 ++++++++
 .../android_two_no_perms/AndroidManifest.xml       |   49 ++++++++++++
 .../android_two_no_perms/res/xml/config.xml        |   54 +++++++++++++
 spec/util/config-changes.spec.js                   |   61 +++++++++++++++
 src/util/xml-helpers.js                            |    2 +-
 5 files changed, 200 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/spec/plugins/shared-deps-multi-child/plugin.xml
----------------------------------------------------------------------
diff --git a/spec/plugins/shared-deps-multi-child/plugin.xml b/spec/plugins/shared-deps-multi-child/plugin.xml
new file mode 100644
index 0000000..3b7b102
--- /dev/null
+++ b/spec/plugins/shared-deps-multi-child/plugin.xml
@@ -0,0 +1,35 @@
+<?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://www.phonegap.com/ns/plugins/1.0"
+    xmlns="http://www.phonegap.com/ns/plugins/1.0"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    id="ca.filmaj.shareddeps"
+    version="1.0.0">
+
+    <name>Sharing Dependencies with the Multi-Child Plugin, woo</name>
+
+    <!-- android -->
+    <platform name="android">
+		<config-file target="AndroidManifest.xml" parent="/manifest">
+			<uses-permission android:name="android.permission.INTERNET"/>
+		</config-file>
+    </platform>
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/spec/projects/android_two_no_perms/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/spec/projects/android_two_no_perms/AndroidManifest.xml b/spec/projects/android_two_no_perms/AndroidManifest.xml
new file mode 100644
index 0000000..6e4b480
--- /dev/null
+++ b/spec/projects/android_two_no_perms/AndroidManifest.xml
@@ -0,0 +1,49 @@
+<?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.
+
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:windowSoftInputMode="adjustPan"
+      package="com.alunny.childapp" android:versionName="1.1" android:versionCode="5">
+    <supports-screens
+    	android:largeScreens="true"
+    	android:normalScreens="true"
+    	android:smallScreens="true"
+    	android:xlargeScreens="true"
+    	android:resizeable="true"
+    	android:anyDensity="true"
+    	/>
+
+    <application android:icon="@drawable/icon" android:label="@string/app_name"
+    	android:debuggable="true">
+		<activity android:name="ChildApp" android:label="@string/app_name" 
+				  android:configChanges="orientation|keyboardHidden">
+			<intent-filter>
+				<action android:name="android.intent.action.MAIN" />
+				<category android:name="android.intent.category.LAUNCHER" />
+			</intent-filter>
+        </activity>
+        <activity android:name="com.phonegap.DroidGap" android:label="@string/app_name" 
+            	  android:configChanges="orientation|keyboardHidden">
+        	<intent-filter>
+        	</intent-filter>
+        </activity>
+    </application>
+
+	<uses-sdk android:minSdkVersion="5" />
+</manifest> 

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/spec/projects/android_two_no_perms/assets/www/.gitkeep
----------------------------------------------------------------------
diff --git a/spec/projects/android_two_no_perms/assets/www/.gitkeep b/spec/projects/android_two_no_perms/assets/www/.gitkeep
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/spec/projects/android_two_no_perms/res/xml/config.xml
----------------------------------------------------------------------
diff --git a/spec/projects/android_two_no_perms/res/xml/config.xml b/spec/projects/android_two_no_perms/res/xml/config.xml
new file mode 100644
index 0000000..d37aba5
--- /dev/null
+++ b/spec/projects/android_two_no_perms/res/xml/config.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you 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.
+-->
+<cordova>
+    <!--
+    access elements control the Android whitelist.
+    Domains are assumed blocked unless set otherwise
+     -->
+
+    <access origin="http://127.0.0.1*"/> <!-- allow local pages -->
+
+    <!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
+    <!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
+    <!-- <access origin=".*"/> Allow all domains, suggested development use only -->
+
+    <log level="DEBUG"/>
+    <preference name="useBrowserHistory" value="false" />
+<plugins>
+    <plugin name="App" value="org.apache.cordova.App"/>
+    <plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
+    <plugin name="Device" value="org.apache.cordova.Device"/>
+    <plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
+    <plugin name="Compass" value="org.apache.cordova.CompassListener"/>
+    <plugin name="Media" value="org.apache.cordova.AudioHandler"/>
+    <plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
+    <plugin name="Contacts" value="org.apache.cordova.ContactManager"/>
+    <plugin name="File" value="org.apache.cordova.FileUtils"/>
+    <plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
+    <plugin name="Notification" value="org.apache.cordova.Notification"/>
+    <plugin name="Storage" value="org.apache.cordova.Storage"/>
+    <plugin name="Temperature" value="org.apache.cordova.TempListener"/>
+    <plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
+    <plugin name="Capture" value="org.apache.cordova.Capture"/>
+    <plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
+    <plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
+</plugins>
+</cordova>
+

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/spec/projects/android_two_no_perms/src/.gitkeep
----------------------------------------------------------------------
diff --git a/spec/projects/android_two_no_perms/src/.gitkeep b/spec/projects/android_two_no_perms/src/.gitkeep
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/spec/util/config-changes.spec.js
----------------------------------------------------------------------
diff --git a/spec/util/config-changes.spec.js b/spec/util/config-changes.spec.js
index d9b29c8..ddf7af5 100644
--- a/spec/util/config-changes.spec.js
+++ b/spec/util/config-changes.spec.js
@@ -9,9 +9,11 @@ var configChanges = require('../../src/util/config-changes'),
     temp    = path.join(os.tmpdir(), 'plugman'),
     dummyplugin = path.join(__dirname, '..', 'plugins', 'DummyPlugin'),
     childrenplugin = path.join(__dirname, '..', 'plugins', 'multiple-children'),
+    shareddepsplugin = path.join(__dirname, '..', 'plugins', 'shared-deps-multi-child'),
     configplugin = path.join(__dirname, '..', 'plugins', 'ConfigTestPlugin'),
     varplugin = path.join(__dirname, '..', 'plugins', 'VariablePlugin'),
     android_two_project = path.join(__dirname, '..', 'projects', 'android_two', '*'),
+    android_two_no_perms_project = path.join(__dirname, '..', 'projects', 'android_two_no_perms', '*'),
     ios_plist_project = path.join(__dirname, '..', 'projects', 'ios-plist', '*'),
     ios_config_xml = path.join(__dirname, '..', 'projects', 'ios-config-xml', '*'),
     plugins_dir = path.join(temp, 'cordova', 'plugins');
@@ -329,14 +331,73 @@ describe('config-changes module', function() {
                 expect(munge_params[2]['API_KEY']).toEqual('canucks');
             });
             it('should not call pruneXML for a config munge that another plugin depends on', function() {
+                shell.cp('-rf', android_two_no_perms_project, temp);
+                shell.cp('-rf', childrenplugin, plugins_dir);
+                shell.cp('-rf', shareddepsplugin, plugins_dir);
+
+                // Run through and "install" two plugins (they share a permission for INTERNET)
+                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'multiple-children', 'android', {});
+                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'shared-deps-multi-child', 'android', {});
+                configChanges.process(plugins_dir, temp, 'android');
+
+                // Now set up an uninstall for multi-child plugin
+                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'multiple-children', 'android');
+                configChanges.process(plugins_dir, temp, 'android');
+                var am_xml = new et.ElementTree(et.XML(fs.readFileSync(path.join(temp, 'AndroidManifest.xml'), 'utf-8')));
+                var permission = am_xml.find('./uses-permission');
+                expect(permission).toBeDefined();
+                expect(permission.attrib['android:name']).toEqual('android.permission.INTERNET');
             });
             it('should not call pruneXML for a config munge targeting a config file that does not exist', function() {
+                shell.cp('-rf', android_two_project, temp);
+                // install a plugin
+                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin', 'android', {});
+                configChanges.process(plugins_dir, temp, 'android');
+                // set up an uninstall for the same plugin
+                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin', 'android', {});
+
+                var spy = spyOn(fs, 'readFileSync').andCallThrough();
+                configChanges.process(plugins_dir, temp, 'android');
+
+                expect(spy).not.toHaveBeenCalledWith(path.join(temp, 'res', 'xml', 'plugins.xml'), 'utf-8');
             });
             it('should remove uninstalled plugins from installed plugins list', function() {
+                shell.cp('-rf', varplugin, plugins_dir);
+                // install the var plugin
+                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'VariablePlugin', 'android', {"API_KEY":"eat my shorts"});
+                configChanges.process(plugins_dir, temp, 'android');
+                // queue up an uninstall for the same plugin
+                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'VariablePlugin', 'android');
+                configChanges.process(plugins_dir, temp, 'android');
+
+                var cfg = configChanges.get_platform_json(plugins_dir, 'android');
+                expect(cfg.prepare_queue.uninstalled.length).toEqual(0);
+                expect(cfg.installed_plugins['com.adobe.vars']).not.toBeDefined();
             });
             it('should only parse + remove plist plugin entries in applicably old ios projects', function() {
+                shell.cp('-rf', ios_plist_project, temp);
+                // install plugin
+                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin', 'ios', {});
+                configChanges.process(plugins_dir, temp, 'ios');
+                // set up an uninstall
+                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'DummyPlugin', 'ios');
+
+                var spy = spyOn(plist, 'parseFileSync').andReturn({Plugins:{}});
+                configChanges.process(plugins_dir, temp, 'ios');
+                expect(spy).toHaveBeenCalledWith(path.join(temp, 'SampleApp', 'PhoneGap.plist'));
             });
             it('should save changes to global config munge after completing an uninstall', function() {
+                shell.cp('-rf', android_two_project, temp);
+                shell.cp('-rf', varplugin, plugins_dir);
+                // install a plugin
+                configChanges.add_installed_plugin_to_prepare_queue(plugins_dir, 'VariablePlugin', 'android', {"API_KEY":"eat my shorts"});
+                configChanges.process(plugins_dir, temp, 'android');
+                // set up an uninstall for the plugin
+                configChanges.add_uninstalled_plugin_to_prepare_queue(plugins_dir, 'VariablePlugin', 'android');
+
+                var spy = spyOn(configChanges, 'save_platform_json');
+                configChanges.process(plugins_dir, temp, 'android');
+                expect(spy).toHaveBeenCalled();
             });
         });
     });

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/6ee05039/src/util/xml-helpers.js
----------------------------------------------------------------------
diff --git a/src/util/xml-helpers.js b/src/util/xml-helpers.js
index e96fc20..ba6e5b3 100644
--- a/src/util/xml-helpers.js
+++ b/src/util/xml-helpers.js
@@ -151,7 +151,7 @@ function findChild(node, parent) {
       , i, j;
 
     for (i = 0, j = matchingKids.length ; i < j ; i++) {
-        if (exports.equalNodes(node, matchingKids[i])) {
+        if (module.exports.equalNodes(node, matchingKids[i])) {
             return matchingKids[i];
         }
     }