Skip to content

Commit

Permalink
Merge pull request #44 from sbmadhav/feature/time-out
Browse files Browse the repository at this point in the history
option to set time out
  • Loading branch information
stefanjudis committed Apr 19, 2016
2 parents 0370572 + 386229e commit 9d91025
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ module.exports = function(grunt) {
}
},
// 'magic',
urls : [ 'http://4waisenkinder.de' ]
urls : [ 'http://4waisenkinder.de' ],
timeOut : 1000
}
}
},
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ Default value: `default`
- `darker` - image information in diff image will be changed to a darker image
- `brighter` - image information in diff image will be change to a brighter image

+#### options.timeOut

Type: `Integer`

Default value: 1000

An Integer representing the delay in milliseconds after the screenshot should be taken.

### Usage Examples

#### Default Options
Expand Down
3 changes: 2 additions & 1 deletion tasks/lib/photobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ PhotoBox.prototype.startPhotoSession = function() {
localToRemoteUrlAccessEnabled : this.options.localToRemoteUrlAccessEnabled,
password : this.options.password,
userAgent : this.options.userAgent,
userName : this.options.userName
userName : this.options.userName,
timeOut : this.options.timeOut
} );

this.pictures.forEach( function( picture ) {
Expand Down
4 changes: 3 additions & 1 deletion tasks/lib/photoboxScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var system = require ( 'system' ),
width = +split[ 1 ],
image = split[ 2 ],
indexPath = system.args[ 2 ],
timeOut = 1000,
settings = fs.read( indexPath + 'options.json' );

if ( settings !== '{}' ) {
Expand All @@ -28,6 +29,7 @@ if ( settings !== '{}' ) {
settings = JSON.parse( settings );

page.settings = settings;
timeOut = settings.timeOut || timeOut;
} catch( e ) {
console.warn( 'CONSOLE: Error parsing settings | ' + e );

Expand Down Expand Up @@ -75,5 +77,5 @@ page.open( url, function( status ) {
page.render( imgPath );

phantom.exit();
}, 1000 );
}, timeOut );
} );
3 changes: 2 additions & 1 deletion tasks/photobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module.exports = function( grunt ) {
template : 'canvas',
userAgent : 'Photobox',
userName : '',
urls : [ 'http://4waisenkinder.de' ]
urls : [ 'http://4waisenkinder.de' ],
timeOut : 1000
} ),
Photobox = require( './lib/photobox' ),
pb = new Photobox( grunt, options, done );
Expand Down
33 changes: 33 additions & 0 deletions test/lib/photoboxTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,5 +713,38 @@ exports.photoBox = {
test.done();

grunt.file.delete( 'tmp/img/current/timestamp.json' );
},

setTimeOut : function ( test ) {
var options = {
indexPath : 'tmp',
template : {
name : 'canvas',
options : {
highlightColor : '#ff0000', // template.options.hightlightColor || highlightcolor || default
diffFilter : 'default' // default == no filter 'grayscale' | 'darker' | 'brighter'
}
},
screenSizes : [ '1000' ],
urls : [ 'http://google.com' ],
timeOut : 2000
},
pb = new Photobox( grunt, options ),
readOptions;

pb.writeOptionsFile( options );

readOptions = JSON.parse( grunt.file.read( 'tmp/options.json' ) );

test.strictEqual( grunt.file.exists( 'tmp/options.json' ), true );
test.strictEqual( readOptions.indexPath, 'tmp/' );
test.strictEqual( readOptions.screenSizes.length, 1 );
test.strictEqual( readOptions.screenSizes[ 0 ], '1000' );
test.strictEqual( readOptions.urls.length, 1 );
test.strictEqual( readOptions.urls[ 0 ], 'http://google.com' );
test.strictEqual( readOptions.timeOut, 2000 );
test.done();

grunt.file.delete( 'tmp/options.json' );
}
};

0 comments on commit 9d91025

Please sign in to comment.