Skip to content

Commit

Permalink
Merge branch 'master-src' into master-rc: open callback (#109) implem…
Browse files Browse the repository at this point in the history
…ented; close callbacks (#110) & deleteDatabase reliability (#112) on Android & iOS
  • Loading branch information
Chris Brody committed Aug 21, 2014
2 parents 198d339 + 79ebebf commit e0e9555
Show file tree
Hide file tree
Showing 8 changed files with 677 additions and 266 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.DS_Store
.plugin
.metadata/*
*.swp
*~
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,22 @@ Available for integration with SQLCipher.

# Unit test(s)

Unit testing is done in `test-www/`. To run the tests, simply do either:
Unit testing is done in `test-www/`. To run the tests from *nix shell, simply do either:

./bin/test.sh ios

or in Android:

./bin/test.sh android

To run then from a windows powershell do either

.\bin\test.ps1 android

or for Windows Phone 8:

.\bin\test.ps1 wp8

# Adapters

## Lawnchair Adapter
Expand Down
20 changes: 17 additions & 3 deletions SQLitePlugin.coffee.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ License for common Javascript: MIT or Apache
return
SQLitePlugin::transaction = (fn, error, success) ->
if !@openDBs[@dbname]
error('database not open')
return
@addTransaction new SQLitePluginTransaction(this, fn, error, success, true, false)
return
SQLitePlugin::readTransaction = (fn, error, success) ->
if !@openDBs[@dbname]
error('database not open')
return
@addTransaction new SQLitePluginTransaction(this, fn, error, success, true, true)
return
Expand All @@ -105,10 +111,17 @@ License for common Javascript: MIT or Apache
return
SQLitePlugin::open = (success, error) ->
onSuccess = () => success this
unless @dbname of @openDBs
@openDBs[@dbname] = true
cordova.exec success, error, "SQLitePlugin", "open", [ @openargs ]
cordova.exec onSuccess, error, "SQLitePlugin", "open", [ @openargs ]
else
###
for a re-open run onSuccess async so that the openDatabase return value
can be used in the success handler as an alternative to the handler's
db argument
###
nextTick () -> onSuccess();
return
SQLitePlugin::close = (success, error) ->
Expand All @@ -117,7 +130,7 @@ License for common Javascript: MIT or Apache
if @dbname of @openDBs
delete @openDBs[@dbname]
cordova.exec null, null, "SQLitePlugin", "close", [ { path: @dbname } ]
cordova.exec success, error, "SQLitePlugin", "close", [ { path: @dbname } ]
return
Expand Down Expand Up @@ -381,6 +394,7 @@ License for common Javascript: MIT or Apache
new SQLitePlugin openargs, okcb, errorcb
deleteDb: (databaseName, success, error) ->
delete SQLitePlugin::openDBs[databaseName]
cordova.exec success, error, "SQLitePlugin", "delete", [{ path: databaseName }]
### Exported API:
Expand Down
57 changes: 57 additions & 0 deletions bin/test.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Automated cordova tests. Installs the correct cordova platform,
# installs the plugin, installs the test app, and then runs it on
# a device or emulator.
#
# usage: .\bin\test.ps1 [android|ios|wp8]

# N.B. if you functionally change this script you _must_ change .\bin\test.sh too.

param([string]$platform)

if (! $platform) {
echo "usage: .\bin\test.sh [android|ios|wp8]"
exit 1
}

if (! (get-command coffee) ) {
echo "you need coffeescript. please install with:"
echo "npm install -g coffee-script"
exit 1
}

if (! (get-command cordova) ) {
echo "you need cordova. please install with:"
echo "npm install -g cordova"
exit 1
}


pushd test-www
if (!$?) { # run from the bin/ directory
echo "re-pushing"
pushd ../test-www
}
try {
# compile coffeescript
coffee --no-header -cl -o ../www ../SQLitePlugin.coffee.md
if (!$?) {
echo "coffeescript compilation failed"
exit 1
}
echo "compiled coffeescript to javascript"

# move everything to a temp folder to avoid infinite recursion errors
if (test-path ../.plugin) {
rm -force -recurse ../.plugin -ErrorAction ignore
}
mkdir -ErrorAction ignore ../.plugin | out-null
cp -recurse ../src, ../plugin.xml, ../www ../.plugin

# update the plugin, run the test app
cordova platform add $platform
cordova plugin rm com.phonegap.plugins.sqlite
cordova plugin add ../.plugin
cordova run $platform
} finally {
popd
}
4 changes: 3 additions & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# usage: ./bin/test.sh [android|ios]
#

# N.B. if you functionally change this script you _must_ change ./bin/test.ps1 too.

platform=$1

if [[ -z $platform ]]; then
Expand All @@ -22,7 +24,7 @@ fi

if [[ ! -x $(which cordova) ]]; then
echo "you need cordova. please install with:"
echo "npm install -g coffee-script"
echo "npm install -g cordova"
exit 1
fi

Expand Down
Loading

0 comments on commit e0e9555

Please # to comment.