2016-06-21 22:21:46 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
*
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Julius Haertl <jus@bitgrid.net>
|
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
* @author oparoz <owncloud@interfasys.ch>
|
|
|
|
*
|
2016-06-21 22:21:46 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
namespace OCA\Theming\Tests\Controller;
|
|
|
|
|
|
|
|
use OCA\Theming\Controller\ThemingController;
|
|
|
|
use OCA\Theming\Template;
|
2016-07-25 18:32:11 +03:00
|
|
|
use OCA\Theming\Util;
|
2016-06-21 22:21:46 +03:00
|
|
|
use OCP\AppFramework\Http;
|
|
|
|
use OCP\AppFramework\Http\DataResponse;
|
2016-06-27 11:47:44 +03:00
|
|
|
use OCP\Files\IRootFolder;
|
2016-06-21 22:21:46 +03:00
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\IL10N;
|
|
|
|
use OCP\IRequest;
|
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
class ThemingControllerTest extends TestCase {
|
|
|
|
/** @var IRequest */
|
|
|
|
private $request;
|
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
|
|
|
/** @var Template */
|
|
|
|
private $template;
|
|
|
|
/** @var IL10N */
|
|
|
|
private $l10n;
|
|
|
|
/** @var ThemingController */
|
|
|
|
private $themingController;
|
2016-06-27 11:47:44 +03:00
|
|
|
/** @var IRootFolder */
|
|
|
|
private $rootFolder;
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
$this->request = $this->getMock('\\OCP\\IRequest');
|
|
|
|
$this->config = $this->getMock('\\OCP\\IConfig');
|
|
|
|
$this->template = $this->getMockBuilder('\\OCA\\Theming\\Template')
|
|
|
|
->disableOriginalConstructor()->getMock();
|
|
|
|
$this->l10n = $this->getMock('\\OCP\\IL10N');
|
2016-06-27 11:47:44 +03:00
|
|
|
$this->rootFolder = $this->getMock('\\OCP\\Files\\IRootFolder');
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$this->themingController = new ThemingController(
|
|
|
|
'theming',
|
|
|
|
$this->request,
|
|
|
|
$this->config,
|
|
|
|
$this->template,
|
2016-06-27 11:47:44 +03:00
|
|
|
$this->l10n,
|
|
|
|
$this->rootFolder
|
2016-06-21 22:21:46 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
return parent::setUp();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateStylesheet() {
|
|
|
|
$this->template
|
|
|
|
->expects($this->once())
|
|
|
|
->method('set')
|
|
|
|
->with('MySetting', 'MyValue');
|
|
|
|
$this->l10n
|
|
|
|
->expects($this->once())
|
|
|
|
->method('t')
|
|
|
|
->with('Saved')
|
|
|
|
->willReturn('Saved');
|
|
|
|
|
|
|
|
$expected = new DataResponse(
|
|
|
|
[
|
|
|
|
'data' =>
|
|
|
|
[
|
|
|
|
'message' => 'Saved',
|
|
|
|
],
|
|
|
|
'status' => 'success'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $this->themingController->updateStylesheet('MySetting', 'MyValue'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateLogoNoData() {
|
|
|
|
$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(null);
|
|
|
|
$this->l10n
|
|
|
|
->expects($this->once())
|
|
|
|
->method('t')
|
|
|
|
->with('No file uploaded')
|
|
|
|
->willReturn('No file uploaded');
|
|
|
|
|
|
|
|
$expected = new DataResponse(
|
|
|
|
[
|
|
|
|
'data' =>
|
|
|
|
[
|
|
|
|
'message' => 'No file uploaded',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
Http::STATUS_UNPROCESSABLE_ENTITY
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->themingController->updateLogo());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateLogoNormalLogoUpload() {
|
|
|
|
$tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg';
|
|
|
|
$destination = \OC::$server->getTempManager()->getTemporaryFolder();
|
|
|
|
|
|
|
|
touch($tmpLogo);
|
|
|
|
$this->request
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getUploadedFile')
|
|
|
|
->with('uploadlogo')
|
|
|
|
->willReturn([
|
|
|
|
'tmp_name' => $tmpLogo,
|
|
|
|
'type' => 'text/svg',
|
|
|
|
'name' => 'logo.svg',
|
|
|
|
]);
|
|
|
|
$this->request
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getUploadedFile')
|
|
|
|
->with('upload-login-background')
|
|
|
|
->willReturn(null);
|
|
|
|
$this->l10n
|
|
|
|
->expects($this->once())
|
|
|
|
->method('t')
|
|
|
|
->with('Saved')
|
|
|
|
->willReturn('Saved');
|
2016-06-27 11:47:44 +03:00
|
|
|
$file = $this->getMockBuilder('\\OCP\\Files\\File')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$this->rootFolder
|
|
|
|
->expects($this->once())
|
|
|
|
->method('newFile')
|
|
|
|
->with('themedinstancelogo')
|
|
|
|
->willReturn($file);
|
|
|
|
$file
|
|
|
|
->expects($this->once())
|
|
|
|
->method('fopen')
|
|
|
|
->with('w')
|
|
|
|
->willReturn(fopen($destination . '/themedinstancelogo', 'w'));
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
|
|
$expected = new DataResponse(
|
|
|
|
[
|
|
|
|
'data' =>
|
|
|
|
[
|
|
|
|
'name' => 'logo.svg',
|
|
|
|
'message' => 'Saved',
|
|
|
|
],
|
|
|
|
'status' => 'success'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $this->themingController->updateLogo());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdateLogoLoginScreenUpload() {
|
|
|
|
$tmpLogo = \OC::$server->getTempManager()->getTemporaryFolder() . '/logo.svg';
|
|
|
|
$destination = \OC::$server->getTempManager()->getTemporaryFolder();
|
|
|
|
|
|
|
|
touch($tmpLogo);
|
|
|
|
$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('Saved')
|
|
|
|
->willReturn('Saved');
|
2016-06-27 11:47:44 +03:00
|
|
|
$file = $this->getMockBuilder('\\OCP\\Files\\File')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
|
|
|
$this->rootFolder
|
|
|
|
->expects($this->once())
|
|
|
|
->method('newFile')
|
|
|
|
->with('themedbackgroundlogo')
|
|
|
|
->willReturn($file);
|
|
|
|
$file
|
|
|
|
->expects($this->once())
|
|
|
|
->method('fopen')
|
|
|
|
->with('w')
|
|
|
|
->willReturn(fopen($destination . '/themedbackgroundlogo', 'w'));
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
|
|
$expected = new DataResponse(
|
|
|
|
[
|
|
|
|
'data' =>
|
|
|
|
[
|
|
|
|
'name' => 'logo.svg',
|
|
|
|
'message' => 'Saved',
|
|
|
|
],
|
|
|
|
'status' => 'success'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $this->themingController->updateLogo());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUndo() {
|
|
|
|
$this->l10n
|
|
|
|
->expects($this->once())
|
|
|
|
->method('t')
|
|
|
|
->with('Saved')
|
|
|
|
->willReturn('Saved');
|
|
|
|
$this->template
|
|
|
|
->expects($this->once())
|
|
|
|
->method('undo')
|
|
|
|
->with('MySetting')
|
|
|
|
->willReturn('MyValue');
|
|
|
|
|
|
|
|
$expected = new DataResponse(
|
|
|
|
[
|
|
|
|
'data' =>
|
|
|
|
[
|
|
|
|
'value' => 'MyValue',
|
|
|
|
'message' => 'Saved',
|
|
|
|
],
|
|
|
|
'status' => 'success'
|
|
|
|
]
|
|
|
|
);
|
|
|
|
$this->assertEquals($expected, $this->themingController->undo('MySetting'));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetLogoNotExistent() {
|
|
|
|
$expected = new DataResponse();
|
|
|
|
$this->assertEquals($expected, $this->themingController->getLogo());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetLogo() {
|
|
|
|
$dataFolder = \OC::$server->getTempManager()->getTemporaryFolder();
|
|
|
|
$tmpLogo = $dataFolder . '/themedinstancelogo';
|
|
|
|
touch($tmpLogo);
|
|
|
|
$this->config
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('datadirectory', \OC::$SERVERROOT . '/data/')
|
|
|
|
->willReturn($dataFolder);
|
|
|
|
$this->config
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('text/svg');
|
|
|
|
|
|
|
|
@$expected = new Http\StreamResponse($tmpLogo);
|
|
|
|
$expected->cacheFor(3600);
|
|
|
|
$expected->addHeader('Content-Disposition', 'attachment');
|
|
|
|
$expected->addHeader('Content-Type', 'text/svg');
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getLogo());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetLoginBackgroundNotExistent() {
|
|
|
|
$expected = new DataResponse();
|
|
|
|
$this->assertEquals($expected, $this->themingController->getLoginBackground());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetLoginBackground() {
|
|
|
|
$dataFolder = \OC::$server->getTempManager()->getTemporaryFolder();
|
|
|
|
$tmpLogo = $dataFolder . '/themedbackgroundlogo';
|
|
|
|
touch($tmpLogo);
|
|
|
|
$this->config
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getSystemValue')
|
|
|
|
->with('datadirectory', \OC::$SERVERROOT . '/data/')
|
|
|
|
->willReturn($dataFolder);
|
|
|
|
$this->config
|
|
|
|
->expects($this->once())
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('image/png');
|
|
|
|
|
|
|
|
@$expected = new Http\StreamResponse($tmpLogo);
|
|
|
|
$expected->cacheFor(3600);
|
|
|
|
$expected->addHeader('Content-Disposition', 'attachment');
|
|
|
|
$expected->addHeader('Content-Type', 'image/png');
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getLoginBackground());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStylesheetWithOnlyColor() {
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$color = '#000';
|
|
|
|
|
2016-07-15 15:04:19 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
->willReturn('0');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'color', '')
|
2016-07-28 12:45:42 +03:00
|
|
|
->willReturn($color);
|
2016-07-15 15:04:19 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(2))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(3))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('');
|
|
|
|
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData = sprintf(
|
|
|
|
'#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}' . "\n",
|
|
|
|
$color
|
|
|
|
);
|
|
|
|
$expectedData .= sprintf('input[type="checkbox"].checkbox:checked:enabled:not(.checkbox--white) + label:before {' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'background-image:url(\'%s/core/img/actions/checkmark-white.svg\');' .
|
|
|
|
'background-color: %s; background-position: center center; background-size:contain;' .
|
|
|
|
'width:12px; height:12px; padding:0; margin:2px 6px 6px 2px; border-radius:1px;' .
|
|
|
|
"}\n",
|
|
|
|
\OC::$WEBROOT,
|
2016-07-28 12:45:42 +03:00
|
|
|
$color
|
2016-07-25 17:44:56 +03:00
|
|
|
);
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
|
|
|
'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton($color).'\');' .
|
2016-07-25 18:32:11 +03:00
|
|
|
"}\n";
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$expectedData .= '
|
|
|
|
#firstrunwizard .firstrunwizard-header {
|
|
|
|
background-color: ' . $color . ';
|
|
|
|
}
|
|
|
|
#firstrunwizard p a {
|
|
|
|
color: ' . $color . ';
|
|
|
|
}
|
|
|
|
';
|
|
|
|
|
|
|
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
|
|
|
|
2016-07-15 15:04:19 +03:00
|
|
|
$expected->cacheFor(3600);
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStylesheetWithOnlyColorInvert() {
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$color = '#fff';
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
->willReturn('0');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'color', '')
|
2016-07-28 12:45:42 +03:00
|
|
|
->willReturn($color);
|
2016-06-21 22:21:46 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(2))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(3))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('');
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$expectedData = sprintf(
|
|
|
|
'#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}' . "\n",
|
|
|
|
$color
|
|
|
|
);
|
|
|
|
$expectedData .= sprintf('input[type="checkbox"].checkbox:checked:enabled:not(.checkbox--white) + label:before {' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'background-image:url(\'%s/core/img/actions/checkmark-white.svg\');' .
|
2016-07-28 12:45:42 +03:00
|
|
|
'background-color: #555555; background-position: center center; background-size:contain;' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'width:12px; height:12px; padding:0; margin:2px 6px 6px 2px; border-radius:1px;' .
|
|
|
|
"}\n",
|
2016-07-28 12:45:42 +03:00
|
|
|
\OC::$WEBROOT
|
2016-07-25 17:44:56 +03:00
|
|
|
);
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
|
|
|
'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton('#555555').'\');' .
|
2016-07-25 18:32:11 +03:00
|
|
|
"}\n";
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$expectedData .= '
|
|
|
|
#firstrunwizard .firstrunwizard-header {
|
|
|
|
background-color: ' . $color . ';
|
|
|
|
}
|
|
|
|
#firstrunwizard p a {
|
|
|
|
color: ' . $color . ';
|
|
|
|
}
|
|
|
|
';
|
|
|
|
$expectedData .= '#header .header-appname, #expandDisplayName { color: #000000; }' . "\n";
|
|
|
|
$expectedData .= '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); }' . "\n";
|
|
|
|
$expectedData .= '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . "\n";
|
|
|
|
$expectedData .= '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }' . "\n";
|
|
|
|
|
|
|
|
|
|
|
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$expected->cacheFor(3600);
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStylesheetWithOnlyHeaderLogo() {
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
->willReturn('0');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'color', '')
|
|
|
|
->willReturn('');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(2))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('image/png');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(3))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('');
|
|
|
|
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData = '#header .logo {' .
|
2016-07-19 15:39:53 +03:00
|
|
|
'background-image: url(\'./logo?v=0\')' .
|
|
|
|
'background-size: contain;' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'}' . "\n" .
|
2016-07-19 15:39:53 +03:00
|
|
|
'#header .logo-icon {' .
|
|
|
|
'background-image: url(\'./logo?v=0\');' .
|
|
|
|
'background-size: contain;' .
|
2016-07-28 12:45:42 +03:00
|
|
|
'}' . "\n" .
|
|
|
|
'#firstrunwizard .firstrunwizard-header .logo {' .
|
|
|
|
'background-image: url(\'./logo?v=0\');' .
|
|
|
|
'background-size: contain;' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'}' . "\n";
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$expected->cacheFor(3600);
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStylesheetWithOnlyBackgroundLogin() {
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
->willReturn('0');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'color', '')
|
|
|
|
->willReturn('');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(2))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(3))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('text/svg');
|
|
|
|
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData = '#body-login {background-image: url(\'./loginbackground?v=0\');}' . "\n";
|
|
|
|
$expectedData .= 'firstrunwizard .firstrunwizard-header {' .
|
|
|
|
'background-image: url(\'./loginbackground?v=0\');' .
|
|
|
|
'}' . "\n";
|
|
|
|
|
|
|
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$expected->cacheFor(3600);
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetStylesheetWithAllCombined() {
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$color = '#000';
|
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
->willReturn('0');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'color', '')
|
2016-07-28 12:45:42 +03:00
|
|
|
->willReturn($color);
|
2016-06-21 22:21:46 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(2))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('text/svg');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(3))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('image/png');
|
|
|
|
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData = sprintf(
|
|
|
|
'#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}' . "\n",
|
|
|
|
$color);
|
|
|
|
|
|
|
|
$expectedData .= sprintf('input[type="checkbox"].checkbox:checked:enabled:not(.checkbox--white) + label:before {' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'background-image:url(\'%s/core/img/actions/checkmark-white.svg\');' .
|
|
|
|
'background-color: %s; background-position: center center; background-size:contain;' .
|
|
|
|
'width:12px; height:12px; padding:0; margin:2px 6px 6px 2px; border-radius:1px;' .
|
|
|
|
"}\n",
|
|
|
|
\OC::$WEBROOT,
|
2016-07-28 12:45:42 +03:00
|
|
|
$color
|
2016-07-25 17:44:56 +03:00
|
|
|
);
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
|
|
|
'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton($color).'\');' .
|
2016-07-25 18:32:11 +03:00
|
|
|
"}\n";
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData .= '
|
|
|
|
#firstrunwizard .firstrunwizard-header {
|
|
|
|
background-color: ' . $color . ';
|
|
|
|
}
|
|
|
|
#firstrunwizard p a {
|
|
|
|
color: ' . $color . ';
|
|
|
|
}
|
|
|
|
';
|
|
|
|
$expectedData .= sprintf(
|
|
|
|
'#header .logo {' .
|
2016-07-19 15:39:53 +03:00
|
|
|
'background-image: url(\'./logo?v=0\')' .
|
|
|
|
'background-size: contain;' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'}' . "\n" .
|
2016-07-19 15:39:53 +03:00
|
|
|
'#header .logo-icon {' .
|
|
|
|
'background-image: url(\'./logo?v=0\');' .
|
|
|
|
'background-size: contain;' .
|
2016-07-28 12:45:42 +03:00
|
|
|
'}' . "\n" .
|
|
|
|
'#firstrunwizard .firstrunwizard-header .logo {' .
|
|
|
|
'background-image: url(\'./logo?v=0\');' .
|
|
|
|
'background-size: contain;' .
|
|
|
|
'}' . "\n"
|
|
|
|
);
|
|
|
|
$expectedData .= '#body-login {background-image: url(\'./loginbackground?v=0\');}' . "\n";
|
|
|
|
$expectedData .= 'firstrunwizard .firstrunwizard-header {' .
|
|
|
|
'background-image: url(\'./loginbackground?v=0\');' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'}' . "\n";
|
2016-07-28 12:45:42 +03:00
|
|
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
2016-07-19 15:39:53 +03:00
|
|
|
|
2016-06-21 22:21:46 +03:00
|
|
|
$expected->cacheFor(3600);
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
|
|
|
}
|
2016-07-28 12:45:42 +03:00
|
|
|
|
2016-07-15 15:04:19 +03:00
|
|
|
public function testGetStylesheetWithAllCombinedInverted() {
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$color = '#fff';
|
|
|
|
|
2016-07-15 15:04:19 +03:00
|
|
|
$this->config
|
|
|
|
->expects($this->at(0))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'cachebuster', '0')
|
|
|
|
->willReturn('0');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(1))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'color', '')
|
|
|
|
->willReturn('#fff');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(2))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'logoMime', '')
|
|
|
|
->willReturn('text/svg');
|
|
|
|
$this->config
|
|
|
|
->expects($this->at(3))
|
|
|
|
->method('getAppValue')
|
|
|
|
->with('theming', 'backgroundMime', '')
|
|
|
|
->willReturn('image/png');
|
|
|
|
|
2016-07-28 12:45:42 +03:00
|
|
|
|
|
|
|
$expectedData = sprintf(
|
|
|
|
'#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}' . "\n",
|
|
|
|
$color);
|
|
|
|
|
|
|
|
$expectedData .= sprintf('input[type="checkbox"].checkbox:checked:enabled:not(.checkbox--white) + label:before {' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'background-image:url(\'%s/core/img/actions/checkmark-white.svg\');' .
|
2016-07-28 12:45:42 +03:00
|
|
|
'background-color: #555555; background-position: center center; background-size:contain;' .
|
2016-07-25 17:44:56 +03:00
|
|
|
'width:12px; height:12px; padding:0; margin:2px 6px 6px 2px; border-radius:1px;' .
|
|
|
|
"}\n",
|
2016-07-28 12:45:42 +03:00
|
|
|
\OC::$WEBROOT
|
2016-07-25 17:44:56 +03:00
|
|
|
);
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData .= 'input[type="radio"].radio:checked:not(.radio--white):not(:disabled) + label:before {' .
|
|
|
|
'background-image: url(\'data:image/svg+xml;base64,'.Util::generateRadioButton('#555555').'\');' .
|
2016-07-25 18:32:11 +03:00
|
|
|
"}\n";
|
2016-07-28 12:45:42 +03:00
|
|
|
$expectedData .= '
|
|
|
|
#firstrunwizard .firstrunwizard-header {
|
|
|
|
background-color: ' . $color . ';
|
|
|
|
}
|
|
|
|
#firstrunwizard p a {
|
|
|
|
color: ' . $color . ';
|
|
|
|
}
|
|
|
|
';
|
|
|
|
$expectedData .= sprintf(
|
|
|
|
'#header .logo {' .
|
2016-07-19 15:39:53 +03:00
|
|
|
'background-image: url(\'./logo?v=0\')' .
|
|
|
|
'background-size: contain;' .
|
2016-07-28 12:45:42 +03:00
|
|
|
'}' . "\n" .
|
2016-07-19 15:39:53 +03:00
|
|
|
'#header .logo-icon {' .
|
|
|
|
'background-image: url(\'./logo?v=0\');' .
|
|
|
|
'background-size: contain;' .
|
2016-07-28 12:45:42 +03:00
|
|
|
'}' . "\n" .
|
|
|
|
'#firstrunwizard .firstrunwizard-header .logo {' .
|
|
|
|
'background-image: url(\'./logo?v=0\');' .
|
|
|
|
'background-size: contain;' .
|
|
|
|
'}' . "\n"
|
|
|
|
);
|
|
|
|
$expectedData .= '#body-login {background-image: url(\'./loginbackground?v=0\');}' . "\n";
|
|
|
|
$expectedData .= 'firstrunwizard .firstrunwizard-header {' .
|
|
|
|
'background-image: url(\'./loginbackground?v=0\');' .
|
|
|
|
'}' . "\n";
|
|
|
|
$expectedData .= '#header .header-appname, #expandDisplayName { color: #000000; }' . "\n";
|
|
|
|
$expectedData .= '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); }' . "\n";
|
|
|
|
$expectedData .= '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . "\n";
|
|
|
|
$expectedData .= '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }' . "\n";
|
|
|
|
$expected = new Http\DataDownloadResponse($expectedData, 'style', 'text/css');
|
|
|
|
|
2016-07-15 15:04:19 +03:00
|
|
|
$expected->cacheFor(3600);
|
|
|
|
@$this->assertEquals($expected, $this->themingController->getStylesheet());
|
|
|
|
}
|
2016-06-21 22:21:46 +03:00
|
|
|
|
|
|
|
}
|