summaryrefslogtreecommitdiffstats
path: root/apps/theming/tests/Controller
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-08-27 12:38:15 +0200
committerLukas Reschke <lukas@statuscode.ch>2016-08-27 21:02:08 +0200
commit73bc108451169aa8ba95eba3749c6450de2ded2e (patch)
tree49cc8f70889aa2760b0bad356640e5626c4eac85 /apps/theming/tests/Controller
parentc40df1d9904be51db00bdcf8bc9b3f85511fb24c (diff)
downloadnextcloud-server-73bc108451169aa8ba95eba3749c6450de2ded2e.tar.gz
nextcloud-server-73bc108451169aa8ba95eba3749c6450de2ded2e.zip
Increase theming performance
1. Set proper caching headers (`Pragma: cache`) 2. Resize image proportionally to a max size of 1920px 3. Store images with progressive mode This resizes a previous 2.8 MB picture to 300kb and makes it rendering going down from 11 seconds to less than 1 here. And future requests won't have to download the file newly.
Diffstat (limited to 'apps/theming/tests/Controller')
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index da2137e9da0..6171b30215e 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -214,6 +214,7 @@ class ThemingControllerTest extends TestCase {
$destination = \OC::$server->getTempManager()->getTemporaryFolder();
touch($tmpLogo);
+ file_put_contents($tmpLogo, file_get_contents(__DIR__ . '/../../../../tests/data/desktopapp.png'));
$this->request
->expects($this->at(0))
->method('getUploadedFile')
@@ -261,6 +262,52 @@ class ThemingControllerTest extends TestCase {
$this->assertEquals($expected, $this->themingController->updateLogo());
}
+ public function testUpdateLogoLoginScreenUploadWithInvalidImage() {
+ $tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg';
+ $destination = \OC::$server->getTempManager()->getTemporaryFolder();
+
+ touch($tmpLogo);
+ file_put_contents($tmpLogo, file_get_contents(__DIR__ . '/../../../../tests/data/data.zip'));
+ $this->request
+ ->expects($this->at(0))
+ ->method('getUploadedFile')
+ ->with('uploadlogo')
+ ->willReturn(null);
+ $this->request
+ ->expects($this->at(1))
+ ->method('getUploadedFile')
+ ->with('upload-login-background')
+ ->willReturn([
+ 'tmp_name' => $tmpLogo,
+ 'type' => 'text/svg',
+ 'name' => 'logo.svg',
+ ]);
+ $this->l10n
+ ->expects($this->once())
+ ->method('t')
+ ->with('Unsupported image type')
+ ->willReturn('Unsupported image type');
+ $file = $this->getMockBuilder('\\OCP\\Files\\File')
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->rootFolder
+ ->expects($this->once())
+ ->method('newFile')
+ ->with('themedbackgroundlogo')
+ ->willReturn($file);
+ $expected = new DataResponse(
+ [
+ 'data' =>
+ [
+ 'message' => 'Unsupported image type',
+ ],
+ 'status' => 'failure'
+ ],
+ Http::STATUS_UNPROCESSABLE_ENTITY
+ );
+ $this->assertEquals($expected, $this->themingController->updateLogo());
+ }
+
public function testUndo() {
$this->l10n
->expects($this->once())
@@ -311,6 +358,7 @@ class ThemingControllerTest extends TestCase {
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
$expected->addHeader('Content-Disposition', 'attachment');
$expected->addHeader('Content-Type', 'text/svg');
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getLogo());
}
@@ -340,6 +388,7 @@ class ThemingControllerTest extends TestCase {
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
$expected->addHeader('Content-Disposition', 'attachment');
$expected->addHeader('Content-Type', 'image/png');
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getLoginBackground());
}
@@ -422,6 +471,7 @@ class ThemingControllerTest extends TestCase {
$expected->cacheFor(3600);
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -510,6 +560,7 @@ class ThemingControllerTest extends TestCase {
$expected->cacheFor(3600);
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -553,6 +604,7 @@ class ThemingControllerTest extends TestCase {
$expected->cacheFor(3600);
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -588,6 +640,7 @@ class ThemingControllerTest extends TestCase {
$expected->cacheFor(3600);
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -687,6 +740,7 @@ class ThemingControllerTest extends TestCase {
$expected->cacheFor(3600);
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -791,6 +845,7 @@ class ThemingControllerTest extends TestCase {
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
$expected->cacheFor(3600);
$expected->addHeader('Expires', date(\DateTime::RFC2822, 123));
+ $expected->addHeader('Pragma', 'cache');
@$this->assertEquals($expected, $this->themingController->getStylesheet());
}
@@ -825,6 +880,7 @@ class ThemingControllerTest extends TestCase {
$expected = new Http\DataDisplayResponse($expectedResponse);
$expected->addHeader("Content-type","text/javascript");
$expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
+ $expected->addHeader('Pragma', 'cache');
$expected->cacheFor(3600);
@$this->assertEquals($expected, $this->themingController->getJavascript());
}
@@ -858,6 +914,7 @@ class ThemingControllerTest extends TestCase {
$expected = new Http\DataDisplayResponse($expectedResponse);
$expected->addHeader("Content-type","text/javascript");
$expected->addHeader('Expires', date(\DateTime::RFC2822, $this->timeFactory->getTime()));
+ $expected->addHeader('Pragma', 'cache');
$expected->cacheFor(3600);
@$this->assertEquals($expected, $this->themingController->getJavascript());
}