Merge commit '808a866c8b' into webgui8. 7.9.4 release point

Conflicts:
	docs/upgrades/packages-7.9.3/root_import_gallery-templates_default-gallery-edit-album.wgpkg
	docs/upgrades/upgrade_7.9.2-7.9.3.pl
	lib/WebGUI.pm
	lib/WebGUI/Asset/MapPoint.pm
	lib/WebGUI/Asset/Wobject/Calendar.pm
	lib/WebGUI/Asset/Wobject/Gallery.pm
	lib/WebGUI/Asset/Wobject/GalleryAlbum.pm
	lib/WebGUI/Asset/Wobject/WikiMaster.pm
	lib/WebGUI/AssetClipboard.pm
	lib/WebGUI/AssetVersioning.pm
	lib/WebGUI/Auth.pm
	t/Asset/Asset.t
This commit is contained in:
Colin Kuskie 2010-06-25 20:08:11 -07:00
commit b30491f3a6
31 changed files with 1974 additions and 415 deletions

View file

@ -448,11 +448,24 @@ is($fixTitleAsset->getUiLevel, 8, 'getUiLevel: Snippet has a configured uiLevel
################################################################
#
# isValidRssItem
# assetExists
#
################################################################
#is($canViewAsset->isValidRssItem, 1, 'isValidRssItem: By default, all Assets are valid RSS items');
{
my $id = $canViewAsset->getId;
my $class = 'WebGUI::Asset';
my $date = $canViewAsset->get('revisionDate');
ok ( WebGUI::Asset->assetExists($session, $id, $class, $date), 'assetExists with proper class, id and revisionDate');
ok (!WebGUI::Asset->assetExists($session, $id, 'WebGUI::Asset::Snippet', $date), 'assetExists with wrong class does not exist');
my $id2 = $id;
++$id2;
ok (!WebGUI::Asset->assetExists($session, $id2, $class, $date), 'assetExists with wrong id does not exist');
ok (!WebGUI::Asset->assetExists($session, $id, $class, $date+1), 'assetExists with wrong revisionDate does not exist');
}
################################################################
#

View file

@ -0,0 +1,109 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../../../../lib";
# The goal of this test is to confirm correct rotation of all files attached
# to a Photo asset after calling the rotate method.
# We will only do a quick check by comparing dimensions of all attached files
# after rotation. Checks on individual pixels are alreay done in testing code
# for WebGUI::Storage
use WebGUI::Test;
use WebGUI::Session;
use Test::More;
use Test::Deep;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode($session);
my $versionTag = WebGUI::VersionTag->getWorking($session);
# Name version tag and make sure it gets cleaned up
$versionTag->set({name=>"Photo rotation test"});
addToCleanup($versionTag);
# Create gallery and a single album
my $gallery
= $node->addChild({
className => "WebGUI::Asset::Wobject::Gallery",
imageResolutions => "1024x768",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
my $album
= $gallery->addChild({
className => "WebGUI::Asset::Wobject::GalleryAlbum",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Create single photo inside the album
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
},
undef,
undef,
{
skipAutoCommitWorkflows => 1,
});
# Attach image file to photo asset (setFile also makes download versions)
$photo->setFile( WebGUI::Test->getTestCollateralPath("rotation_test.png") );
my $storage = $photo->getStorageLocation;
# Commit all changes
$versionTag->commit;
#----------------------------------------------------------------------------
plan tests => 2;
#----------------------------------------------------------------------------
# Save dimensions of images
my @oldDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @oldDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Rotate photo (i.e. all attached images) by 90° CW
$photo->rotate(90);
# Save new dimensions of images in reverse order
my @newDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newDims, [ reverse($storage->getSizeInPixels($file)) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newDims, "Check if all files were rotated by 90° CW" );
# Rotate photo (i.e. all attached images) by 90° CCW
$photo->rotate(-90);
# Save new dimensions of images in original order
my @newerDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newerDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newerDims, "Check if all files were rotated by 90° CCW" );

View file

@ -266,10 +266,6 @@ is(scalar @{ $windowCal->getLineage(['children'])}, 13, 'added events to the win
my @window = $windowCal->getEventsIn($startDt->toDatabase, $endDt->toDatabase);
#note $startDt->toDatabase;
#note join "\n", map { join ' ', $_->get('title'), $_->get('startDate'), $_->get('startTime')} @window;
#note $endDt->toDatabase;
cmp_bag(
[ map { $_->get('title') } @window ],
[ map { $_->get('title') }
@ -499,9 +495,6 @@ my $listCal = $node->addChild({
$allDayDt = $bday->cloneToUserTimeZone->truncate( to => 'day' );
my $prevDayDt = $bday->cloneToUserTimeZone->truncate( to => 'day' )->subtract(days => 1)->add(hours => 19);
note $allDayDt->toDatabase;
note $prevDayDt->toDatabase;
$allDay = $listCal->addChild({
className => 'WebGUI::Asset::Event',
title => 'An event with explicit times that lasts all day',

View file

@ -9,9 +9,10 @@
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------
# Test editing a GalleryAlbum from the web interface
#
#
# Test editing a GalleryAlbum from the web interface. Currently, it
# is tested whether...
# - users can add albums.
# - photos can be rotated.
use FindBin;
use strict;
@ -73,7 +74,7 @@ if ( !$mech->success ) {
plan skip_all => "Cannot load URL '$baseUrl'. Will not test.";
}
plan tests => 6; # Increment this number for each test you create
plan tests => 11; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Visitor user cannot add albums
@ -112,6 +113,65 @@ $mech->content_contains(
my $album = WebGUI::Asset->newById( $session, $gallery->getAlbumIds->[0] );
cmp_deeply( $properties, subhashof( $album->get ), "Properties from edit form are set correctly" );
#----------------------------------------------------------------------------
# Photos can be rotated using the respective form buttons
# Use album from previous test
my $album = $gallery->getFirstChild;
# Add single photo to this album. No need to commit since auto-commit was
# enabled for the Gallery asset.
my $photo
= $album->addChild({
className => "WebGUI::Asset::File::GalleryFile::Photo",
});
my $photoId = $photo->getId;
# Attach image file to photo asset (setFile also makes download versions)
$photo->setFile( WebGUI::Test->getTestCollateralPath("rotation_test.png") );
my $storage = $photo->getStorageLocation;
# Save dimensions of images
my @oldDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @oldDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Rotate photo (i.e. all attached images) by 90° CW
$mech->get_ok( $baseUrl . $album->getUrl('func=edit'), 'Request GalleryAlbum edit screen' );
# Select the proper form
$mech->form_name( 'galleryAlbumEdit' );
# Try to click the "rotate right" button
$mech->submit_form_ok( {
button => 'rotateRight-' . $photoId,
}, 'Request rotation of photo by 90° CW' );
# Save new dimensions of images in reverse order
my @newDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newDims, [ reverse($storage->getSizeInPixels($file)) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newDims, "Check if all files were rotated by 90° CW" );
# Rotate photo (i.e. all attached images) by 90° CCW. No need to request the edit view since
# an updated view was returned after the last form submittal.
$mech->form_name( 'galleryAlbumEdit' );
# Try to click the "rotate left" button
$mech->submit_form_ok( {
button => 'rotateLeft-' . $photoId,
}, 'Request rotation of photo by 90° CCW' );
# Save new dimensions of images in original order
my @newerDims;
foreach my $file ( @{$storage->getFiles('showAll') } ) {
push ( @newerDims, [ $storage->getSizeInPixels($file) ] ) unless $file eq '.';
}
# Compare dimensions
cmp_deeply( \@oldDims, \@newerDims, "Check if all files were rotated by 90° CCW" );
#----------------------------------------------------------------------------
# getMechLogin( baseUrl, WebGUI::User, "identifier" )
# Returns a Test::WWW::Mechanize session after logging in the given user using

View file

@ -411,12 +411,15 @@ $archive->update({storiesPerPage => 25});
$templateVars = $archive->viewTemplateVariables('search');
is($templateVars->{mode}, 'search', 'viewTemplateVariables mode == search');
use Data::Dumper;
diag Dumper $templateVars->{date_loop};
cmp_bag(
$templateVars->{date_loop},
[
{
epochDate => ignore(),
story_loop => [
story_loop => bag(
{
creationDate => ignore(),
url => ignore(),
@ -431,7 +434,7 @@ cmp_bag(
editIcon => ignore(),
deleteIcon => ignore(),
},
],
),
},
{
epochDate => $wgBdayMorn,

View file

@ -0,0 +1,250 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------
# Test the featured page of the Wiki
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
use Test::More;
use Test::Differences;
use Test::Deep;
use Data::Dumper;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $import = WebGUI::Asset->getImportNode( $session );
my @childCoda = (undef, undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, } );
my @revCoda = (undef, { skipAutoCommitWorkflows => 1, skipNotification => 1, } );
my $wiki
= $import->addChild( {
className => 'WebGUI::Asset::Wobject::WikiMaster',
topLevelKeywords => 'criminals,inmates,staff',
url => 'testwiki',
title => 'testwiki',
}, @childCoda );
my $wikitag = WebGUI::VersionTag->getWorking( $session );
$wikitag->commit;
WebGUI::Test->addToCleanup($wikitag);
$wiki = $wiki->cloneFromDb;
my %page_set = ();
foreach my $keywords (qw/staff inmates criminals/) {
$page_set{$keywords} = $wiki->addChild({
className => 'WebGUI::Asset::WikiPage',
title => $keywords,
}, @childCoda);
}
my $tag_set1 = WebGUI::VersionTag->getWorking($session);
$tag_set1->commit;
WebGUI::Test->addToCleanup($tag_set1);
#----------------------------------------------------------------------------
# Tests
plan tests => 11; # Increment this number for each test you create
#----------------------------------------------------------------------------
#
is $wiki->get('topLevelKeywords'), 'criminals,inmates,staff', 'checking wiki setup';
cmp_deeply($wiki->getTopLevelKeywordsList, [qw/criminals inmates staff/], 'getTopLevelKeywordList returns keywords');
cmp_deeply(
$wiki->getKeywordHierarchy(),
[
superhashof({ title => 'criminals', }),
superhashof({ title => 'inmates', }),
superhashof({ title => 'staff', }),
],
"getKeywordHierarchy, simple setup",
);
my $hierarchy = $wiki->getKeywordHierarchy();
my $variables = $wiki->getKeywordVariables($hierarchy);
cmp_deeply(
$hierarchy->[0],
{
title => 'criminals',
url => '/testwiki/criminals',
},
"getKeywordVariables, does not alter the original hierarchy passed in",
);
cmp_deeply(
$variables,
[
{
title => 'criminals',
url => '/testwiki/criminals',
level => 0,
indent_loop => [],
},
{
title => 'inmates',
url => '/testwiki/inmates',
level => 0,
indent_loop => [],
},
{
title => 'staff',
url => '/testwiki/staff',
level => 0,
indent_loop => [],
},
],
"... variables",
);
$wiki->update({topLevelKeywords => 'criminals,criminals,inmates,staff'});
is $wiki->get('topLevelKeywords'), 'criminals,criminals,inmates,staff', 'checking wiki setup 2';
cmp_deeply($wiki->getTopLevelKeywordsList, [qw/criminals criminals inmates staff/], 'getTopLevelKeywordList returns keywords, even with duplicates');
cmp_deeply(
$wiki->getKeywordHierarchy(),
[
superhashof({ title => 'criminals', }),
superhashof({ title => 'criminals', }),
superhashof({ title => 'inmates', }),
superhashof({ title => 'staff', }),
],
"getKeywordHierarchy, simple setup, duplicates listed",
);
$wiki->update({topLevelKeywords => 'criminals,inmates,staff'});
$page_set{criminals}->update({keywords => 'red,andy'});
$page_set{inmates}->update({keywords => 'brooks,heywood'});
$page_set{staff}->update({keywords => 'norton,hadley'});
foreach my $title (qw/red andy brooks heywood norton hadley/) {
$page_set{$title} = $wiki->addChild({
className => 'WebGUI::Asset::WikiPage',
title => $title,
}, @childCoda);
}
my $tag_set2 = WebGUI::VersionTag->getWorking($session);
$tag_set2->commit;
WebGUI::Test->addToCleanup($tag_set2);
cmp_bag(
$wiki->getKeywordHierarchy(),
[
{
title => 'criminals', url => '/testwiki/criminals',
children => bag(
superhashof({ title => 'red', }),
superhashof({ title => 'andy', }),
),
},
{
title => 'inmates', url => '/testwiki/inmates',
children => bag(
superhashof({ title => 'heywood', }),
superhashof({ title => 'brooks', }),
),
},
{
title => 'staff', url => '/testwiki/staff',
children => bag(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }),
),
},
],
"getKeywordHierarchy: simple hierarchy",
);
##Check depth-first display, and try to make a keyword loop
$page_set{andy}->update({keywords => 'criminals,inmates'});
$page_set{brooks}->update({keywords => 'criminals'});
my $tag_set3 = WebGUI::VersionTag->getWorking($session);
$tag_set3->commit;
WebGUI::Test->addToCleanup($tag_set3);
cmp_bag(
$wiki->getKeywordHierarchy(),
[
superhashof({
title => 'criminals',
children => bag(
superhashof({
title => 'andy',
children => bag(
superhashof({
title => 'inmates',
children => bag(
superhashof({ title => 'heywood', }),
superhashof({
title => 'brooks',
children => bag(
superhashof({ title => 'criminals', }),
),
}),
),
}),
superhashof({ title => 'criminals', }),
),
}),
superhashof({ title => 'red', }),
),
}),
superhashof({
title => 'inmates',
}),
superhashof({
title => 'staff',
children => bag(
superhashof({ title => 'norton', }),
superhashof({ title => 'hadley', }),
),
}),
],
"getKeywordHierarchy: complex hierarcy, depth-first display and loop handling",
);
cmp_deeply(
$wiki->getKeywordVariables([
{
title => 'title 0', url => 'url 0',
children => [ {
title => 'title 1', url => 'url 1',
children => [ {
title => 'title 2', url => 'url 2',
}, ],
}, ],
},
]),
[
{ title => 'title 0', url => 'url 0', level => 0, indent_loop => [], },
{ title => 'title 1', url => 'url 1', level => 1, indent_loop => [{indent => 1}], },
{ title => 'title 2', url => 'url 2', level => 2, indent_loop => [{indent => 1,}, {indent => 2,},], },
],
'getKeywordVariables: checking deeply'
);
$page_set{criminals}->update({keywords => 'red,andy,tommy'});
#vim:ft=perl

View file

@ -65,7 +65,7 @@ my $extensionTests = [
},
];
plan tests => 49 + scalar @{ $extensionTests }; # increment this value for each test you create
plan tests => 54 + scalar @{ $extensionTests }; # increment this value for each test you create
my $session = WebGUI::Test->session;
@ -276,6 +276,40 @@ foreach my $testImage (@testImages) {
});
####################################################
#
# rotate
#
####################################################
my $rotateTest = WebGUI::Storage->create( $session );
WebGUI::Test->storagesToDelete($rotateTest);
# Add test image to the storage
ok( $rotateTest->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath("rotation_test.png")), "Can add test image to storage" );
# Rotate test image by 90° CW
my $file = $rotateTest->getFiles->[0];
$rotateTest->rotate($file, 90);
# Check dimensions
cmp_bag( [$rotateTest->getSizeInPixels( $file )], [2,3], "Check size of photo after rotating 90° CW" );
# Check pixels
my $image = Image::Magick->new;
$image->Read( $rotateTest->getPath($file) );
is( $image->GetPixel(x=>2, y=>0), 0, "Pixel at location [2,0] should be black" );
# Rotate test image by 90° CCW
my $file = $rotateTest->getFiles->[0];
$rotateTest->rotate($file, -90);
# Check dimensions
cmp_bag( [$rotateTest->getSizeInPixels( $file )], [3,2], "Check size of photo after rotating 90° CCW" );
# Check pixels
$image = Image::Magick->new;
$image->Read( $rotateTest->getPath($file) );
is( $image->GetPixel(x=>0, y=>0), 0, "Pixel at location [0,0] should be black" );
TODO: {
local $TODO = "Methods that need to be tested";
ok(0, 'resize');

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B