3
* Gallery - a web based photo album viewer and editor
4
* Copyright (C) 2000-2007 Bharat Mediratta
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
21
GalleryCoreApi::requireOnce('modules/panorama/classes/PanoramaHelper.class');
22
GalleryCoreApi::requireOnce('modules/panorama/classes/PanoramaRenderer.class');
25
* PanoramaOption tests
26
* Also tests PanoramaHelper::fetchViewableImages
29
* @author Alan Harder <alan.harder@sun.com>
30
* @version $Revision: 15513 $
32
class PanoramaOptionTest extends ItemEditOptionTestCase {
34
function PanoramaOptionTest($methodName) {
35
$this->ItemEditOptionTestCase($methodName, 'panorama', 'PanoramaOption');
41
list ($ret, $this->_item) =
42
$this->_createRandomDataItem($this->_getRootId(), 'image/test',
43
array('width' => 10000, 'height' => 100), __FILE__, 'GalleryPhotoItem');
45
print $ret->getAsHtml();
46
return $this->failWithStatus($ret);
48
$this->_markForCleanup($this->_item);
50
list ($ret, $this->_derivative) = $this->_createDerivative(
51
$this->_item, $this->_item->getId(), DERIVATIVE_TYPE_IMAGE_PREFERRED,
52
'test-operation|80', 'image/test', array('width' => 8000, 'height' => 80));
54
print $ret->getAsHtml();
55
return $this->failWithStatus($ret);
58
$this->_renderer = new PanoramaRenderer();
61
function _makePanoramas() {
62
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($this->_item->getId());
64
return $this->failWithStatus($ret);
67
list ($ret, $this->_item) = $this->_item->refresh();
69
return $this->failWithStatus($ret);
72
$this->_item->setRenderer('PanoramaRenderer');
73
$ret = $this->_item->save();
75
return $this->failWithStatus($ret);
78
$ret = GalleryCoreApi::releaseLocks($lockId);
80
return $this->failWithStatus($ret);
86
function testPanoramaOn() {
87
$form['PanoramaOption']['isPanorama'] = 1;
89
$result = $this->_handleRequestAfterEdit($form, $this->_item);
90
$this->assertEquals(array(array(), array()), $result);
92
list ($ret, $item) = $this->_item->refresh();
94
return $this->failWithStatus($ret);
96
$this->assertEquals('PanoramaRenderer', $item->getRenderer());
99
function testPanoramaOff() {
100
$ret = $this->_makePanoramas();
102
return $this->failWithStatus($ret);
105
$result = $this->_handleRequestAfterEdit(array(), $this->_item);
106
$this->assertEquals(array(array(), array()), $result, 'controller results');
108
list ($ret, $item) = $this->_item->refresh();
110
return $this->failWithStatus($ret);
112
/* For Oracle, null is replaced with '' when loading data from the database */
113
$this->assert(in_array($item->getRenderer(), array(null, '')), 'renderer not empty');
116
function testHelper() {
117
list ($ret, $images) = PanoramaHelper::fetchViewableImages(array($this->_item));
119
return $this->failWithStatus($ret);
121
$this->assert(isset($images[$this->_item->getId()]), 'Missing result');
122
$this->assertEquals($this->_derivative->getId(),
123
$images[$this->_item->getId()]->getId(), 'Id');
126
function testRender() {
127
/* Make sure we use full urls in applet parameters, and sessionid in image url */
128
$ret = $this->_makePanoramas();
130
return $this->failWithStatus($ret);
133
$html = $this->_renderer->render('HTML', $this->_item, $this->_item, array());
135
preg_match('{<param name="archive" value="http}', $html),
136
'item: jar full url: ' . htmlentities($html));
137
$this->assert(preg_match('{<param[^>]*name="ScrollerThumb"[^>]*value="http}', $html),
138
'item: slider full url: ' . htmlentities($html));
139
$this->assert(preg_match('{<param[^>]*name="PanoramaTile"[^>]*value="http[^"]*'
140
. SESSION_ID_PARAMETER . '}', $html),
141
'item: image full url: ' . htmlentities($html));
143
$html = $this->_renderer->render('HTML', $this->_derivative, $this->_item, array());
144
$this->assert(preg_match('{<param name="archive" value="http}', $html),
145
'deriv: jar full url: ' . htmlentities($html));
146
$this->assert(preg_match('{<param[^>]*name="ScrollerThumb"[^>]*value="http}', $html),
147
'deriv: slider full url: ' . htmlentities($html));
148
$this->assert(preg_match('{<param[^>]*name="PanoramaTile"[^>]*value="http[^"]*'
149
. SESSION_ID_PARAMETER . '}', $html),
150
'deriv: image full url: ' . htmlentities($html));
152
/* Accept forceRawImage parameter to bypass applet display */
153
$html = $this->_renderer->render(
154
'HTML', $this->_item, $this->_item, array('forceRawImage' => true));
155
$this->assertEquals(null, $html, 'item: raw image');
157
$html = $this->_renderer->render(
158
'HTML', $this->_derivative, $this->_item, array('forceRawImage' => true));
159
$this->assertEquals(null, $html, 'deriv: raw image');