Skip to content

Commit 34c3902

Browse files
authored
Merge pull request #245 from Unity-Technologies/Uni-32201_unitTest_for_GetDCCOptions()
Uni-32201 unit test for GetDCCOptions()
2 parents 5f6680f + 7821dac commit 34c3902

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,11 @@ public void SetDCCOptionNames(List<string> newList)
373373
dccOptionNames = newList;
374374
}
375375

376+
public void SetDCCOptionPaths(List<string> newList)
377+
{
378+
dccOptionPaths = newList;
379+
}
380+
376381
public void ClearDCCOptionNames()
377382
{
378383
dccOptionNames.Clear();

Assets/FbxExporters/Editor/UnitTests/FbxExportSettingsTest.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,5 +213,56 @@ public void TestFindPreferredProgram()
213213
Assert.AreEqual(preferred, -1);
214214
}
215215

216+
[Test]
217+
public void TestGetDCCOptions()
218+
{
219+
//Our.exe file
220+
string executableName = "/maya.exe";
221+
222+
//Our folder names
223+
string firstSubFolder = "/maya 3000";
224+
string secondSubFolder = "/maya 3001";
225+
226+
//Make a folder structure to mimic an 'autodesk' type hierarchy
227+
string testFolder = Path.GetRandomFileName();
228+
var firstPath = Directory.CreateDirectory(testFolder + firstSubFolder);
229+
var secondPath = Directory.CreateDirectory(testFolder + secondSubFolder);
230+
231+
try
232+
{
233+
//Create any files we need within the folders
234+
FileInfo firstExe = new FileInfo(firstPath.FullName + executableName);
235+
using (FileStream s = firstExe.Create()) { }
236+
237+
//Add the paths which will be copied to DCCOptionPaths
238+
List<string> testPathList = new List<string>();
239+
testPathList.Add(firstPath.FullName + executableName); //this path is valid!
240+
testPathList.Add(secondPath.FullName + executableName);
241+
testPathList.Add(null);
242+
testPathList.Add("cookies/milk/foo/bar");
243+
244+
//Add the names which will be copied to DCCOptionNames
245+
List<string> testNameList = new List<string>();
246+
testNameList.Add(firstSubFolder.TrimStart('/'));
247+
testNameList.Add(secondSubFolder.TrimStart('/'));
248+
testNameList.Add(null);
249+
testNameList.Add("Cookies & Milk");
250+
251+
ExportSettings.instance.SetDCCOptionNames(testNameList);
252+
ExportSettings.instance.SetDCCOptionPaths(testPathList);
253+
254+
GUIContent[] options = ExportSettings.GetDCCOptions();
255+
256+
//We expect 1, as the others are purposefully bogus
257+
Assert.AreEqual(options.Length, 1);
258+
259+
Assert.IsTrue(options[0].text == "maya 3000");
260+
}
261+
finally
262+
{
263+
Directory.Delete(testFolder, true);
264+
}
265+
}
266+
216267
}
217268
}

0 commit comments

Comments
 (0)