Merge remote branch 'spunky/rfe620'
Conflicts: docs/changelog/7.x.x.txt docs/upgrades/packages-7.9.3/root_import_gallery-templates_default-gallery-edit-album.wgpkg
This commit is contained in:
commit
e60c6fdc91
10 changed files with 336 additions and 16 deletions
109
t/Asset/File/GalleryFile/Photo/rotate.t
Normal file
109
t/Asset/File/GalleryFile/Photo/rotate.t
Normal 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" );
|
||||
|
|
@ -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->newByDynamicClass( $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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
@ -277,6 +277,40 @@ foreach my $testImage (@testImages) {
|
|||
|
||||
$session->setting->set('maxImageSize', $origMaxImageSize );
|
||||
|
||||
####################################################
|
||||
#
|
||||
# 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');
|
||||
|
|
|
|||
BIN
t/supporting_collateral/rotation_test.png
Normal file
BIN
t/supporting_collateral/rotation_test.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 189 B |
Loading…
Add table
Add a link
Reference in a new issue