Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
eab25d54
Commit
eab25d54
authored
8 years ago
by
Lukas Reschke
Committed by
GitHub
8 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1372 from nextcloud/upstream-26039
Fix failing preview unit tests
parents
4e3aa897
6eba111e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/Preview.php
+1
-1
1 addition, 1 deletion
lib/private/Preview.php
tests/lib/PreviewTest.php
+21
-21
21 additions, 21 deletions
tests/lib/PreviewTest.php
with
22 additions
and
22 deletions
lib/private/Preview.php
+
1
−
1
View file @
eab25d54
...
@@ -131,7 +131,7 @@ class Preview {
...
@@ -131,7 +131,7 @@ class Preview {
$this
->
setFile
(
$file
);
$this
->
setFile
(
$file
);
$this
->
setMaxX
((
int
)
$maxX
);
$this
->
setMaxX
((
int
)
$maxX
);
$this
->
setMaxY
((
int
)
$maxY
);
$this
->
setMaxY
((
int
)
$maxY
);
$this
->
setScaling
U
p
(
$scalingUp
);
$this
->
setScaling
u
p
(
$scalingUp
);
$this
->
preview
=
null
;
$this
->
preview
=
null
;
...
...
This diff is collapsed.
Click to expand it.
tests/lib/PreviewTest.php
+
21
−
21
View file @
eab25d54
...
@@ -23,8 +23,10 @@
...
@@ -23,8 +23,10 @@
namespace
Test
;
namespace
Test
;
use
OC\Files\FileInfo
;
use
OC\Files\FileInfo
;
use
OC\Files\Filesystem
;
use
OC\Files\Storage\Temporary
;
use
OC\Files\Storage\Temporary
;
use
OC\Files\View
;
use
OC\Files\View
;
use
OC\Preview
;
use
Test\Traits\MountProviderTrait
;
use
Test\Traits\MountProviderTrait
;
use
Test\Traits\UserTrait
;
use
Test\Traits\UserTrait
;
...
@@ -41,7 +43,7 @@ class PreviewTest extends TestCase {
...
@@ -41,7 +43,7 @@ class PreviewTest extends TestCase {
const
TEST_PREVIEW_USER1
=
"test-preview-user1"
;
const
TEST_PREVIEW_USER1
=
"test-preview-user1"
;
/** @var
\OC\Files\
View */
/** @var View */
private
$rootView
;
private
$rootView
;
/**
/**
* Note that using 756 with an image with a ratio of 1.6 brings interesting rounding issues
* Note that using 756 with an image with a ratio of 1.6 brings interesting rounding issues
...
@@ -77,10 +79,10 @@ class PreviewTest extends TestCase {
...
@@ -77,10 +79,10 @@ class PreviewTest extends TestCase {
$this
->
createUser
(
self
::
TEST_PREVIEW_USER1
,
self
::
TEST_PREVIEW_USER1
);
$this
->
createUser
(
self
::
TEST_PREVIEW_USER1
,
self
::
TEST_PREVIEW_USER1
);
$this
->
loginAsUser
(
self
::
TEST_PREVIEW_USER1
);
$this
->
loginAsUser
(
self
::
TEST_PREVIEW_USER1
);
$storage
=
new
\OC\Files\Storage\
Temporary
([]);
$storage
=
new
Temporary
([]);
\OC\Files\
Filesystem
::
mount
(
$storage
,
[],
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
);
Filesystem
::
mount
(
$storage
,
[],
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
);
$this
->
rootView
=
new
\OC\Files\
View
(
''
);
$this
->
rootView
=
new
View
(
''
);
$this
->
rootView
->
mkdir
(
'/'
.
self
::
TEST_PREVIEW_USER1
);
$this
->
rootView
->
mkdir
(
'/'
.
self
::
TEST_PREVIEW_USER1
);
$this
->
rootView
->
mkdir
(
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/files'
);
$this
->
rootView
->
mkdir
(
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/files'
);
...
@@ -133,7 +135,7 @@ class PreviewTest extends TestCase {
...
@@ -133,7 +135,7 @@ class PreviewTest extends TestCase {
$x
=
50
;
$x
=
50
;
$y
=
50
;
$y
=
50
;
$preview
=
new
\OC\
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'test.txt'
,
$x
,
$y
);
$preview
=
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'test.txt'
,
$x
,
$y
);
$preview
->
getPreview
();
$preview
->
getPreview
();
$fileInfo
=
$this
->
rootView
->
getFileInfo
(
$sampleFile
);
$fileInfo
=
$this
->
rootView
->
getFileInfo
(
$sampleFile
);
...
@@ -164,14 +166,14 @@ class PreviewTest extends TestCase {
...
@@ -164,14 +166,14 @@ class PreviewTest extends TestCase {
$x
=
50
;
$x
=
50
;
$y
=
50
;
$y
=
50
;
$preview
=
new
\OC\
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'test.txt'
,
$x
,
$y
);
$preview
=
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'test.txt'
,
$x
,
$y
);
$preview
->
getPreview
();
$preview
->
getPreview
();
$fileInfo
=
$this
->
rootView
->
getFileInfo
(
$sampleFile
);
$fileInfo
=
$this
->
rootView
->
getFileInfo
(
$sampleFile
);
/** @var int $fileId */
/** @var int $fileId */
$fileId
=
$fileInfo
[
'fileid'
];
$fileId
=
$fileInfo
[
'fileid'
];
$thumbCacheFolder
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
.
\OC\
Preview
::
THUMBNAILS_FOLDER
.
$thumbCacheFolder
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
.
Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$fileId
.
'/'
;
'/'
.
$fileId
.
'/'
;
$this
->
assertSame
(
true
,
$this
->
rootView
->
is_dir
(
$thumbCacheFolder
),
"
$thumbCacheFolder
\n
"
);
$this
->
assertSame
(
true
,
$this
->
rootView
->
is_dir
(
$thumbCacheFolder
),
"
$thumbCacheFolder
\n
"
);
...
@@ -203,7 +205,7 @@ class PreviewTest extends TestCase {
...
@@ -203,7 +205,7 @@ class PreviewTest extends TestCase {
$sample
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/files/test.'
.
$extension
;
$sample
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/files/test.'
.
$extension
;
$this
->
rootView
->
file_put_contents
(
$sample
,
$data
);
$this
->
rootView
->
file_put_contents
(
$sample
,
$data
);
$preview
=
new
\OC\
Preview
(
$preview
=
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'test.'
.
$extension
,
$x
,
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'test.'
.
$extension
,
$x
,
$y
$y
);
);
...
@@ -233,7 +235,7 @@ class PreviewTest extends TestCase {
...
@@ -233,7 +235,7 @@ class PreviewTest extends TestCase {
$this
->
rootView
->
file_put_contents
(
$imgPath
,
$imgData
);
$this
->
rootView
->
file_put_contents
(
$imgPath
,
$imgData
);
$preview
=
$preview
=
new
\OC\
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'testimage.odt'
,
$width
,
$height
);
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'testimage.odt'
,
$width
,
$height
);
$preview
->
getPreview
();
$preview
->
getPreview
();
$image
=
$preview
->
getPreview
();
$image
=
$preview
->
getPreview
();
...
@@ -310,8 +312,6 @@ class PreviewTest extends TestCase {
...
@@ -310,8 +312,6 @@ class PreviewTest extends TestCase {
public
function
testCreateMaxAndNormalPreviewsAtFirstRequest
(
public
function
testCreateMaxAndNormalPreviewsAtFirstRequest
(
$sampleId
,
$widthAdjustment
,
$heightAdjustment
,
$keepAspect
=
false
,
$scalingUp
=
false
$sampleId
,
$widthAdjustment
,
$heightAdjustment
,
$keepAspect
=
false
,
$scalingUp
=
false
)
{
)
{
//$this->markTestSkipped('Not testing this at this time');
// Get the right sample for the experiment
// Get the right sample for the experiment
$this
->
getSample
(
$sampleId
);
$this
->
getSample
(
$sampleId
);
$sampleWidth
=
$this
->
sampleWidth
;
$sampleWidth
=
$this
->
sampleWidth
;
...
@@ -328,7 +328,7 @@ class PreviewTest extends TestCase {
...
@@ -328,7 +328,7 @@ class PreviewTest extends TestCase {
$preview
=
$this
->
createPreview
(
$previewWidth
,
$previewHeight
);
$preview
=
$this
->
createPreview
(
$previewWidth
,
$previewHeight
);
// There should be no cached thumbnails
// There should be no cached thumbnails
$thumbnailFolder
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
.
\OC\
Preview
::
THUMBNAILS_FOLDER
.
$thumbnailFolder
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
.
Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$sampleFileId
;
'/'
.
$sampleFileId
;
$this
->
assertSame
(
false
,
$this
->
rootView
->
is_dir
(
$thumbnailFolder
));
$this
->
assertSame
(
false
,
$this
->
rootView
->
is_dir
(
$thumbnailFolder
));
...
@@ -562,10 +562,10 @@ class PreviewTest extends TestCase {
...
@@ -562,10 +562,10 @@ class PreviewTest extends TestCase {
* @param int $width
* @param int $width
* @param int $height
* @param int $height
*
*
* @return
\OC\
Preview
* @return Preview
*/
*/
private
function
createPreview
(
$width
,
$height
)
{
private
function
createPreview
(
$width
,
$height
)
{
$preview
=
new
\OC\
Preview
(
$preview
=
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
$this
->
sampleFilename
,
$width
,
self
::
TEST_PREVIEW_USER1
,
'files/'
,
$this
->
sampleFilename
,
$width
,
$height
$height
);
);
...
@@ -581,7 +581,7 @@ class PreviewTest extends TestCase {
...
@@ -581,7 +581,7 @@ class PreviewTest extends TestCase {
/**
/**
* Creates the Max preview which will be used in the rest of the test
* Creates the Max preview which will be used in the rest of the test
*
*
* @return
\OC\
Preview
* @return Preview
*/
*/
private
function
createMaxPreview
()
{
private
function
createMaxPreview
()
{
$this
->
keepAspect
=
true
;
$this
->
keepAspect
=
true
;
...
@@ -741,7 +741,7 @@ class PreviewTest extends TestCase {
...
@@ -741,7 +741,7 @@ class PreviewTest extends TestCase {
$userPath
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
;
$userPath
=
'/'
.
self
::
TEST_PREVIEW_USER1
.
'/'
;
}
}
return
$userPath
.
\OC\
Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$fileId
return
$userPath
.
Preview
::
THUMBNAILS_FOLDER
.
'/'
.
$fileId
.
'/'
.
$width
.
'-'
.
$height
.
$postfix
.
'.png'
;
.
'/'
.
$width
.
'-'
.
$height
.
$postfix
.
'.png'
;
}
}
...
@@ -891,7 +891,7 @@ class PreviewTest extends TestCase {
...
@@ -891,7 +891,7 @@ class PreviewTest extends TestCase {
$originalHeight
=
1050
;
$originalHeight
=
1050
;
$originalAspectRation
=
$originalWidth
/
$originalHeight
;
$originalAspectRation
=
$originalWidth
/
$originalHeight
;
$preview
=
new
\OC\
Preview
(
$preview
=
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'testimage.jpg'
,
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'testimage.jpg'
,
150
,
150
,
150
150
...
@@ -911,13 +911,13 @@ class PreviewTest extends TestCase {
...
@@ -911,13 +911,13 @@ class PreviewTest extends TestCase {
$originalHeight
=
1050
;
$originalHeight
=
1050
;
$originalAspectRation
=
$originalWidth
/
$originalHeight
;
$originalAspectRation
=
$originalWidth
/
$originalHeight
;
$preview
=
new
\OC\
Preview
(
$preview
=
new
Preview
(
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'testimage.jpg'
,
self
::
TEST_PREVIEW_USER1
,
'files/'
,
'testimage.jpg'
,
150
,
150
,
150
150
);
);
$preview
->
setKeepAspect
(
true
);
$preview
->
setKeepAspect
(
true
);
$preview
->
setMode
(
\OC\
Preview
::
MODE_COVER
);
$preview
->
setMode
(
Preview
::
MODE_COVER
);
$image
=
$preview
->
getPreview
();
$image
=
$preview
->
getPreview
();
$aspectRatio
=
$image
->
width
()
/
$image
->
height
();
$aspectRatio
=
$image
->
width
()
/
$image
->
height
();
...
@@ -929,7 +929,7 @@ class PreviewTest extends TestCase {
...
@@ -929,7 +929,7 @@ class PreviewTest extends TestCase {
public
function
testSetFileWithInfo
()
{
public
function
testSetFileWithInfo
()
{
$info
=
new
FileInfo
(
'/foo'
,
null
,
'/foo'
,
[
'mimetype'
=>
'foo/bar'
],
null
);
$info
=
new
FileInfo
(
'/foo'
,
null
,
'/foo'
,
[
'mimetype'
=>
'foo/bar'
],
null
);
$preview
=
new
\OC\
Preview
();
$preview
=
new
Preview
();
$preview
->
setFile
(
'/foo'
,
$info
);
$preview
->
setFile
(
'/foo'
,
$info
);
$this
->
assertEquals
(
$info
,
$this
->
invokePrivate
(
$preview
,
'getFileInfo'
));
$this
->
assertEquals
(
$info
,
$this
->
invokePrivate
(
$preview
,
'getFileInfo'
));
}
}
...
@@ -945,7 +945,7 @@ class PreviewTest extends TestCase {
...
@@ -945,7 +945,7 @@ class PreviewTest extends TestCase {
\OC_Util
::
tearDownFS
();
\OC_Util
::
tearDownFS
();
\OC_Util
::
setupFS
(
$userId
);
\OC_Util
::
setupFS
(
$userId
);
$preview
=
new
\OC\
Preview
(
$userId
,
'files'
);
$preview
=
new
Preview
(
$userId
,
'files'
);
$view
=
new
View
(
'/'
.
$userId
.
'/files'
);
$view
=
new
View
(
'/'
.
$userId
.
'/files'
);
$view
->
file_put_contents
(
'test.png'
,
file_get_contents
(
$sourceFile
));
$view
->
file_put_contents
(
'test.png'
,
file_get_contents
(
$sourceFile
));
$info
=
$view
->
getFileInfo
(
'test.png'
);
$info
=
$view
->
getFileInfo
(
'test.png'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment