| | 9 | # =begin testing |
|---|
| | 10 | { |
|---|
| | 11 | # Make sure Log::Log4perl loads |
|---|
| | 12 | BEGIN { use_ok('Log::Log4perl', qw(:nowarn)) |
|---|
| | 13 | or diag("Can't load Log::Log4perl package. Check to make sure the package library is correctly listed within the path."); |
|---|
| | 14 | |
|---|
| | 15 | # Suppress all logging messages, since we need clean output for unit testing. |
|---|
| | 16 | Log::Log4perl->init({ |
|---|
| | 17 | "log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| | 18 | "log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| | 19 | "log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| | 20 | "log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| | 21 | "log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| | 22 | }); |
|---|
| | 23 | } |
|---|
| | 24 | require_ok('Log::Log4perl'); |
|---|
| | 25 | use Log::Log4perl qw(:easy); |
|---|
| | 26 | |
|---|
| | 27 | # Make sure HoneyClient::Util::Config loads. |
|---|
| | 28 | BEGIN { use_ok('HoneyClient::Util::Config', qw(getVar)) |
|---|
| | 29 | or diag("Can't load HoneyClient::Util::Config package. Check to make sure the package library is correctly listed within the path."); |
|---|
| | 30 | |
|---|
| | 31 | # Suppress all logging messages, since we need clean output for unit testing. |
|---|
| | 32 | Log::Log4perl->init({ |
|---|
| | 33 | "log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| | 34 | "log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| | 35 | "log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| | 36 | "log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| | 37 | "log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| | 38 | }); |
|---|
| | 39 | |
|---|
| | 40 | } |
|---|
| | 41 | require_ok('HoneyClient::Util::Config'); |
|---|
| | 42 | can_ok('HoneyClient::Util::Config', 'getVar'); |
|---|
| | 43 | use HoneyClient::Util::Config qw(getVar); |
|---|
| | 44 | |
|---|
| | 45 | # Make sure the module loads properly, with the exportable |
|---|
| | 46 | # functions shared. |
|---|
| | 47 | BEGIN { use_ok('HoneyClient::Agent::Driver::Browser::IE') or diag("Can't load HoneyClient::Agent::Driver::Browser::IE package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 48 | require_ok('HoneyClient::Agent::Driver::Browser::IE'); |
|---|
| | 49 | can_ok('HoneyClient::Agent::Driver::Browser::IE', 'new'); |
|---|
| | 50 | can_ok('HoneyClient::Agent::Driver::Browser::IE', 'drive'); |
|---|
| | 51 | can_ok('HoneyClient::Agent::Driver::Browser::IE', 'isFinished'); |
|---|
| | 52 | can_ok('HoneyClient::Agent::Driver::Browser::IE', 'next'); |
|---|
| | 53 | can_ok('HoneyClient::Agent::Driver::Browser::IE', 'status'); |
|---|
| | 54 | can_ok('HoneyClient::Agent::Driver::Browser::IE', 'getNextLink'); |
|---|
| | 55 | use HoneyClient::Agent::Driver::Browser::IE; |
|---|
| | 56 | |
|---|
| | 57 | # Suppress all logging messages, since we need clean output for unit testing. |
|---|
| | 58 | Log::Log4perl->init({ |
|---|
| | 59 | "log4perl.rootLogger" => "DEBUG, Buffer", |
|---|
| | 60 | "log4perl.appender.Buffer" => "Log::Log4perl::Appender::TestBuffer", |
|---|
| | 61 | "log4perl.appender.Buffer.min_level" => "fatal", |
|---|
| | 62 | "log4perl.appender.Buffer.layout" => "Log::Log4perl::Layout::PatternLayout", |
|---|
| | 63 | "log4perl.appender.Buffer.layout.ConversionPattern" => "%d{yyyy-MM-dd HH:mm:ss} %5p [%M] (%F:%L) - %m%n", |
|---|
| | 64 | }); |
|---|
| | 65 | |
|---|
| | 66 | # Make sure Win32::Job loads. |
|---|
| | 67 | BEGIN { use_ok('Win32::Job') or diag("Can't load Win32::Job package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 68 | require_ok('Win32::Job'); |
|---|
| | 69 | use Win32::Job; |
|---|
| | 70 | |
|---|
| | 71 | # Make sure ExtUtils::MakeMaker loads. |
|---|
| | 72 | BEGIN { use_ok('ExtUtils::MakeMaker', qw(prompt)) or diag("Can't load ExtUtils::MakeMaker package. Check to make sure the package library is correctly listed within the path."); } |
|---|
| | 73 | require_ok('ExtUtils::MakeMaker'); |
|---|
| | 74 | can_ok('ExtUtils::MakeMaker', 'prompt'); |
|---|
| | 75 | use ExtUtils::MakeMaker qw(prompt); |
|---|
| | 76 | } |
|---|
| | 77 | |
|---|
| | 78 | |
|---|
| | 79 | |
|---|
| | 80 | # =begin testing |
|---|
| | 81 | { |
|---|
| | 82 | # Generate a notice, to clarify our assumptions. |
|---|
| | 83 | diag(""); |
|---|
| | 84 | diag("About to run basic IE-specific browser tests."); |
|---|
| | 85 | diag("Note: These tests *require* network connectivity and"); |
|---|
| | 86 | diag("*expect* IE to be installed at the following location."); |
|---|
| | 87 | diag(""); |
|---|
| | 88 | |
|---|
| | 89 | my $processExec = getVar(name => "process_exec", |
|---|
| | 90 | namespace => "HoneyClient::Agent::Driver::Browser::IE"); |
|---|
| | 91 | my $processName = getVar(name => "process_name", |
|---|
| | 92 | namespace => "HoneyClient::Agent::Driver::Browser::IE"); |
|---|
| | 93 | |
|---|
| | 94 | diag("Process Name:\t\t'" . $processName . "'"); |
|---|
| | 95 | diag("Process Location:\t'" . $processExec . "'"); |
|---|
| | 96 | diag(""); |
|---|
| | 97 | diag("If IE is installed in a different location or has a different executable name,"); |
|---|
| | 98 | diag("then please answer *NO* to the next question and update your etc/honeyclient.xml"); |
|---|
| | 99 | diag("file, changing the 'process_name' and 'process_exec' elements in the"); |
|---|
| | 100 | diag("<HoneyClient/><Agent/><Driver/><Browser/><IE/> section."); |
|---|
| | 101 | diag(""); |
|---|
| | 102 | diag("Then, once updated, re-run these tests."); |
|---|
| | 103 | diag(""); |
|---|
| | 104 | |
|---|
| | 105 | my $question; |
|---|
| | 106 | $question = prompt("# Do you want to run these tests?", "yes"); |
|---|
| | 107 | if ($question !~ /^y.*/i) { |
|---|
| | 108 | exit; |
|---|
| | 109 | } |
|---|
| | 110 | |
|---|
| | 111 | my $ie = HoneyClient::Agent::Driver::Browser::IE->new(test => 1); |
|---|
| | 112 | is($ie->{test}, 1, "new(test => 1)") or diag("The new() call failed."); |
|---|
| | 113 | isa_ok($ie, 'HoneyClient::Agent::Driver::Browser::IE', "new(test => 1)") or diag("The new() call failed."); |
|---|
| | 114 | |
|---|
| | 115 | diag(""); |
|---|
| | 116 | diag("About to drive IE to a specific website for *exactly* " . $ie->{timeout} . " seconds."); |
|---|
| | 117 | diag("Note: Please do *NOT* close the browser manually; the test code should close it automatically."); |
|---|
| | 118 | diag(""); |
|---|
| | 119 | |
|---|
| | 120 | $question = prompt("# Which website should IE browse to?", "http://www.google.com"); |
|---|
| | 121 | $ie->drive(url => $question); |
|---|
| | 122 | |
|---|
| | 123 | diag(""); |
|---|
| | 124 | $question = prompt("# Did IE properly render the page and automatically exit?", "yes"); |
|---|
| | 125 | if ($question !~ /^y.*/i) { |
|---|
| | 126 | diag(""); |
|---|
| | 127 | diag("Check your network connectivity and verify that you can manually browse this page in IE."); |
|---|
| | 128 | diag("Then, re-run these tests."); |
|---|
| | 129 | diag(""); |
|---|
| | 130 | diag("If the tests still do not work, please submit a ticket to:"); |
|---|
| | 131 | diag("http://www.honeyclient.org/trac/newticket"); |
|---|
| | 132 | diag(""); |
|---|
| | 133 | fail("The drive() call failed."); |
|---|
| | 134 | } |
|---|
| | 135 | } |
|---|