Moved ownership of test location into the Test Scripting class.

This commit is contained in:
NissimHadar 2018-05-14 16:32:04 -07:00
parent 8e3844a235
commit d4d2f3c957
4 changed files with 15 additions and 15 deletions

View file

@ -1033,7 +1033,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
QFileInfo fileInfo(path); QFileInfo fileInfo(path);
if (fileInfo.isDir() && fileInfo.isWritable()) { if (fileInfo.isDir() && fileInfo.isWritable()) {
testResultsLocation = path; TestScriptingInterface::getInstance()->setTestResultsLocation(path);
} }
} }
} }
@ -7591,8 +7591,8 @@ void Application::loadAvatarBrowser() const {
void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {
// Get a screenshot and save it // Get a screenshot and save it
QString path = QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename,
Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testResultsLocation); TestScriptingInterface::getInstance()->getTestResultsLocation());
// If we're not doing an animated snapshot as well... // If we're not doing an animated snapshot as well...
if (!includeAnimated) { if (!includeAnimated) {
@ -7607,8 +7607,8 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
void Application::takeSecondaryCameraSnapshot(const QString& filename) { void Application::takeSecondaryCameraSnapshot(const QString& filename) {
postLambdaEvent([filename, this] { postLambdaEvent([filename, this] {
QString snapshotPath = QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename,
Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testResultsLocation); TestScriptingInterface::getInstance()->getTestResultsLocation());
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true); emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
}); });

View file

@ -419,8 +419,6 @@ public slots:
void updateVerboseLogging(); void updateVerboseLogging();
Q_INVOKABLE void openAndroidActivity(const QString& activityName); Q_INVOKABLE void openAndroidActivity(const QString& activityName);
QString getTestResultsLocation() { return testResultsLocation; };
private slots: private slots:
void onDesktopRootItemCreated(QQuickItem* qmlContext); void onDesktopRootItemCreated(QQuickItem* qmlContext);
void onDesktopRootContextCreated(QQmlContext* qmlContext); void onDesktopRootContextCreated(QQmlContext* qmlContext);
@ -754,7 +752,6 @@ private:
std::atomic<bool> _pendingIdleEvent { true }; std::atomic<bool> _pendingIdleEvent { true };
std::atomic<bool> _pendingRenderEvent { true }; std::atomic<bool> _pendingRenderEvent { true };
QString testResultsLocation;
bool quitWhenFinished { false }; bool quitWhenFinished { false };
}; };
#endif // hifi_Application_h #endif // hifi_Application_h

View file

@ -162,8 +162,7 @@ void TestScriptingInterface::clearCaches() {
// Writes a JSON object from javascript to a file // Writes a JSON object from javascript to a file
void TestScriptingInterface::saveObject(QVariant variant, const QString& filename) { void TestScriptingInterface::saveObject(QVariant variant, const QString& filename) {
QString testResultsLocation = qApp->getTestResultsLocation(); if (_testResultsLocation.isNull()) {
if (testResultsLocation.isNull()) {
return; return;
} }
@ -176,11 +175,11 @@ void TestScriptingInterface::saveObject(QVariant variant, const QString& filenam
QByteArray jsonData = jsonDocument.toJson(); QByteArray jsonData = jsonDocument.toJson();
// Append trailing slash if needed // Append trailing slash if needed
if (testResultsLocation.right(1) != "/") { if (_testResultsLocation.right(1) != "/") {
testResultsLocation += "/"; _testResultsLocation += "/";
} }
QString filepath = QDir::cleanPath(testResultsLocation + filename); QString filepath = QDir::cleanPath(_testResultsLocation + filename);
QFile file(filepath); QFile file(filepath);
file.open(QFile::WriteOnly); file.open(QFile::WriteOnly);

View file

@ -18,6 +18,10 @@ class QScriptValue;
class TestScriptingInterface : public QObject { class TestScriptingInterface : public QObject {
Q_OBJECT Q_OBJECT
public:
void setTestResultsLocation(const QString path) { _testResultsLocation = path; }
const QString& getTestResultsLocation() { return _testResultsLocation; };
public slots: public slots:
static TestScriptingInterface* getInstance(); static TestScriptingInterface* getInstance();
@ -46,7 +50,6 @@ public slots:
*/ */
void waitIdle(); void waitIdle();
bool waitForConnection(qint64 maxWaitMs = 10000); bool waitForConnection(qint64 maxWaitMs = 10000);
void wait(int milliseconds); void wait(int milliseconds);
@ -90,6 +93,7 @@ public slots:
private: private:
bool waitForCondition(qint64 maxWaitMs, std::function<bool()> condition); bool waitForCondition(qint64 maxWaitMs, std::function<bool()> condition);
QString _testResultsLocation;
}; };
#endif // hifi_TestScriptingInterface_h #endif // hifi_TestScriptingInterface_h