Skip to content

Commit

Permalink
support macOS ("osx" platform)
Browse files Browse the repository at this point in the history
fix constraint violation tests for newer versions of iOS WebKit Web SQL
update .travis.yml to use Node 4.6
  • Loading branch information
Christopher J. Brody committed Sep 29, 2016
1 parent 733d77c commit fb097bc
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -10,7 +10,7 @@ git:
depth: 2

node_js:
- "4.4"
- "4.6"

install:
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
Expand Down
2 changes: 1 addition & 1 deletion AUTHORS.md
Expand Up @@ -16,7 +16,7 @@
- Fixes to support old Android versions by @nolanlawson
- Thanks to Mark Oppenheim <mark.oppenheim@mnetics.co.uk> for fixes to open/close callbacks and repeated open/close/delete operations

## iOS version
## iOS/macOS version

- Original authors: @davibe (Davide Bertola <dade@dadeb.it>) and @joenoon (Joe Noon <joenoon@gmail.com>)
- Cordova 2.7+ port with background processing by @j3k0 (Jean-Christophe Hoelt <hoelt@fovea.cc>)
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.md
@@ -1,7 +1,8 @@
# Changes

### cordova-sqlite-storage 1.4.8-pre4
### cordova-sqlite-storage 1.4.8-pre5

- Support macOS ("osx" platform)
- Signal an error in case of SQL with too many parameter argument values on iOS (in addition to Android & Windows)
- _Include proper SQL error code on Android (in certain cases)_
- Fix reporting of SQL statement _execution_ errors in Windows version
Expand Down
3 changes: 1 addition & 2 deletions LICENSE.md
Expand Up @@ -8,7 +8,7 @@ MIT or Apache 2.0

MIT or Apache 2.0

## iOS version
## iOS/macOS version

MIT only

Expand All @@ -21,4 +21,3 @@ MIT or Apache 2.0
by @doo (doo GmbH)

MIT License

44 changes: 24 additions & 20 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "cordova-sqlite-storage",
"version": "1.4.8-pre4",
"version": "1.4.8-pre5",
"description": "Native interface to SQLite for PhoneGap/Cordova",
"cordova": {
"id": "cordova-sqlite-storage",
Expand Down
25 changes: 22 additions & 3 deletions plugin.xml
Expand Up @@ -2,7 +2,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-sqlite-storage"
version="1.4.8-pre4">
version="1.4.8-pre5">

<name>Cordova sqlite storage plugin</name>

Expand Down Expand Up @@ -53,15 +53,15 @@

</platform>

<!-- ios -->
<!-- iOS -->
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="SQLitePlugin">
<param name="ios-package" value="SQLitePlugin" />
</feature>
</config-file>

<!-- Note: the ios src is based off src/ios implicitly -->
<!-- Note: the iOS src is based off src/ios implicitly -->
<header-file src="src/ios/SQLitePlugin.h" />
<source-file src="src/ios/SQLitePlugin.m" />

Expand All @@ -71,6 +71,25 @@

</platform>

<!-- macOS -->
<platform name="osx">
<config-file target="config.xml" parent="/*">
<feature name="SQLitePlugin">
<param name="ios-package" value="SQLitePlugin" />
</feature>
</config-file>

<!-- Note: the macOS src is based off src/ios implicitly -->
<header-file src="src/ios/SQLitePlugin.h" />
<source-file src="src/ios/SQLitePlugin.m" />
<!-- FUTURE TBD: more common directory name for Apple macOS/iOS versions -->

<header-file src="node_modules/cordova-sqlite-storage-dependencies/sqlite3.h" />
<source-file src="node_modules/cordova-sqlite-storage-dependencies/sqlite3.c"
compiler-flags="-DSQLITE_TEMP_STORE=2 -DSQLITE_THREADSAFE=2 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_COLUMN_METADATA -DSQLITE_ENABLE_RTREE -DSQLITE_LOCKING_STYLE=1 -DSQLITE_OMIT_BUILTIN_TEST -DSQLITE_OMIT_LOAD_EXTENSION" />

</platform>

<!-- windows -->
<platform name="windows">
<js-module src="src/windows/sqlite-proxy.js" name="SQLiteProxy">
Expand Down
5 changes: 4 additions & 1 deletion spec/www/spec/browser-check-startup.js
Expand Up @@ -11,9 +11,12 @@ var isWindows = /Windows /.test(navigator.userAgent); // Windows (8.1)
//var isIE = isWindows || isWP8 || isWindowsPhone_8_1;
var isIE = isWindows || isWP8;
var isWebKit = !isIE; // TBD [Android or iOS]
var isMac = /Macintosh/.test(navigator.userAgent);

window.hasBrowser = true;
window.hasWebKitBrowser = isWebKit;
// XXX TODO rename to something like window.hasWebKitWebSQL here and
// in actual test scripts
window.hasWebKitBrowser = (isWebKit && !isMac);

describe('check startup', function() {
it('receives deviceready event', function(done) {
Expand Down
20 changes: 10 additions & 10 deletions spec/www/spec/db-open-close-delete-test.js
Expand Up @@ -740,8 +740,8 @@ var mytests = function() {
});

test_it(suiteName + ' database.close (immediately after open) calls its success callback', function () {
// XXX POSSIBLY BROKEN on iOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('POSSIBLY BROKEN on iOS (background processing implementation)');
// XXX POSSIBLY BROKEN on iOS/macOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('POSSIBLY BROKEN on iOS/macOS (background processing implementation)');

// asynch test coming up
stop(1);
Expand Down Expand Up @@ -954,7 +954,7 @@ var mytests = function() {
test_it(suiteName + ' close then re-open (2x) allows subsequent queries to run', function () {
// asynch test coming up
stop(1);

var dbName = "Database-Close-and-Reopen";

openDatabase({name: dbName, location: 0}, function (db) {
Expand All @@ -976,7 +976,7 @@ var mytests = function() {
}, function(tx) {
// close on transaction success not while executing
// or commit will fail
db.close();
db.close();
});
}, function (error) {
ok(false, error.message);
Expand Down Expand Up @@ -1044,8 +1044,8 @@ var mytests = function() {
// Needed to support some large-scale applications:
test_it(suiteName + ' immediate close, then delete then re-open allows subsequent queries to run', function () {

// XXX POSSIBLY BROKEN on iOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('POSSIBLY BROKEN on iOS (background processing implementation)');
// XXX POSSIBLY BROKEN on iOS/macOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('POSSIBLY BROKEN on iOS/macOS (background processing implementation)');

var dbName = "Immediate-close-delete-Reopen.db";

Expand Down Expand Up @@ -1189,8 +1189,8 @@ var mytests = function() {
});

test_it(suiteName + ' repeatedly open and close database faster (5x)', function () {
// XXX CURRENTLY BROKEN on iOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('CURRENTLY BROKEN on iOS (background processing implementation)');
// XXX CURRENTLY BROKEN on iOS/macOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('CURRENTLY BROKEN on iOS/macOS (background processing implementation)');

var dbName = "repeatedly-open-and-close-faster-5x.db";

Expand Down Expand Up @@ -1310,8 +1310,8 @@ var mytests = function() {

// Needed to support some large-scale applications:
test_it(suiteName + ' repeatedly open and delete database faster (5x)', function () {
// XXX CURRENTLY BROKEN on iOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('CURRENTLY BROKEN on iOS (background processing implementation)');
// XXX CURRENTLY BROKEN on iOS/macOS due to current background processing implementation
if (!(isAndroid || isIE)) pending('CURRENTLY BROKEN on iOS/macOS (background processing implementation)');

var dbName = "repeatedly-open-and-delete-faster-5x.db";

Expand Down
12 changes: 8 additions & 4 deletions spec/www/spec/db-tx-error-mapping-test.js
Expand Up @@ -247,7 +247,9 @@ var mytests = function() {
expect(error.code).toBeDefined();
expect(error.message).toBeDefined();

if (isWindows)
if (isWebSql && !isAndroid)
expect(true).toBe(true); // SKIP for iOS (WebKit) Web SQL
else if (isWindows)
expect(error.code).toBe(0);
else
expect(error.code).toBe(6);
Expand All @@ -256,7 +258,7 @@ var mytests = function() {
if (isWebSql && isAndroid)
expect(error.message).toMatch(/could not execute statement due to a constr?aint failure.*19 constraint failed/);
else if (isWebSql)
expect(error.message).toMatch(/could not execute statement due to a constr?aint failure.*19 column data is not unique/);
expect(error.message).toMatch(/constr?aint fail/);
else if (isWindows)
expect(error.message).toMatch(/SQLite3 step error result code: 1/);
else if (isAndroid && !isImpl2)
Expand Down Expand Up @@ -695,7 +697,9 @@ var mytests = function() {
expect(error.code).toBeDefined();
expect(error.message).toBeDefined();

if (isWindows)
if (isWebSql && !isAndroid)
expect(true).toBe(true); // SKIP for iOS (WebKit) Web SQL
else if (isWindows)
expect(error.code).toBe(0);
else
expect(error.code).toBe(6);
Expand All @@ -704,7 +708,7 @@ var mytests = function() {
if (isWebSql && isAndroid)
expect(error.message).toMatch(/could not execute statement due to a constr?aint failure.*19 constraint failed/);
else if (isWebSql)
expect(error.message).toMatch(/could not execute statement due to a constr?aint failure.*19 column data is not unique/);
expect(error.message).toMatch(/constr?aint fail/);
else if (isWindows)
expect(error.message).toMatch(/a statement with no error handler failed: SQLite3 step error result code: 1/);
else if (isAndroid && !isImpl2)
Expand Down
37 changes: 20 additions & 17 deletions spec/www/spec/db-tx-sql-select-value-test.js
Expand Up @@ -7,6 +7,7 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios
var isWP8 = /IEMobile/.test(navigator.userAgent); // Matches WP(7/8/8.1)
var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);

// NOTE: In the core-master branch there is no difference between the default
// implementation and implementation #2. But the test will also apply
Expand Down Expand Up @@ -432,7 +433,7 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (isWebSql)
if (isWebSql || isMac)
expect(rs.rows.item(0).myresult).toBe('real');
else if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
Expand Down Expand Up @@ -497,7 +498,7 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (isWebSql)
if (isWebSql || isMac)
expect(rs.rows.item(0).myresult).toBe('real');
else if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
Expand Down Expand Up @@ -688,7 +689,7 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (isWebSql)
if (isWebSql || isMac)
expect(rs.rows.item(0).myresult).toBe('real');
else if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
Expand Down Expand Up @@ -753,7 +754,7 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (isWebSql)
if (isWebSql || isMac)
expect(rs.rows.item(0).myresult).toBe('real');
else if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
Expand Down Expand Up @@ -821,7 +822,7 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (isWebSql)
if (isWebSql || isMac)
expect(rs.rows.item(0).myresult).toBe('real');
else if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
Expand Down Expand Up @@ -886,7 +887,7 @@ var mytests = function() {
expect(rs).toBeDefined();
expect(rs.rows).toBeDefined();
expect(rs.rows.length).toBe(1);
if (isWebSql)
if (isWebSql || isMac)
expect(rs.rows.item(0).myresult).toBe('real');
else if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
Expand Down Expand Up @@ -950,7 +951,7 @@ var mytests = function() {
it(suiteName + "SELECT ABS(?) with '9e999' (Infinity) parameter argument" +
((!isWebSql && isAndroid) ? ' [Android PLUGIN BROKEN: result with missing row]' : ''), function(done) {
if (isWP8) pending('SKIP for WP8'); // (no callback received)
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('SKIP for iOS plugin due to CRASH');
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('SKIP for iOS/macOS plugin due to CRASH');

var db = openDatabase('SELECT-ABS-Infinite-parameter-results-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand All @@ -966,7 +967,7 @@ var mytests = function() {
else
expect(rs.rows.length).toBe(1);

if (isWebSql || isWindows)
if (isWebSql || isWindows || isMac)
expect(rs.rows.item(0).myresult).toBe(Infinity);

// Close (plugin only) & finish:
Expand All @@ -985,9 +986,9 @@ var mytests = function() {
it(suiteName + "SELECT -ABS(?) with '9e999' (Infinity) parameter argument" +
((!isWebSql && isAndroid) ? ' [Android PLUGIN BROKEN: missing result]' : ''), function(done) {
if (isWP8) pending('SKIP for WP8'); // (no callback received)
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('SKIP for iOS plugin due to CRASH');
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('SKIP for iOS/macOS plugin due to CRASH');

var db = openDatabase('SELECT-ABS-Infinite-parameter-results-test.db', '1.0', 'Test', DEFAULT_SIZE);
var db = openDatabase('SELECT-ABS-minus-Infinite-parameter-results-test.db', '1.0', 'Test', DEFAULT_SIZE);

db.transaction(function(tx) {
expect(tx).toBeDefined();
Expand All @@ -1001,7 +1002,7 @@ var mytests = function() {
else
expect(rs.rows.length).toBe(1);

if (isWebSql || isWindows)
if (isWebSql || isWindows || isMac)
expect(rs.rows.item(0).myresult).toBe(-Infinity);

// Close (plugin only) & finish:
Expand Down Expand Up @@ -1086,7 +1087,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('');
else if (!isWebSql && !isWindows)
else if (!isWebSql && !isWindows && !isMac)
expect(rs.rows.item(0).myresult).toBe(null);
else
expect(rs.rows.item(0).myresult).toBe('inf');
Expand Down Expand Up @@ -1121,7 +1122,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('');
else if (!isWebSql && !isWindows)
else if (!isWebSql && !isWindows && !isMac)
expect(rs.rows.item(0).myresult).toBe(null);
else
expect(rs.rows.item(0).myresult).toBe('-INF');
Expand Down Expand Up @@ -1156,7 +1157,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
else if (!isWebSql && !isWindows)
else if (!isWebSql && !isWindows && !isMac)
expect(rs.rows.item(0).myresult).toBe('null');
else
expect(rs.rows.item(0).myresult).toBe('real');
Expand Down Expand Up @@ -1191,7 +1192,7 @@ var mytests = function() {
// Android/iOS plugin issue
if (!isWebSql && isAndroid && isImpl2)
expect(rs.rows.item(0).myresult).toBe('text');
else if (!isWebSql && !isWindows)
else if (!isWebSql && !isWindows && !isMac)
expect(rs.rows.item(0).myresult).toBe('null');
else
expect(rs.rows.item(0).myresult).toBe('real');
Expand All @@ -1209,8 +1210,9 @@ var mytests = function() {
});
}, MYTIMEOUT);

it(suiteName + 'SELECT (?) with Infinity parameter argument [Android/iOS Plugin BROKEN: result with null value]', function(done) {
it(suiteName + 'SELECT (?) with Infinity parameter argument [Android/iOS Plugin BROKEN: result with null value; CRASH on macOS]', function(done) {
if (isWP8) pending('SKIP for WP8'); // SKIP for now
if (isMac) pending('SKIP for macOS [CRASH]'); // FUTURE TBD

var db = openDatabase('SELECT-Infinite-parameter-results-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down Expand Up @@ -1243,8 +1245,9 @@ var mytests = function() {
});
}, MYTIMEOUT);

it(suiteName + 'SELECT (?) with -Infinity parameter argument [Android/iOS Plugin BROKEN: result with null value]', function(done) {
it(suiteName + 'SELECT (?) with -Infinity parameter argument [Android/iOS Plugin BROKEN: result with null value; CRASH on macOS]', function(done) {
if (isWP8) pending('SKIP for WP8'); // SKIP for now
if (isMac) pending('SKIP for macOS [CRASH]'); // FUTURE TBD

var db = openDatabase('SELECT-minus-Infinite-parameter-results-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down
4 changes: 2 additions & 2 deletions spec/www/spec/db-tx-string-test.js
Expand Up @@ -361,7 +361,7 @@ var mytests = function() {

it(suiteName + ' handles UNICODE \\u2028 line separator correctly [string test]', function (done) {
if (isWP8) pending('BROKEN for WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('BROKEN for iOS plugin'); // [BUG #147] (no callback received)
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('BROKEN for iOS/macOS plugin'); // [BUG #147] (no callback received)

// NOTE: since the above test shows the UNICODE line separator (\u2028)
// is seen by the sqlite implementation OK, it is now concluded that
Expand Down Expand Up @@ -412,7 +412,7 @@ var mytests = function() {

it(suiteName + ' handles UNICODE \\u2029 paragraph separator correctly [string test]', function (done) {
if (isWP8) pending('BROKEN for WP(8)'); // [BUG #202] UNICODE characters not working with WP(8)
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('BROKEN for iOS plugin'); // [BUG #147] (no callback received)
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('BROKEN for iOS/macOS plugin'); // [BUG #147] (no callback received)

// NOTE: since the above test shows the UNICODE paragraph separator (\u2029)
// is seen by the sqlite implementation OK, it is now concluded that
Expand Down

0 comments on commit fb097bc

Please sign in to comment.