cordova-sqlite-evmax-build-free 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AUTHORS.md CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
  - Extracted from DroidGap by @brodybits (Chris Brody)
16
16
  - Transaction batch processing of Android version by @marcucio
17
+ - Updated for Android 11 by @brodybits (Chris Brody)
17
18
  - Maintained by @brodybits (Chris Brody)
18
19
  - Fixes to support old Android versions by @nolanlawson
19
20
  - Thanks to Mark Oppenheim <mark.oppenheim@mnetics.co.uk> for fixes to open/close callbacks and repeated open/close/delete operations
package/CHANGES.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changes
2
2
 
3
+ # cordova-sqlite-evmax-build-free 0.0.9
4
+
5
+ - Custom Android database file location - now merged into cordova-sqlite-evmax-build-free
6
+ - SQLite 3.43.1 update, with `SQLITE_ENABLE_MATH_FUNCTIONS` enabled for Android/iOS/Windows
7
+ - build cleanup: remove extra dummy WinMD (etc.)
8
+
9
+ ## cordova-sqlite-evmax-feat-android-db-location 0.0.2-dev
10
+
11
+ ## cordova-sqlite-evmax-common-free 0.0.7-dev
12
+
13
+ - _SQLite3 math functions now tested for Android/iOS/Windows_
14
+
15
+ ### cordova-sqlite-evcore-common-free 0.7.3-dev
16
+
17
+ - enable SQLite3 math functions for Windows (and update test case)
18
+
19
+ ### cordova-sqlite-evcore-common-free 0.7.2-dev
20
+
21
+ - enable SQLite3 math functions for iOS (only), with new test case feature ref: https://www.sqlite.org/lang_mathfunc.html
22
+
3
23
  # cordova-sqlite-evmax-build-free 0.0.8
4
24
 
5
25
  ## cordova-sqlite-evmax-common-free 0.0.6-dev
@@ -73,6 +93,12 @@
73
93
  - update affected test cases
74
94
  - update documentation
75
95
 
96
+ ## cordova-sqlite-evplus-feat-android-db-location 0.0.2-dev
97
+
98
+ ## cordova-sqlite-evcore-feat-android-db-location 0.8.0
99
+
100
+ - refactor: update androidDatabaseLocation error messages
101
+
76
102
  ### cordova-sqlite-evcore-commoncore-free 0.3.0
77
103
 
78
104
  ### cordova-sqlite-ext-common 4.0.0
@@ -89,6 +115,12 @@
89
115
  - http://sqlite.1065341.n5.nabble.com/Crash-Bug-Report-tc109903.html
90
116
  - https://github.com/xpbrew/cordova-sqlite-storage/issues/904
91
117
 
118
+ ## cordova-sqlite-evplus-feat-android-db-location 0.0.1-dev
119
+
120
+ ### cordova-sqlite-evcore-feature-android-db-location 0.7.2-dev1
121
+
122
+ - Custom Android database file location
123
+
92
124
  ## cordova-plugin-sqlite-evplus-ext-common-free 0.4.1-rc01
93
125
 
94
126
  - SQLite 3.32.3 update from github:brodybits/cordova-sqlite-evplus-ext-free-dependencies#0.1.0-rc02
package/LICENSE.md CHANGED
@@ -18,7 +18,7 @@ sqlite3-regexp-cached - adapted by @brodybits (Christopher J. Brody), based on s
18
18
 
19
19
  sqlite3-base64 by @brodybits (Christopher J. Brody), Unlicense (http://unlicense.org/ - public domain)
20
20
 
21
- libb64-encode - based on libb64 (http://libb64.sourceforge.net/) by Chris Venter, public domain
21
+ libb64-core - based on libb64 (http://libb64.sourceforge.net/) by Chris Venter, public domain
22
22
 
23
23
  MIT or Apache 2.0
24
24
 
@@ -36,7 +36,7 @@ Based on <http://git.altlinux.org/people/at/packages/?p=sqlite3-pcre.git> by Ale
36
36
 
37
37
  Unlicense (public domain)
38
38
 
39
- ### libb64-encode
39
+ ### libb64-core
40
40
 
41
41
  Based on <http://libb64.sourceforge.net/> by Chris Venter, public domain)
42
42
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Cordova/PhoneGap sqlite storage evmax - super-premium enterprise version with super-premium stability and performance improvements with limited extra features
1
+ # Cordova/PhoneGap sqlite storage evmax - super-premium enterprise version with super-premium stability and performance improvements with EXTRA FEATURES INCLUDING ARBITRARY ANDROID DB LOCATION
2
2
 
3
3
  Native SQLite component with API based on HTML5/[Web SQL (DRAFT) API](http://www.w3.org/TR/webdatabase/) for the following platforms:
4
4
  - Android
@@ -201,7 +201,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
201
201
  - This plugin version includes the following extra (non-standard) features:
202
202
  - BASE64 and BLOBFROMBASE64 integrated from [brodybits / sqlite3-base64](https://github.com/brodybits/sqlite3-base64), using [brodybits / libb64-core](https://github.com/brodybits/libb64-core) (based on <http://libb64.sourceforge.net/> by Chris Venter, public domain)
203
203
  - REGEXP for Android (default Android-sqlite-connector database implementation), iOS, and macOS using [brodybits / sqlite3-regexp-cached](https://github.com/brodybits/sqlite3-regexp-cached) (based on <http://git.altlinux.org/people/at/packages/?p=sqlite3-pcre.git> by Alexey Tourbin, public domain)
204
- - SQLite __`3.40.0`__ included when building (all platforms), with the following compile-time definitions:
204
+ - SQLite __`3.43.1`__ included when building (all platforms), with the following compile-time definitions:
205
205
  - `SQLITE_THREADSAFE=1`
206
206
  - `SQLITE_DEFAULT_SYNCHRONOUS=3` (EXTRA DURABLE build setting) ref: [xpbrew/cordova-sqlite-storage#736](https://github.com/xpbrew/cordova-sqlite-storage/issues/736)
207
207
  - `SQLITE_LOCKING_STYLE=1` on iOS/macOS ONLY
@@ -220,6 +220,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
220
220
  - `SQLITE_ENABLE_RTREE`
221
221
  - `SQLITE_ENABLE_JSON1`
222
222
  - `SQLITE_ENABLE_RTREE`
223
+ - `SQLITE_ENABLE_MATH_FUNCTIONS` - _Android/iOS/Windows_
223
224
  - `SQLITE_DEFAULT_PAGE_SIZE=4096` - new default page size ref: <http://sqlite.org/pgszchng2016.html>
224
225
  - `SQLITE_DEFAULT_CACHE_SIZE=-2000` - new default cache size ref: <http://sqlite.org/pgszchng2016.html>
225
226
  - `SQLITE_OS_WINRT` (Windows only)
@@ -263,6 +264,7 @@ See the [Sample section](#sample) for a sample with a more detailed explanation
263
264
 
264
265
  - This plugin version includes super-premium workarounds to support super-large INSERT transactions on Android and resolve an issue with `/` character in Capacitor. It also includes premium improvements to the internal JSON interface between Javascript and native parts on Android, iOS, and macOS which improves the performance and resolves memory issues in case of some very large SQL batches and large SELECT results, with help from [`android-sqlite-evmax-ndk-driver-free`](https://github.com/brodybits/android-sqlite-evmax-ndk-driver-free) on Android.
265
266
  - This plugin version includes additional JavaScript performance enhancements with special benefit for Android.
267
+ - Custom Android database location (supports external storage directory)
266
268
  - This plugin version includes the following extra (non-standard) features: BASE 64 (all platforms Android/iOS/macOS/Windows), REGEXP (Android/iOS/macOS)
267
269
  - Using `SQLITE_DEFAULT_SYNCHRONOUS=3` (EXTRA DURABLE) build setting to be extra robust against possible database corruption ref: [xpbrew/cordova-sqlite-storage#736](https://github.com/xpbrew/cordova-sqlite-storage/issues/736)
268
270
  - `SQLITE_DBCONFIG_DEFENSIVE` flag is used for extra SQL safety, as described above
@@ -855,6 +857,32 @@ where the `iosDatabaseLocation` option may be set to one of the following choice
855
857
  - `Library`: `Library` subdirectory - backed up by iCloud, *NOT* visible to iTunes
856
858
  - `Documents`: `Documents` subdirectory - visible to iTunes and backed up by iCloud
857
859
 
860
+ To specify a external or another custom Android database location, with help from cordova-plugin-file:
861
+
862
+ ```js
863
+ window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(externalDataDirectoryEntry) {
864
+ var db = window.sqlitePlugin.openDatabase({name: 'external.db', androidDatabaseLocation: externalDataDirectoryEntry.toURL()});
865
+
866
+ db.transaction(function(tx) {
867
+ tx.executeSql('CREATE TABLE IF NOT EXISTS MyTable (data)');
868
+ tx.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value']);
869
+ }, function(error) {
870
+ console.log('Populate database error: ' + error.message);
871
+
872
+ }, function() {
873
+ db.transaction(function(tx) {
874
+ tx.executeSql('SELECT data from MyTable', [], function(tx_ignored, resultSet) {
875
+ console.log('Record count: ' + resultSet.rows.length);
876
+ for (var i=0; i<resultSet.rows.length; ++i)
877
+ console.log('index: ' + i + ' value: ' + resultSet.rows.item(i).data);
878
+ });
879
+ }, function(error) {
880
+ console.log('Populate database error: ' + error.message);
881
+ });
882
+ });
883
+ });
884
+ ```
885
+
858
886
  **WARNING:** Again, the new "default" iosDatabaseLocation value is *NOT* the same as the old default location and would break an upgrade for an app using the old default value (0) on iOS.
859
887
 
860
888
  DEPRECATED ALTERNATIVE to be removed in an upcoming release:
@@ -907,17 +907,22 @@
907
907
  if !openargs.name
908
908
  throw newSQLError 'Database name value is missing in openDatabase call'
909
909
 
910
- if !openargs.iosDatabaseLocation and !openargs.location and openargs.location isnt 0
911
- throw newSQLError 'Database location or iosDatabaseLocation setting is now mandatory in openDatabase call.'
910
+ if !openargs.iosDatabaseLocation and !openargs.location and openargs.location isnt 0 and !openargs.androidDatabaseLocation
911
+ throw newSQLError 'Database location (or iosDatabaseLocation or androidDatabaseLocation) setting is now mandatory in openDatabase call.'
912
912
 
913
913
  if !!openargs.location and !!openargs.iosDatabaseLocation
914
914
  throw newSQLError 'AMBIGUOUS: both location and iosDatabaseLocation settings are present in openDatabase call. Please use either setting, not both.'
915
915
 
916
+ if !!openargs.location and !!openargs.androidDatabaseLocation
917
+ throw newSQLError 'AMBIGUOUS: both location and androidDatabaseLocation settings are present in openDatabase call. Please use either setting, not both. But you *can* use androidDatabaseLocation and iosDatabaseLocation together.'
918
+
916
919
  dblocation =
917
920
  if !!openargs.location and openargs.location is 'default'
918
921
  iosLocationMap['default']
919
922
  else if !!openargs.iosDatabaseLocation
920
923
  iosLocationMap[openargs.iosDatabaseLocation]
924
+ else if !openargs.location and openargs.location isnt 0
925
+ iosLocationMap['default']
921
926
  else
922
927
  dblocations[openargs.location]
923
928
 
@@ -984,17 +989,22 @@
984
989
  #args.dblocation = dblocation || dblocations[0]
985
990
  #args.dblocation = dblocation || dblocations[2]
986
991
 
987
- if !first.iosDatabaseLocation and !first.location and first.location isnt 0
988
- throw newSQLError 'Database location or iosDatabaseLocation setting is now mandatory in deleteDatabase call.'
992
+ if !first.iosDatabaseLocation and !first.location and first.location isnt 0 and !first.androidDatabaseLocation
993
+ throw newSQLError 'Database location (or iosDatabaseLocation or androidDatabaseLocation) setting is now mandatory in deleteDatabase call.'
989
994
 
990
995
  if !!first.location and !!first.iosDatabaseLocation
991
996
  throw newSQLError 'AMBIGUOUS: both location and iosDatabaseLocation settings are present in deleteDatabase call. Please use either setting value, not both.'
992
997
 
998
+ if !!first.location and !!first.androidDatabaseLocation
999
+ throw newSQLError 'AMBIGUOUS: both location and androidDatabaseLocation settings are present in deleteDatabase call. Please use either setting, not both. But you *can* use androidDatabaseLocation and iosDatabaseLocation together.'
1000
+
993
1001
  dblocation =
994
1002
  if !!first.location and first.location is 'default'
995
1003
  iosLocationMap['default']
996
1004
  else if !!first.iosDatabaseLocation
997
1005
  iosLocationMap[first.iosDatabaseLocation]
1006
+ else if !first.location and first.location isnt 0
1007
+ iosLocationMap['default']
998
1008
  else
999
1009
  dblocations[first.location]
1000
1010
 
@@ -1002,6 +1012,8 @@
1002
1012
  throw newSQLError 'Valid iOS database location could not be determined in deleteDatabase call'
1003
1013
 
1004
1014
  args.dblocation = dblocation
1015
+ if !!first.androidDatabaseLocation
1016
+ args.androidDatabaseLocation = first.androidDatabaseLocation
1005
1017
 
1006
1018
  # XXX TODO BUG litehelpers/Cordova-sqlite-storage#367 (repeated here):
1007
1019
  # abort all pending transactions (with error callback)
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "cordova-sqlite-evmax-build-free",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Cordova/PhoneGap sqlite storage - free evmax enterprise version with premium stability and performance improvements including workaround for super-large INSERT transactions & SELECT results on Android (version with external sqlite3 dependencies)",
5
5
  "cordova": {
6
- "id": "cordova-sqlite-evmax-common-free",
6
+ "id": "cordova-sqlite-evmax-build-free",
7
7
  "platforms": [
8
8
  "android",
9
9
  "ios",
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova-sqlite-evmax-build-free"
5
- version="0.0.8">
5
+ version="0.0.9">
6
6
 
7
7
  <name>Cordova sqlite storage - free evmax common version branch with premium stability performance improvements including workaround for super-large INSERT transactions and SELECT results on Android (with external sqlite3 dependencies)</name>
8
8
 
@@ -66,7 +66,7 @@
66
66
 
67
67
  <header-file src="src/deps/common/sqlite3.h" />
68
68
  <source-file src="src/deps/common/sqlite3.c"
69
- compiler-flags="-w -DSQLITE_THREADSAFE=1 -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_LOCKING_STYLE=1 -DHAVE_USLEEP=1 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_JSON1 -DSQLITE_DEFAULT_PAGE_SIZE=4096 -DSQLITE_DEFAULT_CACHE_SIZE=-2000" />
69
+ compiler-flags="-w -DSQLITE_THREADSAFE=1 -DSQLITE_DEFAULT_SYNCHRONOUS=3 -DSQLITE_LOCKING_STYLE=1 -DHAVE_USLEEP=1 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_TEMP_STORE=2 -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_DEFAULT_PAGE_SIZE=4096 -DSQLITE_DEFAULT_CACHE_SIZE=-2000" />
70
70
  </platform>
71
71
 
72
72
  <!-- macOS (osx) -->
@@ -122,9 +122,9 @@
122
122
  - https://www.dynamsoft.com/codepool/cordova-plugin-barcode-winrt.html
123
123
  - https://github.com/yushulx/cordova-windows-barcode
124
124
  - -->
125
- <framework src="src/windows/libs/x86/BarcodeComponent.winmd" target-dir="x86" arch="x86" custom="true"/>
125
+ <framework src="src/windows/libs/dummy/BarcodeComponent.winmd" target-dir="x86" arch="x86" custom="true"/>
126
126
  <framework src="src/windows/libs/x86/SQLite3.winmd" target-dir="x86" arch="x86" custom="true" implementation="src/windows/libs/x86/SQLite3.UWP.dll"/>
127
- <framework src="src/windows/libs/x86/BarcodeComponent.winmd" target-dir="x64" arch="x64" custom="true"/>
127
+ <framework src="src/windows/libs/dummy/BarcodeComponent.winmd" target-dir="x64" arch="x64" custom="true"/>
128
128
  <framework src="src/windows/libs/x86/SQLite3.winmd" target-dir="x64" arch="x64" custom="true" implementation="src/windows/libs/x64/SQLite3.UWP.dll"/>
129
129
  </platform>
130
130
 
package/spec/package.json CHANGED
@@ -1,4 +1,11 @@
1
1
  {
2
2
  "name": "cordova-sqlite-spec",
3
- "cordova": {}
3
+ "cordova": {
4
+ "plugins": {
5
+ "cordova-plugin-file": {}
6
+ }
7
+ },
8
+ "devDependencies": {
9
+ "cordova-plugin-file": "^6.0.2"
10
+ }
4
11
  }
@@ -39,6 +39,7 @@
39
39
  <script src="spec/ext-tx-blob-test.js"></script>
40
40
  <script src="spec/base64-encode-test.js"></script>
41
41
  <script src="spec/blobfrombase64-test.js"></script>
42
+ <script src="spec/android-db-location-test.js"></script>
42
43
  <!--
43
44
  <script src="spec/big-memory-test.js"></script>
44
45
  - -->
@@ -0,0 +1,327 @@
1
+ /* 'use strict'; */
2
+
3
+ var MYTIMEOUT = 20000;
4
+
5
+ var isWindows = /Windows /.test(navigator.userAgent); // Windows
6
+ var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
7
+
8
+ var pluginScenarioList = [
9
+ isAndroid ? 'Plugin-implementation-default' : 'Plugin',
10
+ 'Plugin-implementation-2'
11
+ ];
12
+
13
+ //var pluginScenarioCount = isAndroid ? 2 : 1;
14
+ var pluginScenarioCount = 1;
15
+
16
+ var mytests = function() {
17
+
18
+ for (var i=0; i<pluginScenarioCount; ++i) {
19
+
20
+ describe(pluginScenarioList[i] + ': Android db directory test(s)', function() {
21
+ var scenarioName = pluginScenarioList[i];
22
+ var suiteName = scenarioName + ': ';
23
+ // FUTURE TBD
24
+ //var isImpl2 = (i === 1);
25
+
26
+ it(suiteName + 'Create db file in Documents, check size, copy to default location, check copy, and delete original', function(done) {
27
+ if (!isAndroid) pending('SKIP for iOS/Windows/WP8');
28
+
29
+ var dbname = 'Create-db-in-documents-test.db';
30
+ var copyname = 'copy-db-from-documents.db';
31
+
32
+ window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function(dataDirectoryEntry) {
33
+ expect(dataDirectoryEntry).toBeDefined();
34
+
35
+ expect(dataDirectoryEntry.isDirectory).toBe(true);
36
+
37
+ dataDirectoryEntry.getDirectory('Documents', null, function(documentsDirectoryEntry) {
38
+ expect(documentsDirectoryEntry).toBeDefined();
39
+ expect(documentsDirectoryEntry.isDirectory).toBe(true);
40
+
41
+ var createDatabaseDirectoryEntry = documentsDirectoryEntry;
42
+ var db = window.sqlitePlugin.openDatabase({name: dbname, androidDatabaseLocation: createDatabaseDirectoryEntry.toURL()});
43
+
44
+ db.transaction(function(tx) {
45
+ tx.executeSql('DROP TABLE IF EXISTS tt');
46
+ tx.executeSql('CREATE TABLE tt (data)');
47
+ tx.executeSql('INSERT INTO tt VALUES (?)', ['test-value']);
48
+
49
+ }, function(error) {
50
+ // NOT EXPECTED:
51
+ expect(false).toBe(true);
52
+ expect(JSON.stringify(error)).toBe('---');
53
+ // Close (PLUGIN) & finish:
54
+ db.close(done, done);
55
+
56
+ }, function() {
57
+ db.close(function() {
58
+ createDatabaseDirectoryEntry.getFile(dbname, null, function(dbFileEntry) {
59
+ expect(dbFileEntry).toBeDefined();
60
+ expect(dbFileEntry.isFile).toBe(true);
61
+
62
+ dbFileEntry.file(function(f) {
63
+ expect(f).toBeDefined();
64
+ expect(f.size).toBeDefined();
65
+ expect(f.size).not.toBe(-1);
66
+ expect(f.size).not.toBe(0);
67
+ expect(f.size > 1000).toBe(true);
68
+
69
+ window.resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory, function(storageDirectoryEntry) {
70
+ expect(storageDirectoryEntry).toBeDefined();
71
+ expect(storageDirectoryEntry.isDirectory).toBe(true);
72
+
73
+ storageDirectoryEntry.getDirectory('databases', null, function(dbDirectoryEntry) {
74
+ expect(dbDirectoryEntry).toBeDefined();
75
+
76
+ dbFileEntry.copyTo(dbDirectoryEntry, copyname, function(newFileEntry) {
77
+ expect(newFileEntry).toBeDefined();
78
+ expect(newFileEntry.isFile).toBe(true);
79
+
80
+ var db2 = window.sqlitePlugin.openDatabase({name: copyname, location: 'default'});
81
+
82
+ db2.transaction(function(tx) {
83
+ tx.executeSql('SELECT * FROM tt', [], function(tx_ignored, rs) {
84
+ expect(rs).toBeDefined();
85
+ expect(rs.rows).toBeDefined();
86
+ expect(rs.rows.length).toBe(1);
87
+ expect(rs.rows.item(0).data).toBeDefined();
88
+ expect(rs.rows.item(0).data).toBe('test-value');
89
+
90
+ var deleteOptions = {name: dbname, androidDatabaseLocation: createDatabaseDirectoryEntry.toURL()};
91
+ window.sqlitePlugin.deleteDatabase(deleteOptions, function() {
92
+ createDatabaseDirectoryEntry.getFile(dbname, null, function(dbFileEntry) {
93
+ // NOT EXPECTED - old database file is still available:
94
+ expect(false).toBe(true);
95
+ done();
96
+ }, function(error) {
97
+ // EXPECTED RESULT - old database file is gone:
98
+ expect(true).toBe(true);
99
+ done();
100
+ });
101
+
102
+ }, function(error) {
103
+ // NOT EXPECTED:
104
+ expect(false).toBe(true);
105
+ expect(JSON.stringify(error)).toBe('---');
106
+ done();
107
+ });
108
+
109
+ });
110
+ }, function(error) {
111
+ // NOT EXPECTED:
112
+ expect(false).toBe(true);
113
+ expect(JSON.stringify(error)).toBe('---');
114
+ // Close (PLUGIN) & finish:
115
+ db.close(done, done);
116
+ });
117
+
118
+ }, function(error) {
119
+ // NOT EXPECTED:
120
+ expect(false).toBe(true);
121
+ expect(JSON.stringify(error)).toBe('---');
122
+ done();
123
+ });
124
+
125
+ }, function(error) {
126
+ // NOT EXPECTED:
127
+ expect(false).toBe(true);
128
+ expect(JSON.stringify(error)).toBe('---');
129
+ done();
130
+ });
131
+
132
+ }, function(error) {
133
+ // NOT EXPECTED:
134
+ expect(false).toBe(true);
135
+ expect(JSON.stringify(error)).toBe('---');
136
+ done();
137
+ });
138
+
139
+ }, function(error) {
140
+ // NOT EXPECTED:
141
+ expect(false).toBe(true);
142
+ expect(JSON.stringify(error)).toBe('---');
143
+ done();
144
+ });
145
+
146
+ }, function(error) {
147
+ // NOT EXPECTED:
148
+ expect(false).toBe(true);
149
+ expect(JSON.stringify(error)).toBe('---');
150
+ done();
151
+ });
152
+
153
+ }, function(error) {
154
+ // NOT EXPECTED:
155
+ expect(false).toBe(true);
156
+ expect(JSON.stringify(error)).toBe('---');
157
+ done();
158
+ });
159
+ });
160
+
161
+ }, function(error) {
162
+ // NOT EXPECTED:
163
+ expect(false).toBe(true);
164
+ expect(JSON.stringify(error)).toBe('---');
165
+ done();
166
+ });
167
+
168
+ }, function(error) {
169
+ // NOT EXPECTED:
170
+ expect(false).toBe(true);
171
+ expect(JSON.stringify(error)).toBe('---');
172
+ done();
173
+ });
174
+
175
+ }, MYTIMEOUT);
176
+
177
+ it(suiteName + 'Create db file in external files directory, check size, copy to default location, check copy, and delete original', function(done) {
178
+ if (!isAndroid) pending('SKIP for iOS/Windows/WP8');
179
+
180
+ var dbname = 'Create-db-in-external-files-test.db';
181
+ var copyname = 'copy-db-from-external-files.db';
182
+
183
+ window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory, function(externalDataDirectoryEntry) {
184
+ expect(externalDataDirectoryEntry).toBeDefined();
185
+
186
+ expect(externalDataDirectoryEntry.isDirectory).toBe(true);
187
+
188
+ var createDatabaseDirectoryEntry = externalDataDirectoryEntry;
189
+ var db = window.sqlitePlugin.openDatabase({name: dbname, androidDatabaseLocation: createDatabaseDirectoryEntry.toURL()});
190
+
191
+ db.transaction(function(tx) {
192
+ tx.executeSql('DROP TABLE IF EXISTS tt');
193
+ tx.executeSql('CREATE TABLE tt (data)');
194
+ tx.executeSql('INSERT INTO tt VALUES (?)', ['test-value']);
195
+
196
+ }, function(error) {
197
+ // NOT EXPECTED:
198
+ expect(false).toBe(true);
199
+ expect(JSON.stringify(error)).toBe('---');
200
+ // Close (PLUGIN) & finish:
201
+ db.close(done, done);
202
+
203
+ }, function() {
204
+ db.close(function() {
205
+ createDatabaseDirectoryEntry.getFile(dbname, null, function(dbFileEntry) {
206
+ expect(dbFileEntry).toBeDefined();
207
+ expect(dbFileEntry.isFile).toBe(true);
208
+
209
+ dbFileEntry.file(function(f) {
210
+ expect(f).toBeDefined();
211
+ expect(f.size).toBeDefined();
212
+ expect(f.size).not.toBe(-1);
213
+ expect(f.size).not.toBe(0);
214
+ expect(f.size > 1000).toBe(true);
215
+
216
+ window.resolveLocalFileSystemURL(cordova.file.applicationStorageDirectory, function(storageDirectoryEntry) {
217
+ expect(storageDirectoryEntry).toBeDefined();
218
+ expect(storageDirectoryEntry.isDirectory).toBe(true);
219
+
220
+ storageDirectoryEntry.getDirectory('databases', null, function(dbDirectoryEntry) {
221
+ expect(dbDirectoryEntry).toBeDefined();
222
+
223
+ dbFileEntry.copyTo(dbDirectoryEntry, copyname, function(newFileEntry) {
224
+ expect(newFileEntry).toBeDefined();
225
+ expect(newFileEntry.isFile).toBe(true);
226
+
227
+ var db2 = window.sqlitePlugin.openDatabase({name: copyname, location: 'default'});
228
+
229
+ db2.transaction(function(tx) {
230
+ tx.executeSql('SELECT * FROM tt', [], function(tx_ignored, rs) {
231
+ expect(rs).toBeDefined();
232
+ expect(rs.rows).toBeDefined();
233
+ expect(rs.rows.length).toBe(1);
234
+ expect(rs.rows.item(0).data).toBeDefined();
235
+ expect(rs.rows.item(0).data).toBe('test-value');
236
+
237
+ var deleteOptions = {name: dbname, androidDatabaseLocation: createDatabaseDirectoryEntry.toURL()};
238
+ window.sqlitePlugin.deleteDatabase(deleteOptions, function() {
239
+ createDatabaseDirectoryEntry.getFile(dbname, null, function(dbFileEntry) {
240
+ // NOT EXPECTED - old database file is still available:
241
+ expect(false).toBe(true);
242
+ done();
243
+ }, function(error) {
244
+ // EXPECTED RESULT - old database file is gone:
245
+ expect(true).toBe(true);
246
+ done();
247
+ });
248
+
249
+ }, function(error) {
250
+ // NOT EXPECTED:
251
+ expect(false).toBe(true);
252
+ expect(JSON.stringify(error)).toBe('---');
253
+ done();
254
+ });
255
+
256
+ });
257
+ }, function(error) {
258
+ // NOT EXPECTED:
259
+ expect(false).toBe(true);
260
+ expect(JSON.stringify(error)).toBe('---');
261
+ // Close (PLUGIN) & finish:
262
+ db.close(done, done);
263
+ });
264
+
265
+ }, function(error) {
266
+ // NOT EXPECTED:
267
+ expect(false).toBe(true);
268
+ expect(JSON.stringify(error)).toBe('---');
269
+ done();
270
+ });
271
+
272
+ }, function(error) {
273
+ // NOT EXPECTED:
274
+ expect(false).toBe(true);
275
+ expect(JSON.stringify(error)).toBe('---');
276
+ done();
277
+ });
278
+
279
+ }, function(error) {
280
+ // NOT EXPECTED:
281
+ expect(false).toBe(true);
282
+ expect(JSON.stringify(error)).toBe('---');
283
+ done();
284
+ });
285
+
286
+ }, function(error) {
287
+ // NOT EXPECTED:
288
+ expect(false).toBe(true);
289
+ expect(JSON.stringify(error)).toBe('---');
290
+ done();
291
+ });
292
+
293
+ }, function(error) {
294
+ // NOT EXPECTED:
295
+ expect(false).toBe(true);
296
+ expect(JSON.stringify(error)).toBe('---');
297
+ done();
298
+ });
299
+
300
+ }, function(error) {
301
+ // NOT EXPECTED:
302
+ expect(false).toBe(true);
303
+ expect(JSON.stringify(error)).toBe('---');
304
+ done();
305
+ });
306
+ });
307
+
308
+ }, function(error) {
309
+ // NOT EXPECTED:
310
+ expect(false).toBe(true);
311
+ expect(JSON.stringify(error)).toBe('---');
312
+ done();
313
+ });
314
+
315
+
316
+ }, MYTIMEOUT);
317
+
318
+ });
319
+
320
+ }
321
+
322
+ }
323
+
324
+ if (window.hasBrowser) mytests();
325
+ else exports.defineAutoTests = mytests;
326
+
327
+ /* vim: set expandtab : */
@@ -362,6 +362,27 @@ var mytests = function() {
362
362
  });
363
363
  }, MYTIMEOUT);
364
364
 
365
+ it(suiteName + 'Math functions test', function(done) {
366
+ if (isWebSql) pending('SKIP for (WebKit) Web SQL');
367
+ if (isAndroid && isImpl2) pending('XXX XXX android.database'); // XXX
368
+ if (isMac) pending('NOT SUPPORTED for macOS');
369
+
370
+ var db = openDatabase('math-functions-test.db');
371
+ expect(db).toBeDefined();
372
+
373
+ db.transaction(function(tx) {
374
+ tx.executeSql("SELECT COS(PI()) AS my_value;", null, function(tx, res) {
375
+ expect(res.rows.item(0).my_value).toEqual(-1);
376
+ // Close (plugin only) & finish:
377
+ db.close(done, done);
378
+ }, function(tx, e) {
379
+ // NOT EXPECTED (went wrong):
380
+ expect(JSON.stringify(e)).toBe('--');
381
+ done.fail();
382
+ });
383
+ });
384
+ }, MYTIMEOUT);
385
+
365
386
  });
366
387
 
367
388
  }
@@ -104,7 +104,7 @@ var mytests = function() {
104
104
  expect(rs).toBeDefined();
105
105
  expect(rs.rows).toBeDefined();
106
106
  expect(rs.rows.length).toBe(1);
107
- expect(rs.rows.item(0).myResult).toBe('3.40.0');
107
+ expect(rs.rows.item(0).myResult).toBe('3.43.1');
108
108
 
109
109
  // Close (plugin only) & finish:
110
110
  (isWebSql) ? done() : db.close(done, done);