generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: avoid loading assets unnecessarily from ChangeNotifier
Reported in #1357
- Loading branch information
1 parent
de08af7
commit 58aa7f9
Showing
5 changed files
with
112 additions
and
13 deletions.
There are no files selected for viewing
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
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
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,48 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using nadena.dev.ndmf.preview; | ||
using NUnit.Framework; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
|
||
namespace UnitTests | ||
{ | ||
public class ChangeNotifierTest : TestBase | ||
{ | ||
[Test] | ||
public void WhenAssetReimported_InvalidatesListeners() | ||
{ | ||
var path = "Assets/ChangeNotifierTest.txt"; | ||
using (var f = System.IO.File.CreateText(path)) | ||
{ | ||
f.WriteLine("Hello, world!"); | ||
} | ||
|
||
AssetDatabase.Refresh(); | ||
|
||
var asset = AssetDatabase.LoadAssetAtPath<TextAsset>(path); | ||
|
||
var ctx = new ComputeContext("test"); | ||
ctx.Observe(asset); | ||
|
||
using (var f = System.IO.File.CreateText(path)) | ||
{ | ||
f.WriteLine("Goodbye, world!"); | ||
} | ||
|
||
Assert.IsFalse(ctx.IsInvalidated); | ||
|
||
AssetDatabase.Refresh(); | ||
|
||
Assert.IsTrue(ctx.IsInvalidated); | ||
|
||
ctx = new ComputeContext("test"); | ||
ctx.Observe(asset); | ||
|
||
AssetDatabase.DeleteAsset(path); | ||
|
||
Assert.IsTrue(ctx.IsInvalidated); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.