Skip to content

Commit

Permalink
Run simple-test.js in CircleCI (Android) & TravisCI (iOS) and legacy.…
Browse files Browse the repository at this point in the history
…js in CircleCI (Android)
  • Loading branch information
Chris Brody committed May 12, 2015
1 parent 490052b commit 31010a4
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 25 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -5,9 +5,10 @@ node_js:
- "0.10"
install:
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
- cd ..
- npm install -g cordova-paramedic
- npm install -g cordova
- npm install -g ios-sim
script:
- cordova-paramedic --platform ios --plugin ${TRAVIS_BUILD_DIR}
- cp ${TRAVIS_BUILD_DIR}/spec/www/spec/simple-test.js ${TRAVIS_BUILD_DIR}/tests/tests.js
- cordova-paramedic --platform ios --plugin ${TRAVIS_BUILD_DIR} --timeout 3600000
4 changes: 4 additions & 0 deletions circle.yml
Expand Up @@ -15,3 +15,7 @@ test:
- circle-android wait-for-boot
override:
- cordova-paramedic --platform android --plugin .
- cp spec/www/spec/simple-test.js tests/tests.js
- cordova-paramedic --platform android --plugin . --timeout 3600000
- cp spec/www/spec/legacy.js tests/tests.js
- cordova-paramedic --platform android --plugin . --timeout 7200000
1 change: 1 addition & 0 deletions spec/www/index.html
Expand Up @@ -19,6 +19,7 @@
<script src="SQLitePlugin.js"></script>

<!-- spec file(s): -->
<script src="spec/browser-check-startup.js"></script>
<script src="spec/simple-test.js"></script>
<script src="spec/legacy.js"></script>

Expand Down
33 changes: 33 additions & 0 deletions spec/www/spec/browser-check-startup.js
@@ -0,0 +1,33 @@
/* 'use strict'; */

var MYTIMEOUT = 12000;

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]

window.hasBrowser = true;
window.hasWebKitBrowser = isWebKit;

describe('check startup', function() {
it('receives deviceready event', function(done) {
expect(true).toBe(true);
document.addEventListener("deviceready", function() {
done();
});
}, MYTIMEOUT);

it('has openDatabase', function() {
if (isWebKit) expect(window.openDatabase).toBeDefined();
expect(window.sqlitePlugin).toBeDefined();
expect(window.sqlitePlugin.openDatabase).toBeDefined();
});
});

/* vim: set expandtab : */
10 changes: 7 additions & 3 deletions spec/www/spec/legacy.js
Expand Up @@ -42,9 +42,10 @@ var isWebKit = !isIE; // TBD [Android or iOS]

var scenarioList = [ 'Plugin', 'HTML5' ];

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

describe('legacy tests', function() {
// legacy tests:
var mytests = function() {

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

Expand Down Expand Up @@ -2202,6 +2203,9 @@ describe('legacy tests', function() {

});

});
}

if (window.hasBrowser) mytests();
else exports.defineAutoTests = mytests;

/* vim: set expandtab : */
34 changes: 13 additions & 21 deletions spec/www/spec/simple-test.js
Expand Up @@ -10,32 +10,21 @@ function equal(a, b, desc) { expect(a).toEqual(b); } // '=='
function strictEqual(a, b, desc) { expect(a).toBe(b); } // '==='

var isAndroid = /Android/.test(navigator.userAgent);
var isWindows = /Windows NT/.test(navigator.userAgent); // Windows [NT] (8.1)
var isWP8 = /IEMobile/.test(navigator.userAgent); // WP(8)
// FUTURE:
//var isWindowsPhone = /Windows Phone 8.1/.test(navigator.userAgent); // Windows [NT] (8.1)
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 scenarioList = [ 'Plugin', 'HTML5' ];

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

describe('check startup', function() {

it('receives deviceready event', function(done) {
expect(true).toBe(true);
document.addEventListener("deviceready", function() { done(); });
}, MYTIMEOUT);

it('has openDatabase', function() {
if (isWebKit) expect(window.openDatabase).toBeDefined();
expect(window.sqlitePlugin).toBeDefined();
expect(window.sqlitePlugin.openDatabase).toBeDefined();
});
});

describe('simple tests', function() {
// simple tests:
var mytests = function() {

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

Expand Down Expand Up @@ -244,6 +233,9 @@ describe('simple tests', function() {

});
};
});
}

if (window.hasBrowser) mytests();
else exports.defineAutoTests = mytests;

/* vim: set expandtab : */

0 comments on commit 31010a4

Please sign in to comment.