cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [71/91] [abbrv] git commit: Adding tests for BlackBerry 10 and fixed some errors up
Date Mon, 04 Mar 2013 19:32:51 GMT
Adding tests for BlackBerry 10 and fixed some errors up


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

Branch: refs/heads/master
Commit: b45b3dd3d7e9f8c1dab2344d67f6d055b32d2e96
Parents: 396989a
Author: Tim Kim <timk@adobe.com>
Authored: Thu Jan 31 12:47:27 2013 -0800
Committer: Tim Kim <timk@adobe.com>
Committed: Thu Jan 31 12:47:27 2013 -0800

----------------------------------------------------------------------
 platforms/bb10.js                          |   14 +++
 test/android-one-install.js                |    1 -
 test/bb10-install.js                       |   80 +++++++++++++++++++
 test/projects/BlackBerry10/www/config.xml  |   97 +++++++++++++++++++++++
 test/projects/BlackBerry10/www/plugins.xml |   35 ++++++++
 5 files changed, 226 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b45b3dd3/platforms/bb10.js
----------------------------------------------------------------------
diff --git a/platforms/bb10.js b/platforms/bb10.js
index 8d32bbc..81cc551 100644
--- a/platforms/bb10.js
+++ b/platforms/bb10.js
@@ -20,6 +20,7 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
       , sourceFiles = platformTag.findall('./source-file')
       , libFiles = platformTag.findall('./library-file')
       , configChanges = getConfigChanges(platformTag);
+      
     // find which config-files we're interested in
     Object.keys(configChanges).forEach(function (configFile) {
         if (!fs.existsSync(path.resolve(project_dir, configFile))) {
@@ -27,6 +28,13 @@ exports.handlePlugin = function (action, project_dir, plugin_dir, plugin_et)
{
         }
     });
 
+    // collision detection 
+    if(action == "install" && pluginInstalled(plugin_et, project_dir)) {
+        throw "Plugin "+plugin_id+" already installed"
+    } else if(action == "uninstall" && !pluginInstalled(plugin_et, project_dir))
{
+        throw "Plugin "+plugin_id+" not installed"
+    }
+    
     // move asset files
     assets.forEach(function (asset) {
         var srcPath = path.resolve(
@@ -141,3 +149,9 @@ function srcPath(pluginPath, filename) {
     }
 }
 
+function pluginInstalled(plugin_et, project_dir) {
+    var config_tag = plugin_et.find('./platform[@name="BlackBerry10"]/config-file[@target="config.xml"]/feature')
+    var plugin_name = config_tag.attrib.id;
+    return (fs.readFileSync(path.resolve(project_dir, 'config.xml'), 'utf8')
+           .match(new RegExp(plugin_name, "g")) != null);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b45b3dd3/test/android-one-install.js
----------------------------------------------------------------------
diff --git a/test/android-one-install.js b/test/android-one-install.js
index 59bee17..ed417c0 100644
--- a/test/android-one-install.js
+++ b/test/android-one-install.js
@@ -52,7 +52,6 @@ exports['should install webless plugin'] = function (test) {
 
 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);
     fs.stat(jsPath, function(err, stats) {
         test.ok(!err);

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b45b3dd3/test/bb10-install.js
----------------------------------------------------------------------
diff --git a/test/bb10-install.js b/test/bb10-install.js
new file mode 100644
index 0000000..cf48fe9
--- /dev/null
+++ b/test/bb10-install.js
@@ -0,0 +1,80 @@
+var fs = require('fs')
+  , path = require('path')
+  , shell = require('shelljs')
+  , et = require('elementtree')
+  , osenv = require('osenv')
+  , bb10 = require(path.join(__dirname, '..', 'platforms', 'bb10'))
+  , test_dir = path.join(osenv.tmpdir(), 'test_plugman')
+  , test_project_dir = path.join(test_dir, 'projects', 'BlackBerry10', 'www')
+  , test_plugin_dir = path.join(test_dir, 'plugins', 'cordova.echo')
+  , xml_path     = path.join(test_dir, 'plugins', 'cordova.echo', 'plugin.xml')
+  , xml_text, plugin_et
+  , srcDir = path.resolve(test_project_dir, 'ext-qnx/cordova.echo');
+  
+exports.setUp = function(callback) {
+    shell.mkdir('-p', test_dir);
+    
+    // copy the bb10 test project to a temp directory
+    shell.cp('-r', path.join(__dirname, 'projects'), test_dir);
+
+    // copy the bb10 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)
+    console.log(fs.readdirSync(test_dir));
+    shell.rm('-rf', test_dir);
+    //console.log(fs.readdirSync(test_dir));
+    callback();
+}
+
+exports['should move the source files'] = function (test) {
+    // run the platform-specific function
+    bb10.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+
+    test.ok(fs.existsSync(srcDir + '/client.js'));
+    test.ok(fs.existsSync(srcDir + '/index.js'));
+    test.ok(fs.existsSync(srcDir + '/manifest.json'));
+    test.ok(fs.existsSync(srcDir + '/device/echoJnext.so'));
+    test.ok(fs.existsSync(srcDir + '/simulator/echoJnext.so'));
+    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.done();
+}
+*/
+exports['should not install a plugin that is already installed'] = function (test) {
+    bb10.handlePlugin('install', test_project_dir, test_plugin_dir, plugin_et);
+
+    test.throws(function(){bb10.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/b45b3dd3/test/projects/BlackBerry10/www/config.xml
----------------------------------------------------------------------
diff --git a/test/projects/BlackBerry10/www/config.xml b/test/projects/BlackBerry10/www/config.xml
new file mode 100644
index 0000000..6b132c2
--- /dev/null
+++ b/test/projects/BlackBerry10/www/config.xml
@@ -0,0 +1,97 @@
+<?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.
+-->
+<!--
+  Widget Configuration Reference:
+    http://docs.blackberry.com/en/developers/deliverables/15274/
+-->
+
+<widget xmlns="http://www.w3.org/ns/widgets"
+        xmlns:rim="http://www.blackberry.com/ns/widgets"
+	version="1.0.0.0" id="cordovaExample">
+
+  <name>cordovaExample</name>
+
+  <author>Your Name Here</author>
+
+  <description>
+       A sample Apache Cordova application that responds to the deviceready event.
+  </description>
+    
+  <license href="http://opensource.org/licenses/alphabetical">
+  </license>
+
+  <!-- Cordova API -->
+  <feature id="blackberry.system" required="true" version="1.0.0.0" />
+  <feature id="org.apache.cordova" required="true" version="1.0.0" />
+  <feature id="blackberry.find" required="true" version="1.0.0.0" />
+  <feature id="blackberry.identity" required="true" version="1.0.0.0" />
+  <feature id="blackberry.identity.phone" required="true" version="1.0.0.0" />
+  <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
+  <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
+  <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
+  <feature id="blackberry.utils" required="true" version="1.0.0.0" />
+  <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
+  <feature id="blackberry.app" required="true" version="1.0.0.0" />
+  <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
+  <feature id="blackberry.system.event" required="true" version="1.0.0.0"/>
+  <feature id="blackberry.widgetcache" required="true" version="1.0.0.0"/>
+  <feature id="blackberry.media.camera" />
+  <feature id="blackberry.ui.dialog" />
+  <feature id="blackberry.connection" />
+  <feature id="blackberry.bbm.platform" />
+  <feature id="blackberry.invoke.card" />
+  <feature id="blackberry.pim.contacts" />
+  <feature id="blackberry.ui.contextmenu" />
+  <feature id="blackberry.io.filetransfer" />
+  <feature id="blackberry.io" />
+  <feature id="blackberry.invoke" />
+  <feature id="blackberry.invoked" />
+  <feature id="blackberry.push" />
+  <feature id="blackberry.media.microphone" required="true" version="1.0.0.0"/>
+  
+  <!-- Cordova API -->
+  <access subdomains="true" uri="file:///store/home" />
+  <access subdomains="true" uri="file:///SDCard" />
+
+  <!-- Expose access to all URIs, including the file and http protocols -->
+  <access subdomains="true" uri="*" />
+
+  
+  <icon rim:hover="false" src="res/icon/blackberry/icon-80.png" />
+  <icon rim:hover="true" src="res/icon/blackberry/icon-80.png" />
+
+  <rim:loadingScreen backgroundColor="#CFCFCF"
+                     foregroundImage="res/screen/blackberry/screen-225.png"
+		     onFirstLaunch="true">
+    <rim:transitionEffect type="fadeOut" />
+  </rim:loadingScreen>
+
+  <content src="index.html" />
+
+  <rim:permissions>
+    <rim:permit>use_camera</rim:permit>
+    <rim:permit>read_device_identifying_information</rim:permit>
+    <rim:permit>access_shared</rim:permit>
+    <rim:permit>read_geolocation</rim:permit>
+    <rim:permit>record_audio</rim:permit> 
+    <rim:permit>access_pimdomain_contacts</rim:permit> 
+  </rim:permissions>
+
+</widget>

http://git-wip-us.apache.org/repos/asf/cordova-plugman/blob/b45b3dd3/test/projects/BlackBerry10/www/plugins.xml
----------------------------------------------------------------------
diff --git a/test/projects/BlackBerry10/www/plugins.xml b/test/projects/BlackBerry10/www/plugins.xml
new file mode 100644
index 0000000..3d41236
--- /dev/null
+++ b/test/projects/BlackBerry10/www/plugins.xml
@@ -0,0 +1,35 @@
+<?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.
+-->
+<plugins>
+  <plugin name="App"            value="org.apache.cordova.app.App"/>
+  <plugin name="Device"         value="org.apache.cordova.device.Device"/>
+  <plugin name="Camera"         value="org.apache.cordova.camera.Camera"/>
+  <plugin name="NetworkStatus"  value="org.apache.cordova.network.Network"/>
+  <plugin name="Notification"   value="org.apache.cordova.notification.Notification"/>
+  <plugin name="Accelerometer"  value="org.apache.cordova.accelerometer.Accelerometer"/>
+  <plugin name="Geolocation"    value="org.apache.cordova.geolocation.Geolocation"/>
+  <plugin name="File"           value="org.apache.cordova.file.FileManager"/>
+  <plugin name="FileTransfer"   value="org.apache.cordova.http.FileTransfer"/>
+  <plugin name="Contacts"       value="org.apache.cordova.pim.Contact"/>
+  <plugin name="Capture"        value="org.apache.cordova.capture.MediaCapture"/>
+  <plugin name="Battery"        value="org.apache.cordova.battery.Battery"/>
+  <plugin name="Media"          value="org.apache.cordova.media.Media"/>
+  <plugin name="Globalization"  value="org.apache.cordova.globalization.Globalization"/>
+</plugins>


Mime
View raw message