mirror of
https://github.com/nextcloud/server.git
synced 2026-11-05 23:15:19 +01:00
Clients sizing a preview to the screen get no more than preview_max_x and preview_max_y, 4096 by default. Knowing it, a client that needs more detail can load the file itself instead of asking for a preview the server will not render. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: John Molakvoæ <14975046+skjnldsv@users.noreply.github.com>
69 lines
1.9 KiB
PHP
69 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
namespace Test\OCS;
|
|
|
|
use OC\OCS\CoreCapabilities;
|
|
use OCP\IConfig;
|
|
use OCP\IPreview;
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
use Test\TestCase;
|
|
|
|
class CoreCapabilitiesTest extends TestCase {
|
|
private IConfig&MockObject $config;
|
|
private IPreview&MockObject $preview;
|
|
private CoreCapabilities $capabilities;
|
|
|
|
protected function setUp(): void {
|
|
parent::setUp();
|
|
|
|
$this->config = $this->createMock(IConfig::class);
|
|
$this->preview = $this->createMock(IPreview::class);
|
|
$this->capabilities = new CoreCapabilities($this->config, $this->preview);
|
|
}
|
|
|
|
public function testEnabledPreviewProvidersAreReported(): void {
|
|
$this->preview->method('getProviders')
|
|
->willReturn([
|
|
'/image\/jpeg/' => [],
|
|
'/image\/hei(f|c)/' => [],
|
|
]);
|
|
|
|
$capabilities = $this->capabilities->getCapabilities();
|
|
|
|
$this->assertSame(
|
|
['/image\/jpeg/', '/image\/hei(f|c)/'],
|
|
$capabilities['core']['previews']['enabled_providers'],
|
|
);
|
|
}
|
|
|
|
public function testNoPreviewProvidersAreReportedWhenPreviewsAreOff(): void {
|
|
// The manager returns nothing at all when `enable_previews` is off
|
|
$this->preview->method('getProviders')->willReturn([]);
|
|
|
|
$capabilities = $this->capabilities->getCapabilities();
|
|
|
|
$this->assertSame([], $capabilities['core']['previews']['enabled_providers']);
|
|
}
|
|
|
|
public function testLargestPreviewIsReported(): void {
|
|
$this->config->method('getSystemValueInt')
|
|
->willReturnMap([
|
|
['pollinterval', 60, 60],
|
|
['preview_max_x', 4096, 512],
|
|
['preview_max_y', 4096, 384],
|
|
]);
|
|
|
|
$capabilities = $this->capabilities->getCapabilities();
|
|
|
|
$this->assertSame(512, $capabilities['core']['previews']['max_width']);
|
|
$this->assertSame(384, $capabilities['core']['previews']['max_height']);
|
|
}
|
|
}
|