Esempio n. 1
0
 /**
  * @NoAdminRequired
  *
  * Returns an app configuration array
  *
  * @param bool $slideshow
  *
  * @return array
  */
 public function getConfig($slideshow = false)
 {
     $features = $this->configService->getFeaturesList();
     //$this->logger->debug("Features: {features}", ['features' => $features]);
     $nativeSvgSupport = $this->isNativeSvgActivated($features);
     $mediaTypes = $this->previewService->getSupportedMediaTypes($slideshow, $nativeSvgSupport);
     return ['features' => $features, 'mediatypes' => $mediaTypes];
 }
Esempio n. 2
0
 /**
  * @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);
 }
 /**
  * @expectedException \OCA\GalleryPlus\Service\InternalServerErrorServiceException
  */
 public function testPreviewValidatorWithBrokenSetup()
 {
     $square = true;
     $base64Encode = true;
     $this->mockPreviewValidatorWithBrokenSystem();
     $this->service->previewValidator($square, $base64Encode);
 }
Esempio n. 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];
 }
Esempio n. 5
0
 /**
  * @param $file
  * @param $previewRequired
  * @param $width
  * @param $height
  * @param $keepAspect
  * @param $base64Encode
  *
  * @return array
  */
 private function getPreviewData($file, $previewRequired, $width, $height, $keepAspect, $base64Encode)
 {
     $status = Http::STATUS_OK;
     if ($previewRequired) {
         $type = 'preview';
         $preview = $this->previewService->createPreview($file, $width, $height, $keepAspect, $base64Encode);
     } else {
         $type = 'download';
         $preview = $this->downloadService->downloadFile($file, $base64Encode);
     }
     if (!$preview) {
         $type = 'error';
         $status = Http::STATUS_INTERNAL_SERVER_ERROR;
         $preview = null;
     }
     return [$preview, $status, $type];
 }
 private function mockPreviewValidator($square, $base64Encode, $base64EncodedPreview)
 {
     $this->previewService->expects($this->once())->method('previewValidator')->with($square, $base64Encode)->willReturn($base64EncodedPreview);
 }
 /**
  * Mocks PreviewService->getSupportedMediaTypes
  *
  * @param $slideshow
  * @param $nativeSvgSupport
  * @param $mimeTypes
  */
 private function mockSupportedMediaTypes($slideshow, $nativeSvgSupport, $mimeTypes)
 {
     $this->previewService->expects($this->any())->method('getSupportedMediaTypes')->with($this->equalTo($slideshow), $this->equalTo($nativeSvgSupport))->willReturn($mimeTypes);
 }