Skip to content

Commit

Permalink
repeated open/close/delete tests also for androidDatabaseImplementati…
Browse files Browse the repository at this point in the history
…on: 2

other minor test fixes
  • Loading branch information
Christopher J. Brody committed Dec 12, 2017
1 parent 45aba72 commit a6c3997
Showing 1 changed file with 42 additions and 9 deletions.
51 changes: 42 additions & 9 deletions spec/www/spec/db-open-close-delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,46 @@ var mytests = function() {
});
}

describe('repeated open/close/delete test(s)', function() {
var scenarioName = isAndroid ? 'Plugin-implementation-default' : 'Plugin';
var suiteName = scenarioName + ': ';
for (var i=0; i<pluginScenarioCount; ++i) {

describe(pluginScenarioList[i] + ': repeated open/close/delete test(s)', function() {
var scenarioName = pluginScenarioList[i];
var suiteName = scenarioName + ': ';
var isImpl2 = (i === 1);

// NOTE: MUST be defined in function scope, NOT outer scope:
var openDatabase = function(first, second, third) {
if (first.constructor === String ) throw new Error('string not expected here');

// androidDatabaseImplementation: 2 (builtin android.database implementation):
if (isImpl2) {
var dbname = first.name;
return window.sqlitePlugin.openDatabase({
name: 'i2-'+dbname,
// database location setting needed here (value ignored on Android):
location: 'default',
androidDatabaseImplementation: 2,
androidLockWorkaround: 1
}, second, third);
}

return window.sqlitePlugin.openDatabase(first, second, third);
}

var deleteDatabase = function(first, second, third) {
if (first.constructor === String ) throw new Error('string not expected here');

// androidDatabaseImplementation: 2 (builtin android.database implementation):
if (isImpl2) {
var dbname = first.name;
return window.sqlitePlugin.deleteDatabase({
name: 'i2-'+dbname,
// database location setting needed here (value ignored on Android):
location: 'default',
androidDatabaseImplementation: 2
}, second, third);
}

window.sqlitePlugin.deleteDatabase(first, second, third);
}

Expand All @@ -471,23 +501,23 @@ var mytests = function() {
var db1 = openDatabase(dbargs, function () {
var db2 = openDatabase(dbargs, function () {
db1.readTransaction(function(tx1) {
tx1.executeSql('SELECT 1', [], function(tx1d, results) {
tx1.executeSql('SELECT 1', [], function(tx_ignored, results) {
ok(true, 'db1 transaction working');
start(1);
}, function(error) {
}, function(tx_ignored, error) {
ok(false, error);
});
}, function(error) {
ok(false, error);
});
db2.readTransaction(function(tx2) {
tx2.executeSql('SELECT 1', [], function(tx2d, results) {
tx2.executeSql('SELECT 1', [], function(tx_ignored, results) {
ok(true, 'db2 transaction working');
start(1);
}, function(error) {
}, function(tx_ignored, error) {
ok(false, error);
});
}, function(error) {
}, function(tx_ignored, error) {
ok(false, error);
});
}, function (error) {
Expand Down Expand Up @@ -741,6 +771,8 @@ var mytests = function() {
test_it(suiteName + ' repeatedly open and close database faster (5x)', function () {
// TBD CURRENTLY BROKEN on iOS/macOS due to current background processing implementation:
if (!isAndroid && !isWindows && !isWP8) pending('CURRENTLY BROKEN on iOS/macOS (background processing implementation)');
// TBD ???:
if (isAndroid && isImpl2) pending('FAILS on builtin android.database implementation (androidDatabaseImplementation: 2)');

var dbName = 'repeatedly-open-and-close-faster-5x.db';
var dbargs = {name: dbName, location: 'default'};
Expand Down Expand Up @@ -920,7 +952,8 @@ var mytests = function() {
});
});

});
});
}

});

Expand Down

0 comments on commit a6c3997

Please sign in to comment.