Skip to content

Commit 55c371f

Browse files
committed
fix get/set fields unit tests
1 parent f7767a1 commit 55c371f

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ public static string[] GetRelativeSavePaths(List<string> exportSavePaths){
960960
// that affects the dropdown layout.
961961
string forwardslash = "\u2044";
962962
for (int i = 0; i < relSavePaths.Length; i++) {
963-
relSavePaths [i] = string.Format("Assets {0} {1}", forwardslash, exportSavePaths[i] == "."? "" : NormalizePath(exportSavePaths [i], isRelative: true).Replace("/", "\\"));
963+
relSavePaths [i] = string.Format("Assets {0} {1}", forwardslash, exportSavePaths[i] == "."? "" : NormalizePath(exportSavePaths [i], isRelative: true).Replace("/", forwardslash));
964964
}
965965
return relSavePaths;
966966
}
@@ -989,6 +989,7 @@ public static string[] GetRelativePrefabSavePaths(){
989989
/// <param name="savePath">Save path.</param>
990990
/// <param name="exportSavePaths">Export save paths.</param>
991991
public static void AddSavePath(string savePath, ref List<string> exportSavePaths){
992+
savePath = NormalizePath (savePath, isRelative: true);
992993
if (exportSavePaths.Contains (savePath)) {
993994
// move to first place if it isn't already
994995
if (exportSavePaths [0] == savePath) {

Assets/FbxExporters/Editor/UnitTests/FbxExportSettingsTest.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,6 @@ public void TestGetRelativePath ()
163163
[Test]
164164
public void TestGetSetFields ()
165165
{
166-
/* var defaultRelativePath = ExportSettings.GetRelativeSavePath ();
167-
Assert.AreEqual (ExportSettings.kDefaultSavePath, defaultRelativePath);
168-
169166
// the path to Assets but with platform-dependent separators
170167
var appDataPath = Application.dataPath.Replace (Path.AltDirectorySeparatorChar,
171168
Path.DirectorySeparatorChar);
@@ -174,15 +171,28 @@ public void TestGetSetFields ()
174171
var dataPath = Path.GetFullPath (Path.Combine (appDataPath, ExportSettings.kDefaultSavePath));
175172
Assert.AreEqual (dataPath, defaultAbsolutePath);
176173

174+
var prefabDefaultAbsPath = ExportSettings.GetPrefabAbsoluteSavePath ();
175+
Assert.AreEqual (dataPath, prefabDefaultAbsPath);
176+
177177
// set; check that the saved value is platform-independent,
178178
// that the relative path uses / like in unity,
179179
// and that the absolute path is platform-specific
180-
ExportSettings.SetRelativeSavePath ("/a\\b/c/\\");
181-
var convertToModelSavePath = s_SavePathField.GetValue (ExportSettings.instance);
182-
Assert.AreEqual ("a/b/c", convertToModelSavePath);
183-
Assert.AreEqual ("a/b/c", ExportSettings.GetRelativeSavePath ());
180+
ExportSettings.AddFbxSavePath ("/a\\b/c/\\");
181+
ExportSettings.AddPrefabSavePath ("/a\\b/c/\\");
182+
183+
Assert.That (ExportSettings.GetRelativeFbxSavePaths () [0], Is.EqualTo ("Assets \u2044 a⁄b⁄c"));
184+
Assert.That (ExportSettings.GetRelativePrefabSavePaths () [0], Is.EqualTo ("Assets \u2044 a⁄b⁄c"));
185+
184186
var platformPath = Path.Combine ("a", Path.Combine ("b", "c"));
185-
Assert.AreEqual (Path.Combine (appDataPath, platformPath), ExportSettings.GetFbxAbsoluteSavePath ());*/
187+
Assert.AreEqual (Path.Combine (appDataPath, platformPath), ExportSettings.GetFbxAbsoluteSavePath ());
188+
Assert.AreEqual (Path.Combine (appDataPath, platformPath), ExportSettings.GetPrefabAbsoluteSavePath ());
189+
190+
ExportSettings.AddFbxSavePath ("test");
191+
ExportSettings.AddPrefabSavePath ("test2");
192+
193+
// 3 including the default path
194+
Assert.That (ExportSettings.GetRelativeFbxSavePaths ().Length, Is.EqualTo (3));
195+
Assert.That (ExportSettings.GetRelativePrefabSavePaths ().Length, Is.EqualTo (3));
186196
}
187197

188198
[Test]

0 commit comments

Comments
 (0)