Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test cases written and bugs fixed to loadmanager
- Loading branch information
Showing
11 changed files
with
281 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using UnityEngine.Assertions.Comparers; | ||
using UnityLoader; | ||
|
||
public class TestFocus : MonoBehaviour, IAssetLoader | ||
{ | ||
public float loadDuration = 10; | ||
|
||
private void Start() | ||
{ | ||
LoadManager.CreateManager(1f/30); | ||
LoadManager.instance.RegisterObject(gameObject); | ||
LoadManager.instance.StartLoading(() => Debug.Log("Loading Complete!")); | ||
} | ||
|
||
private void OnApplicationFocus(bool focus) | ||
{ | ||
Debug.Log("Focus Change: " + focus); | ||
} | ||
|
||
public IEnumerator LoadAssets() | ||
{ | ||
float loadTime = Time.realtimeSinceStartup + loadDuration; | ||
|
||
while (Time.realtimeSinceStartup < loadTime) | ||
{ | ||
Debug.Log("Frame: " + Time.renderedFrameCount); | ||
|
||
float delayTime = Time.realtimeSinceStartup + 1f / 30; | ||
|
||
while (Time.realtimeSinceStartup < delayTime) | ||
{ | ||
|
||
} | ||
|
||
yield return null; | ||
} | ||
} | ||
|
||
public void AssetsLoaded() | ||
{ | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
using System.Reflection; | ||
using UnityEngine.Assertions; | ||
using UnityLoader; | ||
|
||
namespace UnityLoaderTests | ||
{ | ||
public class TestFunctionality : MonoBehaviour | ||
{ | ||
public int targetFPS = 30; | ||
|
||
private void Awake() | ||
{ | ||
LoadManager.CreateManager(targetFPS); | ||
} | ||
|
||
// | ||
// Test Correct Steps | ||
// | ||
|
||
private const int STEPS_USED = 10; | ||
|
||
public class TestCorrectStepsClass : IAssetLoader | ||
{ | ||
public IEnumerator LoadAssets() | ||
{ | ||
for (int i = 0; i < STEPS_USED; i++) | ||
{ | ||
LoadManager.instance.IncrementLoadStep(); | ||
yield return null; | ||
} | ||
|
||
yield return null; | ||
} | ||
|
||
public void AssetsLoaded() | ||
{ | ||
|
||
} | ||
} | ||
|
||
public void TestCorrectSteps() | ||
{ | ||
TestCorrectStepsClass test = new TestCorrectStepsClass(); | ||
LoadManager.instance.RegisterObject(test, STEPS_USED); | ||
LoadManager.instance.StartLoading(() => Assert.IsTrue(LoadManager.instance.progress == 1f)); | ||
} | ||
|
||
// | ||
// Test Too Few Steps | ||
// | ||
|
||
public class TestTooFewStepsClass : IAssetLoader | ||
{ | ||
public IEnumerator LoadAssets() | ||
{ | ||
for (int i = 0; i < STEPS_USED; i++) | ||
{ | ||
if (i % 2 == 0) | ||
{ | ||
LoadManager.instance.IncrementLoadStep(); | ||
} | ||
|
||
yield return null; | ||
} | ||
|
||
yield return null; | ||
} | ||
|
||
public void AssetsLoaded() | ||
{ | ||
|
||
} | ||
} | ||
|
||
public void TestTooFewSteps() | ||
{ | ||
TestTooFewStepsClass test = new TestTooFewStepsClass(); | ||
LoadManager.instance.RegisterObject(test, STEPS_USED); | ||
LoadManager.instance.StartLoading(() => Assert.IsTrue(LoadManager.instance.progress == 1f)); | ||
} | ||
|
||
// | ||
// Test Too Few Steps | ||
// | ||
|
||
public class TestTooManyStepsClass : IAssetLoader | ||
{ | ||
public IEnumerator LoadAssets() | ||
{ | ||
for (int i = 0; i < STEPS_USED; i++) | ||
{ | ||
LoadManager.instance.IncrementLoadStep(); | ||
yield return null; | ||
} | ||
|
||
LoadManager.instance.IncrementLoadStep(); | ||
yield return null; | ||
} | ||
|
||
public void AssetsLoaded() | ||
{ | ||
|
||
} | ||
} | ||
|
||
public void TestTooManySteps() | ||
{ | ||
TestTooManyStepsClass test = new TestTooManyStepsClass(); | ||
LoadManager.instance.RegisterObject(test, STEPS_USED); | ||
LoadManager.instance.StartLoading(() => Assert.IsTrue(LoadManager.instance.progress == 1f)); | ||
} | ||
|
||
// | ||
// Test Force Yield | ||
// | ||
|
||
public class TestForceYieldClass : IAssetLoader | ||
{ | ||
public IEnumerator LoadAssets() | ||
{ | ||
float time = Time.realtimeSinceStartup + 10; | ||
|
||
while (Time.realtimeSinceStartup < time) | ||
{ | ||
Debug.Log("Frame: " + Time.renderedFrameCount); | ||
yield return new ForceYield(); | ||
} | ||
} | ||
|
||
public void AssetsLoaded() | ||
{ | ||
|
||
} | ||
} | ||
|
||
public void TestForceYield() | ||
{ | ||
TestForceYieldClass test = new TestForceYieldClass(); | ||
LoadManager.instance.secondsAllowedPerFrame = 100; | ||
LoadManager.instance.RegisterObject(test); | ||
LoadManager.instance.StartLoading(() => Assert.IsTrue(LoadManager.instance.progress == 1f)); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.