Skip to content

Commit

Permalink
CB-10729 Move plugin handlers tests for into platform's repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Kotikov committed Mar 1, 2016
1 parent aa2b3d3 commit 8ab75e7
Show file tree
Hide file tree
Showing 29 changed files with 786 additions and 14 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Desktop.ini
*.swp
*.class
*.jar
!/spec/fixtures/org.test.plugins.dummyplugin/src/android/TestLib.jar
# IntelliJ IDEA files
*.iml
.idea
Expand All @@ -43,3 +44,6 @@ npm-debug.log
node_modules/jshint
node_modules/promise-matchers
node_modules/jasmine-node
node_modules/rewire
node_modules/istanbul
/coverage
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin/node_modules/*
bin/templates/project/*
spec/fixtures/*
30 changes: 16 additions & 14 deletions bin/templates/cordova/lib/pluginHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var handlers = {
if (!obj.src) throw new CordovaError('<source-file> element is missing "src" attribute for plugin: ' + plugin.id);
if (!obj.targetDir) throw new CordovaError('<source-file> element is missing "target-dir" attribute for plugin: ' + plugin.id);
var dest = path.join(obj.targetDir, path.basename(obj.src));
copyNewFile(plugin.dir, obj.src, project.projectDir, dest, options && options.link);
copyNewFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
},
uninstall:function(obj, plugin, project, options) {
var dest = path.join(obj.targetDir, path.basename(obj.src));
Expand All @@ -41,7 +41,7 @@ var handlers = {
'lib-file':{
install:function(obj, plugin, project, options) {
var dest = path.join('libs', path.basename(obj.src));
copyFile(plugin.dir, obj.src, project.projectDir, dest, options && options.link);
copyFile(plugin.dir, obj.src, project.projectDir, dest, !!(options && options.link));
},
uninstall:function(obj, plugin, project, options) {
var dest = path.join('libs', path.basename(obj.src));
Expand All @@ -50,7 +50,7 @@ var handlers = {
},
'resource-file':{
install:function(obj, plugin, project, options) {
copyFile(plugin.dir, obj.src, project.projectDir, path.normalize(obj.target), options && options.link);
copyFile(plugin.dir, obj.src, project.projectDir, path.normalize(obj.target), !!(options && options.link));
},
uninstall:function(obj, plugin, project, options) {
removeFile(project.projectDir, path.normalize(obj.target));
Expand All @@ -65,22 +65,24 @@ var handlers = {
var parentDir = obj.parent ? path.resolve(project.projectDir, obj.parent) : project.projectDir;
var subDir;

if (obj.custom) {
var subRelativeDir = project.getCustomSubprojectRelativeDir(plugin.id, src);
copyNewFile(plugin.dir, src, project.projectDir, subRelativeDir, options && options.link);
subDir = path.resolve(project.projectDir, subRelativeDir);
} else {
obj.type = 'sys';
subDir = src;
if (obj.custom) {
var subRelativeDir = project.getCustomSubprojectRelativeDir(plugin.id, src);
copyNewFile(plugin.dir, src, project.projectDir, subRelativeDir, !!(options && options.link));
subDir = path.resolve(project.projectDir, subRelativeDir);
} else {
obj.type = 'sys';
subDir = src;
}

if (obj.type == 'gradleReference') {
project.addGradleReference(parentDir, subDir);
} else if (obj.type == 'sys') {
project.addSystemLibrary(parentDir, subDir);
} else {
project.addSubProject(parentDir, subDir);
} else if (obj.type == 'sys') {
project.addSystemLibrary(parentDir, subDir);
} else {
project.addSubProject(parentDir, subDir);
}

project.addSubProject(parentDir, subDir);
},
uninstall:function(obj, plugin, project, options) {
var src = obj.src;
Expand Down
15 changes: 15 additions & 0 deletions node_modules/.bin/istanbul

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions node_modules/.bin/istanbul.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"scripts": {
"test": "npm run jshint && jasmine-node --color spec/unit",
"cover": "istanbul cover --root bin/templates/cordova --print detail node_modules/jasmine-node/bin/jasmine-node -- spec/unit",
"test-build": "jasmine-node --captureExceptions --color spec/e2e",
"jshint": "node node_modules/jshint/bin/jshint bin && node node_modules/jshint/bin/jshint spec"
},
Expand All @@ -39,6 +40,7 @@
"shelljs"
],
"devDependencies": {
"istanbul": "^0.4.2",
"jasmine-node": "^1.14.5",
"jshint": "^2.6.0",
"promise-matchers": "~0",
Expand Down
69 changes: 69 additions & 0 deletions spec/fixtures/android_project/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?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"
/>

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.BROADCAST_STICKY" />

<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />

<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="org.test.DroidGap" android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden">
<intent-filter>
</intent-filter>
</activity>
</application>

<uses-sdk android:minSdkVersion="5" />
</manifest>
Empty file.
54 changes: 54 additions & 0 deletions spec/fixtures/android_project/res/xml/config.xml
Original file line number Diff line number Diff line change
@@ -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="org.apache.cordova.core.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>

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./org.test.plugins.dummyplugin/android-resource.xml
1 change: 1 addition & 0 deletions spec/fixtures/org.test.plugins.dummyplugin/extra.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extra.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" package="com.test.somelib">
<uses-sdk android:minSdkVersion="9"/>
<application/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libFile contents
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target=android-11
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1" package="com.test.somelib">
<uses-sdk android:minSdkVersion="9"/>
<application/>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libFile contents
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target=android-11
75 changes: 75 additions & 0 deletions spec/fixtures/org.test.plugins.dummyplugin/plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2013 Anis Kadri
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<plugin xmlns="http://cordova.apache.org/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="org.test.plugins.dummyplugin"
version="0.6.0">

<!-- new requirement: NO SPACES -->
<name>dummyplugin</name>
<!-- These are going to be required by plugman-registry -->
<description>my description</description>
<author>Jackson Badman</author>
<keywords>dummy,plugin</keywords>
<license>BSD</license>
<!-- end plugman-registry requirements -->

<asset src="www/dummyplugin.js" target="dummyplugin.js" />
<asset src="www/dummyplugin" target="dummyplugin" />

<config-file target="config.xml" parent="/*">
<access origin="build.phonegap.com" />
<access origin="s3.amazonaws.com" />
</config-file>

<!-- android -->
<platform name="android">
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="DummyPlugin.org.test.plugins.dummyplugin"
android:label="@string/app_name">
<intent-filter>
</intent-filter>
</activity>
</config-file>

<framework src="plugin-lib" custom="true" />
<framework src="plugin-lib2" custom="true" parent="plugin-lib" />
<framework src="extras/android/support/v7/appcompat" />
<framework src="extra.gradle" type="gradleReference" />
<resource-file src="android-resource.xml" target="res/xml/dummy.xml" />

<!-- CDV < 2.0 -->
<config-file target="res/xml/plugins.xml" parent="/plugins">
<plugin name="org.test.plugins.dummyplugin"
value="DummyPlugin.org.test.plugins.dummyplugin"/>
</config-file>

<!-- CDV 2.0+ (for now) -->
<config-file target="res/xml/config.xml" parent="/cordova/plugins">
<plugin name="org.test.plugins.dummyplugin"
value="DummyPlugin.org.test.plugins.dummyplugin"/>
</config-file>

<source-file src="src/android/DummyPlugin.java"
target-dir="src/com/phonegap/plugins/dummyplugin" />
<lib-file src="src/android/TestLib.jar" />
</platform>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./org.test.plugins.dummyplugin/src/android/DummyPlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./org.test.plugins.dummyplugin/src/android/TestLib.jar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./org.test.plugins.dummyplugin/www/dummyplugin.js
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8ab75e7

Please sign in to comment.