History

Merge pull request #13046 from NissimHadar/commandLineParametersForAutotester

Command line parameters for autotester

Sam Gateau committed 8 years ago

Commit 17350a72 parents a42491d 175fa9114 files · +255 −150Browse files

Showing the changes to interface/src/Application.cpp (1 of 14 files). Show all

Unified · Split

interface/src/Application.cpp+54−7
@@ -743,6 +743,11 @@ extern DisplayPluginList getDisplayPlugins(); · 742 unmodified lines
743extern InputPluginList getInputPlugins();743extern InputPluginList getInputPlugins();
744extern void saveInputPluginSettings(const InputPluginList& plugins);744extern void saveInputPluginSettings(const InputPluginList& plugins);
745 745
746// Parameters used for running tests from teh command line
747const QString TEST_SCRIPT_COMMAND { "--testScript" };
748const QString TEST_QUIT_WHEN_FINISHED_OPTION { "quitWhenFinished" };
749const QString TEST_SNAPSHOT_LOCATION_COMMAND { "--testSnapshotLocation" };
750
746bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {751bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
747 const char** constArgv = const_cast<const char**>(argv);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 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";783 static const auto SUPPRESS_SETTINGS_RESET = "--suppress-settings-reset";
779 bool suppressPrompt = cmdOptionExists(argc, const_cast<const char**>(argv), SUPPRESS_SETTINGS_RESET);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 // get dir to use for cache801 // get dir to use for cache
782 static const auto CACHE_SWITCH = "--cache";802 static const auto CACHE_SWITCH = "--cache";
783 QString cacheDir = getCmdOption(argc, const_cast<const char**>(argv), CACHE_SWITCH);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 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));1016 setProperty(hifi::properties::STEAM, (steamClient && steamClient->isRunning()));
997 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);1017 setProperty(hifi::properties::CRASHED, _previousSessionCrashed);
998 {1018 {
999 const QString TEST_SCRIPT = "--testScript";
1000 const QStringList args = arguments();1019 const QStringList args = arguments();
1020
1001 for (int i = 0; i < args.size() - 1; ++i) {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 QString testScriptPath = args.at(i + 1);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 setProperty(hifi::properties::TEST, QUrl::fromLocalFile(testScriptPath));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 if (testProperty.isValid()) {2172 if (testProperty.isValid()) {
2136 auto scriptEngines = DependencyManager::get<ScriptEngines>();2173 auto scriptEngines = DependencyManager::get<ScriptEngines>();
2137 const auto testScript = property(hifi::properties::TEST).toUrl();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 } else {2186 } else {
2140 PROFILE_RANGE(render, "GetSandboxStatus");2187 PROFILE_RANGE(render, "GetSandboxStatus");
2141 auto reply = SandboxUtils::getStatus();2188 auto reply = SandboxUtils::getStatus();
@@ -7465,7 +7512,7 @@ void Application::loadAvatarBrowser() const { · 5323 unmodified lines
7465void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {7512void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio, const QString& filename) {
7466 postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {7513 postLambdaEvent([notify, includeAnimated, aspectRatio, filename, this] {
7467 // Get a screenshot and save it7514 // 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 // If we're not doing an animated snapshot as well...7516 // If we're not doing an animated snapshot as well...
7470 if (!includeAnimated) {7517 if (!includeAnimated) {
7471 // Tell the dependency manager that the capture of the still snapshot has taken place.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
7480void Application::takeSecondaryCameraSnapshot(const QString& filename) {7527void Application::takeSecondaryCameraSnapshot(const QString& filename) {
7481 postLambdaEvent([filename, this] {7528 postLambdaEvent([filename, this] {
7482 QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename);7529 QString snapshotPath = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getSecondaryCameraScreenshot(), filename, testSnapshotLocation);
7483 emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);7530 emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(snapshotPath, true);
7484 });7531 });
7485}7532}