AutomationPresetRef FAutomationTestPresetManager::AddNewPreset( const FText& PresetName, const TArray<FString>& SelectedTests ) { AutomationPresetRef NewPreset = AddNewPreset(); NewPreset->SetPresetName(PresetName); NewPreset->SetEnabledTests(SelectedTests); SavePreset(NewPreset); return NewPreset; }
void FAutomationTestPresetManager::SavePreset( const AutomationPresetRef Preset ) { TSharedPtr<FJsonObject> PresetJson = FJsonObjectConverter::UStructToJsonObject(Preset.Get()); if ( PresetJson.IsValid() ) { FString PresetFileName = GetPresetFolder() / Preset->GetID().ToString() + TEXT(".json"); FArchive* PresetFileWriter = IFileManager::Get().CreateFileWriter(*PresetFileName); if ( PresetFileWriter != nullptr ) { TSharedRef<TJsonWriter<> > JsonWriter = TJsonWriterFactory<>::Create(PresetFileWriter, 0); FJsonSerializer::Serialize(PresetJson.ToSharedRef(), JsonWriter); delete PresetFileWriter; } } }
void FAutomationTestPresetManager::RemovePreset( const AutomationPresetRef Preset ) { if (Presets.Remove(Preset) > 0) { // Find the name of the preset on disk FString PresetFileName = GetPresetFolder() / Preset->GetID().ToString() + TEXT(".uap"); // delete the preset on disk IFileManager::Get().Delete(*PresetFileName); } }
void FAutomationTestPresetManager::SavePreset( const AutomationPresetRef Preset ) { FString PresetFileName = GetPresetFolder() / Preset->GetID().ToString() + TEXT(".uap"); FArchive* PresetFileWriter = IFileManager::Get().CreateFileWriter(*PresetFileName); if (PresetFileWriter != nullptr) { SavePreset(Preset, *PresetFileWriter); delete PresetFileWriter; } }
AutomationPresetPtr FAutomationTestPresetManager::AddNewPreset( const FText& PresetName, const TArray<FString>& SelectedTests ) { if ( PresetName.IsEmpty() ) { return nullptr; } const FName NewNameSlug = MakeObjectNameFromDisplayLabel(PresetName.ToString(), NAME_None); if ( !Presets.FindByPredicate([&NewNameSlug] (const AutomationPresetPtr& Preset) { return Preset.IsValid() && Preset->GetID() == NewNameSlug; }) ) { AutomationPresetRef NewPreset = MakeShareable(new FAutomationTestPreset(NewNameSlug)); NewPreset->SetName(PresetName); NewPreset->SetEnabledTests(SelectedTests); Presets.Add(NewPreset); SavePreset(NewPreset); return NewPreset; } return nullptr; }
void FAutomationTestPresetManager::SavePreset( const AutomationPresetRef Preset, FArchive& Archive ) { Preset->Serialize(Archive); }