fix AdSpace, Ad tests
This commit is contained in:
parent
c84e875612
commit
c7f887e47a
3 changed files with 37 additions and 25 deletions
|
|
@ -261,27 +261,32 @@ sub set {
|
|||
$self->{_properties}{priority} = exists $properties->{priority} ? $properties->{priority} : $self->{_properties}{priority};
|
||||
# prerender the ad for faster display
|
||||
my $adSpace = WebGUI::AdSpace->new($self->session, $self->get("adSpaceId"));
|
||||
if ($self->get("type") eq "text") {
|
||||
$self->{_properties}{renderedAd} = '<div style="position:relative; width:' . ($adSpace->get("width")-2) . 'px; height:' .
|
||||
($adSpace->get("height")-2) . 'px; margin:0px; overflow:hidden; border:solid ' . $self->get("borderColor") .
|
||||
q{ 1px;"><a href='#' OnClick="window.location.assign('} .
|
||||
$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId) .
|
||||
q{')" style="position:absolute; padding: 3px; top:0px; left:0px; width:100%; height:100%; z-index:10;} .
|
||||
' display:block; text-decoration:none; vertical-align:top; background-color:' . $self->get("backgroundColor") .
|
||||
'; font-size: 13px; font-weight: normal;"><b><span style="color:' . $self->get("textColor") . ';">' .
|
||||
$self->get("title") . '</span></b><br /><span style="color:' . $self->get("textColor") . ';">' .
|
||||
$self->get("adText") . '</span></a></div>';
|
||||
} elsif ($self->get("type") eq "image") {
|
||||
my $storage = WebGUI::Storage->get($self->session, $self->get("storageId"));
|
||||
$self->{_properties}{renderedAd} = '<div style="position:relative; width:' . $adSpace->get("width") . 'px; height:' .
|
||||
$adSpace->get("height") . 'px; margin:0px; overflow:hidden; border:0px;"><a href="#" ' .
|
||||
q{onClick="window.location.assign('} .
|
||||
$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId) . q{')" style="position:absolute; padding: } .
|
||||
'3px; top:0px; left:0px; width:100%; height:100%; z-index:10; display:block; text-decoration:none; ' .
|
||||
'vertical-align:top;"><img ' .
|
||||
'src="' . $storage->getUrl($storage->getFiles->[0]) . '" alt="' . $self->get("title") .
|
||||
'" style="z-index:0;position:relative;border-style:none;border: 0px;" /></a></div>';
|
||||
} elsif ($self->get("type") eq "rich") {
|
||||
if ($self->get("type") eq "text") {
|
||||
$self->{_properties}{renderedAd} =
|
||||
q{<div style="position:relative; width:} . ($adSpace->get("width")-2) . q{px; height:}
|
||||
. ($adSpace->get("height")-2) . q{px; margin:0px; overflow:hidden; border:solid }
|
||||
. $self->get("borderColor") . q{ 1px;"><a href='#' onclick="window.location.assign('}
|
||||
. $self->session->url->gateway(undef, "op=clickAd;id=".$self->getId)
|
||||
. q{')" style="position:absolute; padding: 3px; top:0px; left:0px; width:100%; height:100%; z-index:10;}
|
||||
. q{ display:block; text-decoration:none; vertical-align:top; background-color:}
|
||||
. $self->get("backgroundColor") . q{; font-size: 13px; font-weight: normal;"><b><span style="color:}
|
||||
. $self->get("textColor") . q{;">} . $self->get("title")
|
||||
. q{</span></b><br /><span style="color:} . $self->get("textColor") . q{;">}
|
||||
. $self->get("adText") . q{</span></a></div>};
|
||||
}
|
||||
elsif ($self->get("type") eq "image") {
|
||||
my $storage = WebGUI::Storage->get($self->session, $self->get("storageId"));
|
||||
$self->{_properties}{renderedAd} =
|
||||
q{<div style="position:relative; width:} . $adSpace->get("width") . q{px; height:}
|
||||
. $adSpace->get("height") . q{px; margin:0px; overflow:hidden; border:0px;"><a href="#" }
|
||||
. q{onclick="window.location.assign('} .$self->session->url->gateway(undef, "op=clickAd;id=".$self->getId)
|
||||
. q{')" style="position:absolute; padding: }
|
||||
. q{3px; top:0px; left:0px; width:100%; height:100%; z-index:10; display:block; text-decoration:none; }
|
||||
. q{vertical-align:top;"><img }
|
||||
. q{src="} . $storage->getUrl($storage->getFiles->[0]) . q{" alt="} . $self->get("title")
|
||||
. q{" style="z-index:0;position:relative;border-style:none;border: 0px;" /></a></div>};
|
||||
}
|
||||
elsif ($self->get("type") eq "rich") {
|
||||
my $ad = $self->get("richMedia");
|
||||
WebGUI::Macro::process($self->session, \$ad);
|
||||
$self->{_properties}{renderedAd} = $ad;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ SKIP: {
|
|||
|
||||
skip "Unable to load WebGUI::AdSpace", $numTests-1 unless $loaded;
|
||||
|
||||
local $ENV{REMOTE_ADDR} = '10.0.0.1';
|
||||
local $ENV{HTTP_USER_AGENT} = 'Mozilla/5.0';
|
||||
|
||||
$adSpace = WebGUI::AdSpace->create($session, {name=>"Alfred"});
|
||||
|
||||
isa_ok($adSpace, 'WebGUI::AdSpace');
|
||||
|
|
|
|||
|
|
@ -54,6 +54,10 @@ $imageStorage->addFileFromScalar('foo.bmp', 'This is not really an image');
|
|||
SKIP: {
|
||||
|
||||
skip "Unable to load WebGUI::AdSpace::Ad", $numTests-1 unless $loaded;
|
||||
|
||||
local $ENV{REMOTE_ADDR} = '10.0.0.1';
|
||||
local $ENV{HTTP_USER_AGENT} = 'Mozilla/5.0';
|
||||
|
||||
$adSpace = WebGUI::AdSpace->create($session, {name=>"Alfred"});
|
||||
$ad=WebGUI::AdSpace::Ad->create($session, $adSpace->getId, {"type" => "text"});
|
||||
isa_ok($ad,"WebGUI::AdSpace::Ad");
|
||||
|
|
@ -115,11 +119,11 @@ SKIP: {
|
|||
|
||||
##Link checks
|
||||
$token = $textP->get_tag("a");
|
||||
my $href = $token->[1]{href};
|
||||
my $href = $token->[1]{onclick};
|
||||
like($href, qr/op=clickAd/, 'ad link has correct operation');
|
||||
|
||||
my $adId = $textAd->getId;
|
||||
like($href, qr/id=$adId/, 'ad link has correct ad id');
|
||||
like($href, qr/id=\Q$adId\E/, 'ad link has correct ad id');
|
||||
|
||||
$style = $token->[1]{style};
|
||||
like($style, qr/background-color:white/, 'ad link background is white');
|
||||
|
|
@ -159,11 +163,11 @@ SKIP: {
|
|||
|
||||
##Link checks
|
||||
$token = $textP->get_tag("a");
|
||||
my $href = $token->[1]{href};
|
||||
my $href = $token->[1]{onclick};
|
||||
like($href, qr/op=clickAd/, 'ad link has correct operation, image');
|
||||
|
||||
$adId = $imageAd->getId;
|
||||
like($href, qr/id=$adId/, 'ad link has correct ad id, image');
|
||||
like($href, qr/id=\Q$adId\E/, 'ad link has correct ad id, image');
|
||||
|
||||
$token = $textP->get_tag("img");
|
||||
$style = $token->[1]{src};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue