Command line parameters for autotester
Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all
Unified · Split
| @@ -743,6 +743,11 @@ extern DisplayPluginList getDisplayPlugins(); · 742 unmodified lines | ||
| 743 | 743 | extern InputPluginList getInputPlugins(); |
| 744 | 744 | extern void saveInputPluginSettings(const InputPluginList& plugins); |
| 745 | 745 | |
| 746 | +// Parameters used for running tests from teh command line | |
| 747 | +const QString TEST_SCRIPT_COMMAND { "--testScript" }; | |
| 748 | +const QString TEST_QUIT_WHEN_FINISHED_OPTION { "quitWhenFinished" }; | |
| 749 | +const QString TEST_SNAPSHOT_LOCATION_COMMAND { "--testSnapshotLocation" }; | |
| 750 | + | |
| 746 | 751 | bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { |
| 747 | 752 | const char** constArgv = const_cast<const char**>(argv); |
| 748 | 753 | |
| @@ -777,7 +782,22 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) { · 28 unmodified lines | ||
| 777 | 782 | |
| 778 | 783 | static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset"; |
| 779 | 784 | bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET); |
| 780 | − bool previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); | |
| 785 | + | |
| 786 | + // Ignore any previous crashes if running from command line with a test script. | |
| 787 | + bool inTestMode { false }; | |
| 788 | + for (int i = 0; i < argc; ++i) { | |
| 789 | + QString parameter(argv[i]); | |
| 790 | + if (parameter == TEST_SCRIPT_COMMAND) { | |
| 791 | + inTestMode = true; | |
| 792 | + break; | |
| 793 | + } | |
| 794 | + } | |
| 795 | + | |
| 796 | + bool previousSessionCrashed { false }; | |
| 797 | + if (!inTestMode) { | |
| 798 | + previousSessionCrashed = CrashHandler::checkForResetSettings(runningMarkerExisted, suppressPrompt); | |
| 799 | + } | |
| 800 | + | |
| 781 | 801 | // get dir to use for cache |
| 782 | 802 | static const auto CACHE_SWITCH = "--cache"; |
| 783 | 803 | QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH); |
| @@ -996,13 +1016,30 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 212 unmodified lines | ||
| 996 | 1016 | setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning())); |
| 997 | 1017 | setProperty(hifi::properties::CRASHED, _previousSessionCrashed); |
| 998 | 1018 | { |
| 999 | − const QString TEST_SCRIPT = "--testScript"; | |
| 1000 | 1019 | const QStringList args = arguments(); |
| 1020 | + | |
| 1001 | 1021 | for (int i = 0; i < args.size() - 1; ++i) { |
| 1002 | − if (args.at(i) == TEST_SCRIPT) { | |
| 1022 | + if (args.at(i) == TEST_SCRIPT_COMMAND && (i + 1) < args.size()) { | |
| 1003 | 1023 | QString testScriptPath = args.at(i + 1); |
| 1004 | − if (QFileInfo(testScriptPath).exists()) { | |
| 1024 | + | |
| 1025 | + // If the URL scheme is http(s) or ftp, then use as is, else - treat it as a local file | |
| 1026 | + // This is done so as not break previous command line scripts | |
| 1027 | + if (testScriptPath.left(URL_SCHEME_HTTP.length()) == URL_SCHEME_HTTP || testScriptPath.left(URL_SCHEME_FTP.length()) == URL_SCHEME_FTP) { | |
| 1028 | + setProperty(hifi::properties::TEST, QUrl::fromUserInput(testScriptPath)); | |
| 1029 | + } else if (QFileInfo(testScriptPath).exists()) { | |
| 1005 | 1030 | setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath)); |
| 1031 | + } | |
| 1032 | + | |
| 1033 | + // quite when finished parameter must directly follow the test script | |
| 1034 | + if ((i + 2) < args.size() && args.at(i + 2) == TEST_QUIT_WHEN_FINISHED_OPTION) { | |
| 1035 | + quitWhenFinished = true; | |
| 1036 | + } | |
| 1037 | + } else if (args.at(i) == TEST_SNAPSHOT_LOCATION_COMMAND) { | |
| 1038 | + // Set test snapshot location only if it is a writeable directory | |
| 1039 | + QString pathname(args.at(i + 1)); | |
| 1040 | + QFileInfo fileInfo(pathname); | |
| 1041 | + if (fileInfo.isDir() && fileInfo.isWritable()) { | |
| 1042 | + testSnapshotLocation = pathname; | |
| 1006 | 1043 | } |
| 1007 | 1044 | } |
| 1008 | 1045 | } |
| @@ -2135,7 +2172,17 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1126 unmodified lines | ||
| 2135 | 2172 | if (testProperty.isValid()) { |
| 2136 | 2173 | auto scriptEngines = DependencyManager::get<ScriptEngines>(); |
| 2137 | 2174 | const auto testScript = property(hifi::properties::TEST).toUrl(); |
| 2138 | − scriptEngines->loadScript(testScript, false); | |
| 2175 | + | |
| 2176 | + // Set last parameter to exit interface when the test script finishes, if so requested | |
| 2177 | + scriptEngines->loadScript(testScript, false, false, false, false, quitWhenFinished); | |
| 2178 | + | |
| 2179 | + // This is done so we don't get a "connection time-out" message when we haven't passed in a URL. | |
| 2180 | + if (arguments().contains("--url")) { | |
| 2181 | + auto reply = SandboxUtils::getStatus(); | |
| 2182 | + connect(reply, &QNetworkReply::finished, this, [=] { | |
| 2183 | + handleSandboxStatus(reply); | |
| 2184 | + }); | |
| 2185 | + } | |
| 2139 | 2186 | } else { |
| 2140 | 2187 | PROFILE_RANGE(render, "GetSandboxStatus"); |
| 2141 | 2188 | auto reply = SandboxUtils::getStatus(); |
| @@ -7465,7 +7512,7 @@ void Application::loadAvatarBrowser() const { · 5323 unmodified lines | ||
| 7465 | 7512 | void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) { |
| 7466 | 7513 | postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] { |
| 7467 | 7514 | // Get a screenshot and save it |
| 7468 | − QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename); | |
| 7515 | + QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio), filename, testSnapshotLocation); | |
| 7469 | 7516 | // If we're not doing an animated snapshot as well... |
| 7470 | 7517 | if (!includeAnimated) { |
| 7471 | 7518 | // Tell the dependency manager that the capture of the still snapshot has taken place. |
| @@ -7479,7 +7526,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa · 7 unmodified lines | ||
| 7479 | 7526 | |
| 7480 | 7527 | void Application::takeSecondaryCameraSnapshot(const QString& filename) { |
| 7481 | 7528 | postLambdaEvent([filename, this] { |
| 7482 | − QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename); | |
| 7529 | + QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testSnapshotLocation); | |
| 7483 | 7530 | emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true); |
| 7484 | 7531 | }); |
| 7485 | 7532 | } |