// #script_properties
// #paramters
// 'Script File Name'='C:\Users\tedson\Documents\Easy Automation\scripts\test.eaf'
// 'Disabled'='No','Script MD5'='2F75-F14D-245F-0E9C-C1D1-1587-0A80-C082'
// 'Root File Name'='C:\Users\tedson\Documents\Easy Automation\scripts\test.eaf'
// 'Script ID'='24B1-5F4B-EA51-2049-3EF4-3F4F-3D62-AE02','Script Description'='This script is used to test everything Easy Automation can do'
// 'Run Script at Startup'='No','Size in Bytes'='55042','Number of Lines'='985'
// 'Version'='2.6.0','Script Name'='Test Everything','Number of Fold Points'='0'
// 'Encrypted'='No'
// #end_parameters
// #end_script_properties
// build a template that will ask the users what they want to test
var templateXML = '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '';
var template = new Template( templateXML );
if( template == null )
{
log( 'ERROR', "Failed to create template error = " + template.lastError );
System.exit( 3 );
}
// display the template and if they hit cancel exit the script
var text = template.expand( true );
if( text == null ) System.exit( 2 );
// they didnt hit cancel so break down the resulting text and see what they want to test
var settings = text.split( ',' );
// parse out the settings
var doAll = ( settings[ 0 ] == 'yes' );
var doPrompt = ( settings[ 1 ] == 'yes' );
var doWindows = ( settings[ 2 ] == 'yes' );
var doServices = ( settings[ 3 ] == 'yes' );
var doEmail = ( settings[ 4 ] == 'yes' );
var doFTP = ( settings[ 5 ] == 'yes' );
var doHTTP = ( settings[ 6 ] == 'yes' );
var doTelnet = ( settings[ 7 ] == 'yes' );
var doPing = ( settings[ 8 ] == 'yes' );
var doSystem = ( settings[ 9 ] == 'yes' );
var doBuiltIn = ( settings[ 10 ] == 'yes' );
var doReboot = ( settings[ 11 ] == 'yes' );
var doShutdown = ( settings[ 12 ] == 'yes' );
var doLogoff = ( settings[ 13 ] == 'yes' );
var doGlobals = ( settings[ 14 ] == 'yes' );
var doFiles = ( settings[ 15 ] == 'yes' );
var doAudio = ( settings[ 16 ] == 'yes' );
var doTemplate = ( settings[ 17 ] == 'yes' );
var doXML = ( settings[ 18 ] == 'yes' );
var doEncrypt = ( settings[ 19 ] == 'yes' );
var doRegistry = ( settings[ 20 ] == 'yes' );
var doImage = ( settings[ 21 ] == 'yes' );
if( doReboot ) System.reboot();
if( doShutdown ) System.shutdown();
if( doLogoff ) System.logoff();
if( doPrompt || doAll )
{
log( 'INFO', '********** Testing Built in dialogs ************************************' );
log( 'DEBUG', 'about()' );
about();
log( 'DEBUG', 'testing file prompt' );
var result = prompt( 'xml|html|txt|all', 'file', 'c:\\test.txt' );
log( 'DEBUG', 'result was = ' + result );
log( 'DEBUG', 'testing folder prompt' );
var result = prompt( 'Please choose a folder.', 'folder', '' );
log( 'DEBUG', 'result was = ' + result );
log( 'DEBUG', 'testing yesno prompt' );
var result = prompt( 'choose yes or no', 'yesno', 'yes' );
log( 'DEBUG', 'result was = ' + result );
log( 'DEBUG', 'testing input prompt' );
var result = prompt( 'type something', 'input', 'something' );
log( 'DEBUG', 'result was = ' + result );
log( 'DEBUG', 'testing choice prompt' );
var result = prompt( 'choose something', 'choice', 'a|b|*c|d|a||b' );
log( 'DEBUG', 'result was = ' + result );
prompt( 'This is just a message', 'ok', '' );
log( 'INFO', '********** Testing progress *********************************************' );
log( 'DEBUG', 'var progress = new Progress( "This is a test" );' );
var progress = new Progress( 'This is a test' );
for( i = 0; i < 100; i++ )
{
wasCanceled = progress.update( 'Working ' + i + '% complete', i );
if( wasCanceled )
{
log( 'DEBUG', 'progress was canceled' );
break;
}
sleep( 200 );
}
log( 'DEBUG', 'progress.close();' );
progress.close();
log( 'INFO', '********** Testing alert *************************************************' );
alert( 'Hello World', 'This is the title' );
log( 'INFO', '********** Testing notify ************************************************' );
log( 'DEBUG', 'alert( "Test Message", "Test Title", 1000, "slide", 200, 200 );' );
notify( "Test Message", "Test Title", 1000, "slide", 200, 200 );
log( 'DEBUG', 'alert( "Test Message", "Test Title", 2000, "fade", 100, 100 );' );
notify( "Test Message", "Test Title", 2000, "fade", 100, 100 );
log( 'DEBUG', 'alert( "Test Message", "Test Title", 1000, "unfold", 300, 300 );' );
notify( "Test Message", "Test Title", 1000, "unfold", 300, 300 );
log( 'DEBUG', 'alert( "Test Message", "Test Title", 1000, "none", 200, 200 );' );
notify( "Test Message", "Test Title", 1000, "none", 200, 200 );
}
if( doWindows || doAll )
{
log( 'INFO', '********** Testing window manipulations *****************************' );
// run notepad
log( 'DEBUG', 'System.runProgram( "notepad.exe" )' );
System.runProgram( 'notepad.exe' );
// find the window so we can work with it
log( 'DEBUG', 'findWindow( "Untitled - Notepad", "", "true" )' );
var notepadWindow = findWindow( 'Untitled - Notepad', '', 'true' );
log( 'DEBUG', 'notepadWindow = ' + notepadWindow );
// find some windows and dump out information about them
log( 'DEBUG', 'finding child window at 10, 10' );
var childWindow = notepadWindow.getChildWindowAtPoint( 10, 10 );
log( 'DEBUG', 'child window = ' + childWindow );
log( 'DEBUG', 'finding root window of childWindow' );
var rootWindow = childWindow.getRootWindow();
log( 'DEBUG', 'rootWindow window = ' + rootWindow );
log( 'DEBUG', 'finding top window' );
var topWindow = notepadWindow.getTopWindow();
log( 'DEBUG', 'topWindow window = ' + topWindow + ' root of top = ' + topWindow.getRootWindow() );
log( 'DEBUG', 'Notepad innerRect = ' + notepadWindow.innerRect );
log( 'DEBUG', 'Notepad outerRect = ' + notepadWindow.outerRect );
log( 'DEBUG', 'Notepad state = ' + notepadWindow.state );
log( 'DEBUG', 'Notepad text = ' + notepadWindow.text );
// move and resize the notepad window
log( 'DEBUG', 'moving notepad to 1,1' );
notepadWindow.moveTo( 1, 1 );
log( 'DEBUG', 'resizing notepad to 400, 400' );
notepadWindow.resize( 400, 400 );
log( 'DEBUG', 'bringing window to front' );
notepadWindow.toFront();
sleep( 500 );
// find the notepad window on the screen
log( 'DEBUG', 'finding window at 2,2' );
var windowAt22 = getWindowAtPoint( 2, 2 );
log( 'DEBUG', 'found ' + windowAt22 + ' rootwindow = ' + windowAt22.getRootWindow() );
log( 'DEBUG', 'getting window with focus' );
var windowWithFocus = getWindowWithFocus( true );
log( 'DEBUG', 'found ' + windowWithFocus );
// type something in notepad
log( 'DEBUG', 'sending keystrokes "Hello World!" to window with focus' );
sendKeys( stringToKeys( 'Hello World!' ) );
log( 'DEBUG', 'sending keystrokes "Good-bye World!" to notepad window' );
notepadWindow.sendKeys( stringToKeys( 'Good-bye World!' ) );
sleep( 500 );
// close notepad using a windows message
log( 'DEBUG', 'sending WM_CLOSE to notepad window' );
notepadWindow.postMessage( 16, 0, 0 );
sleep( 500 );
// find the right button to click and cancel the close
log( 'DEBUG', 'finding do you want to save dialog' );
var promptWindow = findWindow( 'Notepad', '', 'true' );
log( 'DEBUG', 'found ' + promptWindow );
if( !promptWindow ) System.exit();
log( 'DEBUG', 'finding cancel button' );
var cancelWindow = promptWindow.findWindow( 'Cancel', '', 'true' );
log( 'DEBUG', 'found ' + cancelWindow )
log( 'DEBUG', 'mouseClick at cancel button - 3, 3' );
cancelWindow.mouseClick( 'left', 3, 3 );
sleep( 500 );
// pop up the font dialog using the menus
log( 'DEBUG', 'popping up the format menu' );
notepadWindow.mouseClick( 'left', 93, -8 );
sleep( 500 );
log( 'DEBUG', 'pop up the font dialog' );
var menu = getWindowAtPoint( 75, 50 );
menu.mouseClick( 'left', 41, 32 );
sleep( 500 );
// use the cancel button to close the window
log( 'DEBUG', 'finding the font window' );
var fontWindow = findWindow( 'Font', '', 'true' );
log( 'DEBUG', 'fontWindow = ' + fontWindow );
log( 'DEBUG', 'finding the cancel button' );
var cancelButton = fontWindow.getControl( 2 );
log( 'DEBUG', 'cancelButton = ' + cancelButton );
cancelButton.mouseClick( 'left', 3, 3 );
sleep( 500 );
// move the mouse around and click on stuff
log( 'DEBUG', 'mouseClick screen at 10 10' );
mouseClick( 'left', 10, 10 );
log( 'DEBUG', 'mouseMoveTo screen moving to 40,40' );
mouseMoveTo( 40, 40 );
log( 'DEBUG', 'mouseDown screen at 40, 40' );
mouseDown( 'left', 40, 40 );
log( 'DEBUG', 'mouseUp at screen 40, 40' );
mouseUp( 'left', 40, 40 );
log( 'DEBUG', 'mouseUp at 200, 200' );
notepadWindow.mouseMoveTo( 200, 200 );
// close down the notepad
log( 'DEBUG', 'closing notepad window' );
notepadWindow.close();
log( 'DEBUG', 'sleeping 1 seconds' );
sleep( 1000 );
log( 'DEBUG', 'finding do you want to save dialog' );
var promptWindow = findWindow( 'Notepad', '', 'true' );
log( 'DEBUG', 'found ' + promptWindow );
// click on the dont save button
log( 'DEBUG', 'finding dont save button' );
var dontSave = promptWindow.findWindow( 'Do&n\'t Save', '', 'true' );
log( 'DEBUG', 'found ' + dontSave );
log( 'DEBUG', 'clicking on dont save' );
dontSave.mouseClick( 'left', 2, 2 );
// get the desktop window
log( 'DEBUG', 'Desktop Window = ' + getDesktop() );
}
if( doGlobals || doAll )
{
log( 'INFO', '********** Testing global functions *****************************' );
log( 'DEBUG', 'escapeForFile( "hello\nworld" )' );
var escapedForFileString = escapeForFile( "hello\nworld" );
log( 'DEBUG', 'escaped for file results = ' + escapedForFileString );
var unescapedForFileString = unescapeForFile( escapedForFileString );
log( 'DEBUG', 'unescaped for file results = ' + unescapedForFileString );
log( 'DEBUG', 'new Date()' );
var date = new Date();
log( 'DEBUG', 'formatDate( date, "%d-%m-%y %H:%M:%S" )' );
var formattedDate = formatDate( date, "%d-%m-%y %H:%M:%S" );
log( 'DEBUG', 'formatted date = ' + formattedDate );
log( 'DEBUG', 'getting setting "Last Update Version"' );
var lastUpdateVersion = getSetting( 'LastUpdate' );
log( 'DEBUG', '"Last Update Version" = ' + lastUpdateVersion );
log( 'DEBUG', 'md5( hello ) = ' + md5( 'hello' ) );
setMinLogLevel( 'INFO' );
log( 'DEBUG', 'Min log level is now info' );
log( 'INFO', 'Min log level is now info' );
setMinLogLevel( 'DEBUG' );
log( 'DEBUG', 'Min log level is now debug' );
log( 'DEBUG', 'stringToKeys( "Hello World!" ) = ' + stringToKeys( 'Hello World!' ) );
log( 'DEBUG', 'trim( " Hello World! " ) = ' + trim( ' Hello World! ' ) );
log( 'INFO', '********** Testing points, rectangles and colors *************************' );
var point = new Point( 10, 10 );
log( 'DEBUG', 'Point = ' + point );
var rectangle = new Rectangle( 10, 10, 20, 30 );
log( 'DEBUG', 'Rectangle = ' + rectangle );
log( 'DEBUG', 'Rectangle width = ' + rectangle.getWidth() + ' Rectangle width = ' + rectangle.getHeight() );
log( 'DEBUG', 'Rectangle top left = ' + rectangle.getTopLeft() + ' Rectangle bottom right = ' + rectangle.getBottomRight() );
var color = new Color( 10, 20, 30, 100 );
log( 'DEBUG', 'Color = ' + color );
log( 'DEBUG', 'Color.red = ' + color.red );
log( 'DEBUG', 'Color.green = ' + color.green );
log( 'DEBUG', 'Color.blue = ' + color.blue );
log( 'DEBUG', 'Color.opacity = ' + color.opacity );
log( 'DEBUG', 'Color in hex = #' + color.hex );
log( 'DEBUG', 'Setting color to #ffffff' );
color.hex = 'ffffff';
log( 'DEBUG', 'Color in hex = #' + color.hex );
log( 'DEBUG', 'Setting color to #AA' );
color.hex = 'AA';
log( 'DEBUG', 'Color in hex = #' + color.hex );
log( 'DEBUG', 'Setting color to 10, 20, 30, 40' );
color.red = 10;
color.green = 20;
color.blue = 30;
color.opacity = 40;
log( 'DEBUG', 'Color.red = ' + color.red );
log( 'DEBUG', 'Color.green = ' + color.green );
log( 'DEBUG', 'Color.blue = ' + color.blue );
log( 'DEBUG', 'Color.opacity = ' + color.opacity );
log( 'DEBUG', 'Color in hex = #' + color.hex );
log( 'DEBUG', 'setting color to red' );
color.setColor( 'red' );
log( 'DEBUG', 'Color.red = ' + color.red );
log( 'DEBUG', 'Color.green = ' + color.green );
log( 'DEBUG', 'Color.blue = ' + color.blue );
log( 'INFO', '********** Testing Binary Blobs ******************************************' );
var blob = new BinaryBlob();
log( 'DEBUG', 'Setting value 255 into blob offset by 4 bits - blob.setValue( 0, 4, 8, 255 )' );
blob.setValue( 0, 4, 8, 255 );
log( 'DEBUG', 'blob = ' + blob );
log( 'DEBUG', 'blob size = ' + blob.size );
log( 'DEBUG', 'contents of blob using getByte = ' + blob.getByte( 0 ) + ' ' + blob.getByte( 1 ) );
log( 'DEBUG', 'contents of blob using getValue = ' + blob.getValue( 0, 0, 8 ) + ' ' + blob.getValue( 1, 0, 8 ) );
log( 'DEBUG', 'getting origional 255 offset by 4 bits back out - blob.getValue( 0, 4, 8 ) = ' + blob.getValue( 0, 4, 8 ) );
log( 'DEBUG', 'md5 of blob = ' + blob.md5 );
log( 'DEBUG', 'clearing blob' );
blob.clear();
log( 'DEBUG', 'blob = ' + blob );
log( 'DEBUG', 'Writing string abcde into blob at byte zero' );
blob.setString( 0, 0, 5, 'abcde' );
log( 'DEBUG', 'md5 of blob = ' + blob.md5 );
var base64 = blob.toBase64();
log( 'DEBUG', 'base64 of blob = ' + base64 );
blob.fromBase64( base64 );
log( 'DEBUG', 'contents after converting back ' + blob.getString( 0, 0, 5 ) );
log( 'DEBUG', 'md5 of blob = ' + blob.md5 );
blob.clear();
log( 'DEBUG', 'Writing string "Now is the time for all good men to" into blob at byte zero' );
blob.setString( 0, 0, 35, "Now is the time for all good men to" );
log( 'DEBUG', 'md5 of blob = ' + blob.md5 );
base64 = blob.toBase64();
log( 'DEBUG', 'base64 of blob = ' + base64 );
blob.fromBase64( base64 );
log( 'DEBUG', 'contents after converting back ' + blob.getString( 0, 0, 35 ) );
log( 'DEBUG', 'md5 of blob = ' + blob.md5 );
log( 'DEBUG', 'Writing 2 bytes of string abcde into blob at byte zero' );
blob.setString( 0, 0, 2, 'abcde' );
log( 'DEBUG', 'contents of blob using getByte (should be 97 98) = ' + blob.getByte( 0 ) + ' ' + blob.getByte( 1 ) );
log( 'DEBUG', 'contents of blob using getByte as characters = ' + String.fromCharCode( blob.getByte( 0 ) ) + ' ' + String.fromCharCode( blob.getByte( 1 ) ) );
blob.clear();
log( 'DEBUG', 'Writing 2 bytes of string abcde into blob at byte zero offset by 4 bits' );
blob.setString( 0, 4, 2, 'abcde' );
log( 'DEBUG', 'contents of blob using getByte (should be 16, 38) = ' + blob.getByte( 0 ) + ' ' + blob.getByte( 1 ) );
log( 'DEBUG', 'contents of blob using getValue as characters offset by 4 bits = ' + String.fromCharCode( blob.getValue( 0, 4, 8 ) ) + ' ' + String.fromCharCode( blob.getValue( 1, 4, 8 ) ) )
log( 'DEBUG', 'blob.getString( 0, 4, 1 ) = ' + blob.getString( 0, 4, 1 ) );
log( 'DEBUG', 'blob.getString( 0, 4, 2 ) = ' + blob.getString( 0, 4, 2 ) );
log( 'DEBUG', 'blob.getString( 0, 4, 3 ) = ' + blob.getString( 0, 4, 3 ) );
log( 'DEBUG', 'last error = ' + blob.lastError );
blob.clear();
log( 'DEBUG', 'Writing 2 characters from unicode string abcde' );
blob.setUnicodeString( 0, 4, 2, "abcde" );
log( 'DEBUG', 'contents of blob using getValue = ' + blob.getValue( 0, 4, 8 ) + ' ' + blob.getValue( 1, 4, 8 ) + ' ' + blob.getValue( 2, 4, 8 ) + ' ' + blob.getValue( 3, 4, 8 ) )
log( 'DEBUG', 'blob.getUnicodeString( 0, 4, 1 ) = ' + blob.getUnicodeString( 0, 4, 1 ) );
log( 'DEBUG', 'blob.getUnicodeString( 0, 4, 2 ) = ' + blob.getUnicodeString( 0, 4, 2 ) );
log( 'DEBUG', 'blob.getUnicodeString( 0, 4, 3 ) = ' + blob.getUnicodeString( 0, 4, 3 ) );
log( 'INFO', '********** Testing URL **************************************************' );
if( typeof( URL ) == 'undefined' ) log( 'INFO', 'Skipping URL - Internet Tools Module not installed' );
else
{
log( 'DEBUG', 'new URL( "http://images.google.com/imghp?hl=en&tab=wi" )' );
var url = new URL( "http://images.google.com/imghp?hl=en&tab=wi" );
log( 'DEBUG', 'url = ' + url.url );
log( 'DEBUG', 'protocol = ' + url.protocol + ' domain = ' + url.domain + ' port = ' + url.port + ' page = ' + url.page + ' params = ' + url.parameters );
}
log( 'INFO', '********** Testing Script *************************************************' );
log( 'DEBUG', 'getting information about the currently running script' );
var currentScript = getRunningScript();
log( 'DEBUG', 'currentScript.getCurrentLineNumber() = ' + currentScript.getCurrentLineNumber() );
log( 'DEBUG', 'currentScript.description = ' + currentScript.description );
log( 'DEBUG', 'currentScript.fileName = ' + currentScript.fileName );
log( 'DEBUG', 'currentScript.name = ' + currentScript.name );
log( 'DEBUG', 'currentScript.numberLines = ' + currentScript.numberLines );
log( 'DEBUG', 'currentScript.size = ' + currentScript.size );
log( 'DEBUG', 'currentScript.id = ' + currentScript.id );
log( 'DEBUG', 'currentScript.hasPassword = ' + currentScript.hasPassword );
log( 'DEBUG', 'currentScript.isEncrypted = ' + currentScript.isEncrypted );
log( 'DEBUG', 'currentScript.type = ' + currentScript.type );
log( 'DEBUG', 'currentScript.md5 = ' + currentScript.md5 );
log( 'DEBUG', 'currentScript.runAtStartup = ' + currentScript.runAtStartup );
log( 'DEBUG', 'setting runAtStartup to Yes = ' + currentScript.setScriptStartupMode( 'Yes' ) );
log( 'DEBUG', 'currentScript.runAtStartup = ' + currentScript.runAtStartup );
log( 'DEBUG', 'setting runAtStartup to No = ' + currentScript.setScriptStartupMode( 'No' ) );
log( 'DEBUG', 'currentScript.runAtStartup = ' + currentScript.runAtStartup );
log( 'DEBUG', 'currentScript.isDisabled = ' + currentScript.isDisabled );
log( 'DEBUG', 'disabling the script = ' + currentScript.enableScript( false ) );
log( 'DEBUG', 'currentScript.isDisabled = ' + currentScript.isDisabled );
log( 'DEBUG', 'enabling the script = ' + currentScript.enableScript( true ) );
log( 'DEBUG', 'currentScript.isDisabled = ' + currentScript.isDisabled );
log( 'DEBUG', 'the list of known scripts' );
var allScripts = getScripts();
for( i in allScripts )
log( 'DEBUG', allScripts[ i ] );
}
if( doFiles || doAll )
{
log( 'INFO', '********** Testing files *************************************************' );
var dirName = System.tempDirectory + 'bob';
log( 'DEBUG', 'adding directory ' + dirName );
addDirectory( dirName );
log( 'DEBUG', 'removing directory ' + dirName );
removeDirectory( dirName );
log( 'DEBUG', 'getting the directories at \\' );
var directories = getDirectories( 'c:\\*' );
log( 'DEBUG', 'the directories are ' + directories );
log( 'DEBUG', 'getting the files at \\' );
var files = getFiles( 'c:\\*' );
log( 'DEBUG', 'the files are ' + files );
var fileName = System.tempDirectory + 'test.txt';
log( 'DEBUG', 'working with the text file ' + fileName );
var filetext = new FileText( fileName );
log( 'DEBUG', 'fullName = ' + filetext.fullName );
log( 'DEBUG', 'isOpen = ' + filetext.isOpen + ' size = ' + filetext.size );
log( 'DEBUG', 'creating the file result = ' + filetext.open( 'create|write' ) );
log( 'DEBUG', 'isOpen = ' + filetext.isOpen + ' size = ' + filetext.size );
log( 'DEBUG', 'writing "hello world" to the file result = ' + filetext.writeln( 'hello world!' ) );
log( 'DEBUG', 'isOpen = ' + filetext.isOpen + ' size = ' + filetext.size );
log( 'DEBUG', 'closing the file result = ' + filetext.close() );
log( 'DEBUG', 'exists = ' + filetext.exists() );
log( 'DEBUG', 'reading all the lines from the file = ' + filetext.readAll() );
log( 'DEBUG', 'reading the lines the hard way open = ' + filetext.open( 'read' ) );
log( 'DEBUG', 'reading the line = ' + filetext.readln() );
log( 'DEBUG', 'closing the file result = ' + filetext.close() );
log( 'DEBUG', 'creating a file object for "' + fileName + '"' );
var file = new File( fileName );
log( 'DEBUG', 'creationTime = ' + file.creationTime );
log( 'DEBUG', 'extension = ' + file.extension );
log( 'DEBUG', 'fullName = ' + file.fullName );
log( 'DEBUG', 'lastAccessed = ' + file.lastAccessed );
log( 'DEBUG', 'lastModified = ' + file.lastModified );
log( 'DEBUG', 'md5 = ' + file.md5 );
log( 'DEBUG', 'name = ' + file.name );
log( 'DEBUG', 'path = ' + file.path );
log( 'DEBUG', 'size = ' + file.size + ' bytes' );
log( 'DEBUG', 'exists = ' + file.exists() );
var newFileName = System.tempDirectory + 'test-copy.txt';
log( 'DEBUG', 'copying the file to ' + newFileName );
log( 'DEBUG', 'results = ' + file.copyTo( newFileName ) );
var newFile = new File( newFileName );
log( 'DEBUG', newFileName + ' exists = ' + newFile.exists() );
log( 'DEBUG', 'removing copy results = ' + newFile.remove() );
log( 'DEBUG', newFileName + ' exists = ' + newFile.exists() );
log( 'DEBUG', 'renaming to ' + newFileName + ' results = ' + file.renameTo( newFileName ) );
log( 'DEBUG', newFileName + ' exists = ' + newFile.exists() );
log( 'DEBUG', 'removing file results = ' + file.remove() );
log( 'DEBUG', 'working with a binary file ' + fileName );
var filebinary = new FileBinary( fileName );
log( 'DEBUG', 'fullName = ' + filebinary.fullName );
log( 'DEBUG', 'isOpen = ' + filebinary.isOpen + ' size = ' + filebinary.size );
log( 'DEBUG', 'exists = ' + filebinary.exists() );
log( 'DEBUG', 'creating the file result = ' + filebinary.open( 'create|write' ) );
var result;
for( var i = 0; i < 100; i++ )
result = filebinary.writeByte( i )
log( 'DEBUG', 'writing a bytes 0-99 to file result = ' + result );
log( 'DEBUG', 'closing the file result = ' + filebinary.close() );
log( 'DEBUG', 'exists = ' + filebinary.exists() );
log( 'DEBUG', 'opening the file to read result = ' + filebinary.open( 'read' ) );
log( 'DEBUG', 'reading a byte = ' + filebinary.readByte() );
log( 'DEBUG', 'closing the file result = ' + filebinary.close() );
log( 'DEBUG', 'opening the file to read result = ' + filebinary.open( 'read' ) );
var blob = filebinary.readBinaryBlob( 1 );
log( 'DEBUG', 'reading one byte as binaryblob = ' + blob.getByte( 0 ) );
blob = filebinary.readBinaryBlob();
log( 'DEBUG', 'reading rest of file as binaryblob = ' + blob );
log( 'DEBUG', 'first byte in blob = ' + blob.getByte( 0 ) );
log( 'DEBUG', 'last byte in blob = ' + blob.getByte( blob.size - 1 ) );
log( 'DEBUG', 'closing the file result = ' + filebinary.close() );
var file = new File( fileName );
log( 'DEBUG', 'removing file results = ' + file.remove() );
var dirArray = new Array( 'c:\\temp', 'c:\\temp\\foo\\', 'c:\\temp\\bar' );
log( 'DEBUG', 'finding root direcotry of ' + dirArray );
var rootdir = getRootDirectory( dirArray );
log( 'DEBUG', 'root directory is ' + rootdir );
}
if( doAudio || doAll )
{
log( 'INFO', '********** Testing Audio *************************************************' );
log( 'DEBUG', 'Testing Audio.Say( "Hello World" )' );
// TODO need to test Audio.play
Audio.say( 'Hello World' );
}
if( doEmail || doAll )
{
log( 'INFO', '********** Testing Email *************************************************' );
log( 'DEBUG', 'Sending email to test@athyrium.com, testcc@athyrium.com, and testbcc@athyrium.com ' );
var email = new Email( getSetting( 'ErrorEmailAddress' ), 'faketest@athyrium.com', 'faketestcc@athyrium.com', 'faketestbcc@athyrium.com', 'This is a test', 'This is a test this is only a test. Had there been an actual emergency...', '' );
email.send();
}
if( doPing || doAll )
{
log( 'INFO', '********** Testing Ping *************************************************' );
if( typeof( WebUtils ) == 'undefined' ) log( 'INFO', 'Skipping Ping - Internet Tools Module not installed' );
else
{
log( 'DEBUG', 'WebUtils.ping( "www.athyrium.com" )' );
var pingTimeMS = WebUtils.ping( "www.athyrium.com" );
if( typeof pingTimeMS == "number" ) log( 'DEBUG', 'ping result = ' + pingTimeMS + 'ms' );
else log( 'ERROR', 'ping had error - result = ' + pingTimeMS );
}
}
if( doTelnet || doAll )
{
log( 'INFO', '********** Testing Telnet ***********************************************' );
if( typeof( TelnetSession ) == 'undefined' ) log( 'INFO', 'Skipping Telnet - Internet Tools Module not installed' );
else
{
log( 'DEBUG', 'Testing telnet' );
var telnetsession = new TelnetSession();
log( 'DEBUG', 'telnetsession.open( "rainmaker.wunderground.com" )' );
var result = telnetsession.open( 'rainmaker.wunderground.com' );
if( result == false ) log( 'DEBUG', 'telnet error = ' + telnetsession.lastError );
else log( 'DEBUG', 'telnet result = ' + result );
log( 'DEBUG', 'sending enter' );
result = telnetsession.send( "\n" );
if( result == false ) log( 'DEBUG', 'telnet error = ' + telnetsession.lastError );
else log( 'DEBUG', 'telnet result = ' + result );
log( 'DEBUG', 'sending aus code' );
result = telnetsession.send( "aus\n" );
if( result == false ) log( 'DEBUG', 'telnet error = ' + telnetsession.lastError );
else log( 'DEBUG', 'telnet result = ' + result );
log( 'DEBUG', 'closing session' );
telnetsession.close();
}
}
if( doFTP || doAll )
{
log( 'INFO', '********** Testing ftp **************************************************' );
if( typeof( FTPSession ) == 'undefined' ) log( 'INFO', 'Skipping FTP - Internet Tools Module not installed' );
else
{
log( 'DEBUG', 'Creating FTPSession' );
var ftpsession = new FTPSession();
log( 'DEBUG', 'opening ftp.freebsd.org' );
ftpsession.open( 'ftp.freebsd.org', 'anonymous', '' );
var worked = ftpsession.changeDirectory( '/pub/FreeBSD/' );
log( 'DEBUG', 'changed remote directory to "/pub/FreeBSD/" worked = ' + worked );
log( 'DEBUG', 'remote directory = ' + ftpsession.remoteDirectory );
var fileList = ftpsession.getFileList();
log( 'DEBUG', 'files = ' + fileList + ' last error = ' + ftpsession.lastError );
var worked = ftpsession.downloadFile( '.message', 'c:\\test.txt', true )
log( 'DEBUG', 'downloaded .message to c:\\test.txt worked = ' + worked + ' last error = ' + ftpsession.lastError );
var worked = ftpsession.uploadFile( 'c:\\test.txt', '.message', true )
log( 'DEBUG', 'uploaded c:\\test.txt to .message worked = ' + worked + ' last error = ' + ftpsession.lastError );
var worked = ftpsession.deleteFile( '.message' );
log( 'DEBUG', 'delete .message worked = ' + worked + ' last error = ' + ftpsession.lastError );
var worked = ftpsession.makeDirectory( 'bob' );
log( 'DEBUG', 'makeDirectory bob worked = ' + worked + ' last error = ' + ftpsession.lastError );
var worked = ftpsession.removeDirectory( 'bob' );
log( 'DEBUG', 'removeDirectory bob worked = ' + worked + ' last error = ' + ftpsession.lastError );
log( 'DEBUG', 'closing connection' );
ftpsession.close();
}
}
if( doHTTP || doAll )
{
log( 'INFO', '********** Testing http *************************************************' );
if( typeof( HTTPSession ) == 'undefined' ) log( 'INFO', 'Skipping HTTP - Internet Tools Module not installed' );
else
{
log( 'DEBUG', 'Creating HTTPSession' );
var httpSession = new HTTPSession();
log( 'DEBUG', 'Setting cookie foo=1 and bar=2' );
httpSession.cookies = 'foo=1;bar=2';
log( 'DEBUG', 'Getting www.google.com and saving as ' + System.tempDirectory + "output.html" );
var worked = httpSession.get( "http://www.google.com", System.tempDirectory + "output.html" );
log( 'DEBUG', 'Get worked = ' + worked );
if( httpSession.headers )
{
for( i in httpSession.headers )
log( 'DEBUG', 'Header[' + i + '] = ' + httpSession.headers[ i ] );
}
log( 'DEBUG', 'cookies = ' + httpSession.cookies );
sleep( 3000 );
log( 'DEBUG', 'Getting www.google.com saving results as string' );
var pageHTML = httpSession.get( "http://www.google.com" );
log( 'DEBUG', 'Get results = ' + pageHTML );
log( 'DEBUG', 'Current Status = ' + httpSession.status );
log( 'DEBUG', 'Current URL = ' + httpSession.url );
if( httpSession.headers )
{
for( i in httpSession.headers )
log( 'DEBUG', 'Header[' + i + '] = ' + httpSession.headers[ i ] );
}
log( 'DEBUG', 'cookies = ' + httpSession.cookies );
sleep( 3000 );
log( 'DEBUG', 'testing post to www.google.com saving results as ' + System.tempDirectory + "output.html" );
var worked = httpSession.post( "http://www.google.com", "", System.tempDirectory + "output.html" );
log( 'DEBUG', 'status = ' + httpSession.status );
log( 'DEBUG', 'Post worked = ' + worked );
if( httpSession.headers )
{
for( i in httpSession.headers )
log( 'DEBUG', 'Header[' + i + '] = ' + httpSession.headers[ i ] );
}
}
}
if( doBuiltIn || doAll )
{
log( 'INFO', 'Testing Built-in Functions ***********************************************' );
log( 'DEBUG', 'Testing decodeURI and encodeURI with uri "my test.asp?name=ståle&car=ford"' );
var uri = "my test.asp?name=ståle&car=ford";
var encURIString = encodeURI( uri );
log( 'DEBUG', 'encodeURI result = ' + encURIString );
var decURIString = decodeURI( encURIString );
log( 'DEBUG', 'decodeURI result = ' + decURIString );
log( 'DEBUG', 'Testing decodeURIComponent and encodeURIComponent with uri "http://website.com/my test.asp?name=ståle&car=ford"' );
var uri = "http://website.com/my test.asp?name=ståle&car=ford";
var encURIString = encodeURIComponent( uri );
log( 'DEBUG', 'encodeURIComponent result = ' + encURIString );
var decURIString = decodeURIComponent( encURIString );
log( 'DEBUG', 'decodeURIComponent result = ' + decURIString );
log( 'DEBUG', 'eval( "2+2" ) = ' + eval( '2+2' ) );
log( 'DEBUG', 'Testing escape and unescape with string "Is this a test? Yes it is!"' );
var testString = 'Is this a test? Yes it is!';
var escapeStr = escape( testString );
log( 'DEBUG', 'escape result = ' + escapeStr );
var unescapeStr = unescape( escapeStr );
log( 'DEBUG', 'unescape result = ' + unescapeStr );
log( 'DEBUG', 'isFinite( 123 ) = ' + isFinite( 123 ) );
log( 'DEBUG', 'isFinite( 1/0 ) = ' + isFinite( 1/0 ) );
log( 'DEBUG', 'isNaN( 123 ) = ' + isNaN( 123 ) );
log( 'DEBUG', 'isNaN( 1/0 ) = ' + isNaN( 1/0 ) );
log( 'DEBUG', 'isNaN( "aaa" ) = ' + isFinite( 'aaa' ) );
log( 'DEBUG', 'Number( "999" ) = ' + Number( '999' ) );
log( 'DEBUG', 'Number( "aaa" ) = ' + Number( 'aaa' ) );
log( 'DEBUG', 'parseFloat( " 999.001 " ) = ' + parseFloat( ' 999.001 ' ) );
log( 'DEBUG', 'parseFloat( "aaa" ) = ' + parseFloat( 'aaa' ) );
log( 'DEBUG', 'parseInt( " 999.001 " ) = ' + parseInt( ' 999.001 ' ) );
log( 'DEBUG', 'parseInt( "aaa" ) = ' + parseInt( 'aaa' ) );
log( 'DEBUG', 'String( 999 ) = ' + String( 999 ) );
log( 'DEBUG', 'applicationVersion = ' + applicationVersion );
log( 'DEBUG', 'currentTrigger = ' + currentTrigger );
log( 'DEBUG', 'Infinity = ' + Infinity );
log( 'DEBUG', 'NaN = ' + NaN );
log( 'DEBUG', 'productVersion = ' + productVersion );
log( 'DEBUG', 'undefined = ' + undefined );
}
if( doTemplate || doAll )
{
log( 'INFO', '********** Testing Templates **********************************************' );
var templateXML = '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '\n';
templateXML += '';
log( 'DEBUG', 'Creating new template from XML = ' + templateXML );
var template = new Template( templateXML );
var text = template.expand( true );
if( text == null ) log( 'DEBUG', 'user hit cancel when prompted for variables' );
else
{
log( 'DEBUG', 'expanded to = ' + text );
alert( text );
}
log( 'DEBUG', 'pre-filling variables, name = Bob, Account Overdrawn = yes' );
template.setVariable( 'Name', 'Bob' );
template.setVariable( 'Account Overdrawn', 'yes' );
var text = template.expand( false );
if( text == null ) log( 'DEBUG', 'user hit cancel when prompted for variables' );
else log( 'DEBUG', 'expanded to = ' + text );
}
if( doXML || doAll )
{
log( 'INFO', '********** Testing XML ****************************************************' );
log( 'DEBUG', 'Parsing XML document body text' );
var xmlParser = new XMLParser( 'body text' );
log( 'DEBUG', 'XML Parser = ' + xmlParser );
log( 'DEBUG', 'Finding element test' );
var testElement = xmlParser.findElement( 'test', 0 );
log( 'DEBUG', 'Element "test" = ' + testElement );
var pookieElement = testElement.findElement( 'pookieElement', 0 );
log( 'DEBUG', 'Looking for element "pookie" = ' + pookieElement );
var hoppyElement = testElement.findElement( 'hoppy', 0 );
log( 'DEBUG', 'Element "hoppy" = ' + hoppyElement );
log( 'DEBUG', '"hoppy" property "value" = ' + hoppyElement.getAttribute( 'value' ) );
var skippyElement = testElement.findElement( 'skippy', 0 );
log( 'DEBUG', 'Element "skippy" = ' + skippyElement );
log( 'DEBUG', '"skippy" body text = ' + skippyElement.text );
}
if( doServices || doAll )
{
log( 'INFO', '********** Testing Services ***********************************************' );
log( 'DEBUG', 'Connecting to remote registry service' );
var service = new Service( 'RemoteRegistry' );
log( 'DEBUG', 'service = ' + service );
log( 'DEBUG', 'service isInstalled = ' + service.isInstalled + ' service isRunning = ' + service.isRunning );
if( !service.isRunning )
{
log( 'DEBUG', 'starting service' );
service.start( 5000 );
log( 'DEBUG', 'sleeping 5 seconds' );
sleep( 5000 );
log( 'DEBUG', 'stopping service' );
service.stop( 5000 );
}
else
{
log( 'DEBUG', 'stopping service' );
service.stop( 5000 );
log( 'DEBUG', 'sleeping 5 seconds' );
sleep( 5000 );
log( 'DEBUG', 'starting service' );
service.start( 5000 );
}
}
if( doImage || doAll )
{
log( 'INFO', '********** Testing Images *********************************************' );
log( 'DEBUG', 'converting cat image blob to image' );
var catImageBase64 = '/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAHgAA/+4ADkFkb2JlAGTAAAAAAf/bAIQAEAsLCwwLEAwMEBcPDQ8XGxQQEBQbHxcXFxcXHx4XGhoaGhceHiMlJyUjHi8vMzMvL0BAQEBAQEBAQEBAQEBAQAERDw8RExEVEhIVFBEUERQaFBYWFBomGhocGhomMCMeHh4eIzArLicnJy4rNTUwMDU1QEA/QEBAQEBAQEBAQEBA/8AAEQgAiwCeAwEiAAIRAQMRAf/EAI4AAAMBAQEBAAAAAAAAAAAAAAIDBAUBAAYBAAIDAQAAAAAAAAAAAAAAAAECAAMEBRAAAQMCBAMGAwYEBgMAAAAAAQARAiEDMUESBFFhcYGRoSIyE7EjBfDB0eFCFPFSsgZyksIzQyRjFSURAAICAgEDBQEBAQAAAAAAAAABEQIhAzFBURJhcTJyBCJiE//aAAwDAQACEQMRAD8AR9Ttat1P2wcXCjjvd1ZJhKLjPVEyHwWv9SlK1clIB4k4rGnehcl5xKJGcJSfuZc5JS0dKrwh8d3GQecBA8YnT4F1w34yHlm/Ixc94ISBft/+WY5in4pmgkPpMQfSCPwUagMHfcgH9s1zjkrNlKYlVuDOpIWJSkGJJ4E/mtCzDREAjt+CWUB8FFNRLMSUcZHUI481zSCQ66GEhySN5JUYZtQ5UQkh+BQSk55GqCRJB4nLwUCN1QLMccUWvVAgZKQy0ilSC3RMtHEclCSdmebBDORhYOjGWJ5LpDxQ3NYtgRD0dFIDZl3txPXJ8qd5QxuTnQzMY/yxCpu7cXAQKN4sobli7KVJRbt+5WVyBsrjd04m4eBMYt4Jv7q3EeZieTD/AFLOG03NZHSQP5anuKC4N1AMIziOcm8E7QEkWz3VmRaOtxkVZZu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E2+poP7uXr0v2st39MccM1s3T44Mur5CJSJJAY8uCXrAwrLj+CZcz+770r7UWJm1cASD0epxJ5qS7GhjEUOJ48lUcT0ShkkY2CG4JCgA58ylxuzBxOKpuerJIl2Y5Jc9COCmO6EmEuicLlijLNzGOKdHAYp1PYUpu37cA0A5r4Ka9f1lwWAGSGeJ7Uo/q6KPyBgGMnlXCoI5FMsyb5cjQGh4HIgpUPX3poxy7UuSYCjb8xiRV3MePMKgR1RAnUCkZ5jg6AYQ6DqqBnh9yKIDG3IAAluBHDkiJIDSrzRj/b7c8EmeBTqAHQWwXXfsQx9IXRgVOhOp/9k=';
var binaryblob = new BinaryBlob();
binaryblob.fromBase64( catImageBase64 );
var image = new Image();
image.fromBinaryBlob( binaryblob );
log( 'DEBUG', 'image.depth = ' + image.depth + 'image.height = ' + image.height + 'image.width = ' + image.width );
image.display( 1000 );
log( 'DEBUG', 'converting to blob' );
var blob = image.toBinaryBlob();
var temp = new Image();
log( 'DEBUG', 'converting from blob' );
temp.fromBinaryBlob( blob );
temp.display( 1000 );
log( 'DEBUG', 'image rotate - 30' );
temp = image.copy();
temp.rotate( -30 );
temp.display( 1000 );
log( 'DEBUG', 'image rotate 10' );
temp = image.copy();
temp.rotate( 10 );
temp.display( 1000 );
log( 'DEBUG', 'image scale 20' );
temp = image.copy();
temp.scale( 20.0, 20.0 );
temp.display( 1000 );
log( 'DEBUG', 'image contrast 3' );
temp = image.copy();
temp.contrast( 3 );
temp.display( 1000 );
log( 'DEBUG', 'image contrast -3' );
temp = image.copy();
temp.contrast( -3 );
temp.display( 1000 );
log( 'DEBUG', 'image pixelate 5' );
temp = image.copy();
temp.pixelate( 5 );
temp.display( 1000 );
log( 'DEBUG', 'image wave 20' );
temp = image.copy();
temp.wave( 20.0, 20.0 );
temp.display( 1000 );
log( 'DEBUG', 'image swirl 270' );
temp = image.copy();
temp.swirl( 270 );
temp.display( 1000 );
log( 'DEBUG', 'image threshold 20' );
temp = image.copy();
temp.threshold( 20.0 );
temp.display( 1000 );
log( 'DEBUG', 'image implode 0.5' );
temp = image.copy();
temp.implode( 0.5 );
temp.display( 1000 );
log( 'DEBUG', 'image oilPaint 3.0' );
temp = image.copy();
temp.oilPaint( 3.0 );
temp.display( 2000 );
log( 'DEBUG', 'image roll 30' );
temp = image.copy();
temp.roll( new Point( 30, 30 ) );
temp.display( 1000 );
log( 'DEBUG', 'image age' );
temp = image.copy();
temp.age();
temp.display( 1000 );
log( 'DEBUG', 'image negative' );
temp = image.copy();
temp.negative();
temp.display( 1000 );
log( 'DEBUG', 'image blackandwhite' );
temp = image.copy();
temp.blackAndWhite();
temp.display( 1000 );
log( 'DEBUG', 'image sepia' );
temp = image.copy();
temp.sepia();
temp.display( 1000 );
log( 'DEBUG', 'image despeckle' );
temp = image.copy();
temp.despeckle();
temp.display( 1000 );
log( 'DEBUG', 'image enhance' );
temp = image.copy();
temp.enhance();
temp.display( 1000 );
log( 'DEBUG', 'image emboss' );
temp = image.copy();
temp.emboss( 5.0, 1.0 );
temp.display( 1000 );
log( 'DEBUG', 'image flip - true' );
temp = image.copy();
temp.flip( true );
temp.display( 1000 );
log( 'DEBUG', 'image flip - false' );
temp = image.copy();
temp.flip( false );
temp.display( 1000 );
log( 'DEBUG', 'image equalize' );
temp = image.copy();
temp.equalize();
temp.display( 1000 );
log( 'DEBUG', 'image edge' );
temp = image.copy();
temp.edge( 1.0 );
temp.display( 1000 );
log( 'DEBUG', 'image blure 10' );
temp = image.copy();
temp.blur( 10.0, 5.0 );
temp.display( 1000 );
log( 'DEBUG', 'image sharpen 10' );
temp = image.copy();
temp.sharpen( 10.0, 5.0 );
temp.display( 1000 );
log( 'DEBUG', 'image motionBlur' );
temp = image.copy();
temp.motionBlur( 10.0, 5.0, 0.0 );
temp.display( 1000 );
log( 'DEBUG', 'image charcoal' );
temp = image.copy();
temp.charcoal( 5.0, 1.0 );
temp.display( 1000 );
log( 'DEBUG', 'image scale' );
image.scale( 150.0, 150.0 );
image.display( 1000 );
log( 'DEBUG', 'image cropBy' );
temp = image.copy();
temp.cropBy( new Rectangle( 10, 10, 20, 20 ) );
temp.display( 1000 );
log( 'DEBUG', 'image cropTo' );
temp = image.copy();
temp.cropTo( new Rectangle( 10, 10, 20, 20 ) );
temp.display( 1000 );
}
if( doRegistry || doAll )
{
log( 'INFO', '********** Testing Registry *********************************************' );
log( 'DEBUG', 'writing string to registry - HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\stringValue' );
Registry.writeString( 'HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\stringValue', 'hello' );
log( 'DEBUG', 'writing int to registry - HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\intValue' );
Registry.writeInt( 'HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\intValue', 1 );
var value = Registry.readString( 'HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\stringValue' );
log( 'DEBUG', 'reading registry - HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\stringValue - value = ' + value );
value = Registry.readInt( 'HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\intValue' );
log( 'DEBUG', 'reading registry - HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\intValue - value = ' + value );
value = Registry.readString( 'HKEY_CURRENT_USER\\blablabla' );
log( 'DEBUG', 'reading registry - HKEY_CURRENT_USER\\blablabla result = ' + value + ' error = ' + Registry.lastError );
var result = Registry.remove( 'HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\stringValue' );
log( 'DEBUG', 'removing string from registry - HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test\\stringValue - error = ' + Registry.lastError );
result = Registry.remove( 'HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test' );
log( 'DEBUG', 'removing key from registry - HKEY_CURRENT_USER\\Software\\Athyrium, inc.\\Easy Automation\\Test - error = ' + Registry.lastError );
}
if( doEncrypt || doAll )
{
log( 'INFO', '********** Testing Encryption *********************************************' );
var encString = Encryption.encryptString( "hello world 1", "pookie", "blowfish" );
log( 'DEBUG', 'encrypting "hello world 1" with "blowfish" and key "pookie" - result = ' + encString );
var decString = Encryption.decryptString( encString, "pookie", "blowfish" );
log( 'DEBUG', 'decrypting result back using same key and method - result = ' + decString );
var decStringBad = Encryption.decryptString( "hello", "pookie", "blowfish" );
log( 'DEBUG', 'decrypting non-encrypted string - result = ' + decStringBad );
var fileName = System.tempDirectory + 'test.txt';
log( 'DEBUG', 'writing "hello world" into file ' + fileName );
var filetext = new FileText( fileName );
filetext.open( "write|create" );
filetext.writeln( "hello world" );
filetext.close();
var encFileName = System.tempDirectory + 'test.enc';
log( 'DEBUG', 'decrypting the non-encrypted file ' + fileName );
Encryption.decryptFile( fileName, encFileName, 'pookie', 'blowfish' );
log( 'DEBUG', 'encrypting the file ' + fileName + ' with key "pookie" and method "blowfish" results file - ' + encFileName );
Encryption.encryptFile( fileName, encFileName, 'pookie', 'blowfish' );
log( 'DEBUG', 'decrypting the file ' + encFileName + ' with key "pookie" and method "blowfish" results file - ' + fileName );
Encryption.decryptFile( encFileName, fileName, 'pookie', 'blowfish' );
log( 'DEBUG', 'reading contents of decrypted file - ' + fileName );
contents = filetext.readAll();
log( 'DEBUG', fileName + ' contents = ' + contents );
log( 'DEBUG', 'deleting temp files' );
var file = new File( fileName );
file.remove();
file = new File( encFileName );
file.remove();
log( 'DEBUG', 'creating binary blog with data "hello"' );
var binaryblob = new BinaryBlob();
binaryblob.setString( 0, 0, 5, "hello" );
log( 'DEBUG', 'encrypting the blob' );
var encBlob = Encryption.encryptBlob( binaryblob, 'pookie', 'blowfish' );
var orgBlob = Encryption.decryptBlob( binaryblob, 'pookie', 'blowfish' );
log( 'DEBUG', 'decrypting the non-encrypted blob result = ' + orgBlob );
log( 'DEBUG', 'decrypting the encrypted blob' );
orgBlob = Encryption.decryptBlob( encBlob, 'pookie', 'blowfish' );
log( 'DEBUG', 'blob contents = ' + orgBlob.getString( 0, 0, 5 ) );
}
if( doSystem || doAll )
{
log( 'INFO', '********** Testing System *************************************************' );
log( 'DEBUG', 'System.myDocumentsDirectory = ' + System.myDocumentsDirectory );
log( 'DEBUG', 'System.windowsDirectory = ' + System.windowsDirectory );
log( 'DEBUG', 'System.systemDirectory = ' + System.systemDirectory );
log( 'DEBUG', 'System.tempDirectory = ' + System.tempDirectory );
log( 'DEBUG', 'processes running = ' + System.listProcesses() );
log( 'DEBUG', 'running notepad.exe' );
var processID = System.runProgram( "notepad.exe" );
log( 'DEBUG', 'processes running = ' + System.listProcesses() );
log( 'DEBUG', 'killing notepad.exe' );
System.killProcess( 'notepad.exe' );
log( 'DEBUG', 'processes running = ' + System.listProcesses() );
log( 'DEBUG', 'waiting for notepad.exe to exit' );
var stopped = System.waitForExit( processID, 2000 );
log( 'DEBUG', 'stopped = ' + stopped );
log( 'DEBUG', 'creating shortcut to notepad on desktop' );
System.createShortcut( 'notepad.exe', '', 'Run Notepad', 'this link will run notepad' );
// TODO System.runScript( pathToScript, waitForFinishTimeoutMS );
log( 'INFO', '********** Testing exit ***************************************************' );
System.exit( 5 );
log( 'DEBUG', 'after exit, we should never get this because the script should have stopped' );
}