diff --git a/app/common/filefunctions.cpp b/app/common/filefunctions.cpp index 6f6fbc775..772752d3a 100644 --- a/app/common/filefunctions.cpp +++ b/app/common/filefunctions.cpp @@ -168,7 +168,8 @@ bool FileFunctions::DirectoryIsValid(const QDir &d, bool try_to_create_if_not_exists) { // Return whether the directory exists, or whether it could be created if it doesn't - return d.exists() || d.mkpath(QStringLiteral(".")); + return d.exists() || + (try_to_create_if_not_exists && d.mkpath(QStringLiteral("."))); } QString FileFunctions::EnsureFilenameExtension(QString fn, diff --git a/tests/gtest/dialog_editing_test.cpp b/tests/gtest/dialog_editing_test.cpp index 6f3523b4f..81eb67bf0 100644 --- a/tests/gtest/dialog_editing_test.cpp +++ b/tests/gtest/dialog_editing_test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -803,8 +804,13 @@ TEST(DialogProjectProperties, OcioValidationTogglesOnInvalidFilename) auto *ocio_edit = dialog.findChild(); ASSERT_NE(ocio_edit, nullptr); - // A bad config path flags the line edit as invalid (red text) - ocio_edit->setText(QStringLiteral("/definitely/not/a/config.ocio")); + // A bad config path flags the line edit as invalid (red text). Use a + // nonexistent file inside a temp dir: a fixed absolute path is not + // guaranteed to stay nonexistent on every platform (e.g. an earlier test + // may have created parts of it on a writable drive). + QTemporaryDir dir; + ASSERT_TRUE(dir.isValid()); + ocio_edit->setText(dir.filePath(QStringLiteral("nonexistent.ocio"))); EXPECT_TRUE(ocio_edit->styleSheet().contains(QStringLiteral("red"))); // Restoring an empty (default) filename clears the error again diff --git a/tests/gtest/task_project_test.cpp b/tests/gtest/task_project_test.cpp index d0f9cd830..8d4197e8b 100644 --- a/tests/gtest/task_project_test.cpp +++ b/tests/gtest/task_project_test.cpp @@ -312,7 +312,9 @@ TEST_F(TaskProjectLoadTest, LoadingValidProjectSucceeds) olive::Project *loaded = task.GetLoadedProject(); ASSERT_NE(loaded, nullptr); - EXPECT_EQ(loaded->filename(), path); + // Project::set_filename() stores native separators on Windows + EXPECT_EQ(QDir::fromNativeSeparators(loaded->filename()), + QDir::fromNativeSeparators(path)); EXPECT_FALSE(loaded->nodes().isEmpty()); delete loaded;