Skip to content

Commit

Permalink
Some test updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher J. Brody committed May 3, 2017
1 parent 19cdc32 commit 06ad95b
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 44 deletions.
2 changes: 1 addition & 1 deletion spec/config.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.phonegap.plugins.sqlite.tests" version="0.0.1"
xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>Cordova-sqlite-spec</name>
<name>cordova-sqlite-spec</name>
<description>
Runs the unit tests suite for the Cordova SQLite plugin.
</description>
Expand Down
7 changes: 4 additions & 3 deletions spec/www/spec/basic-db-tx-sql-storage-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ 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
// the androidLockWorkaround: 1 option in the case of implementation #2.
// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
// this test script will also apply the androidLockWorkaround: 1 option
// in case of implementation #2.
var scenarioList = [
isAndroid ? 'Plugin-implementation-default' : 'Plugin',
'HTML5',
Expand Down
6 changes: 3 additions & 3 deletions spec/www/spec/browser-check-startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

var MYTIMEOUT = 12000;

var isAndroid = /Android/.test(navigator.userAgent);
var isWP8 = /IEMobile/.test(navigator.userAgent); // Matches WP(7/8/8.1)
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);

window.hasBrowser = true;
// XXX TODO rename to something like window.hasWebKitWebSQL here and
// in actual test scripts
// XXX FUTURE TODO rename to something like window.hasWebKitWebSQL here
// and in actual test scripts
window.hasWebKitBrowser = (!isWindows && !isWP8 && !isMac && (isAndroid || !(window.webkit && window.webkit.messageHandlers)));

describe('check startup', function() {
Expand Down
2 changes: 1 addition & 1 deletion spec/www/spec/db-simultaneous-tx-access-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function start(n) {
if (wait == 0) test_it_done();
}

var isWindows = /Windows /.test(navigator.userAgent); // Windows (8.1)
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);

// NOTE: In the common storage-master branch there is no difference between the
Expand Down
7 changes: 4 additions & 3 deletions spec/www/spec/db-sql-operations-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isWKWebView = !isWindows && !isAndroid && !isWP8 && !isMac && !!window.webkit && !!window.webkit.messageHandlers;

// NOTE: In the common storage-master branch there is no difference between the
// default implementation and implementation #2. But the test will also apply
// the androidLockWorkaround: 1 option in the case of implementation #2.
// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
// this test script will also apply the androidLockWorkaround: 1 option
// in case of implementation #2.
var scenarioList = [
isAndroid ? 'Plugin-implementation-default' : 'Plugin',
'HTML5',
Expand Down
7 changes: 4 additions & 3 deletions spec/www/spec/db-tx-multiple-update-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ function start(n) {
var isWindows = /Windows /.test(navigator.userAgent); // Windows
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);

// NOTE: In the common storage-master branch there is no difference between the
// default implementation and implementation #2. But the test will also apply
// the androidLockWorkaround: 1 option in the case of implementation #2.
// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
// this test script will also apply the androidLockWorkaround: 1 option
// in case of implementation #2.
var scenarioList = [
isAndroid ? 'Plugin-implementation-default' : 'Plugin',
'HTML5',
Expand Down
7 changes: 4 additions & 3 deletions spec/www/spec/db-tx-sql-features-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ 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);

// NOTE: In the common storage-master branch there is no difference between the
// default implementation and implementation #2. But the test will also apply
// the androidLockWorkaround: 1 option in the case of implementation #2.
// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
// this test script will also apply the androidLockWorkaround: 1 option
// in case of implementation #2.
var scenarioList = [
isAndroid ? 'Plugin-implementation-default' : 'Plugin',
'HTML5',
Expand Down
2 changes: 1 addition & 1 deletion spec/www/spec/db-tx-value-bindings-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var MYTIMEOUT = 12000;
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 (8.1)
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.test(navigator.userAgent);
var isMac = /Macintosh/.test(navigator.userAgent);
var isWKWebView = !isWindows && !isAndroid && !isWP8 && !isMac && !!window.webkit && !!window.webkit.messageHandlers;
Expand Down
12 changes: 3 additions & 9 deletions spec/www/spec/ext-tx-blob-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,9 @@ var DEFAULT_SIZE = 5000000; // max to avoid popup in safari/ios
// FUTURE TODO replace in test(s):
function ok(test, desc) { expect(test).toBe(true); }

var isAndroid = /Android/.test(navigator.userAgent);
var isWP8 = /IEMobile/.test(navigator.userAgent); // Matches WP(7/8/8.1)
//var isWindows = /Windows NT/.test(navigator.userAgent); // Windows [NT] (8.1)
var isWindows = /Windows /.test(navigator.userAgent); // Windows (8.1)
//var isWindowsPC = /Windows NT/.test(navigator.userAgent); // Windows [NT] (8.1)
//var isWindowsPhone_8_1 = /Windows Phone 8.1/.test(navigator.userAgent); // Windows Phone 8.1
//var isIE = isWindows || isWP8 || isWindowsPhone_8_1;
var isIE = isWindows || isWP8;
var isWebKit = !isIE; // TBD [Android or iOS]
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.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 All @@ -32,7 +26,7 @@ var mytests = function() {

for (var i=0; i<scenarioCount; ++i) {

describe(scenarioList[i] + ': tx blob test(s)', function() {
describe(scenarioList[i] + ': ext tx blob test(s)', function() {
var scenarioName = scenarioList[i];
var suiteName = scenarioName + ': ';
var isWebSql = (i === 1);
Expand Down
16 changes: 9 additions & 7 deletions spec/www/spec/regexp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var scenarioList = [ isAndroid ? 'Plugin-implementation-default' : 'Plugin', 'HT

var scenarioCount = (!!window.hasWebKitBrowser) ? (isAndroid ? 3 : 2) : 1;

// simple tests:
var mytests = function() {

for (var i=0; i<scenarioCount; ++i) {
Expand All @@ -28,23 +27,26 @@ var mytests = function() {
// NOTE: MUST be defined in function scope, NOT outer scope:
var openDatabase = function(name, ignored1, ignored2, ignored3) {
if (isImpl2) {
return window.sqlitePlugin.openDatabase({name: name, location: 1, androidDatabaseImplementation: 2});
// explicit database location:
return window.sqlitePlugin.openDatabase({name: name, location: 'default', androidDatabaseImplementation: 2});
}
if (isWebSql) {
return window.openDatabase(name, "1.0", "Demo", DEFAULT_SIZE);
} else {
return window.sqlitePlugin.openDatabase({name: name, location: 0});
// explicit database location:
return window.sqlitePlugin.openDatabase({name: name, location: 'default'});
}
}

it(suiteName + 'Simple REGEXP test',
function(done) {
// Test for Android Web SQL ONLY
// TBD Test for Android Web SQL ONLY in this version branch:
if (isWP8) pending('NOT IMPLEMENTED for WP8');
if (isWindows) pending('NOT IMPLEMENTED for Windows');
//if (!isWebSql && isAndroid && isImpl2 && /Android [1-4]/.test(navigator.userAgent)) pending('BROKEN for android.database (version 1.x-4.x)');
if (!isWebSql && isAndroid) pending('SKIP for android.database'); // TBD (SKIP for Android plugin for now)
if (!isAndroid && !isWindows && !isWP8) pending('SKIP for iOS/macOS');
if (!isWebSql && !isWindows && isAndroid) pending('SKIP for Android plugin'); // TBD SKIP for Android plugin (for now)
if (isWebSql && !isAndroid && !isWindows && !isWP8) pending('SKIP for iOS (WebKit) Web SQL');
// TBD REMOVE from version branches such as cordova-sqlite-ext:
if (!isWebSql && !isAndroid && !isWindows && !isWP8) pending('NOT IMPLEMENTED for iOS/macOS plugin');

var db = openDatabase('simple-regexp-test.db', '1.0', 'test', DEFAULT_SIZE);

Expand Down
23 changes: 13 additions & 10 deletions spec/www/spec/tx-semantics-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ function start(n) {
var isWindows = /Windows /.test(navigator.userAgent); // Windows 8.1/Windows Phone 8.1/Windows 10
var isAndroid = !isWindows && /Android/.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
// the androidLockWorkaround: 1 option in the case of implementation #2.
// NOTE: While in certain version branches there is no difference between
// the default Android implementation and implementation #2,
// this test script will also apply the androidLockWorkaround: 1 option
// in case of implementation #2.
var scenarioList = [
isAndroid ? 'Plugin-implementation-default' : 'Plugin',
'HTML5',
Expand All @@ -52,29 +53,31 @@ var mytests = function() {
var scenarioName = scenarioList[i];
var suiteName = scenarioName + ': ';
var isWebSql = (i === 1);
var isOldImpl = (i === 2);
var isImpl2 = (i === 2);

// NOTE: MUST be defined in function scope, NOT outer scope:
var openDatabase = function(name, ignored1, ignored2, ignored3) {
if (isOldImpl) {
if (isImpl2) {
return window.sqlitePlugin.openDatabase({
// prevent reuse of database from default db implementation:
name: 'i2-'+name,
// explicit database location:
location: 'default',
androidDatabaseImplementation: 2,
androidLockWorkaround: 1,
location: 1
androidLockWorkaround: 1
});
}
if (isWebSql) {
return window.openDatabase(name, "1.0", "Demo", DEFAULT_SIZE);
return window.openDatabase(name, '1.0', 'Test', DEFAULT_SIZE);
} else {
return window.sqlitePlugin.openDatabase({name: name, location: 0});
// explicit database location:
return window.sqlitePlugin.openDatabase({name: name, location: 'default'});
}
}

it(suiteName + 'Simple tx sql order test', function(done) {
// This test shows that executeSql statements run in intermediate callback
// are executed _after_ executeSql statements that were queued before
// are executed AFTER executeSql statements that were queued before

var db = openDatabase('Simple-tx-order-test.db', '1.0', 'Test', DEFAULT_SIZE);

Expand Down

0 comments on commit 06ad95b

Please sign in to comment.