| 2133 | |
| 2134 | |
| 2135 | int MainWindow::autotesterOpen(const QString& jsonPath) { |
| 2136 | if (jsonPath.length() == 0) { |
| 2137 | QMessageBox::warning(this, MSG_ERROR, tr("Please choose a json file or type its path.")); |
| 2138 | return 1; |
| 2139 | } |
| 2140 | std::string jsonContents; |
| 2141 | std::ifstream ifs(jsonPath.toStdString()); |
| 2142 | |
| 2143 | if (ifs.good()) { |
| 2144 | const std::string absJsonDirPath = QDir::toNativeSeparators(QFileInfo(jsonPath).absoluteDir().path()).toStdString(); |
| 2145 | // TODO: fix me (don't use chdir, or at the very least, go back to the previous path afterwards) |
| 2146 | if (chdir(absJsonDirPath.c_str()) != 0) { |
| 2147 | QMessageBox::warning(this, MSG_ERROR, tr("Couldn't go to where the JSON file is.")); |
| 2148 | return 0; |
| 2149 | } |
| 2150 | std::getline(ifs, jsonContents, '\0'); |
| 2151 | if (!ifs.eof()) { |
| 2152 | QMessageBox::critical(this, MSG_ERROR, tr("Couldn't read JSON file.")); |
| 2153 | return 0; |
| 2154 | } |
| 2155 | } else { |
| 2156 | QMessageBox::critical(this, MSG_ERROR, tr("Unable to open the file.")); |
| 2157 | return 1; |
| 2158 | } |
| 2159 | |
| 2160 | autotester::ignoreROMfield = true; |
| 2161 | autotester::debugMode = false; |
| 2162 | if (autotester::loadJSONConfig(jsonContents)) |
| 2163 | { |
| 2164 | ui->JSONconfigPath->setText(jsonPath); |
| 2165 | ui->buttonLaunchTest->setEnabled(true); |
| 2166 | std::cout << jsonPath.toStdString() << " loaded and verified. " << autotester::config.hashes.size() << " unique tests found." << std::endl; |
| 2167 | } else { |
| 2168 | QMessageBox::critical(this, MSG_ERROR, tr("See the test config file format and make sure values are correct and referenced files are there.")); |
| 2169 | return 1; |
| 2170 | } |
| 2171 | return 0; |
| 2172 | } |
| 2173 | |
| 2174 | void MainWindow::autotesterLoad() { |
| 2175 | QFileDialog dialog(this); |
nothing calls this directly
no test coverage detected