Skip to content

Commit 56d6083

Browse files
committed
updated integration unit tests
+ fixed missing null or empty string check in "FolderAlreadyUnzippedAtPath"
1 parent eb34c24 commit 56d6083

File tree

2 files changed

+86
-19
lines changed

2 files changed

+86
-19
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,9 @@ public override int InstallIntegration (string mayaExe)
503503
/// <param name="path">Path.</param>
504504
public override bool FolderAlreadyUnzippedAtPath(string path)
505505
{
506+
if (string.IsNullOrEmpty (path)) {
507+
return false;
508+
}
506509
return System.IO.File.Exists (System.IO.Path.Combine (path, MODULE_TEMPLATE_PATH));
507510
}
508511
}
@@ -726,6 +729,9 @@ public override int InstallIntegration(string maxExe){
726729
/// <param name="path">Path.</param>
727730
public override bool FolderAlreadyUnzippedAtPath(string path)
728731
{
732+
if (string.IsNullOrEmpty (path)) {
733+
return false;
734+
}
729735
return System.IO.File.Exists (System.IO.Path.Combine (path, MaxIntegration.PluginPath));
730736
}
731737
}

Assets/FbxExporters/Editor/UnitTests/IntegrationsTest.cs

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,88 @@ void LogNonEmptyString(string name, string str) {
2525
Assert.IsFalse(string.IsNullOrEmpty(str));
2626
}
2727

28+
/// <summary>
29+
/// Checks if the given text contains "mayalt" as one word.
30+
/// </summary>
31+
/// <param name="text">Text.</param>
32+
void ContainsMayaLT(string text){
33+
Assert.IsFalse (string.IsNullOrEmpty (text));
34+
Assert.IsTrue (text.ToLower ().Contains ("mayalt"));
35+
}
36+
2837
[Test]
2938
public void BasicTest() {
30-
Assert.IsFalse(Editor.MayaIntegration.IsHeadlessInstall());
31-
32-
LogNonEmptyString("module path", Editor.MayaIntegration.GetModulePath());
33-
LogNonEmptyString("module template path", Editor.MayaIntegration.GetModuleTemplatePath());
34-
35-
LogNonEmptyString("app path", Editor.MayaIntegration.GetAppPath());
36-
LogNonEmptyString("project path", Editor.MayaIntegration.GetProjectPath());
37-
LogNonEmptyString("package path", Editor.MayaIntegration.GetPackagePath());
38-
LogNonEmptyString("package version", Editor.MayaIntegration.GetPackageVersion());
39-
LogNonEmptyString("temp path", Editor.MayaIntegration.GetTempSavePath());
40-
LogNonEmptyString("export settings path", Editor.MayaIntegration.GetExportSettingsPath ());
41-
LogNonEmptyString ("instruction path", Editor.MayaIntegration.GetMayaInstructionPath ());
42-
LogNonEmptyString ("full instruction path", Editor.MayaIntegration.GetFullMayaInstructionPath ());
43-
44-
// test that the paths don't contain backslashes
45-
Assert.IsFalse(Editor.MayaIntegration.GetAppPath().Contains("\\"));
46-
Assert.IsFalse(Editor.MayaIntegration.GetProjectPath().Contains("\\"));
47-
Assert.IsFalse(Editor.MayaIntegration.GetTempSavePath().Contains("\\"));
48-
Assert.IsFalse(Editor.MayaIntegration.GetExportSettingsPath ().Contains("\\"));
39+
// test Maya integration
40+
{
41+
var mayaIntegration = new Editor.MayaIntegration ();
42+
43+
LogNonEmptyString ("display name", mayaIntegration.DccDisplayName);
44+
LogNonEmptyString ("integration zip path", mayaIntegration.IntegrationZipPath);
45+
46+
Assert.IsFalse (Editor.MayaIntegration.IsHeadlessInstall ());
47+
48+
LogNonEmptyString ("module template path", mayaIntegration.GetModuleTemplatePath ());
49+
LogNonEmptyString ("app path", Editor.MayaIntegration.GetAppPath ());
50+
LogNonEmptyString ("package path", Editor.MayaIntegration.GetPackagePath ());
51+
LogNonEmptyString ("temp path", Editor.MayaIntegration.GetTempSavePath ());
52+
LogNonEmptyString ("instruction path", Editor.MayaIntegration.GetMayaInstructionPath ());
53+
LogNonEmptyString ("full instruction path", Editor.MayaIntegration.GetFullMayaInstructionPath ());
54+
55+
// make sure the path is absolute
56+
Assert.IsTrue (System.IO.Path.IsPathRooted (Editor.MayaIntegration.GetFullMayaInstructionPath ()));
57+
58+
LogNonEmptyString ("export settings path", mayaIntegration.GetExportSettingsPath ());
59+
LogNonEmptyString ("package version", Editor.MayaIntegration.GetPackageVersion ());
60+
61+
// check if folder is unzipped at invalid paths
62+
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath (null));
63+
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath (""));
64+
Assert.IsFalse (mayaIntegration.FolderAlreadyUnzippedAtPath ("X:/a/b/a/c"));
65+
66+
// test that the paths don't contain backslashes
67+
Assert.IsFalse (Editor.MayaIntegration.GetAppPath ().Contains ("\\"));
68+
Assert.IsFalse (Editor.MayaIntegration.GetProjectPath ().Contains ("\\"));
69+
Assert.IsFalse (Editor.MayaIntegration.GetTempSavePath ().Contains ("\\"));
70+
Assert.IsFalse (mayaIntegration.GetExportSettingsPath ().Contains ("\\"));
71+
Assert.IsFalse (Editor.MayaIntegration.GetMayaInstructionPath ().Contains ("\\"));
72+
Assert.IsFalse (Editor.MayaIntegration.GetFullMayaInstructionPath ().Contains ("\\"));
73+
}
74+
75+
// test Maya LT integration
76+
{
77+
var mayaLTIntegration = new Editor.MayaLTIntegration ();
78+
79+
// make sure that the values we get are for Maya LT since it inherits a lot from Maya Integration
80+
Assert.AreEqual ("Maya LT", mayaLTIntegration.DccDisplayName);
81+
ContainsMayaLT (mayaLTIntegration.IntegrationZipPath);
82+
83+
LogNonEmptyString ("import settings path", mayaLTIntegration.GetImportSettingsPath ());
84+
85+
ContainsMayaLT (mayaLTIntegration.GetModuleTemplatePath ());
86+
ContainsMayaLT (mayaLTIntegration.GetExportSettingsPath ());
87+
88+
// test that the paths don't contain backslashes
89+
Assert.IsFalse (mayaLTIntegration.GetExportSettingsPath ().Contains ("\\"));
90+
Assert.IsFalse (mayaLTIntegration.GetImportSettingsPath ().Contains ("\\"));
91+
}
92+
93+
// test 3ds Max integration
94+
{
95+
var maxIntegration = new Editor.MaxIntegration ();
96+
97+
LogNonEmptyString ("display name", maxIntegration.DccDisplayName);
98+
LogNonEmptyString ("integration zip path", maxIntegration.IntegrationZipPath);
99+
100+
// check getting absolute path
101+
var absPath = Editor.MaxIntegration.GetAbsPath ("foo");
102+
Assert.IsTrue (System.IO.Path.IsPathRooted (absPath));
103+
Assert.IsFalse (absPath.Contains ("\\"));
104+
105+
// check if folder is unzipped at invalid paths
106+
Assert.IsFalse (maxIntegration.FolderAlreadyUnzippedAtPath (null));
107+
Assert.IsFalse (maxIntegration.FolderAlreadyUnzippedAtPath (""));
108+
Assert.IsFalse (maxIntegration.FolderAlreadyUnzippedAtPath ("X:/a/b/a/c"));
109+
}
49110
}
50111
}
51112
}

0 commit comments

Comments
 (0)