lMocking
l
l my $wx = make_mock_obj_in_class( 'Wx' );
l
l my $mock_WxPerlSplashProgress =
make_mock_obj_in_class( 'Wx::Perl::SplashProgress' );
l
$mock_WxPerlSplashProgress->set_true(qw( SetLabelColour SetIcon Show
SetValue Update Destroy ));
l $mock_WxPerlSplashProgress->mock(
SetLabel => sub { diag ' SetLabel: '.$_[1] } );
l
l $mock_Win32OLE = make_mock_obj_in_class(
'Win32::OLE' );
l $mock_Win32OLE->mock( 'SpecialFolders',
sub { shift } );
l $mock_Win32OLE->mock( 'AppData', sub {
return catdir(qw(data win32), 'Application Data') } );
l $mock_Win32OLE->mock( 'StartMenu', sub
{ catdir(qw(data win32 startmenu)) } );
l $mock_Win32OLE->mock( 'Desktop', sub {
catdir(qw(data win32 desktop)) } );
l
l $mock_Win32Shortcut =
make_mock_obj_in_class( 'Win32::Shortcut' );
l $mock_Win32Shortcut->mock( 'Load', sub
{
l my ($self, $filename) = @_;
l $self->{content} =
read_file($filename);
l return 1;
l } );
l $mock_Win32Shortcut->mock( 'Path', sub
{
l my ($self, $path) = @_;
l $self->{content} = $path;
l } );
l $mock_Win32Shortcut->mock( 'Arguments',
sub {
l my ($self, $args) = @_;
l $self->{content} .= ' '.$args .
"\r\n";
l } );
l $mock_Win32Shortcut->mock( 'Save', sub
{
l my ($self, $filename) = @_;
l write_file($filename,
$self->{content} . "writetime ". gmtime() .
"\r\n");
l return 1;
l } );
l $mock_Win32Shortcut->set_true(qw(
ShowCmd Description IconLocation Close ));
l { no strict 'refs';
*{'Win32::Shortcut::SW_SHOWMINNOACTIVE'} = sub {}; }
l