diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..763a8e94 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,17 @@ +{ + "parser": "babel-eslint", + "env": { "browser": true }, + "rules": { + "quotes": 0, + "strict": 0, + "no-underscore-dangle": 0, + "eqeqeq": 0, + "camelcase": 0, + "consistent-return": 0, + "new-cap": 0 + }, + "globals": { + "module": true, + "require": false + } +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 83631f70..c4c53182 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ testbed/plugins testbed/hooks node_modules testbed/ul_web_hooks/ -.installed +.installed \ No newline at end of file diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 00000000..d2e9477e --- /dev/null +++ b/.jscsrc @@ -0,0 +1,40 @@ +{ + "fileExtensions": [".js", ".jsx"], + "requireCurlyBraces": [ "if", "else", "for", "while", "do", "try", "catch" ], + "requireSpaceAfterKeywords": [ "if", "else", "for", "while", "do", "switch", "return", "try", "catch" ], + "requireSpaceBeforeBlockStatements": true, + "requireParenthesesAroundIIFE": true, + "requireSpacesInConditionalExpression": { "afterTest": true, "beforeConsequent": true, "afterConsequent": true, "beforeAlternate": true }, + "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + "requireSpacesInFunction": { "beforeOpeningCurlyBrace": true }, + "disallowSpacesInFunction": { "beforeOpeningRoundBrace": true }, + "disallowSpacesInsideParentheses": true, + "requireSpacesInsideObjectBrackets": "all", + "requireSpacesInsideArrayBrackets": "all", + "disallowSpaceAfterObjectKeys": true, + "requireCommaBeforeLineBreak": true, + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--", ";"], + "disallowSpaceBeforeBinaryOperators": [ "," ], + "requireSpaceBeforeBinaryOperators": [ "=", "+", "-", "/", "*", "==", "===", "!=", "!==" ], + "requireSpaceAfterBinaryOperators": [ "=", ",", "+", "-", "/", "*", "==", "===", "!=", "!==" ], + "disallowMultipleLineStrings": true, + "validateLineBreaks": "LF", + "disallowMixedSpacesAndTabs": "smart", + "disallowTrailingWhitespace": true, + "disallowTrailingComma": true, + "requireKeywordsOnNewLine": [ "else" ], + "requireLineFeedAtFileEnd": true, + "requireCapitalizedConstructors": true, + "safeContextKeyword": [ "self" ], + "disallowYodaConditions": true, + "requireSpaceAfterLineComment": true, + "disallowNewlineBeforeBlockStatements": true +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..8efaee88 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,26 @@ +sudo: false +language: node_js +cache: + directories: + - node_modules +notifications: + email: false +node_js: + - '6' + - '5' + - '4' +before_install: + - npm i -g npm@^2.0.0 +before_script: + - npm prune +script: + - npm run prerelease +after_success: + - 'curl -Lo travis_after_all.py https://git.io/travis_after_all' + - python travis_after_all.py + - export $(cat .to_export_back) &> /dev/null + - test $TRAVIS_PULL_REQUEST = false \ + && npm run semantic-release +branches: + only: + - master \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..7139c6b2 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,28 @@ +# Development Conventions + +This document outlines our development processes. + +## Pull Requests + +All changes to this project should be made in the form of pull requests against master. Use snake-case prefixed by 'feat/' or 'fix/' for features/fixes. Feel free to use any of the commit types listed [here](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#type) as well. Note that when pull requests are merged in they will be automatically released to npm by (Travis CI)[https://travis-ci.org/] and (semantic-release)[https://github.com/semantic-release/semantic-release] so make sure to fully test. + +## Commit Messages + +Please format your commit messages to match [Angular's Conventions](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#-git-commit-guidelines). These messages are parsed using semantic release to determine version numbers so it is important that you stick to them exactly. We recommend using the `npm run commit` script installed in this project to draft conformant messages. + +## Linting + +The style of all js files in this project are strictly checked using [jscs](http://jscs.info/) and [eslint](http://eslint.org/) before any pull request/release is made. You can manually check your local clone using the `gulp lint` command (don't forget to `nom install -g gulp` if you haven't already). Many problems can be automatically fixed by `gulp jscs-fix`. Don't forget to commit before running jscs-fix in case you end up needing to back out changes. + +## Testing + +See [tests-harness/README.md](https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/blob/master/tests-harness/README.md) for details on how to run this project's test suite. Please run the test suite before merging any branches. + +## Updating IOS dependencies + +This project depends on [ios-branch-deep-linking](https://github.com/BranchMetrics/ios-branch-deep-linking). To upgrade that dependency a [release](https://github.com/BranchMetrics/ios-branch-deep-linking/releases) of it run the following script: + +```shell +# is the name of the release. e,g, '0.12.5' +$ src/ios/dependencies/update.sh +``` \ No newline at end of file diff --git a/NPMdeployment.txt b/NPMdeployment.txt deleted file mode 100644 index 0f7bf0ec..00000000 --- a/NPMdeployment.txt +++ /dev/null @@ -1,5 +0,0 @@ -NPM deployment - -1. comment out iOS framework in plugin.xml -2. change header file references of Cordova iOS libs from to "Branch.h" -3. remove "../Fabric" from all Fabric related imports \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..5a44a1aa --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,147 @@ +var gulp = require('gulp'); +var fs = require('fs'); +var sourcemaps = require('gulp-sourcemaps'); +var babel = require('gulp-babel'); +var eslint = require('gulp-eslint'); +var jscs = require('gulp-jscs'); + +gulp.task('prerelease', [ 'setupNpm', 'babel', 'lint' ]); + +// ----------------------------------------------------------------------------- +// setup for development use +gulp.task('setupDev', () => { + getDevPluginXML(); + setIosNpmOrDev('dev'); +}) + +// setup for npm deployment +gulp.task('setupNpm', () => { + genNpmPluginXML(); + setIosNpmOrDev('npm'); +}); + +// generate plugin.xml for use as a cordova plugin +// here we explode the contents of the frameworks +function genNpmPluginXML() { + var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); + + var files = []; + var root = 'src/ios/dependencies/'; + files = files.concat(emitFiles(root + 'Fabric/')); + files = files.concat(emitFiles(root + 'Branch-SDK/')); + files = files.concat(emitFiles(root + 'Branch-SDK/Requests/')); + + var newLineIndent = '\n '; + xml = xml.replace('', newLineIndent + + files.join(newLineIndent)); + + fs.writeFileSync('plugin.xml', xml); +}; + +// generate plugin.xml for local development +// here we reference the frameworks instead of all the files directly +function getDevPluginXML() { + var xml = fs.readFileSync('plugin.template.xml', 'utf-8'); + + xml = xml.replace('', + ''); + + fs.writeFileSync('plugin.xml', xml); +}; + +function setIosNpmOrDev(npmOrDev) { + if (npmOrDev === 'npm') { + content = '#define BRANCH_NPM true'; + } +else if (npmOrDev === 'dev') { + content = '//empty'; + } +else { + throw new Error('expected deployed|local, not ' + deployedOrLocal); + } + fs.writeFileSync('src/ios/BranchNPM.h', content + '\n'); +} + +// emit array of cordova file references for all .h/.m files in path +function emitFiles(path) { + var ret = []; + for (filename of fs.readdirSync(path)) { + var fileType = null; + if (filename.match(/\.m$/)) { + fileType = 'source'; + } +else if (filename.match(/\.h$/) || filename.match(/\.pch$/)) { + fileType = 'header'; + } + if (fileType) { + ret.push('<' + fileType + '-file src="' + path + filename + '" />'); + } + } + ret.push(''); + return ret; +} + +// ----------------------------------------------------------------------------- +// copy resources and compile es6 from corresponding directories +babelTasks = []; // list of all babel tasks so we can build all of them +function babelize(taskName, dir) { + babelTasks.push(taskName + '-babel'); + if (!dir) { + dir = taskName; + } + var srcDir = dir + '.es6/'; + var srcPattern = dir + '.es6/**/*.js' + var destDir = dir + '/'; + gulp.task(taskName + '-copy', () => { + return gulp.src(srcDir + '**/*.*').pipe(gulp.dest(destDir)); + }); + gulp.task(taskName + '-babel', [ taskName + '-copy' ], () => { + return gulp.src(srcPattern) + .pipe(sourcemaps.init()) + .pipe(babel({ + presets: [ 'es2015', 'stage-2' ], + plugins: [ 'transform-runtime' ] // needed for generators etc + })) + .pipe(sourcemaps.write('.')) + .pipe(gulp.dest(destDir)); + }); +} + +babelize('hooks'); +babelize('www'); +babelize('tests'); +babelize('testbed', 'testbed/www/js'); +gulp.task('babel', babelTasks); + +// ----------------------------------------------------------------------------- +// linting + +gulp.task('lint', [ 'eslint', 'jscs-lint' ]); + +var srcs = [ + '**/*.js', + '!node_modules/**', + '!testbed/platforms/ios/cordova/node_modules/**' +]; + +gulp.task('eslint', () => { + return gulp.src(srcs) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}); + +function jscsTask(fix) { + var ret = gulp.src(srcs) + .pipe(jscs({ fix: fix })) + .pipe(jscs.reporter()) + .pipe(jscs.reporter('fail')); + + if (fix) { + ret.pipe(gulp.dest('.')); + } + return ret; +} + +gulp.task('jscs-fix', jscsTask.bind(null, true)); +gulp.task('jscs-lint', jscsTask.bind(null, false)); diff --git a/package.json b/package.json index c55b0068..69d63e5c 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "version": "2.1.10", "name": "branch-cordova-sdk", "description": "Branch Metrics Cordova SDK", "main": "www/branch.js", - "homepage": "https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK", + "version": "0.0.0-semantic-release", + "homepage": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking", "repository": { "type": "git", - "url": "https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git" + "url": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking.git" }, "bugs": { - "url": "https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues" + "url": "https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking/issues" }, "keywords": [ "ecosystem:cordova", @@ -30,6 +30,11 @@ "ios" ], "license": "MIT", + "scripts": { + "prerelease": "gulp prerelease", + "commit": "git-cz", + "semantic-release": "semantic-release pre && npm publish && semantic-release post" + }, "dependencies": { "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", @@ -38,10 +43,27 @@ "xml2js": "^0.4.16" }, "devDependencies": { + "babel-eslint": "^6.1.2", + "babel-plugin-transform-runtime": "^6.12.0", + "babel-polyfill": "^6.13.0", + "babel-preset-es2015": "^6.9.0", + "babel-preset-stage-2": "^6.11.0", + "commitizen": "^2.8.2", + "cz-conventional-changelog": "^1.1.6", + "gulp": "^3.9.1", + "gulp-babel": "^6.1.2", + "gulp-eslint": "^3.0.1", + "gulp-jscs": "^4.0.0", + "gulp-sourcemaps": "^1.6.0", "mkpath": "^1.0.0", "node-version-compare": "^1.0.1", "plist": "^1.2.0", - "rimraf": "^2.5.2", - "xml2js": "^0.4.16" + "semantic-release": "^4.3.5", + "wd": "^0.4.0" + }, + "config": { + "commitizen": { + "path": "node_modules/cz-conventional-changelog" + } } } diff --git a/plugin.template.xml b/plugin.template.xml new file mode 100644 index 00000000..bd03c0ef --- /dev/null +++ b/plugin.template.xml @@ -0,0 +1,111 @@ + + + + + + + branch-cordova-sdk + Branch SDK Plugin + Apache 2.0 + cordova,branch + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git + https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK/issues + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $BRANCH_KEY + + + + + CFBundleURLName + io.branch.sdk + CFBundleURLSchemes + + $URI_SCHEME + + + + + + + + + + + diff --git a/plugin.xml b/plugin.xml index 17420318..91520fc8 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,3 +1,5 @@ + + - - diff --git a/src/ios/AppDelegate+BranchSdk.m b/src/ios/AppDelegate+BranchSdk.m index bd0a480e..7e66c75a 100644 --- a/src/ios/AppDelegate+BranchSdk.m +++ b/src/ios/AppDelegate+BranchSdk.m @@ -7,7 +7,14 @@ // #import "AppDelegate.h" -#import + +#import "BranchNPM.h" + +#ifdef BRANCH_NPM + #import "Branch.h" +#else + #import +#endif @interface AppDelegate (BranchSDK) diff --git a/src/ios/BranchNPM.h b/src/ios/BranchNPM.h new file mode 100644 index 00000000..90fe1bcc --- /dev/null +++ b/src/ios/BranchNPM.h @@ -0,0 +1 @@ +//empty diff --git a/src/ios/BranchSDK.h b/src/ios/BranchSDK.h index ba26e108..e9944313 100644 --- a/src/ios/BranchSDK.h +++ b/src/ios/BranchSDK.h @@ -5,9 +5,18 @@ // Copyright © 2016 Branch Metrics. All rights reserved. // -#import -#import -#import +#import "BranchNPM.h" + +#ifdef BRANCH_NPM + #import "Branch.h" + #import "BranchLinkProperties.h" + #import "BranchUniversalObject.h" +#else + #import + #import + #import +#endif + #import @interface BranchSDK : CDVPlugin diff --git a/src/ios/dependencies/update.sh b/src/ios/dependencies/update.sh new file mode 100755 index 00000000..7a133115 --- /dev/null +++ b/src/ios/dependencies/update.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +#update the ios dependencies in this directory to those storied under passed tag on github + +#fail fast on errors +set -e + +#cd into directory containing this script +cd "$(dirname "$0")" + +#check first parameter is set to tag to download +if [ -z ${1+x} ]; then + echo "You must pass this script the tag to download" + exit -1 +else + echo "downloading tag '$1'" +fi + +#this is the git tag that we'll be updating to, +#we expecct it to be the first parameter to this script +tag_name=$1 +tag_url="https://github.com/BranchMetrics/ios-branch-deep-linking/archive/$tag_name.zip" +#extract is where we stick the extracted archive of the tag +tag_extract=ios-branch-deep-linking-$tag_name + + +#check that tag exists +tag_url_status=`curl -L -o /dev/null --silent --head --write-out '%{http_code}\n' $tag_url` +if [ $tag_url_status = "200" ]; then + echo "found tag" +else + echo "could not find '$tag_url'" + echo "curl returned status '$tag_url_status'" + exit -1 +fi + +#this will overwripte existing versions of sdk.zip +curl -L -o sdk.zip $tag_url + +#delete old extracted content or do nothing if we don't have any +rm -rf $tag_extract + +#silently (-q) extract download +unzip -q -x sdk.zip +rm -f sdk.zip + +#copy in new dependencies +rm -rf Branch-SDK +mv $tag_extract/Branch-SDK/Branch-SDK . + +rm -rf Branch.framework +mv $tag_extract/Branch.framework . + +rm -rf Fabric +mv $tag_extract/Branch-SDK/Fabric . + +#clean up +rm -rf $tag_extract + +#replace all instances of '#import "../Fabric/' with '#import "' in .m files +find . -type f -name '*.m' \ + -exec perl -i -pe 's/\#import \"\.\.\/Fabric\//#import "/' '{}' + diff --git a/testbed/init.sh b/testbed/init.sh old mode 100644 new mode 100755 diff --git a/tests-harness/.gitignore b/tests-harness/.gitignore new file mode 100644 index 00000000..d04ff6f0 --- /dev/null +++ b/tests-harness/.gitignore @@ -0,0 +1,4 @@ + +platforms +plugins +node_modules \ No newline at end of file diff --git a/tests-harness/README.md b/tests-harness/README.md new file mode 100644 index 00000000..136a53f9 --- /dev/null +++ b/tests-harness/README.md @@ -0,0 +1,40 @@ +# Running Plugin Tests + +These tests can currently only run on os x since xcode is not available on other plaforms. You may be able to get the android tests working on other machines by following a similar process to the one outlined here. + + 1. Install [homebrew](http://brew.sh/). If you already have it run `brew update` to get the latest version. + + 1. Run `brew doctor` and fix any problems that it reports. + + 1. Install java and the android development kit: + +```sh +brew install cask +brew cask install java # this should be java 8 +brew install ant maven gradle android-sdk android-ndk +android update sdk --no-ui +``` + + 1. Install node (`brew install node`) and cordova (`npm install -g cordova`) if you haven't already. + + 1. Run `android` check off `android 6.0`, click `Install Packages`, and accept ALL licenses in the next screen before clicking install again to complete installation. + + 1. Run `android avd` and create an image with name `nexus-intel` device `Galaxy Nexus (4.65"...` target `android 6.0 - API Level 23` CPU/ABI `Intel Atom (x86_64)` no skin size `200mb` and `Use Host GPU` checked off. + + 1. Run `npm install` in the project root. + + 1. Run the following commands in the tests-harness directory of this project: + +```sh +cordova prepare +cordova plugin add ../ --link --variable BRANCH_KEY=key_live_fnmRM1FXtu11t6e4LU8WsldpvDcA0bzv --variable URI_SCHEME=testbed +cordova plugin add ../tests --link +cordova compile +``` + + 1. Finally run the tests: + +``` +./android-test.sh +./ios-test.sh +``` \ No newline at end of file diff --git a/tests-harness/android-test.sh b/tests-harness/android-test.sh new file mode 100755 index 00000000..ecd3bbe8 --- /dev/null +++ b/tests-harness/android-test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +rm -rf platforms android +cordova prepare android +cordova run android --emulator \ No newline at end of file diff --git a/tests-harness/config.xml b/tests-harness/config.xml new file mode 100644 index 00000000..35d3cf6e --- /dev/null +++ b/tests-harness/config.xml @@ -0,0 +1,29 @@ + + + Branch Cordova Test Harness + + A testing harness for the Branch Cordova Deep Linking project. + + + Amit Bansil + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests-harness/hooks/README.md b/tests-harness/hooks/README.md new file mode 100644 index 00000000..574ad4c9 --- /dev/null +++ b/tests-harness/hooks/README.md @@ -0,0 +1,23 @@ + +# Cordova Hooks + +Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands. See Hooks Guide for more details: http://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html#Hooks%20Guide. diff --git a/tests-harness/ios-test.sh b/tests-harness/ios-test.sh new file mode 100755 index 00000000..c2c8fbd2 --- /dev/null +++ b/tests-harness/ios-test.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +rm -rf platforms ios +cordova prepare ios +cordova run ios --emulator \ No newline at end of file diff --git a/tests-harness/www/css/index.css b/tests-harness/www/css/index.css new file mode 100644 index 00000000..51daa797 --- /dev/null +++ b/tests-harness/www/css/index.css @@ -0,0 +1,115 @@ +/* + * 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. + */ +* { + -webkit-tap-highlight-color: rgba(0,0,0,0); /* make transparent link selection, adjust last value opacity 0 to 1.0 */ +} + +body { + -webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */ + -webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */ + -webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */ + background-color:#E4E4E4; + background-image:linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + background-image:-webkit-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + background-image:-ms-linear-gradient(top, #A7A7A7 0%, #E4E4E4 51%); + background-image:-webkit-gradient( + linear, + left top, + left bottom, + color-stop(0, #A7A7A7), + color-stop(0.51, #E4E4E4) + ); + background-attachment:fixed; + font-family:'HelveticaNeue-Light', 'HelveticaNeue', Helvetica, Arial, sans-serif; + font-size:12px; + height:100%; + margin:0px; + padding:0px; + text-transform:uppercase; + width:100%; +} + +/* Portrait layout (default) */ +.app { + background:url(../img/logo.png) no-repeat center top; /* 170px x 200px */ + position:absolute; /* position in the center of the screen */ + left:50%; + top:50%; + height:50px; /* text area height */ + width:225px; /* text area width */ + text-align:center; + padding:180px 0px 0px 0px; /* image height is 200px (bottom 20px are overlapped with text) */ + margin:-115px 0px 0px -112px; /* offset vertical: half of image height and text area height */ + /* offset horizontal: half of text area width */ +} + +/* Landscape layout (with min-width) */ +@media screen and (min-aspect-ratio: 1/1) and (min-width:400px) { + .app { + background-position:left center; + padding:75px 0px 75px 170px; /* padding-top + padding-bottom + text area = image height */ + margin:-90px 0px 0px -198px; /* offset vertical: half of image height */ + /* offset horizontal: half of image width and text area width */ + } +} + +h1 { + font-size:24px; + font-weight:normal; + margin:0px; + overflow:visible; + padding:0px; + text-align:center; +} + +.event { + border-radius:4px; + -webkit-border-radius:4px; + color:#FFFFFF; + font-size:12px; + margin:0px 30px; + padding:2px 0px; +} + +.event.listening { + background-color:#333333; + display:block; +} + +.event.received { + background-color:#4B946A; + display:none; +} + +@keyframes fade { + from { opacity: 1.0; } + 50% { opacity: 0.4; } + to { opacity: 1.0; } +} + +@-webkit-keyframes fade { + from { opacity: 1.0; } + 50% { opacity: 0.4; } + to { opacity: 1.0; } +} + +.blink { + animation:fade 3000ms infinite; + -webkit-animation:fade 3000ms infinite; +} diff --git a/tests-harness/www/img/logo.png b/tests-harness/www/img/logo.png new file mode 100644 index 00000000..9519e7dd Binary files /dev/null and b/tests-harness/www/img/logo.png differ diff --git a/tests-harness/www/index.html b/tests-harness/www/index.html new file mode 100644 index 00000000..646f9cb2 --- /dev/null +++ b/tests-harness/www/index.html @@ -0,0 +1,49 @@ + + + + + + + + + + + Hello World + + +
+

Apache Cordova

+ +
+ + + + diff --git a/tests-harness/www/js/index.js b/tests-harness/www/js/index.js new file mode 100644 index 00000000..c31cd831 --- /dev/null +++ b/tests-harness/www/js/index.js @@ -0,0 +1,51 @@ +/* + * 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. + */ +var app = { + // Application Constructor + initialize: function() { + this.bindEvents(); + }, + // Bind Event Listeners + // + // Bind any events that are required on startup. Common events are: + // 'load', 'deviceready', 'offline', and 'online'. + bindEvents: function() { + document.addEventListener('deviceready', this.onDeviceReady, false); + }, + // deviceready Event Handler + // + // The scope of 'this' is the event. In order to call the 'receivedEvent' + // function, we must explicitly call 'app.receivedEvent(...);' + onDeviceReady: function() { + app.receivedEvent('deviceready'); + }, + // Update DOM on a Received Event + receivedEvent: function(id) { + var parentElement = document.getElementById(id); + var listeningElement = parentElement.querySelector('.listening'); + var receivedElement = parentElement.querySelector('.received'); + + listeningElement.setAttribute('style', 'display:none;'); + receivedElement.setAttribute('style', 'display:block;'); + + console.log('Received Event: ' + id); + } +}; + +app.initialize(); \ No newline at end of file diff --git a/tests/README.md b/tests/README.md deleted file mode 100644 index e6cf31de..00000000 --- a/tests/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# Running Plugin Tests - -1. Use your existing cordova app, or create a new one. -2. Add these plugins: -``` -cordova plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-test-framework.git -cordova plugin add https://github.com/BranchMetrics/Cordova-Ionic-PhoneGap-Deferred-Deep-Linking-SDK.git#:/tests -``` -3. Change the start page in `config.xml` with `` or navigate to `cdvtests/index.html` from within your app. -4. That's it. \ No newline at end of file