cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [5/6] git commit: Tests for variable substitution
Date Wed, 20 Mar 2013 22:55:53 GMT
Tests for variable substitution


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

Branch: refs/heads/master
Commit: aeac68b207b197148d3a655be980c3cf8611acd5
Parents: 7ef9b8f
Author: Brett Rudd <brettrudd@gmail.com>
Authored: Wed Mar 20 13:09:30 2013 -0700
Committer: Brett Rudd <brettrudd@gmail.com>
Committed: Wed Mar 20 13:09:30 2013 -0700

----------------------------------------------------------------------
 test/android-one-install.js                      |   40 +++++++++++++---
 test/android-two-install.js                      |   16 +++---
 test/ios-install.js                              |   28 ++++++------
 test/ios-uninstall.js                            |    4 +-
 test/plugins/ChildBrowser/plugin.xml             |    4 +-
 test/projects/android_one/AndroidManifest.xml    |    2 +
 test/projects/ios/SampleApp/SampleApp-Info.plist |    2 +
 7 files changed, 62 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/android-one-install.js
----------------------------------------------------------------------
diff --git a/test/android-one-install.js b/test/android-one-install.js
index 79ee275..bb8b2a6 100644
--- a/test/android-one-install.js
+++ b/test/android-one-install.js
@@ -64,14 +64,14 @@ exports['should install webless plugin'] = function (test) {
     var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
     dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
 
-    android.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+    android.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et,
{ APP_ID: 12345 });
 
     test.done();
 }
 
 exports['should move the js file'] = function (test) {
     var jsPath = path.join(test_dir, 'projects', 'android_one', 'assets', 'www', 'childbrowser.js');
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
     fs.stat(jsPath, function(err, stats) {
         test.ok(!err);
         test.ok(stats.isFile());
@@ -80,7 +80,7 @@ exports['should move the js file'] = function (test) {
 }
 
 exports['should move the directory'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var assetPath = path.join(test_dir, 'projects', 'android_one', 'assets', 'www', 'childbrowser');
 
@@ -92,7 +92,7 @@ exports['should move the directory'] = function (test) {
 }
 
 exports['should move the src file'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var javaPath = path.join(test_dir, 'projects', 'android_one', 'src', 'com', 'phonegap',
'plugins', 'childBrowser', 'ChildBrowser.java');
     test.ok(fs.statSync(javaPath));
@@ -100,7 +100,7 @@ exports['should move the src file'] = function (test) {
 }
 
 exports['should add ChildBrowser to plugins.xml'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var pluginsXmlPath = path.join(test_dir, 'projects', 'android_one', 'res', 'xml', 'plugins.xml');
     var pluginsTxt = fs.readFileSync(pluginsXmlPath, 'utf-8'),
@@ -113,7 +113,7 @@ exports['should add ChildBrowser to plugins.xml'] = function (test) {
 }
 
 exports['should add ChildBrowser to AndroidManifest.xml'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var manifestPath = path.join(test_dir, 'projects', 'android_one', 'AndroidManifest.xml');
     var manifestTxt = fs.readFileSync(manifestPath, 'utf-8'),
@@ -132,7 +132,7 @@ exports['should add ChildBrowser to AndroidManifest.xml'] = function (test)
{
 }
 
 exports['should add whitelist hosts'] = function (test) {
-	android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+	android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var pluginsXmlPath = path.join(test_dir, 'projects', 'android_one', 'res', 'xml', 'plugins.xml');
     var pluginsTxt = fs.readFileSync(pluginsXmlPath, 'utf-8'),
@@ -140,6 +140,30 @@ exports['should add whitelist hosts'] = function (test) {
 
     test.equal(pluginsDoc.findall("access").length, 2, "/access");
 	test.equal(pluginsDoc.findall("access")[0].attrib["origin"], "build.phonegap.com")
-    test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "s3.amazonaws.com")
+    test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "12345.s3.amazonaws.com")
+    test.done();
+}
+
+exports['should search/replace plugin.xml'] = function (test) {
+	android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
+
+    var pluginsXmlPath = path.join(test_dir, 'projects', 'android_one', 'res', 'xml', 'plugins.xml');
+    var pluginsTxt = fs.readFileSync(pluginsXmlPath, 'utf-8'),
+        pluginsDoc = new et.ElementTree(et.XML(pluginsTxt));
+
+    test.equal(pluginsDoc.findall("access").length, 2, "/access");
+	test.equal(pluginsDoc.findall("access")[0].attrib["origin"], "build.phonegap.com")
+    test.equal(pluginsDoc.findall("access")[1].attrib["origin"], "12345.s3.amazonaws.com")
+    test.done();
+}
+
+exports['should search/replace manifest.xml files'] = function (test) {
+	android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
+
+    var manifestXmlPath = path.join(test_dir, 'projects', 'android_one', 'AndroidManifest.xml');
+    var manifestTxt = fs.readFileSync(manifestXmlPath, 'utf-8'),
+        manifestDoc = new et.ElementTree(et.XML(manifestTxt));
+
+	test.equal(manifestDoc.findall("appid")[0].attrib["value"], "12345")
     test.done();
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/android-two-install.js
----------------------------------------------------------------------
diff --git a/test/android-two-install.js b/test/android-two-install.js
index b01cbbd..b8b4c9d 100644
--- a/test/android-two-install.js
+++ b/test/android-two-install.js
@@ -65,7 +65,7 @@ exports['should install webless plugin'] = function (test) {
     var dummy_xml_path = path.join(test_dir, 'plugins', 'WeblessPlugin', 'plugin.xml')
     dummy_plugin_et  = new et.ElementTree(et.XML(fs.readFileSync(dummy_xml_path, 'utf-8')));
 
-    android.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et);
+    android.handlePlugin('install', test_project_dir, dummy_plugin_dir, dummy_plugin_et,
{ APP_ID: 12345 });
 
     test.done();
 }
@@ -73,7 +73,7 @@ exports['should install webless plugin'] = function (test) {
 exports['should move the js file'] = function (test) {
     var jsPath = path.join(test_dir, 'projects', 'android_two', 'assets', 'www', 'childbrowser.js');
 
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
     fs.stat(jsPath, function(err, stats) {
         test.ok(!err);
         test.ok(stats.isFile());
@@ -94,7 +94,7 @@ exports['should move the directory'] = function (test) {
 }
 
 exports['should move the src file'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var javaPath = path.join(test_dir, 'projects', 'android_two', 'src', 'com', 'phonegap',
'plugins', 'childBrowser', 'ChildBrowser.java');
     test.ok(fs.statSync(javaPath));
@@ -102,7 +102,7 @@ exports['should move the src file'] = function (test) {
 }
 
 exports['should add ChildBrowser to config.xml'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var pluginsXmlPath = path.join(test_dir, 'projects', 'android_two', 'res', 'xml', 'config.xml');
     var pluginsTxt = fs.readFileSync(pluginsXmlPath, 'utf-8'),
@@ -115,7 +115,7 @@ exports['should add ChildBrowser to config.xml'] = function (test) {
 }
 
 exports['should add ChildBrowser to AndroidManifest.xml'] = function (test) {
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var manifestPath = path.join(test_dir, 'projects', 'android_two', 'AndroidManifest.xml');
     var manifestTxt = fs.readFileSync(manifestPath, 'utf-8'),
@@ -136,7 +136,7 @@ exports['should add ChildBrowser to AndroidManifest.xml'] = function (test)
{
 exports['should not install a plugin that is already installed'] = function (test) {
     var jsPath = path.join(test_dir, 'projects', 'android_two', 'assets', 'www', 'childbrowser.js');
 
-    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
     
     test.throws(function() {android.handlePlugin('install', test_project_dir, test_plugin_dir,
plugin_et);}, /already installed/);
 
@@ -144,7 +144,7 @@ exports['should not install a plugin that is already installed'] = function
(tes
 }
 
 exports['should add whitelist hosts'] = function (test) {
-	android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+	android.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID:
12345 });
 
     var pluginsXmlPath = path.join(test_dir, 'projects', 'android_two', 'res', 'xml', 'config.xml');
     var pluginsTxt = fs.readFileSync(pluginsXmlPath, 'utf-8'),
@@ -152,6 +152,6 @@ exports['should add whitelist hosts'] = function (test) {
 
     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.equal(pluginsDoc.findall("access")[2].attrib["origin"], "12345.s3.amazonaws.com")
     test.done();
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/ios-install.js
----------------------------------------------------------------------
diff --git a/test/ios-install.js b/test/ios-install.js
index e625fe9..438f48f 100644
--- a/test/ios-install.js
+++ b/test/ios-install.js
@@ -65,14 +65,14 @@ exports['should install webless plugin'] = function (test) {
     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('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);
+    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));
@@ -81,7 +81,7 @@ exports['should move the js file'] = function (test) {
 
 exports['should move the source files'] = function (test) {
     // run the platform-specific function
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    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'))
@@ -92,7 +92,7 @@ exports['should move the source files'] = function (test) {
 
 exports['should move the header files'] = function (test) {
     // run the platform-specific function
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    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'));
@@ -103,7 +103,7 @@ exports['should move the header files'] = function (test) {
 
 exports['should move the xib file'] = function (test) {
     // run the platform-specific function
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345
});
 
     test.ok(fs.statSync(resDir + '/ChildBrowserViewController.xib'));
     test.done();
@@ -111,7 +111,7 @@ exports['should move the xib file'] = function (test) {
 
 exports['should move the bundle'] = function (test) {
     // run the platform-specific function
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345
});
 
     var bundle = fs.statSync(resDir + '/ChildBrowser.bundle');
 
@@ -122,7 +122,7 @@ exports['should move the bundle'] = function (test) {
 
 exports['should edit PhoneGap.plist'] = function (test) {
     // run the platform-specific function
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    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);
@@ -132,7 +132,7 @@ exports['should edit PhoneGap.plist'] = function (test) {
         
     test.equal(obj.ExternalHosts.length, 2)    
     test.equal(obj.ExternalHosts[0], "build.phonegap.com")
-    test.equal(obj.ExternalHosts[1], "s3.amazonaws.com")
+    test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")
 
     test.done();
 }
@@ -172,7 +172,7 @@ exports['should edit config.xml even when using old <plugins-plist>
approach'] =
     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('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'),
@@ -183,14 +183,14 @@ exports['should edit config.xml even when using old <plugins-plist>
approach'] =
     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.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);
+    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et, { APP_ID: 12345
});
 
     var projPath = test_project_dir + '/SampleApp.xcodeproj/project.pbxproj';
 
@@ -205,7 +205,7 @@ exports['should edit the pbxproj file'] = function (test) {
 
 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);
+    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"),
@@ -225,7 +225,7 @@ exports['should add the framework references to the pbxproj file'] = function
(t
 
 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);
+    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"),
@@ -251,7 +251,7 @@ exports['should add the framework references with weak option to the pbxproj
fil
 }
 
 exports['should not install a plugin that is already installed'] = function (test) {
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    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/

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/ios-uninstall.js
----------------------------------------------------------------------
diff --git a/test/ios-uninstall.js b/test/ios-uninstall.js
index 4de23a6..8d7692e 100644
--- a/test/ios-uninstall.js
+++ b/test/ios-uninstall.js
@@ -125,7 +125,7 @@ exports['should remove the bundle'] = function (test) {
 
 exports['should edit PhoneGap.plist'] = function (test) {
     // run the platform-specific function
-    ios.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+    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';
@@ -136,7 +136,7 @@ exports['should edit PhoneGap.plist'] = function (test) {
         
     test.equal(obj.ExternalHosts.length, 2)    
     test.equal(obj.ExternalHosts[0], "build.phonegap.com")
-    test.equal(obj.ExternalHosts[1], "s3.amazonaws.com")
+    test.equal(obj.ExternalHosts[1], "12345.s3.amazonaws.com")
 
     test.done();
 }

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/plugins/ChildBrowser/plugin.xml
----------------------------------------------------------------------
diff --git a/test/plugins/ChildBrowser/plugin.xml b/test/plugins/ChildBrowser/plugin.xml
index 9e87f10..afd4d0b 100644
--- a/test/plugins/ChildBrowser/plugin.xml
+++ b/test/plugins/ChildBrowser/plugin.xml
@@ -28,8 +28,8 @@
     <asset src="www/childbrowser.js" target="childbrowser.js" />
     <asset src="www/childbrowser" target="childbrowser" />
 
-	<access origin="build.phonegap.com" />
-	<access origin="s3.amazonaws.com" />
+	  <access origin="build.phonegap.com" />
+	  <access origin="$APP_ID.s3.amazonaws.com" />
 	
     <!-- android -->
     <platform name="android">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/projects/android_one/AndroidManifest.xml
----------------------------------------------------------------------
diff --git a/test/projects/android_one/AndroidManifest.xml b/test/projects/android_one/AndroidManifest.xml
index 0c52803..0979b02 100644
--- a/test/projects/android_one/AndroidManifest.xml
+++ b/test/projects/android_one/AndroidManifest.xml
@@ -48,6 +48,8 @@
 
     <uses-feature android:name="android.hardware.camera" />
     <uses-feature android:name="android.hardware.camera.autofocus" />
+    
+    <appid value="$APP_ID" />
 
     <application android:icon="@drawable/icon" android:label="@string/app_name"
     	android:debuggable="true">

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/aeac68b2/test/projects/ios/SampleApp/SampleApp-Info.plist
----------------------------------------------------------------------
diff --git a/test/projects/ios/SampleApp/SampleApp-Info.plist b/test/projects/ios/SampleApp/SampleApp-Info.plist
index 6010b61..08b9ee3 100644
--- a/test/projects/ios/SampleApp/SampleApp-Info.plist
+++ b/test/projects/ios/SampleApp/SampleApp-Info.plist
@@ -74,5 +74,7 @@
 	<string></string>
 	<key>NSMainNibFile~ipad</key>
 	<string></string>
+	<key>AppId</key>
+	<string>$APP_ID</string>
 </dict>
 </plist>


Mime
View raw message