Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/model_editor/test/Utilities_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../Utilities.hpp"

#include <clocale>
#include <QUrl>

using openstudio::toPath;
using openstudio::toQString;
Expand Down Expand Up @@ -113,3 +114,35 @@ TEST_F(ModelEditorFixture, Path_Conversions) {
EXPECT_EQ(t, std::string(toQString(toString(p)).toUtf8()));
EXPECT_EQ(t, toString(toPath(toQString(toString(p)))));
}

TEST_F(ModelEditorFixture, MorePath_Conversions) {
struct PathTestCase
{
std::string inputPath;
QString expectedPath;
QString expectedUrl;
};

std::vector<PathTestCase> testCases = {
{"C:\\Users\\Test\\eplustbl.html", "C:/Users/Test/eplustbl.html", "file:///C:/Users/Test/eplustbl.html"},
{"C:/Users/Test/eplustbl.html", "C:/Users/Test/eplustbl.html", "file:///C:/Users/Test/eplustbl.html"},
{"C:\\Users/Test/eplustbl.html", "C:/Users/Test/eplustbl.html", "file:///C:/Users/Test/eplustbl.html"},
{"C:\\Users\\Test# ^\\eplustbl.html", "C:/Users/Test# ^/eplustbl.html", "file:///C:/Users/Test%23%20%5E/eplustbl.html"},
{"/home/Test/eplustbl.html", "/home/Test/eplustbl.html", "file:///home/Test/eplustbl.html"},
{"/home/Test# ^/eplustbl.html", "/home/Test# ^/eplustbl.html", "file:///home/Test%23%20%5E/eplustbl.html"},
};

// double check the conversions in openstudio_lib/ResultsTabView.cpp
for (const auto& testCase : testCases) {
openstudio::path osPath = toPath(testCase.inputPath);
QString qPath = toQString(osPath);
EXPECT_EQ(qPath, testCase.expectedPath);
QUrl url = QUrl::fromLocalFile(qPath);
EXPECT_EQ(url.toString(QUrl::FullyEncoded), testCase.expectedUrl);

std::cout << "Input: " << testCase.inputPath << ", "
<< "OS Path: " << osPath << ", "
<< "QPath: " << qPath.toStdString() << ", "
<< "Url: " << url.toString().toStdString() << std::endl;
}
}
3 changes: 1 addition & 2 deletions src/openstudio_lib/ResultsTabView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ void ResultsView::populateComboBox(const std::vector<openstudio::path>& reports)
QString fullPathString = toQString(report);

QFile file(fullPathString);
fullPathString.prepend("file:///");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for that


if (openstudio::toString(report.filename()) == "eplustbl.html" || openstudio::toString(report.filename()) == "eplustbl.htm") {

Expand Down Expand Up @@ -360,7 +359,7 @@ void ResultsView::comboBoxChanged(int index) {

m_progressBar->setError(false);

QUrl url(filename);
QUrl url = QUrl::fromLocalFile(filename);
m_view->load(url);
}

Expand Down