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);
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) {
postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {
// Get a screenshot and save it
QString path =
Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testResultsLocation);
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename,
TestScriptingInterface::getInstance()->getTestResultsLocation());
// If we're not doing an animated snapshot as well...
if (!includeAnimated) {
@ -7607,8 +7607,8 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
void Application::takeSecondaryCameraSnapshot(const QString& filename) {
postLambdaEvent([filename, this] {
QString snapshotPath =
Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testResultsLocation);
QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename,
TestScriptingInterface::getInstance()->getTestResultsLocation());
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
});

View file

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

View file

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

View file

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