Class ContentFileFixture
Inheritance
ContentFileFixture
Implements
IPrebuildSetup
IPostBuildCleanup
Assembly: Unity.ScriptableBuildPipeline.Tests.dll
Syntax
public abstract class ContentFileFixture : IPrebuildSetup, IPostBuildCleanup
Constructors
ContentFileFixture()
Declaration
public ContentFileFixture()
Fields
m_Catalog
Declaration
protected Catalog m_Catalog
Field Value
m_CatalogDir
Declaration
protected string m_CatalogDir
Field Value
m_ContentRoot
Declaration
protected string m_ContentRoot
Field Value
m_NS
Declaration
protected ContentNamespace m_NS
Field Value
Properties
ContentDir
Declaration
public virtual string ContentDir { get; }
Property Value
ContentRoot
Declaration
protected string ContentRoot { get; }
Property Value
Methods
BuildContentLoadsAndCatalog(string, AssetBundleBuild[])
Declaration
protected void BuildContentLoadsAndCatalog(string outdir, AssetBundleBuild[] bundles)
Parameters
Cleanup()
Implement this method to specify actions that should run as a post-build cleanup step.
Declaration
public virtual void Cleanup()
CreateCatalog(string)
Declaration
public ContentFileFixture.ContentBuildCatalog CreateCatalog(string name)
Parameters
Type |
Name |
Description |
string |
name |
|
Returns
DefaultBuild()
Declaration
protected virtual void DefaultBuild()
GetVFSFilename(string)
Declaration
public string GetVFSFilename(string fn)
Parameters
Type |
Name |
Description |
string |
fn |
|
Returns
LoadCatalog(string, bool)
Declaration
public void LoadCatalog(string name, bool mountAllArchives = true)
Parameters
Type |
Name |
Description |
string |
name |
|
bool |
mountAllArchives |
|
PrepareBuildLayout()
Declaration
protected abstract void PrepareBuildLayout()
SetUp()
Declaration
[SetUp]
public void SetUp()
Setup()
Implement this method to call actions automatically before the build process.
Declaration
Examples
[TestFixture]
public class CreateSpriteTest : IPrebuildSetup
{
Texture2D m_Texture;
Sprite m_Sprite;
public void Setup()
{
#if UNITY_EDITOR
var spritePath = "Assets/Resources/Circle.png";
var ti = UnityEditor.AssetImporter.GetAtPath(spritePath) as UnityEditor.TextureImporter;
ti.textureCompression = UnityEditor.TextureImporterCompression.Uncompressed;
ti.SaveAndReimport();
#endif
}
[SetUp]
public void SetUpTest()
{
m_Texture = Resources.Load<Texture2D>("Circle");
}
[Test]
public void WhenNullTextureIsPassed_CreateShouldReturnNullSprite()
{
// Check with Valid Texture.
LogAssert.Expect(LogType.Log, "Circle Sprite Created");
Sprite.Create(m_Texture, new Rect(0, 0, m_Texture.width, m_Texture.height), new Vector2(0.5f, 0.5f));
Debug.Log("Circle Sprite Created");
// Check with NULL Texture. Should return NULL Sprite.
m_Sprite = Sprite.Create(null, new Rect(0, 0, m_Texture.width, m_Texture.height), new Vector2(0.5f, 0.5f));
Assert.That(m_Sprite, Is.Null, "Sprite created with null texture should be null");
}
}
> **Tip**: Use `#if UNITY_EDITOR` if you want to access Editor only APIs, but the setup/cleanup is inside a **Play Mode** assembly.
TearDown()
Declaration
[TearDown]
public void TearDown()
Implements
UnityEngine.TestTools.IPrebuildSetup
UnityEngine.TestTools.IPostBuildCleanup