mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 19:52:26 +02:00
Cache downloaded assets
This commit is contained in:
parent
7fbad47351
commit
57691d5d66
2 changed files with 26 additions and 29 deletions
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "TextureTest.h"
|
#include "TextureTest.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <QtCore/QTemporaryFile>
|
#include <QtCore/QTemporaryFile>
|
||||||
|
|
||||||
#include <gpu/Forward.h>
|
#include <gpu/Forward.h>
|
||||||
|
@ -22,13 +23,12 @@
|
||||||
|
|
||||||
#include "../../QTestExtensions.h"
|
#include "../../QTestExtensions.h"
|
||||||
|
|
||||||
#pragma optimize("", off)
|
|
||||||
|
|
||||||
QTEST_MAIN(TextureTest)
|
QTEST_MAIN(TextureTest)
|
||||||
|
|
||||||
#define LOAD_TEXTURE_COUNT 40
|
#define LOAD_TEXTURE_COUNT 40
|
||||||
|
|
||||||
static const QString TEST_DATA("https://hifi-public.s3.amazonaws.com/austin/test_data/test_ktx.zip");
|
static const QString TEST_DATA("https://hifi-public.s3.amazonaws.com/austin/test_data/test_ktx.zip");
|
||||||
|
static const QString TEST_DIR_NAME("{630b8f02-52af-4cdf-a896-24e472b94b28}");
|
||||||
|
|
||||||
std::string vertexShaderSource = R"SHADER(
|
std::string vertexShaderSource = R"SHADER(
|
||||||
#line 14
|
#line 14
|
||||||
|
@ -65,9 +65,18 @@ void main() {
|
||||||
|
|
||||||
)SHADER";
|
)SHADER";
|
||||||
|
|
||||||
#define USE_SERVER_DATA 1
|
QtMessageHandler originalHandler;
|
||||||
|
|
||||||
|
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& message) {
|
||||||
|
#if defined(Q_OS_WIN)
|
||||||
|
OutputDebugStringA(message.toStdString().c_str());
|
||||||
|
OutputDebugStringA("\n");
|
||||||
|
#endif
|
||||||
|
originalHandler(type, context, message);
|
||||||
|
}
|
||||||
|
|
||||||
void TextureTest::initTestCase() {
|
void TextureTest::initTestCase() {
|
||||||
|
originalHandler = qInstallMessageHandler(messageHandler);
|
||||||
_resourcesPath = getTestResource("interface/resources");
|
_resourcesPath = getTestResource("interface/resources");
|
||||||
getDefaultOpenGLSurfaceFormat();
|
getDefaultOpenGLSurfaceFormat();
|
||||||
_canvas.create();
|
_canvas.create();
|
||||||
|
@ -77,32 +86,21 @@ void TextureTest::initTestCase() {
|
||||||
gl::initModuleGl();
|
gl::initModuleGl();
|
||||||
gpu::Context::init<gpu::gl::GLBackend>();
|
gpu::Context::init<gpu::gl::GLBackend>();
|
||||||
_gpuContext = std::make_shared<gpu::Context>();
|
_gpuContext = std::make_shared<gpu::Context>();
|
||||||
#if USE_SERVER_DATA
|
|
||||||
if (!_testDataDir.isValid()) {
|
|
||||||
qFatal("Unable to create temp directory");
|
|
||||||
}
|
|
||||||
|
|
||||||
QString path = _testDataDir.path();
|
_resourcesPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/" + TEST_DIR_NAME;
|
||||||
FileDownloader(TEST_DATA,
|
if (!QFileInfo(_resourcesPath).exists()) {
|
||||||
[&](const QByteArray& data) {
|
QDir(_resourcesPath).mkpath(".");
|
||||||
QTemporaryFile zipFile;
|
FileDownloader(TEST_DATA,
|
||||||
if (zipFile.open()) {
|
[&](const QByteArray& data) {
|
||||||
zipFile.write(data);
|
QTemporaryFile zipFile;
|
||||||
zipFile.close();
|
if (zipFile.open()) {
|
||||||
}
|
zipFile.write(data);
|
||||||
if (!_testDataDir.isValid()) {
|
zipFile.close();
|
||||||
qFatal("Unable to create temp dir");
|
}
|
||||||
}
|
JlCompress::extractDir(zipFile.fileName(), _resourcesPath);
|
||||||
auto files = JlCompress::extractDir(zipFile.fileName(), _testDataDir.path());
|
})
|
||||||
for (const auto& file : files) {
|
.waitForDownload();
|
||||||
qDebug() << file;
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
.waitForDownload();
|
|
||||||
_resourcesPath = _testDataDir.path();
|
|
||||||
#else
|
|
||||||
_resourcesPath = "D:/test_ktx";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
_canvas.makeCurrent();
|
_canvas.makeCurrent();
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,7 +29,6 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _resourcesPath;
|
QString _resourcesPath;
|
||||||
QTemporaryDir _testDataDir;
|
|
||||||
OffscreenGLCanvas _canvas;
|
OffscreenGLCanvas _canvas;
|
||||||
gpu::ContextPointer _gpuContext;
|
gpu::ContextPointer _gpuContext;
|
||||||
gpu::PipelinePointer _pipeline;
|
gpu::PipelinePointer _pipeline;
|
||||||
|
|
Loading…
Reference in a new issue