Skip to content

Commit

Permalink
vkconfig3: Add mode unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-lunarg committed Dec 23, 2024
1 parent 22c803a commit d2fcb26
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
6 changes: 5 additions & 1 deletion vkconfig_core/executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ bool Executable::HasActiveOptions() const {

Path Executable::GetLocalLayersSettingsPath() const {
assert(this->GetActiveOptions() != nullptr);
return this->GetActiveOptions()->working_folder + "/vk_layer_settings.txt";
if (this->GetActiveOptions()->working_folder.Empty()) {
return this->path.AbsoluteDir() + "/vk_layer_settings.txt";
} else {
return this->GetActiveOptions()->working_folder + "/vk_layer_settings.txt";
}
}

void Executable::AddOptions(const ExecutableOptions& options) {
Expand Down
10 changes: 10 additions & 0 deletions vkconfig_core/test/test_executable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,21 @@ TEST(test_executable, add) {

ExecutableOptions executable_options;
executable_options.label = "Pouet Options";
executable_options.working_folder =
"."; // set it otherwise GetLocalLayersSettingsPath will use the executable absolute directory
executable.AddOptions(executable_options);
EXPECT_EQ(2, executable.GetOptions().size());

EXPECT_STREQ("Default Options", executable.GetActiveOptionsName().c_str());

executable.SetActiveOptions("Pouet Options");
EXPECT_STREQ("Pouet Options", executable.GetActiveOptionsName().c_str());

Path path = executable.GetLocalLayersSettingsPath();
EXPECT_STREQ(path.AbsolutePath().c_str(), Path("./vk_layer_settings.txt").AbsolutePath().c_str());

executable.GetActiveOptions()->working_folder.Clear();
Path path2 = executable.GetLocalLayersSettingsPath();
// When working_folder is not set, use the executable absolute directory
EXPECT_STREQ(path.AbsoluteDir().c_str(), executable.path.AbsoluteDir().c_str());
}
6 changes: 3 additions & 3 deletions vkconfig_core/test/test_layer_preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ TEST(test_layer_preset, has_preset) {
SettingDataSetConst preset_settings;
SettingDataSet layer_settings;

SettingMetaString* metaA = InstantiateString(layer, "KeyA");
SettingMetaString* metaB = InstantiateString(layer, "KeyB");
SettingMetaString* metaC = InstantiateString(layer, "KeyC");
SettingMetaString* metaA = ::InstantiateString(layer, "KeyA");
SettingMetaString* metaB = ::InstantiateString(layer, "KeyB");
SettingMetaString* metaC = ::InstantiateString(layer, "KeyC");

EXPECT_EQ(false, ::HasPreset(layer_settings, preset_settings));

Expand Down
10 changes: 1 addition & 9 deletions vkconfig_core/test/test_parameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,7 @@ TEST(test_parameter, order_parameter_manual_partial) {

parameters[0].type = LAYER_TYPE_IMPLICIT;
parameters[1].builtin = LAYER_BUILTIN_UNORDERED;
/*
for (std::size_t i = 0, n = parameters.size(); i < n; ++i) {
if (i == 7) {
continue;
}
parameters[i].overridden_rank = static_cast<int>(i);
}
*/

::OrderParameter(parameters, layers);

EXPECT_STREQ(parameters[0].key.c_str(), "VK_LAYER_KHRONOS_missing");
Expand Down
1 change: 0 additions & 1 deletion vkconfig_gui/settings_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ void SettingsTreeManager::BuildTreeItem(QTreeWidgetItem *parent, const SettingMe
const SettingMetaGroup &meta = static_cast<const SettingMetaGroup &>(meta_object);

WidgetSettingGroup *widget = new WidgetSettingGroup(this->ui->configurations_settings, item, meta, parameter->settings);
this->connect(widget, SIGNAL(itemChanged()), this, SLOT(OnSettingChanged()));
} break;
case SETTING_BOOL:
case SETTING_BOOL_NUMERIC_DEPRECATED: {
Expand Down

0 comments on commit d2fcb26

Please sign in to comment.