Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2015-09-30 12:07:18 +0300
committerThomas Müller <thomas.mueller@tmit.eu>2015-09-30 12:07:18 +0300
commit10978a7a610139f96b1d6c9b178e05b459cc6ef6 (patch)
tree9deaab450e7e7291fdd36a1a03922f2c159f613d /tests
parentdcd822bc9623eeb3f467ce1d6d70224dc8a2a732 (diff)
parenta5ad5bf29bdba3aae34473a7fd5114f2ae750be9 (diff)
Merge pull request #19373 from owncloud/sidebar-preview-cover
Cover both width and height for the sidebar preview
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/preview.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/lib/preview.php b/tests/lib/preview.php
index 9e118014bac..a135ed40d0a 100644
--- a/tests/lib/preview.php
+++ b/tests/lib/preview.php
@@ -874,4 +874,45 @@ class Preview extends TestCase {
return [(int)$askedWidth, (int)$askedHeight];
}
+
+ public function testKeepAspectRatio() {
+ $originalWidth = 1680;
+ $originalHeight = 1050;
+ $originalAspectRation = $originalWidth / $originalHeight;
+
+ $preview = new \OC\Preview(
+ self::TEST_PREVIEW_USER1, 'files/', 'testimage.jpg',
+ 150,
+ 150
+ );
+ $preview->setKeepAspect(true);
+ $image = $preview->getPreview();
+
+ $aspectRatio = $image->width() / $image->height();
+ $this->assertEquals(round($originalAspectRation, 2), round($aspectRatio, 2));
+
+ $this->assertLessThanOrEqual(150, $image->width());
+ $this->assertLessThanOrEqual(150, $image->height());
+ }
+
+ public function testKeepAspectRatioCover() {
+ $originalWidth = 1680;
+ $originalHeight = 1050;
+ $originalAspectRation = $originalWidth / $originalHeight;
+
+ $preview = new \OC\Preview(
+ self::TEST_PREVIEW_USER1, 'files/', 'testimage.jpg',
+ 150,
+ 150
+ );
+ $preview->setKeepAspect(true);
+ $preview->setMode(\OC\Preview::MODE_COVER);
+ $image = $preview->getPreview();
+
+ $aspectRatio = $image->width() / $image->height();
+ $this->assertEquals(round($originalAspectRation, 2), round($aspectRatio, 2));
+
+ $this->assertGreaterThanOrEqual(150, $image->width());
+ $this->assertGreaterThanOrEqual(150, $image->height());
+ }
}