/**
  * @dataProvider providesIsPreviewRequiredData
  *
  * @param $isMimeSupported
  */
 public function testIsPreviewRequiredWithSvg($isMimeSupported)
 {
     /** @type File $file */
     $file = $this->mockSvgFile(12345);
     $animatedPreview = true;
     // Has no effect
     $this->mockIsMimeSupported($isMimeSupported);
     $response = $this->service->isPreviewRequired($file, $animatedPreview);
     $this->assertSame($isMimeSupported, $response);
 }
Example #2
0
 /**
  * Returns true if we need to generate a preview for that file
  *
  * @param $file
  * @param bool $animatedPreview
  *
  * @return bool
  */
 private function isPreviewRequired($file, $animatedPreview)
 {
     $previewRequired = false;
     if (!$this->download) {
         $previewRequired = $this->previewService->isPreviewRequired($file, $animatedPreview);
     }
     return $previewRequired;
 }
 /**
  * @expectedException \OCA\GalleryPlus\Service\InternalServerErrorServiceException
  */
 public function testIsPreviewRequiredWithBrokenGif()
 {
     /** @type File $file */
     $file = $this->mockAnimatedGifFile(12345);
     $file = $this->mockBrokenAnimatedGifFileMethods($file);
     $animatedPreview = false;
     // Should require a preview
     $this->mockIsMimeSupported(true);
     $this->service->isPreviewRequired($file, $animatedPreview);
 }
Example #4
0
 /**
  * @param File $file
  * @param bool $animatedPreview
  * @param int $width
  * @param int $height
  * @param bool $keepAspect
  * @param bool $base64Encode
  *
  * @return array
  */
 private function getPreviewData($file, $animatedPreview, $width, $height, $keepAspect, $base64Encode)
 {
     $status = Http::STATUS_OK;
     if ($this->previewService->isPreviewRequired($file, $animatedPreview)) {
         $type = 'preview';
         $preview = $this->previewService->createPreview($file, $width, $height, $keepAspect, $base64Encode);
     } else {
         $type = 'download';
         $preview = $this->downloadService->downloadFile($file, $base64Encode);
     }
     if (!$preview) {
         list($preview, $status, $type) = $this->getErrorData();
     }
     return [$preview, $status, $type];
 }