public void DoesContainVariable_Returns_False() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.False(profileGroupType.ContainsVariable(buildPath)); }
//UI magic to group the path pairs from profile variables List <ProfileGroupType> CreateGroupTypes(AddressableAssetProfileSettings.BuildProfile buildProfile) { Dictionary <string, ProfileGroupType> groups = new Dictionary <string, ProfileGroupType>(); foreach (var profileEntry in settings.profileSettings.profileEntryNames) { string[] parts = profileEntry.ProfileName.Split(k_PrefixSeparator); if (parts.Length > 1) { string prefix = String.Join(k_PrefixSeparator.ToString(), parts, 0, parts.Length - 1); string suffix = parts[parts.Length - 1]; string profileEntryValue = buildProfile.GetValueById(profileEntry.Id); ProfileGroupType group; groups.TryGetValue(prefix, out group); if (group == null) { group = new ProfileGroupType(prefix); } ProfileGroupType.GroupTypeVariable variable = new ProfileGroupType.GroupTypeVariable(suffix, profileEntryValue); group.AddVariable(variable); groups[prefix] = group; } } List <ProfileGroupType> groupList = new List <ProfileGroupType>(); groupList.AddRange(groups.Values.Where(group => group.IsValidGroupType())); return(groupList); }
public void RemoveNonExistentVariable_Returns_ExpectedAction() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.RemoveVariable(buildPath); LogAssert.Expect(LogType.Error, "prefix.BuildPath does not exist."); }
public void GetName_Returns_ExpectedVariableName() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); Assert.AreEqual("prefix.BuildPath", profileGroupType.GetName(buildPath)); }
public void GetPathValuesBySuffix_Returns_ExpectedPathValues() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); Assert.AreEqual("Test Build Path", profileGroupType.GetVariableBySuffix(buildPath.Suffix).Value); }
public void AddDuplicateVariableToGroupType_FailsToAddVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.IsTrue(profileGroupType.AddVariable(buildPath)); LogAssert.Expect(LogType.Error, "prefix.BuildPath already exists."); Assert.IsFalse(profileGroupType.AddVariable(buildPath)); }
public void GetName_Returns_ExpectedVariableName() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); bool gtAdded = profileGroupType.AddVariable(buildPath); Assert.IsTrue(gtAdded, $"Failed to add groupType {gtAdded}"); Assert.AreEqual("prefix.BuildPath", profileGroupType.GetName(buildPath)); }
public void GetPathValuesBySuffix_Returns_ExpectedPathValues() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); bool variableAdded = profileGroupType.AddVariable(buildPath); Assert.IsTrue(variableAdded, "Failed to add GroupType variable"); Assert.AreEqual("Test Build Path", profileGroupType.GetVariableBySuffix(buildPath.Suffix).Value); }
public void RemoveVariable_Returns_ExpectedAction() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); profileGroupType.RemoveVariable(buildPath); Assert.True(profileGroupType.Variables.Count == 0); }
public void AddDuplicateVariableToGroupType_Returns_NullVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.NotNull(profileGroupType.AddVariable(buildPath)); LogAssert.Expect(LogType.Error, "prefix.BuildPath already exists."); Assert.Null(profileGroupType.AddVariable(buildPath)); }
public void AddVariableToGroupType_AddsVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.IsTrue(profileGroupType.AddVariable(buildPath)); Assert.IsTrue(profileGroupType.AddVariable(loadPath)); Assert.True(profileGroupType.Variables.Count == 2); }
public void AddVariableToGroupType_Returns_ExpectedNotNullVariable() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); Assert.NotNull(profileGroupType.AddVariable(buildPath)); Assert.NotNull(profileGroupType.AddVariable(loadPath)); Assert.True(profileGroupType.Variables.Count == 2); }
public void CreateValidProfileGroupType_Returns_ValidProfileGroupType() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); profileGroupType.AddVariable(buildPath); profileGroupType.AddVariable(loadPath); Assert.True(profileGroupType.IsValidGroupType()); }
public void CreateValidProfileGroupType_Returns_ValidProfileGroupType() { ProfileGroupType.GroupTypeVariable buildPath = new ProfileGroupType.GroupTypeVariable("BuildPath", "Test Build Path"); ProfileGroupType.GroupTypeVariable loadPath = new ProfileGroupType.GroupTypeVariable("LoadPath", "Test Load Path"); ProfileGroupType profileGroupType = new ProfileGroupType("prefix"); bool aAdded = profileGroupType.AddVariable(buildPath); bool bAdded = profileGroupType.AddVariable(loadPath); Assert.IsTrue(aAdded && bAdded, "Failed to Add variables"); Assert.True(profileGroupType.IsValidGroupType()); }
void DrawRemoteCatalogPaths() { ProfileValueReference BuildPath = m_AasTarget.RemoteCatalogBuildPath; ProfileValueReference LoadPath = m_AasTarget.RemoteCatalogLoadPath; AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings; if (settings == null) { return; } List <ProfileGroupType> groupTypes = ProfileGroupType.CreateGroupTypes(settings.profileSettings.GetProfile(settings.activeProfileId)); List <string> options = groupTypes.Select(group => group.GroupTypePrefix).ToList(); //set selected to custom options.Add(AddressableAssetProfileSettings.customEntryString); int?selected = options.Count - 1; HashSet <string> vars = settings.profileSettings.GetAllVariableIds(); if (vars.Contains(BuildPath.Id) && vars.Contains(LoadPath.Id) && !m_UseCustomPaths) { for (int i = 0; i < groupTypes.Count; i++) { ProfileGroupType.GroupTypeVariable buildPathVar = groupTypes[i].GetVariableBySuffix("BuildPath"); ProfileGroupType.GroupTypeVariable loadPathVar = groupTypes[i].GetVariableBySuffix("LoadPath"); if (BuildPath.GetName(settings) == groupTypes[i].GetName(buildPathVar) && LoadPath.GetName(settings) == groupTypes[i].GetName(loadPathVar)) { selected = i; break; } } } if (selected.HasValue && selected != options.Count - 1) { m_UseCustomPaths = false; } else { m_UseCustomPaths = true; } EditorGUI.BeginChangeCheck(); var newIndex = EditorGUILayout.Popup("Build & Load Paths", selected.HasValue ? selected.Value : options.Count - 1, options.ToArray()); if (EditorGUI.EndChangeCheck() && newIndex != selected) { if (options[newIndex] != AddressableAssetProfileSettings.customEntryString) { Undo.RecordObject(serializedObject.targetObject, serializedObject.targetObject.name + "Path Pair"); BuildPath.SetVariableByName(settings, groupTypes[newIndex].GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + "BuildPath"); LoadPath.SetVariableByName(settings, groupTypes[newIndex].GroupTypePrefix + ProfileGroupType.k_PrefixSeparator + "LoadPath"); m_UseCustomPaths = false; } else { Undo.RecordObject(serializedObject.targetObject, serializedObject.targetObject.name + "Path Pair"); m_UseCustomPaths = true; } EditorUtility.SetDirty(this); } if (m_UseCustomPaths) { EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogBuildPath"), m_RemoteCatBuildPath); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_RemoteCatalogLoadPath"), m_RemoteCatLoadPath); } EditorGUI.indentLevel++; m_ShowPaths = EditorGUILayout.Foldout(m_ShowPaths, "Path Preview", true); if (m_ShowPaths) { EditorStyles.helpBox.fontSize = 12; var baseBuildPathValue = settings.profileSettings.GetValueById(settings.activeProfileId, BuildPath.Id); var baseLoadPathValue = settings.profileSettings.GetValueById(settings.activeProfileId, LoadPath.Id); EditorGUILayout.HelpBox(String.Format("Build Path: {0}", settings.profileSettings.EvaluateString(settings.activeProfileId, baseBuildPathValue)), MessageType.None); EditorGUILayout.HelpBox(String.Format("Load Path: {0}", settings.profileSettings.EvaluateString(settings.activeProfileId, baseLoadPathValue)), MessageType.None); } EditorGUI.indentLevel--; }