aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Preview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Preview')
-rw-r--r--tests/lib/Preview/BackgroundCleanupJobTest.php15
-rw-r--r--tests/lib/Preview/BitmapTest.php4
-rw-r--r--tests/lib/Preview/HEICTest.php4
-rw-r--r--tests/lib/Preview/ImageTest.php4
-rw-r--r--tests/lib/Preview/MP3Test.php4
-rw-r--r--tests/lib/Preview/MovieTest.php3
-rw-r--r--tests/lib/Preview/OfficeTest.php3
-rw-r--r--tests/lib/Preview/Provider.php22
-rw-r--r--tests/lib/Preview/SVGTest.php7
-rw-r--r--tests/lib/Preview/TXTTest.php4
10 files changed, 47 insertions, 23 deletions
diff --git a/tests/lib/Preview/BackgroundCleanupJobTest.php b/tests/lib/Preview/BackgroundCleanupJobTest.php
index cecb4a7a212..ab904f2b499 100644
--- a/tests/lib/Preview/BackgroundCleanupJobTest.php
+++ b/tests/lib/Preview/BackgroundCleanupJobTest.php
@@ -7,11 +7,14 @@
namespace Test\Preview;
+use OC\Files\Storage\Temporary;
use OC\Preview\BackgroundCleanupJob;
use OC\Preview\Storage\Root;
use OC\PreviewManager;
+use OC\SystemConfig;
use OCP\App\IAppManager;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Files\AppData\IAppDataFactory;
use OCP\Files\File;
use OCP\Files\IMimeTypeLoader;
use OCP\Files\IRootFolder;
@@ -46,7 +49,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$this->userId = $this->getUniqueID();
$user = $this->createUser($this->userId, $this->userId);
- $storage = new \OC\Files\Storage\Temporary([]);
+ $storage = new Temporary([]);
$this->registerMount($this->userId, $storage, '');
$this->loginAsUser($this->userId);
@@ -77,8 +80,8 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
private function getRoot(): Root {
return new Root(
- \OC::$server->get(IRootFolder::class),
- \OC::$server->getSystemConfig()
+ Server::get(IRootFolder::class),
+ Server::get(SystemConfig::class)
);
}
@@ -173,7 +176,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$this->markTestSkipped('old previews are not supported for sharded setups');
return;
}
- $appdata = \OC::$server->getAppDataDir('preview');
+ $appdata = Server::get(IAppDataFactory::class)->get('preview');
$f1 = $appdata->newFolder('123456781');
$f1->newFile('foo.jpg', 'foo');
@@ -189,7 +192,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$appdata->getFolder('/')->newFile('not-a-directory', 'foo');
$appdata->getFolder('/')->newFile('133742', 'bar');
- $appdata = \OC::$server->getAppDataDir('preview');
+ $appdata = Server::get(IAppDataFactory::class)->get('preview');
// AppData::getDirectoryListing filters all non-folders
$this->assertSame(3, count($appdata->getDirectoryListing()));
try {
@@ -206,7 +209,7 @@ class BackgroundCleanupJobTest extends \Test\TestCase {
$job = new BackgroundCleanupJob($this->timeFactory, $this->connection, $this->getRoot(), $this->mimeTypeLoader, true);
$job->run([]);
- $appdata = \OC::$server->getAppDataDir('preview');
+ $appdata = Server::get(IAppDataFactory::class)->get('preview');
// Check if the files created above are still present
// Remember: AppData::getDirectoryListing filters all non-folders
diff --git a/tests/lib/Preview/BitmapTest.php b/tests/lib/Preview/BitmapTest.php
index c4f3f8d3cf5..f442ae73b2e 100644
--- a/tests/lib/Preview/BitmapTest.php
+++ b/tests/lib/Preview/BitmapTest.php
@@ -7,6 +7,8 @@
namespace Test\Preview;
+use OC\Preview\Postscript;
+
/**
* Class BitmapTest
*
@@ -22,6 +24,6 @@ class BitmapTest extends Provider {
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 2400;
$this->height = 1707;
- $this->provider = new \OC\Preview\Postscript;
+ $this->provider = new Postscript;
}
}
diff --git a/tests/lib/Preview/HEICTest.php b/tests/lib/Preview/HEICTest.php
index 5df7b63dd03..61dede00e6b 100644
--- a/tests/lib/Preview/HEICTest.php
+++ b/tests/lib/Preview/HEICTest.php
@@ -6,6 +6,8 @@
namespace Test\Preview;
+use OC\Preview\HEIC;
+
/**
* Class BitmapTest
*
@@ -24,7 +26,7 @@ class HEICTest extends Provider {
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 1680;
$this->height = 1050;
- $this->provider = new \OC\Preview\HEIC;
+ $this->provider = new HEIC;
}
}
}
diff --git a/tests/lib/Preview/ImageTest.php b/tests/lib/Preview/ImageTest.php
index f4b8e7e1dd4..03f3403b1b3 100644
--- a/tests/lib/Preview/ImageTest.php
+++ b/tests/lib/Preview/ImageTest.php
@@ -7,6 +7,8 @@
namespace Test\Preview;
+use OC\Preview\JPEG;
+
/**
* Class ImageTest
*
@@ -22,6 +24,6 @@ class ImageTest extends Provider {
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 1680;
$this->height = 1050;
- $this->provider = new \OC\Preview\JPEG();
+ $this->provider = new JPEG();
}
}
diff --git a/tests/lib/Preview/MP3Test.php b/tests/lib/Preview/MP3Test.php
index 6f40b862b7b..3f1c9aff61c 100644
--- a/tests/lib/Preview/MP3Test.php
+++ b/tests/lib/Preview/MP3Test.php
@@ -7,6 +7,8 @@
namespace Test\Preview;
+use OC\Preview\MP3;
+
/**
* Class MP3Test
*
@@ -22,6 +24,6 @@ class MP3Test extends Provider {
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 200;
$this->height = 200;
- $this->provider = new \OC\Preview\MP3;
+ $this->provider = new MP3;
}
}
diff --git a/tests/lib/Preview/MovieTest.php b/tests/lib/Preview/MovieTest.php
index 6009943b89d..de7ff45988c 100644
--- a/tests/lib/Preview/MovieTest.php
+++ b/tests/lib/Preview/MovieTest.php
@@ -7,6 +7,7 @@
namespace Test\Preview;
+use OC\Preview\Movie;
use OCP\IBinaryFinder;
use OCP\Server;
@@ -33,7 +34,7 @@ class MovieTest extends Provider {
parent::setUp();
$this->imgPath = $this->prepareTestFile($this->fileName, \OC::$SERVERROOT . '/tests/data/' . $this->fileName);
- $this->provider = new \OC\Preview\Movie(['movieBinary' => $movieBinary]);
+ $this->provider = new Movie(['movieBinary' => $movieBinary]);
} else {
$this->markTestSkipped('No Movie provider present');
}
diff --git a/tests/lib/Preview/OfficeTest.php b/tests/lib/Preview/OfficeTest.php
index 167c442dd34..471ff0d2367 100644
--- a/tests/lib/Preview/OfficeTest.php
+++ b/tests/lib/Preview/OfficeTest.php
@@ -7,6 +7,7 @@
namespace Test\Preview;
+use OC\Preview\OpenDocument;
use OCP\IBinaryFinder;
use OCP\Server;
@@ -30,7 +31,7 @@ class OfficeTest extends Provider {
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 595;
$this->height = 842;
- $this->provider = new \OC\Preview\OpenDocument;
+ $this->provider = new OpenDocument;
} else {
$this->markTestSkipped('No Office provider present');
}
diff --git a/tests/lib/Preview/Provider.php b/tests/lib/Preview/Provider.php
index a7f55151354..daa069483fd 100644
--- a/tests/lib/Preview/Provider.php
+++ b/tests/lib/Preview/Provider.php
@@ -8,9 +8,15 @@
namespace Test\Preview;
+use OC\Files\Filesystem;
use OC\Files\Node\File;
+use OC\Files\Storage\Storage;
+use OC\Files\Storage\Temporary;
+use OC\Files\View;
+use OC\Preview\TXT;
use OCP\Files\IRootFolder;
use OCP\IUserManager;
+use OCP\Server;
abstract class Provider extends \Test\TestCase {
protected string $imgPath;
@@ -22,13 +28,13 @@ abstract class Provider extends \Test\TestCase {
protected int $maxHeight = 1024;
protected bool $scalingUp = false;
protected string $userId;
- protected \OC\Files\View $rootView;
- protected \OC\Files\Storage\Storage $storage;
+ protected View $rootView;
+ protected Storage $storage;
protected function setUp(): void {
parent::setUp();
- $userManager = \OCP\Server::get(IUserManager::class);
+ $userManager = Server::get(IUserManager::class);
$userManager->clearBackends();
$backend = new \Test\Util\User\Dummy();
$userManager->registerBackend($backend);
@@ -37,10 +43,10 @@ abstract class Provider extends \Test\TestCase {
$backend->createUser($userId, $userId);
$this->loginAsUser($userId);
- $this->storage = new \OC\Files\Storage\Temporary([]);
- \OC\Files\Filesystem::mount($this->storage, [], '/' . $userId . '/');
+ $this->storage = new Temporary([]);
+ Filesystem::mount($this->storage, [], '/' . $userId . '/');
- $this->rootView = new \OC\Files\View('');
+ $this->rootView = new View('');
$this->rootView->mkdir('/' . $userId);
$this->rootView->mkdir('/' . $userId . '/files');
@@ -84,7 +90,7 @@ abstract class Provider extends \Test\TestCase {
$preview = $this->getPreview($this->provider);
// The TXT provider uses the max dimensions to create its canvas,
// so the ratio will always be the one of the max dimension canvas
- if (!$this->provider instanceof \OC\Preview\TXT) {
+ if (!$this->provider instanceof TXT) {
$this->doesRatioMatch($preview, $ratio);
}
$this->doesPreviewFit($preview);
@@ -117,7 +123,7 @@ abstract class Provider extends \Test\TestCase {
* @return bool|\OCP\IImage
*/
private function getPreview($provider) {
- $file = new File(\OC::$server->get(IRootFolder::class), $this->rootView, $this->imgPath);
+ $file = new File(Server::get(IRootFolder::class), $this->rootView, $this->imgPath);
$preview = $provider->getThumbnail($file, $this->maxWidth, $this->maxHeight, $this->scalingUp);
if (get_class($this) === BitmapTest::class && $preview === null) {
diff --git a/tests/lib/Preview/SVGTest.php b/tests/lib/Preview/SVGTest.php
index 14730bc8034..418ac33c3d6 100644
--- a/tests/lib/Preview/SVGTest.php
+++ b/tests/lib/Preview/SVGTest.php
@@ -7,6 +7,9 @@
namespace Test\Preview;
+use OC\Preview\SVG;
+use OCP\Files\File;
+
/**
* Class SVGTest
*
@@ -24,7 +27,7 @@ class SVGTest extends Provider {
$this->imgPath = $this->prepareTestFile($fileName, \OC::$SERVERROOT . '/tests/data/' . $fileName);
$this->width = 3000;
$this->height = 2000;
- $this->provider = new \OC\Preview\SVG;
+ $this->provider = new SVG;
} else {
$this->markTestSkipped('No SVG provider present');
}
@@ -52,7 +55,7 @@ class SVGTest extends Provider {
</svg>');
rewind($handle);
- $file = $this->createMock(\OCP\Files\File::class);
+ $file = $this->createMock(File::class);
$file->method('fopen')
->willReturn($handle);
diff --git a/tests/lib/Preview/TXTTest.php b/tests/lib/Preview/TXTTest.php
index 7f5510eb60f..9541ec8f31c 100644
--- a/tests/lib/Preview/TXTTest.php
+++ b/tests/lib/Preview/TXTTest.php
@@ -7,6 +7,8 @@
namespace Test\Preview;
+use OC\Preview\TXT;
+
/**
* Class TXTTest
*
@@ -23,6 +25,6 @@ class TXTTest extends Provider {
// Arbitrary width and length which won't be used to calculate the ratio
$this->width = 500;
$this->height = 200;
- $this->provider = new \OC\Preview\TXT;
+ $this->provider = new TXT;
}
}