├── .gitattributes ├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── Assets ├── AssetStoreTools.meta ├── AssetStoreTools │ ├── Editor.meta │ └── Editor │ │ ├── AssetStoreTools.dll │ │ ├── AssetStoreTools.dll.meta │ │ ├── AssetStoreToolsExtra.dll │ │ ├── AssetStoreToolsExtra.dll.meta │ │ ├── DroidSansMono.ttf │ │ ├── DroidSansMono.ttf.meta │ │ ├── icon.png │ │ └── icon.png.meta ├── Editor.meta ├── Editor │ ├── Tests.meta │ └── Tests │ │ ├── BaseStreamTests.cs │ │ ├── BaseStreamTests.cs.meta │ │ ├── DeflateStreamTests.cs │ │ ├── DeflateStreamTests.cs.meta │ │ ├── GZipStreamTests.cs │ │ └── GZipStreamTests.cs.meta ├── Unity.IO.Compression.meta ├── Unity.IO.Compression │ ├── BlockType.cs │ ├── BlockType.cs.meta │ ├── CompressionMode.cs │ ├── CompressionMode.cs.meta │ ├── CopyEncoder.cs │ ├── CopyEncoder.cs.meta │ ├── Crc32Helper.cs │ ├── Crc32Helper.cs.meta │ ├── DeflateInput.cs │ ├── DeflateInput.cs.meta │ ├── DeflateStream.cs │ ├── DeflateStream.cs.meta │ ├── DeflateStreamAsyncResult.cs │ ├── DeflateStreamAsyncResult.cs.meta │ ├── DeflaterManaged.cs │ ├── DeflaterManaged.cs.meta │ ├── FastEncoder.cs │ ├── FastEncoder.cs.meta │ ├── FastEncoderStatics.cs │ ├── FastEncoderStatics.cs.meta │ ├── FastEncoderWindow.cs │ ├── FastEncoderWindow.cs.meta │ ├── FileFormats.cs │ ├── FileFormats.cs.meta │ ├── GZipDecoder.cs │ ├── GZipDecoder.cs.meta │ ├── GZipStream.cs │ ├── GZipStream.cs.meta │ ├── GZipUtils.cs │ ├── GZipUtils.cs.meta │ ├── HuffmanTree.cs │ ├── HuffmanTree.cs.meta │ ├── IDeflater.cs │ ├── IDeflater.cs.meta │ ├── Inflater.cs │ ├── Inflater.cs.meta │ ├── InflaterState.cs │ ├── InflaterState.cs.meta │ ├── InputBuffer.cs │ ├── InputBuffer.cs.meta │ ├── InvalidDataException.cs │ ├── InvalidDataException.cs.meta │ ├── Match.cs │ ├── Match.cs.meta │ ├── MatchState.cs │ ├── MatchState.cs.meta │ ├── OutputBuffer.cs │ ├── OutputBuffer.cs.meta │ ├── OutputWindow.cs │ ├── OutputWindow.cs.meta │ ├── README.md │ ├── README.md.meta │ ├── SR.cs │ └── SR.cs.meta ├── UnityTestTools.meta ├── UnityTestTools │ ├── Assertions.meta │ ├── Assertions │ │ ├── AssertionComponent.cs │ │ ├── AssertionComponent.cs.meta │ │ ├── AssertionException.cs │ │ ├── AssertionException.cs.meta │ │ ├── Assertions.cs │ │ ├── Assertions.cs.meta │ │ ├── CheckMethod.cs │ │ ├── CheckMethod.cs.meta │ │ ├── Comparers.meta │ │ ├── Comparers │ │ │ ├── ActionBase.cs │ │ │ ├── ActionBase.cs.meta │ │ │ ├── BoolComparer.cs │ │ │ ├── BoolComparer.cs.meta │ │ │ ├── ColliderComparer.cs │ │ │ ├── ColliderComparer.cs.meta │ │ │ ├── ComparerBase.cs │ │ │ ├── ComparerBase.cs.meta │ │ │ ├── FloatComparer.cs │ │ │ ├── FloatComparer.cs.meta │ │ │ ├── GeneralComparer.cs │ │ │ ├── GeneralComparer.cs.meta │ │ │ ├── IntComparer.cs │ │ │ ├── IntComparer.cs.meta │ │ │ ├── IsRenderedByCamera.cs │ │ │ ├── IsRenderedByCamera.cs.meta │ │ │ ├── StringComparer.cs │ │ │ ├── StringComparer.cs.meta │ │ │ ├── TransformComparer.cs │ │ │ ├── TransformComparer.cs.meta │ │ │ ├── ValueDoesNotChange.cs │ │ │ ├── ValueDoesNotChange.cs.meta │ │ │ ├── Vector2Comparer.cs │ │ │ ├── Vector2Comparer.cs.meta │ │ │ ├── Vector3Comparer.cs │ │ │ ├── Vector3Comparer.cs.meta │ │ │ ├── Vector4Comparer.cs │ │ │ ├── Vector4Comparer.cs.meta │ │ │ ├── VectorComparerBase.cs │ │ │ └── VectorComparerBase.cs.meta │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── AssertionComponentEditor.cs │ │ │ ├── AssertionComponentEditor.cs.meta │ │ │ ├── AssertionExplorerWindow.cs │ │ │ ├── AssertionExplorerWindow.cs.meta │ │ │ ├── AssertionListRenderer.cs │ │ │ ├── AssertionListRenderer.cs.meta │ │ │ ├── AssertionStripper.cs │ │ │ ├── AssertionStripper.cs.meta │ │ │ ├── DropDownControl.cs │ │ │ ├── DropDownControl.cs.meta │ │ │ ├── GroupByComparerRenderer.cs │ │ │ ├── GroupByComparerRenderer.cs.meta │ │ │ ├── GroupByExecutionMethodRenderer.cs │ │ │ ├── GroupByExecutionMethodRenderer.cs.meta │ │ │ ├── GroupByGORenderer.cs │ │ │ ├── GroupByGORenderer.cs.meta │ │ │ ├── GroupByNothingRenderer.cs │ │ │ ├── GroupByNothingRenderer.cs.meta │ │ │ ├── GroupByTestsRenderer.cs │ │ │ ├── GroupByTestsRenderer.cs.meta │ │ │ ├── PropertyPathSelector.cs │ │ │ ├── PropertyPathSelector.cs.meta │ │ │ ├── PropertyResolver.cs │ │ │ └── PropertyResolver.cs.meta │ │ ├── InvalidPathException.cs │ │ ├── InvalidPathException.cs.meta │ │ ├── MemberResolver.cs │ │ └── MemberResolver.cs.meta │ ├── Common.meta │ ├── Common │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── Icons.cs │ │ │ ├── Icons.cs.meta │ │ │ ├── ProjectSettingsBase.cs │ │ │ ├── ProjectSettingsBase.cs.meta │ │ │ ├── ResultWriter.meta │ │ │ ├── ResultWriter │ │ │ │ ├── ResultSummarizer.cs │ │ │ │ ├── ResultSummarizer.cs.meta │ │ │ │ ├── StackTraceFilter.cs │ │ │ │ ├── StackTraceFilter.cs.meta │ │ │ │ ├── XmlResultWriter.cs │ │ │ │ └── XmlResultWriter.cs.meta │ │ │ ├── Styles.cs │ │ │ ├── Styles.cs.meta │ │ │ ├── TestFilterSettings.cs │ │ │ ├── TestFilterSettings.cs.meta │ │ │ ├── icons.meta │ │ │ └── icons │ │ │ │ ├── failed.png │ │ │ │ ├── failed.png.meta │ │ │ │ ├── ignored.png │ │ │ │ ├── ignored.png.meta │ │ │ │ ├── inconclusive.png │ │ │ │ ├── inconclusive.png.meta │ │ │ │ ├── normal.png │ │ │ │ ├── normal.png.meta │ │ │ │ ├── passed.png │ │ │ │ ├── passed.png.meta │ │ │ │ ├── stopwatch.png │ │ │ │ └── stopwatch.png.meta │ │ ├── ITestResult.cs │ │ ├── ITestResult.cs.meta │ │ ├── Settings.meta │ │ ├── Settings │ │ │ ├── UnitTestsRunnerSettings.asset │ │ │ └── UnitTestsRunnerSettings.asset.meta │ │ ├── TestResultState.cs │ │ └── TestResultState.cs.meta │ ├── LICENSE.txt │ ├── LICENSE.txt.meta │ ├── UnitTesting.meta │ └── UnitTesting │ │ ├── Editor.meta │ │ └── Editor │ │ ├── Batch.cs │ │ ├── Batch.cs.meta │ │ ├── NSubstitute.meta │ │ ├── NSubstitute │ │ ├── NSubstitute.dll │ │ └── NSubstitute.dll.meta │ │ ├── NUnit.meta │ │ ├── NUnit │ │ ├── Libs.meta │ │ ├── Libs │ │ │ ├── Mono.Cecil.Mdb.dll │ │ │ ├── Mono.Cecil.Mdb.dll.meta │ │ │ ├── Mono.Cecil.dll │ │ │ ├── Mono.Cecil.dll.meta │ │ │ ├── nunit.core.dll │ │ │ ├── nunit.core.dll.meta │ │ │ ├── nunit.core.interfaces.dll │ │ │ ├── nunit.core.interfaces.dll.meta │ │ │ ├── nunit.framework.dll │ │ │ └── nunit.framework.dll.meta │ │ ├── Renderer.meta │ │ └── Renderer │ │ │ ├── GroupLine.cs │ │ │ ├── GroupLine.cs.meta │ │ │ ├── RenderingOptions.cs │ │ │ ├── RenderingOptions.cs.meta │ │ │ ├── TestLine.cs │ │ │ ├── TestLine.cs.meta │ │ │ ├── UnitTestRendererLine.cs │ │ │ └── UnitTestRendererLine.cs.meta │ │ ├── TestRunner.meta │ │ ├── TestRunner │ │ ├── BackgroundRunner.cs │ │ ├── BackgroundRunner.cs.meta │ │ ├── GuiHelper.cs │ │ ├── GuiHelper.cs.meta │ │ ├── ITestRunnerCallback.cs │ │ ├── ITestRunnerCallback.cs.meta │ │ ├── IUnitTestEngine.cs │ │ ├── IUnitTestEngine.cs.meta │ │ ├── NUnitExtensions.cs │ │ ├── NUnitExtensions.cs.meta │ │ ├── NUnitTestEngine.cs │ │ ├── NUnitTestEngine.cs.meta │ │ ├── TestRunner.cs │ │ ├── TestRunner.cs.meta │ │ ├── TestRunnerCallbackList.cs │ │ ├── TestRunnerCallbackList.cs.meta │ │ ├── UnitTestInfo.cs │ │ ├── UnitTestInfo.cs.meta │ │ ├── UnitTestResult.cs │ │ ├── UnitTestResult.cs.meta │ │ ├── UnitTestView.cs │ │ └── UnitTestView.cs.meta │ │ ├── UnitTestsRunnerSettings.cs │ │ ├── UnitTestsRunnerSettings.cs.meta │ │ ├── UnityUnitTest.cs │ │ └── UnityUnitTest.cs.meta ├── UnityVS.meta └── UnityVS │ ├── Editor.meta │ └── Editor │ ├── SyntaxTree.VisualStudio.Unity.Bridge.dll │ ├── SyntaxTree.VisualStudio.Unity.Bridge.dll.meta │ ├── SyntaxTree.VisualStudio.Unity.Messaging.dll │ ├── SyntaxTree.VisualStudio.Unity.Messaging.dll.meta │ ├── UnityVS.VersionSpecific.dll │ └── UnityVS.VersionSpecific.dll.meta ├── Info ├── 1024x1024.png ├── 128x128.png ├── 200x258.png ├── CaptureDeflate.png ├── CaptureGzip.png ├── Gzip.png ├── icon.psd ├── icon_promo.psd ├── storebanner.png └── storebanner.psd ├── LICENSE.txt ├── PATENTS.TXT ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset ├── README.md ├── build-helpers.fsx ├── build.bat ├── build.fsx └── nuget.config /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]in/ 5 | [Bb]uild/ 6 | 7 | # Autogenerated VS/MD solution and project files 8 | /*.csproj 9 | /*.unityproj 10 | /*.sln 11 | /*.suo 12 | /*.user 13 | /*.userprefs 14 | /*.pidb 15 | /*.booproj 16 | !/*.Xamarin.sln 17 | *.suo 18 | 19 | #Unity3D Generated File On Crash Reports 20 | sysinfo.txt 21 | 22 | #NuGet 23 | packages 24 | 25 | #Test Results 26 | UnitTestResults.xml 27 | TestResults.xml 28 | 29 | #Unity export 30 | *.unitypackage -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/.nuget/NuGet.exe -------------------------------------------------------------------------------- /Assets/AssetStoreTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0264992f90e27e48beeee54b801c8f2 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47c3c77b488bde14eac761a5144660ed 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/AssetStoreTools.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/AssetStoreTools/Editor/AssetStoreTools.dll -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/AssetStoreTools.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 11188de2b6632fa4486c470af4b55fa0 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/AssetStoreToolsExtra.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e35231d99115e9e4c8cb29414445831f 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/DroidSansMono.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/AssetStoreTools/Editor/DroidSansMono.ttf -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/DroidSansMono.ttf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35021dda9bd03434195c7dcd6ad7618f 3 | TrueTypeFontImporter: 4 | serializedVersion: 2 5 | fontSize: 16 6 | forceTextureCase: -2 7 | characterSpacing: 1 8 | characterPadding: 0 9 | includeFontData: 1 10 | use2xBehaviour: 0 11 | fontNames: [] 12 | customCharacters: 13 | fontRenderingMode: 0 14 | userData: 15 | -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/AssetStoreTools/Editor/icon.png -------------------------------------------------------------------------------- /Assets/AssetStoreTools/Editor/icon.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41844c716792706449720732c95b2747 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: -1 29 | mipBias: -1 30 | wrapMode: -1 31 | nPOTScale: 1 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 0 42 | textureType: -1 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f7c60acdf7a3c34eaa029ded04d5981 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/Tests.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2abf2e5c02b1c864a88fd59478587719 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/Tests/BaseStreamTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.IO; 4 | using System.Net; 5 | using Unity.IO.Compression; 6 | 7 | public class BaseStreamTests 8 | { 9 | protected string Text = "This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this. This is example text that we might want to GZip because it is really long and weird. I would be embarrassed to read this."; 10 | 11 | protected virtual byte[] CompressToArray() 12 | { 13 | throw new NotImplementedException(); 14 | } 15 | 16 | protected virtual byte[] GetHttpBin(string url) 17 | { 18 | var request = HttpWebRequest.Create(url) as HttpWebRequest; 19 | request.Method = WebRequestMethods.Http.Get; 20 | request.Timeout = 10000; 21 | request.Accept = "*/*"; 22 | request.Headers.Add("Accept-Encoding", "gzip, deflate"); 23 | 24 | using (var response = request.GetResponse() as HttpWebResponse) 25 | using (var stream = response.GetResponseStream()) 26 | { 27 | byte[] buffer = new byte[response.ContentLength]; 28 | stream.Read(buffer, 0, buffer.Length); 29 | return buffer; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/Editor/Tests/BaseStreamTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d0513f8fcc49e1428dfad29afcfdabf 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Tests/DeflateStreamTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.IO; 4 | using System.Net; 5 | using Unity.IO.Compression; 6 | 7 | [TestFixture] 8 | public class DeflateStreamTests : BaseStreamTests 9 | { 10 | protected override byte[] CompressToArray() 11 | { 12 | using (var memoryStream = new MemoryStream()) 13 | { 14 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress)) 15 | using (var writer = new StreamWriter(deflateStream)) 16 | { 17 | writer.Write(Text); 18 | } 19 | return memoryStream.ToArray(); 20 | } 21 | } 22 | 23 | //HACK: MS has a bug in their implementation when you try HTTP requests 24 | // More info here: http://george.chiramattel.com/blog/2007/09/deflatestream-block-length-does-not-match.html 25 | protected override byte[] GetHttpBin(string url) 26 | { 27 | var request = HttpWebRequest.Create(url) as HttpWebRequest; 28 | request.Method = WebRequestMethods.Http.Get; 29 | request.Timeout = 10000; 30 | request.Accept = "*/*"; 31 | request.Headers.Add("Accept-Encoding", "gzip, deflate"); 32 | 33 | using (var response = request.GetResponse() as HttpWebResponse) 34 | using (var stream = response.GetResponseStream()) 35 | { 36 | //HACK: skip 2 bytes 37 | stream.ReadByte(); 38 | stream.ReadByte(); 39 | 40 | byte[] buffer = new byte[response.ContentLength - 2]; 41 | stream.Read(buffer, 0, buffer.Length); 42 | return buffer; 43 | } 44 | } 45 | 46 | [Test] 47 | public void Compress() 48 | { 49 | var bytes = CompressToArray(); 50 | Assert.AreEqual(217, bytes.Length); 51 | } 52 | 53 | [Test] 54 | public void Decompress() 55 | { 56 | var bytes = CompressToArray(); 57 | 58 | using (var memoryStream = new MemoryStream(bytes)) 59 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Decompress)) 60 | using (var reader = new StreamReader(deflateStream)) 61 | { 62 | string text = reader.ReadToEnd(); 63 | Assert.AreEqual(Text, text); 64 | } 65 | } 66 | 67 | [Test] 68 | public void WebRequest() 69 | { 70 | var bytes = GetHttpBin("http://httpbin.org/deflate"); 71 | 72 | using (var memoryStream = new MemoryStream(bytes)) 73 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Decompress)) 74 | using (var reader = new StreamReader(deflateStream)) 75 | { 76 | string text = reader.ReadToEnd(); 77 | Assert.IsTrue(text.Contains("\"deflated\": true"), "Request was not compressed!"); 78 | } 79 | } 80 | 81 | [Test] 82 | public void LeaveOpenTrue() 83 | { 84 | using (var memoryStream = new MemoryStream()) 85 | { 86 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, true)) 87 | using (var writer = new StreamWriter(deflateStream)) 88 | { 89 | writer.Write(Text); 90 | } 91 | 92 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, true)) 93 | using (var writer = new StreamWriter(deflateStream)) 94 | { 95 | writer.Write(Text); 96 | } 97 | } 98 | } 99 | 100 | [Test, ExpectedException(typeof(ArgumentException))] 101 | public void LeaveOpenFalse() 102 | { 103 | using (var memoryStream = new MemoryStream()) 104 | { 105 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, false)) 106 | using (var writer = new StreamWriter(deflateStream)) 107 | { 108 | writer.Write(Text); 109 | } 110 | 111 | using (var deflateStream = new DeflateStream(memoryStream, CompressionMode.Compress, false)) 112 | using (var writer = new StreamWriter(deflateStream)) 113 | { 114 | writer.Write(Text); 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Assets/Editor/Tests/DeflateStreamTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 27cc65b2005663142af368c5672ab6d3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Tests/GZipStreamTests.cs: -------------------------------------------------------------------------------- 1 | using NUnit.Framework; 2 | using System; 3 | using System.IO; 4 | using Unity.IO.Compression; 5 | 6 | [TestFixture] 7 | public class GZipStreamTests : BaseStreamTests 8 | { 9 | protected override byte[] CompressToArray() 10 | { 11 | using (var memoryStream = new MemoryStream()) 12 | { 13 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress)) 14 | using (var writer = new StreamWriter(gzipStream)) 15 | { 16 | writer.Write(Text); 17 | } 18 | return memoryStream.ToArray(); 19 | } 20 | } 21 | 22 | [Test] 23 | public void Compress() 24 | { 25 | var bytes = CompressToArray(); 26 | Assert.AreEqual(235, bytes.Length); 27 | } 28 | 29 | [Test] 30 | public void Decompress() 31 | { 32 | var bytes = CompressToArray(); 33 | 34 | using (var memoryStream = new MemoryStream(bytes)) 35 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress)) 36 | using (var reader = new StreamReader(gzipStream)) 37 | { 38 | string text = reader.ReadToEnd(); 39 | Assert.AreEqual(Text, text); 40 | } 41 | } 42 | 43 | [Test] 44 | public void WebRequest() 45 | { 46 | var bytes = GetHttpBin("http://httpbin.org/gzip"); 47 | 48 | using (var memoryStream = new MemoryStream(bytes)) 49 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress)) 50 | using (var reader = new StreamReader(gzipStream)) 51 | { 52 | string text = reader.ReadToEnd(); 53 | Assert.IsTrue(text.Contains("\"gzipped\": true"), "Request was not compressed!"); 54 | } 55 | } 56 | 57 | [Test] 58 | public void LeaveOpenTrue() 59 | { 60 | using (var memoryStream = new MemoryStream()) 61 | { 62 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)) 63 | using (var writer = new StreamWriter(gzipStream)) 64 | { 65 | writer.Write(Text); 66 | } 67 | 68 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, true)) 69 | using (var writer = new StreamWriter(gzipStream)) 70 | { 71 | writer.Write(Text); 72 | } 73 | } 74 | } 75 | 76 | [Test, ExpectedException(typeof(ArgumentException))] 77 | public void LeaveOpenFalse() 78 | { 79 | using (var memoryStream = new MemoryStream()) 80 | { 81 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, false)) 82 | using (var writer = new StreamWriter(gzipStream)) 83 | { 84 | writer.Write(Text); 85 | } 86 | 87 | using (var gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, false)) 88 | using (var writer = new StreamWriter(gzipStream)) 89 | { 90 | writer.Write(Text); 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Assets/Editor/Tests/GZipStreamTests.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 160887b5bb387454d856b9f5169bb0c1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae0929697762fbf408961efa2f8f82e3 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/BlockType.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression { 2 | internal enum BlockType { 3 | Uncompressed = 0, 4 | Static = 1, 5 | Dynamic = 2 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/BlockType.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34db5983ec6daa348b2361f9fb7dc7b4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/CompressionMode.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression 2 | { 3 | public enum CompressionMode { 4 | Decompress = 0, 5 | Compress = 1 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/CompressionMode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6344c619bcacc4e488c3073c5e2c6408 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/CopyEncoder.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | 6 | internal class CopyEncoder { 7 | 8 | // padding for copy encoder formatting 9 | // - 1 byte for header 10 | // - 4 bytes for len, nlen 11 | private const int PaddingSize = 5; 12 | 13 | // max uncompressed deflate block size is 64K. 14 | private const int MaxUncompressedBlockSize = 65536; 15 | 16 | 17 | // null input means write an empty payload with formatting info. This is needed for the final block. 18 | public void GetBlock(DeflateInput input, OutputBuffer output, bool isFinal) { 19 | Debug.Assert(output != null); 20 | Debug.Assert(output.FreeBytes >= PaddingSize); 21 | 22 | // determine number of bytes to write 23 | int count = 0; 24 | if (input != null) { 25 | 26 | // allow space for padding and bits not yet flushed to buffer 27 | count = Math.Min(input.Count, output.FreeBytes - PaddingSize - output.BitsInBuffer); 28 | 29 | // we don't expect the output buffer to ever be this big (currently 4K), but we'll check this 30 | // just in case that changes. 31 | if (count > MaxUncompressedBlockSize - PaddingSize) { 32 | count = MaxUncompressedBlockSize - PaddingSize; 33 | } 34 | } 35 | 36 | // write header and flush bits 37 | if (isFinal) { 38 | output.WriteBits(FastEncoderStatics.BFinalNoCompressionHeaderBitCount, 39 | FastEncoderStatics.BFinalNoCompressionHeader); 40 | } 41 | else { 42 | output.WriteBits(FastEncoderStatics.NoCompressionHeaderBitCount, 43 | FastEncoderStatics.NoCompressionHeader); 44 | } 45 | 46 | // now we're aligned 47 | output.FlushBits(); 48 | 49 | // write len, nlen 50 | WriteLenNLen((ushort)count, output); 51 | 52 | // write uncompressed bytes 53 | if (input != null && count > 0) { 54 | output.WriteBytes(input.Buffer, input.StartIndex, count); 55 | input.ConsumeBytes(count); 56 | } 57 | 58 | } 59 | 60 | private void WriteLenNLen(ushort len, OutputBuffer output) { 61 | 62 | // len 63 | output.WriteUInt16(len); 64 | 65 | // nlen 66 | ushort onesComp = (ushort)(~(ushort)len); 67 | output.WriteUInt16(onesComp); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/CopyEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8e17d68d5f93ac34baf82f1d28d44e48 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/Crc32Helper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | namespace Unity.IO.Compression 3 | { 4 | using System.Diagnostics; 5 | 6 | 7 | internal static class Crc32Helper 8 | { 9 | 10 | // Table for CRC calculation 11 | static readonly uint[] crcTable = new uint[256] { 12 | 0x00000000u, 0x77073096u, 0xee0e612cu, 0x990951bau, 0x076dc419u, 13 | 0x706af48fu, 0xe963a535u, 0x9e6495a3u, 0x0edb8832u, 0x79dcb8a4u, 14 | 0xe0d5e91eu, 0x97d2d988u, 0x09b64c2bu, 0x7eb17cbdu, 0xe7b82d07u, 15 | 0x90bf1d91u, 0x1db71064u, 0x6ab020f2u, 0xf3b97148u, 0x84be41deu, 16 | 0x1adad47du, 0x6ddde4ebu, 0xf4d4b551u, 0x83d385c7u, 0x136c9856u, 17 | 0x646ba8c0u, 0xfd62f97au, 0x8a65c9ecu, 0x14015c4fu, 0x63066cd9u, 18 | 0xfa0f3d63u, 0x8d080df5u, 0x3b6e20c8u, 0x4c69105eu, 0xd56041e4u, 19 | 0xa2677172u, 0x3c03e4d1u, 0x4b04d447u, 0xd20d85fdu, 0xa50ab56bu, 20 | 0x35b5a8fau, 0x42b2986cu, 0xdbbbc9d6u, 0xacbcf940u, 0x32d86ce3u, 21 | 0x45df5c75u, 0xdcd60dcfu, 0xabd13d59u, 0x26d930acu, 0x51de003au, 22 | 0xc8d75180u, 0xbfd06116u, 0x21b4f4b5u, 0x56b3c423u, 0xcfba9599u, 23 | 0xb8bda50fu, 0x2802b89eu, 0x5f058808u, 0xc60cd9b2u, 0xb10be924u, 24 | 0x2f6f7c87u, 0x58684c11u, 0xc1611dabu, 0xb6662d3du, 0x76dc4190u, 25 | 0x01db7106u, 0x98d220bcu, 0xefd5102au, 0x71b18589u, 0x06b6b51fu, 26 | 0x9fbfe4a5u, 0xe8b8d433u, 0x7807c9a2u, 0x0f00f934u, 0x9609a88eu, 27 | 0xe10e9818u, 0x7f6a0dbbu, 0x086d3d2du, 0x91646c97u, 0xe6635c01u, 28 | 0x6b6b51f4u, 0x1c6c6162u, 0x856530d8u, 0xf262004eu, 0x6c0695edu, 29 | 0x1b01a57bu, 0x8208f4c1u, 0xf50fc457u, 0x65b0d9c6u, 0x12b7e950u, 30 | 0x8bbeb8eau, 0xfcb9887cu, 0x62dd1ddfu, 0x15da2d49u, 0x8cd37cf3u, 31 | 0xfbd44c65u, 0x4db26158u, 0x3ab551ceu, 0xa3bc0074u, 0xd4bb30e2u, 32 | 0x4adfa541u, 0x3dd895d7u, 0xa4d1c46du, 0xd3d6f4fbu, 0x4369e96au, 33 | 0x346ed9fcu, 0xad678846u, 0xda60b8d0u, 0x44042d73u, 0x33031de5u, 34 | 0xaa0a4c5fu, 0xdd0d7cc9u, 0x5005713cu, 0x270241aau, 0xbe0b1010u, 35 | 0xc90c2086u, 0x5768b525u, 0x206f85b3u, 0xb966d409u, 0xce61e49fu, 36 | 0x5edef90eu, 0x29d9c998u, 0xb0d09822u, 0xc7d7a8b4u, 0x59b33d17u, 37 | 0x2eb40d81u, 0xb7bd5c3bu, 0xc0ba6cadu, 0xedb88320u, 0x9abfb3b6u, 38 | 0x03b6e20cu, 0x74b1d29au, 0xead54739u, 0x9dd277afu, 0x04db2615u, 39 | 0x73dc1683u, 0xe3630b12u, 0x94643b84u, 0x0d6d6a3eu, 0x7a6a5aa8u, 40 | 0xe40ecf0bu, 0x9309ff9du, 0x0a00ae27u, 0x7d079eb1u, 0xf00f9344u, 41 | 0x8708a3d2u, 0x1e01f268u, 0x6906c2feu, 0xf762575du, 0x806567cbu, 42 | 0x196c3671u, 0x6e6b06e7u, 0xfed41b76u, 0x89d32be0u, 0x10da7a5au, 43 | 0x67dd4accu, 0xf9b9df6fu, 0x8ebeeff9u, 0x17b7be43u, 0x60b08ed5u, 44 | 0xd6d6a3e8u, 0xa1d1937eu, 0x38d8c2c4u, 0x4fdff252u, 0xd1bb67f1u, 45 | 0xa6bc5767u, 0x3fb506ddu, 0x48b2364bu, 0xd80d2bdau, 0xaf0a1b4cu, 46 | 0x36034af6u, 0x41047a60u, 0xdf60efc3u, 0xa867df55u, 0x316e8eefu, 47 | 0x4669be79u, 0xcb61b38cu, 0xbc66831au, 0x256fd2a0u, 0x5268e236u, 48 | 0xcc0c7795u, 0xbb0b4703u, 0x220216b9u, 0x5505262fu, 0xc5ba3bbeu, 49 | 0xb2bd0b28u, 0x2bb45a92u, 0x5cb36a04u, 0xc2d7ffa7u, 0xb5d0cf31u, 50 | 0x2cd99e8bu, 0x5bdeae1du, 0x9b64c2b0u, 0xec63f226u, 0x756aa39cu, 51 | 0x026d930au, 0x9c0906a9u, 0xeb0e363fu, 0x72076785u, 0x05005713u, 52 | 0x95bf4a82u, 0xe2b87a14u, 0x7bb12baeu, 0x0cb61b38u, 0x92d28e9bu, 53 | 0xe5d5be0du, 0x7cdcefb7u, 0x0bdbdf21u, 0x86d3d2d4u, 0xf1d4e242u, 54 | 0x68ddb3f8u, 0x1fda836eu, 0x81be16cdu, 0xf6b9265bu, 0x6fb077e1u, 55 | 0x18b74777u, 0x88085ae6u, 0xff0f6a70u, 0x66063bcau, 0x11010b5cu, 56 | 0x8f659effu, 0xf862ae69u, 0x616bffd3u, 0x166ccf45u, 0xa00ae278u, 57 | 0xd70dd2eeu, 0x4e048354u, 0x3903b3c2u, 0xa7672661u, 0xd06016f7u, 58 | 0x4969474du, 0x3e6e77dbu, 0xaed16a4au, 0xd9d65adcu, 0x40df0b66u, 59 | 0x37d83bf0u, 0xa9bcae53u, 0xdebb9ec5u, 0x47b2cf7fu, 0x30b5ffe9u, 60 | 0xbdbdf21cu, 0xcabac28au, 0x53b39330u, 0x24b4a3a6u, 0xbad03605u, 61 | 0xcdd70693u, 0x54de5729u, 0x23d967bfu, 0xb3667a2eu, 0xc4614ab8u, 62 | 0x5d681b02u, 0x2a6f2b94u, 0xb40bbe37u, 0xc30c8ea1u, 0x5a05df1bu, 63 | 0x2d02ef8du 64 | }; 65 | 66 | // Calculate CRC based on the old CRC and the new bytes 67 | // See RFC1952 for details. 68 | static public uint UpdateCrc32(uint crc32, byte[] buffer, int offset, int length) 69 | { 70 | Debug.Assert((buffer != null) && (offset >= 0) && (length >= 0) 71 | && (offset <= buffer.Length - length), "check the caller"); 72 | 73 | crc32 ^= 0xffffffffU; 74 | 75 | while (--length >= 0) 76 | { 77 | crc32 = crcTable[(crc32 ^ buffer[offset++]) & 0xFF] ^ (crc32 >> 8); 78 | } 79 | 80 | crc32 ^= 0xffffffffU; 81 | return crc32; 82 | } 83 | 84 | 85 | } 86 | 87 | 88 | } 89 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/Crc32Helper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: baa342fbc2f8ff9408912e3dc33456b0 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/DeflateInput.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression { 2 | using System.Diagnostics; 3 | 4 | internal class DeflateInput { 5 | private byte[] buffer; 6 | private int count; 7 | private int startIndex; 8 | 9 | internal byte[] Buffer { 10 | get { 11 | return buffer; 12 | } 13 | set { 14 | buffer = value; 15 | } 16 | } 17 | 18 | internal int Count { 19 | get { 20 | return count; 21 | } 22 | set { 23 | count = value; 24 | } 25 | } 26 | 27 | internal int StartIndex { 28 | get { 29 | return startIndex; 30 | } 31 | set { 32 | startIndex = value; 33 | } 34 | } 35 | 36 | internal void ConsumeBytes(int n) { 37 | Debug.Assert(n <= count, "Should use more bytes than what we have in the buffer"); 38 | startIndex += n; 39 | count -= n; 40 | Debug.Assert(startIndex + count <= buffer.Length, "Input buffer is in invalid state!"); 41 | } 42 | 43 | internal InputState DumpState() { 44 | InputState savedState; 45 | savedState.count = count; 46 | savedState.startIndex = startIndex; 47 | return savedState; 48 | } 49 | 50 | internal void RestoreState(InputState state) { 51 | count = state.count; 52 | startIndex = state.startIndex; 53 | } 54 | 55 | internal struct InputState { 56 | internal int count; 57 | internal int startIndex; 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/DeflateInput.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a70fb53a0a617584bae8e3dbb5432dce 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/DeflateStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06f3733a1fd50b647bc1be13d8a40d5b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/DeflateStreamAsyncResult.cs: -------------------------------------------------------------------------------- 1 | #if !NETFX_CORE 2 | namespace Unity.IO.Compression { 3 | using System; 4 | using System.Threading; 5 | 6 | internal class DeflateStreamAsyncResult : IAsyncResult { 7 | public byte[] buffer; 8 | public int offset; 9 | public int count; 10 | // disable csharp compiler warning #0414: field assigned unused value 11 | #pragma warning disable 0414 12 | public bool isWrite; 13 | #pragma warning restore 0414 14 | 15 | private object m_AsyncObject; // Caller's async object. 16 | private object m_AsyncState; // Caller's state object. 17 | private AsyncCallback m_AsyncCallback; // Caller's callback method. 18 | 19 | private object m_Result; // Final IO result to be returned byt the End*() method. 20 | internal bool m_CompletedSynchronously; // true if the operation completed synchronously. 21 | private int m_InvokedCallback; // 0 is callback is not called 22 | private int m_Completed; // 0 if not completed >0 otherwise. 23 | private object m_Event; // lazy allocated event to be returned in the IAsyncResult for the client to wait on 24 | 25 | public DeflateStreamAsyncResult(object asyncObject, object asyncState, 26 | AsyncCallback asyncCallback, 27 | byte[] buffer, int offset, int count) { 28 | 29 | this.buffer = buffer; 30 | this.offset = offset; 31 | this.count = count; 32 | m_CompletedSynchronously = true; 33 | m_AsyncObject = asyncObject; 34 | m_AsyncState = asyncState; 35 | m_AsyncCallback = asyncCallback; 36 | } 37 | 38 | // Interface method to return the caller's state object. 39 | public object AsyncState { 40 | get { 41 | return m_AsyncState; 42 | } 43 | } 44 | 45 | // Interface property to return a WaitHandle that can be waited on for I/O completion. 46 | // This property implements lazy event creation. 47 | // the event object is only created when this property is accessed, 48 | // since we're internally only using callbacks, as long as the user is using 49 | // callbacks as well we will not create an event at all. 50 | public WaitHandle AsyncWaitHandle { 51 | get { 52 | // save a copy of the completion status 53 | int savedCompleted = m_Completed; 54 | if (m_Event == null) { 55 | // lazy allocation of the event: 56 | // if this property is never accessed this object is never created 57 | Interlocked.CompareExchange(ref m_Event, new ManualResetEvent(savedCompleted != 0), null); 58 | } 59 | 60 | ManualResetEvent castedEvent = (ManualResetEvent)m_Event; 61 | if (savedCompleted == 0 && m_Completed != 0) { 62 | // if, while the event was created in the reset state, 63 | // the IO operation completed, set the event here. 64 | castedEvent.Set(); 65 | } 66 | return castedEvent; 67 | } 68 | } 69 | 70 | // Interface property, returning synchronous completion status. 71 | public bool CompletedSynchronously { 72 | get { 73 | return m_CompletedSynchronously; 74 | } 75 | } 76 | 77 | // Interface property, returning completion status. 78 | public bool IsCompleted { 79 | get { 80 | return m_Completed != 0; 81 | } 82 | } 83 | 84 | // Internal property for setting the IO result. 85 | internal object Result { 86 | get { 87 | return m_Result; 88 | } 89 | } 90 | 91 | internal void Close() { 92 | if (m_Event != null) { 93 | ((ManualResetEvent)m_Event).Close(); 94 | } 95 | } 96 | 97 | internal void InvokeCallback(bool completedSynchronously, object result) { 98 | Complete(completedSynchronously, result); 99 | } 100 | 101 | internal void InvokeCallback(object result) { 102 | Complete(result); 103 | } 104 | 105 | // Internal method for setting completion. 106 | // As a side effect, we'll signal the WaitHandle event and clean up. 107 | private void Complete(bool completedSynchronously, object result) { 108 | m_CompletedSynchronously = completedSynchronously; 109 | Complete(result); 110 | } 111 | 112 | private void Complete(object result) { 113 | m_Result = result; 114 | 115 | // Set IsCompleted and the event only after the usercallback method. 116 | Interlocked.Increment(ref m_Completed); 117 | 118 | if (m_Event != null) { 119 | ((ManualResetEvent)m_Event).Set(); 120 | } 121 | 122 | if (Interlocked.Increment(ref m_InvokedCallback) == 1) { 123 | if (m_AsyncCallback != null) { 124 | m_AsyncCallback(this); 125 | } 126 | } 127 | } 128 | 129 | } 130 | 131 | } 132 | #endif -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/DeflateStreamAsyncResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 769692916772bbf46b1a2a0a4a1ff5e6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/DeflaterManaged.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cb3d0941cfb3c746aef8c291ebe3eb2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/FastEncoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc22362256cea804682de8d27bc3b062 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/FastEncoderStatics.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0a0b1312c597c549862a2990eece005 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/FastEncoderWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e479f6f2cc5ce854d9eb5e17e0f5e4b6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/FileFormats.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression 2 | { 3 | interface IFileFormatWriter { 4 | byte[] GetHeader(); 5 | void UpdateWithBytesRead(byte[] buffer, int offset, int bytesToCopy); 6 | byte[] GetFooter(); 7 | } 8 | 9 | interface IFileFormatReader { 10 | bool ReadHeader(InputBuffer input); 11 | bool ReadFooter(InputBuffer input); 12 | void UpdateWithBytesRead(byte[] buffer, int offset, int bytesToCopy); 13 | void Validate(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/FileFormats.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a719bacb9b3275148ae399b0a64110fa 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/GZipDecoder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae32247f283a26546b161336074d153e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/GZipStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd288fd89ab9ad8429570e158d07477c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/GZipUtils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | namespace Unity.IO.Compression { 3 | using System.Diagnostics; 4 | 5 | internal static class GZipConstants { 6 | internal const int CompressionLevel_3 = 3; 7 | internal const int CompressionLevel_10 = 10; 8 | 9 | internal const long FileLengthModulo = 4294967296; 10 | 11 | internal const byte ID1 = 0x1F; 12 | internal const byte ID2 = 0x8B; 13 | internal const byte Deflate = 0x8; 14 | 15 | internal const int Xfl_HeaderPos = 8; 16 | internal const byte Xfl_FastestAlgorithm = 4; 17 | internal const byte Xfl_MaxCompressionSlowestAlgorithm = 2; 18 | } 19 | 20 | internal class GZipFormatter : IFileFormatWriter { 21 | 22 | private byte[] headerBytes = new byte[] { 23 | GZipConstants.ID1, // ID1 24 | GZipConstants.ID2, // ID2 25 | GZipConstants.Deflate, // CM = deflate 26 | 0, // FLG, no text, no crc, no extra, no name, no comment 27 | 28 | // MTIME (Modification Time) - no time available 29 | 0, 30 | 0, 31 | 0, 32 | 0, 33 | 34 | // XFL 35 | // 2 = compressor used max compression, slowest algorithm 36 | // 4 = compressor used fastest algorithm 37 | GZipConstants.Xfl_FastestAlgorithm, 38 | 39 | // OS: 0 = FAT filesystem (MS-DOS, OS/2, NT/Win32) 40 | 0 41 | }; 42 | 43 | private uint _crc32; 44 | private long _inputStreamSizeModulo; 45 | 46 | internal GZipFormatter() : this(GZipConstants.CompressionLevel_3) { } 47 | 48 | internal GZipFormatter(int compressionLevel) { 49 | if (compressionLevel == GZipConstants.CompressionLevel_10) { 50 | headerBytes[GZipConstants.Xfl_HeaderPos] = GZipConstants.Xfl_MaxCompressionSlowestAlgorithm; 51 | } 52 | } 53 | 54 | public byte[] GetHeader() { 55 | return headerBytes; 56 | } 57 | 58 | public void UpdateWithBytesRead(byte[] buffer, int offset, int bytesToCopy) { 59 | _crc32 = Crc32Helper.UpdateCrc32(_crc32, buffer, offset, bytesToCopy); 60 | 61 | long n = _inputStreamSizeModulo + (uint) bytesToCopy; 62 | if (n >= GZipConstants.FileLengthModulo) { 63 | n %= GZipConstants.FileLengthModulo; 64 | } 65 | _inputStreamSizeModulo = n; 66 | } 67 | 68 | public byte[] GetFooter() { 69 | byte[] b = new byte[8]; 70 | 71 | WriteUInt32(b, _crc32, 0); 72 | WriteUInt32(b, (uint)_inputStreamSizeModulo, 4); 73 | 74 | return b; 75 | 76 | } 77 | 78 | internal void WriteUInt32(byte[] b, uint value, int startIndex) { 79 | b[startIndex] = (byte)value; 80 | b[startIndex + 1] = (byte)(value >> 8); 81 | b[startIndex + 2] = (byte)(value >> 16); 82 | b[startIndex + 3] = (byte)(value >> 24); 83 | } 84 | } 85 | 86 | 87 | } 88 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/GZipUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 730a067bff4eeaf41804bfc2e9bd4dd1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/HuffmanTree.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1fe9afcfe6ac39d4089fea8ee1a07813 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/IDeflater.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace Unity.IO.Compression { 3 | 4 | internal interface IDeflater : IDisposable { 5 | bool NeedsInput(); 6 | void SetInput(byte[] inputBuffer, int startIndex, int count); 7 | int GetDeflateOutput(byte[] outputBuffer); 8 | bool Finish(byte[] outputBuffer, out int bytesRead); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/IDeflater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e4bbb3e48f7e4f04ebe42577c871b0fc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/Inflater.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7fdb136adcd29954995bac65c7219b4d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/InflaterState.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression { 2 | // Do not rearrange the enum values. 3 | internal enum InflaterState { 4 | ReadingHeader = 0, // Only applies to GZIP 5 | 6 | ReadingBFinal = 2, // About to read bfinal bit 7 | ReadingBType = 3, // About to read blockType bits 8 | 9 | ReadingNumLitCodes = 4, // About to read # literal codes 10 | ReadingNumDistCodes = 5, // About to read # dist codes 11 | ReadingNumCodeLengthCodes = 6, // About to read # code length codes 12 | ReadingCodeLengthCodes = 7, // In the middle of reading the code length codes 13 | ReadingTreeCodesBefore = 8, // In the middle of reading tree codes (loop top) 14 | ReadingTreeCodesAfter = 9, // In the middle of reading tree codes (extension; code > 15) 15 | 16 | DecodeTop = 10, // About to decode a literal (char/match) in a compressed block 17 | HaveInitialLength = 11, // Decoding a match, have the literal code (base length) 18 | HaveFullLength = 12, // Ditto, now have the full match length (incl. extra length bits) 19 | HaveDistCode = 13, // Ditto, now have the distance code also, need extra dist bits 20 | 21 | /* uncompressed blocks */ 22 | UncompressedAligning = 15, 23 | UncompressedByte1 = 16, 24 | UncompressedByte2 = 17, 25 | UncompressedByte3 = 18, 26 | UncompressedByte4 = 19, 27 | DecodingUncompressed = 20, 28 | 29 | // These three apply only to GZIP 30 | StartReadingFooter = 21, // (Initialisation for reading footer) 31 | ReadingFooter = 22, 32 | VerifyingFooter = 23, 33 | 34 | Done = 24 // Finished 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/InflaterState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0fe75c6b962577e4bb4559bbb78af6eb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/InputBuffer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5edc22ba82e12ce4aae6e16378803b53 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/InvalidDataException.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression { 2 | 3 | using System; 4 | using System.Runtime.Serialization; 5 | 6 | #if !NETFX_CORE 7 | [Serializable] 8 | #endif // !FEATURE_NETCORE 9 | public sealed class InvalidDataException 10 | #if NETFX_CORE 11 | : Exception 12 | #else 13 | : SystemException 14 | #endif 15 | { 16 | public InvalidDataException () 17 | : base(SR.GetString(SR.GenericInvalidData)) { 18 | } 19 | 20 | public InvalidDataException (String message) 21 | : base(message) { 22 | } 23 | 24 | public InvalidDataException (String message, Exception innerException) 25 | : base(message, innerException) { 26 | } 27 | 28 | #if !NETFX_CORE 29 | internal InvalidDataException (SerializationInfo info, StreamingContext context) : base(info, context) { 30 | } 31 | #endif // !NETFX_CORE 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/InvalidDataException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78ff52880c8e2a74685c7981134cf0a9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/Match.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression { 2 | // This class represents a match in the history window 3 | internal class Match { 4 | private MatchState state; 5 | private int pos; 6 | private int len; 7 | private byte symbol; 8 | 9 | internal MatchState State { 10 | get { return state; } 11 | set { state = value; } 12 | } 13 | 14 | internal int Position { 15 | get { return pos; } 16 | set { pos = value; } 17 | } 18 | 19 | internal int Length { 20 | get { return len; } 21 | set { len = value; } 22 | } 23 | 24 | internal byte Symbol { 25 | get { return symbol; } 26 | set { symbol = value; } 27 | 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/Match.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef38a6c88f4d4e740b955af34b455b6d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/MatchState.cs: -------------------------------------------------------------------------------- 1 | internal enum MatchState { 2 | HasSymbol = 1, 3 | HasMatch = 2, 4 | HasSymbolAndMatch = 3 5 | } 6 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/MatchState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e1492d08233a4b5468e7b44128eb35ce 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/OutputBuffer.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression { 2 | using System; 3 | using System.Diagnostics; 4 | 5 | internal class OutputBuffer { 6 | 7 | private byte[] byteBuffer; // buffer for storing bytes 8 | private int pos; // position 9 | private uint bitBuf; // store uncomplete bits 10 | private int bitCount; // number of bits in bitBuffer 11 | 12 | // set the output buffer we will be using 13 | internal void UpdateBuffer(byte[] output) { 14 | byteBuffer = output; 15 | pos = 0; 16 | } 17 | 18 | internal int BytesWritten { 19 | get { 20 | return pos; 21 | } 22 | } 23 | 24 | internal int FreeBytes { 25 | get { 26 | return byteBuffer.Length - pos; 27 | } 28 | } 29 | 30 | internal void WriteUInt16(ushort value) { 31 | Debug.Assert(FreeBytes >= 2, "No enough space in output buffer!"); 32 | 33 | byteBuffer[pos++] = (byte)value; 34 | byteBuffer[pos++] = (byte)(value >> 8); 35 | } 36 | 37 | internal void WriteBits(int n, uint bits) { 38 | Debug.Assert(n <= 16, "length must be larger than 16!"); 39 | bitBuf |= bits << bitCount; 40 | bitCount += n; 41 | if (bitCount >= 16) { 42 | Debug.Assert(byteBuffer.Length - pos >= 2, "No enough space in output buffer!"); 43 | byteBuffer[pos++] = unchecked((byte)bitBuf); 44 | byteBuffer[pos++] = unchecked((byte)(bitBuf >> 8)); 45 | bitCount -= 16; 46 | bitBuf >>= 16; 47 | } 48 | } 49 | 50 | // write the bits left in the output as bytes. 51 | internal void FlushBits() { 52 | // flush bits from bit buffer to output buffer 53 | while (bitCount >= 8) { 54 | byteBuffer[pos++] = unchecked((byte)bitBuf); 55 | bitCount -= 8; 56 | bitBuf >>= 8; 57 | } 58 | 59 | if (bitCount > 0) { 60 | byteBuffer[pos++] = unchecked((byte)bitBuf); 61 | bitBuf = 0; 62 | bitCount = 0; 63 | } 64 | } 65 | 66 | internal void WriteBytes(byte[] byteArray, int offset, int count) { 67 | Debug.Assert(FreeBytes >= count, "Not enough space in output buffer!"); 68 | // faster 69 | if (bitCount == 0) { 70 | Array.Copy(byteArray, offset, byteBuffer, pos, count); 71 | pos += count; 72 | } 73 | else { 74 | WriteBytesUnaligned(byteArray, offset, count); 75 | } 76 | } 77 | 78 | private void WriteBytesUnaligned(byte[] byteArray, int offset, int count) { 79 | for (int i = 0; i < count; i++) { 80 | byte b = byteArray[offset + i]; 81 | WriteByteUnaligned(b); 82 | } 83 | } 84 | 85 | private void WriteByteUnaligned(byte b) { 86 | WriteBits(8, b); 87 | } 88 | 89 | internal int BitsInBuffer { 90 | get { 91 | return (bitCount / 8) + 1; 92 | } 93 | } 94 | 95 | internal OutputBuffer.BufferState DumpState() { 96 | OutputBuffer.BufferState savedState; 97 | savedState.pos = pos; 98 | savedState.bitBuf = bitBuf; 99 | savedState.bitCount = bitCount; 100 | return savedState; 101 | } 102 | 103 | internal void RestoreState(OutputBuffer.BufferState state) { 104 | pos = state.pos; 105 | bitBuf = state.bitBuf; 106 | bitCount = state.bitCount; 107 | } 108 | 109 | internal struct BufferState { 110 | internal int pos; // position 111 | internal uint bitBuf; // store uncomplete bits 112 | internal int bitCount; // number of bits in bitBuffer 113 | } 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/OutputBuffer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3704840b8764dd40b737804261e847c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/OutputWindow.cs: -------------------------------------------------------------------------------- 1 | namespace Unity.IO.Compression 2 | { 3 | using System; 4 | using System.Diagnostics; 5 | using System.Globalization; 6 | 7 | // This class maintains a window for decompressed output. 8 | // We need to keep this because the decompressed information can be 9 | // a literal or a length/distance pair. For length/distance pair, 10 | // we need to look back in the output window and copy bytes from there. 11 | // We use a byte array of WindowSize circularly. 12 | // 13 | internal class OutputWindow { 14 | 15 | private const int WindowSize = 32768; 16 | private const int WindowMask = 32767; 17 | 18 | private byte[] window = new byte[WindowSize]; //The window is 2^15 bytes 19 | private int end; // this is the position to where we should write next byte 20 | private int bytesUsed; // The number of bytes in the output window which is not consumed. 21 | 22 | // Add a byte to output window 23 | public void Write(byte b) { 24 | Debug.Assert(bytesUsed < WindowSize, "Can't add byte when window is full!"); 25 | window[end++] = b; 26 | end &= WindowMask; 27 | ++bytesUsed; 28 | } 29 | 30 | public void WriteLengthDistance(int length, int distance) { 31 | Debug.Assert((bytesUsed + length) <= WindowSize, "Not enough space"); 32 | 33 | // move backwards distance bytes in the output stream, 34 | // and copy length bytes from this position to the output stream. 35 | bytesUsed += length; 36 | int copyStart = (end - distance) & WindowMask; // start position for coping. 37 | 38 | int border = WindowSize - length; 39 | if (copyStart <= border && end < border) { 40 | if (length <= distance) { 41 | System.Array.Copy(window, copyStart, window, end, length); 42 | end += length; 43 | } else { 44 | // The referenced string may overlap the current 45 | // position; for example, if the last 2 bytes decoded have values 46 | // X and Y, a string reference with 47 | // adds X,Y,X,Y,X to the output stream. 48 | while (length-- > 0) { 49 | window[end++] = window[copyStart++]; 50 | } 51 | } 52 | } 53 | else { // copy byte by byte 54 | while (length-- > 0) { 55 | window[end++] = window[copyStart++]; 56 | end &= WindowMask; 57 | copyStart &= WindowMask; 58 | } 59 | } 60 | } 61 | 62 | // Copy up to length of bytes from input directly. 63 | // This is used for uncompressed block. 64 | public int CopyFrom(InputBuffer input, int length) { 65 | length = Math.Min(Math.Min(length, WindowSize - bytesUsed), input.AvailableBytes); 66 | int copied; 67 | 68 | // We might need wrap around to copy all bytes. 69 | int tailLen = WindowSize - end; 70 | if (length > tailLen) { 71 | // copy the first part 72 | copied = input.CopyTo(window, end, tailLen); 73 | if (copied == tailLen) { 74 | // only try to copy the second part if we have enough bytes in input 75 | copied += input.CopyTo(window, 0, length - tailLen); 76 | } 77 | } 78 | else { 79 | // only one copy is needed if there is no wrap around. 80 | copied = input.CopyTo(window, end, length); 81 | } 82 | 83 | end = (end + copied) & WindowMask; 84 | bytesUsed += copied; 85 | return copied; 86 | } 87 | 88 | // Free space in output window 89 | public int FreeBytes { 90 | get { 91 | return WindowSize - bytesUsed; 92 | } 93 | } 94 | 95 | // bytes not consumed in output window 96 | public int AvailableBytes { 97 | get { 98 | return bytesUsed; 99 | } 100 | } 101 | 102 | // copy the decompressed bytes to output array. 103 | public int CopyTo(byte[] output, int offset, int length) { 104 | int copy_end; 105 | 106 | if (length > bytesUsed) { // we can copy all the decompressed bytes out 107 | copy_end = end; 108 | length = bytesUsed; 109 | } else { 110 | copy_end = (end - bytesUsed + length) & WindowMask; // copy length of bytes 111 | } 112 | 113 | int copied = length; 114 | 115 | int tailLen = length - copy_end; 116 | if ( tailLen > 0) { // this means we need to copy two parts seperately 117 | // copy tailLen bytes from the end of output window 118 | System.Array.Copy(window, WindowSize - tailLen, 119 | output, offset, tailLen); 120 | offset += tailLen; 121 | length = copy_end; 122 | } 123 | System.Array.Copy(window, copy_end - length, output, offset, length); 124 | bytesUsed -= copied; 125 | Debug.Assert(bytesUsed >= 0, "check this function and find why we copied more bytes than we have"); 126 | return copied; 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/OutputWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f334e9704b79a394b9b21ca7d6a12b1f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/README.md: -------------------------------------------------------------------------------- 1 | # Unity.IO.Compression 2 | This is a port of Microsoft's code from [here](https://github.com/Microsoft/referencesource/tree/master/System/sys/system/IO/compression). 3 | 4 | The classes in System.IO.Compression in Unity 4.x [do not seem to work on Windows](http://answers.unity3d.com/questions/692250/gzipstream-and-deflatestream-give-entrypointnotfou.html) and perhaps several other platforms. 5 | 6 | Luckily, Microsoft has released much of the source code of the .NET BCL. We have ported Microsoft's code to work in Unity. This seems like the cleanest and most stable way to get the GZipStream and DeflateStream classes working in Unity. 7 | 8 | Find the plugin on the Unity Asset Store [here](https://www.assetstore.unity3d.com/#!/content/31902). 9 | 10 | Built by [Hitcents](http://hitcents.com/), contact us [here](http://hitcents.com/contact) for questions. 11 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ea4af6e593d40d4dbbf149f22bf9e7f 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/SR.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Hitcents 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. 3 | namespace Unity.IO.Compression { 4 | /// 5 | /// NOTE: this is a hacked in replacement for the SR class 6 | /// Unity games don't care about localized exception messages, so we just hacked these in the best we could 7 | /// 8 | internal class SR 9 | { 10 | public const string ArgumentOutOfRange_Enum = "Argument out of range"; 11 | public const string CorruptedGZipHeader = "Corrupted gzip header"; 12 | public const string CannotReadFromDeflateStream = "Cannot read from deflate stream"; 13 | public const string CannotWriteToDeflateStream = "Cannot write to deflate stream"; 14 | public const string GenericInvalidData = "Invalid data"; 15 | public const string InvalidCRC = "Invalid CRC"; 16 | public const string InvalidStreamSize = "Invalid stream size"; 17 | public const string InvalidHuffmanData = "Invalid Huffman data"; 18 | public const string InvalidBeginCall = "Invalid begin call"; 19 | public const string InvalidEndCall = "Invalid end call"; 20 | public const string InvalidBlockLength = "Invalid block length"; 21 | public const string InvalidArgumentOffsetCount = "Invalid argument offset count"; 22 | public const string NotSupported = "Not supported"; 23 | public const string NotWriteableStream = "Not a writeable stream"; 24 | public const string NotReadableStream = "Not a readable stream"; 25 | public const string ObjectDisposed_StreamClosed = "Object disposed"; 26 | public const string UnknownState = "Unknown state"; 27 | public const string UnknownCompressionMode = "Unknown compression mode"; 28 | public const string UnknownBlockType = "Unknown block type"; 29 | 30 | private SR() 31 | { 32 | } 33 | 34 | internal static string GetString(string p) 35 | { 36 | //HACK: just return the string passed in, not doing localization 37 | return p; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/Unity.IO.Compression/SR.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ba2bb8eed28cba4eb48ad0d624fd824 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 704b78295ffcef940959f1b521c1e255 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b27b28700d3365146808b6e082748201 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/AssertionComponent.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8bafa54482a87ac4cbd7ff1bfd1ac93a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/AssertionException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class AssertionException : Exception 8 | { 9 | private readonly AssertionComponent m_Assertion; 10 | 11 | public AssertionException(AssertionComponent assertion) : base(assertion.Action.GetFailureMessage()) 12 | { 13 | m_Assertion = assertion; 14 | } 15 | 16 | public override string StackTrace 17 | { 18 | get 19 | { 20 | return "Created in " + m_Assertion.GetCreationLocation(); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/AssertionException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef3769ab00d50bc4fbb05a9a91c741d9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Assertions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Object = UnityEngine.Object; 5 | 6 | namespace UnityTest 7 | { 8 | public static class Assertions 9 | { 10 | public static void CheckAssertions() 11 | { 12 | var assertions = Object.FindObjectsOfType(typeof(AssertionComponent)) as AssertionComponent[]; 13 | CheckAssertions(assertions); 14 | } 15 | 16 | public static void CheckAssertions(AssertionComponent assertion) 17 | { 18 | CheckAssertions(new[] {assertion}); 19 | } 20 | 21 | public static void CheckAssertions(GameObject gameObject) 22 | { 23 | CheckAssertions(gameObject.GetComponents()); 24 | } 25 | 26 | public static void CheckAssertions(AssertionComponent[] assertions) 27 | { 28 | if (!Debug.isDebugBuild) 29 | return; 30 | foreach (var assertion in assertions) 31 | { 32 | assertion.checksPerformed++; 33 | var result = assertion.Action.Compare(); 34 | if (!result) 35 | { 36 | assertion.hasFailed = true; 37 | assertion.Action.Fail(assertion); 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Assertions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 85280dad1e618c143bd3fb07a197b469 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/CheckMethod.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | [Flags] 8 | public enum CheckMethod 9 | { 10 | AfterPeriodOfTime = 1 << 0, 11 | Start = 1 << 1, 12 | Update = 1 << 2, 13 | FixedUpdate = 1 << 3, 14 | LateUpdate = 1 << 4, 15 | OnDestroy = 1 << 5, 16 | OnEnable = 1 << 6, 17 | OnDisable = 1 << 7, 18 | OnControllerColliderHit = 1 << 8, 19 | OnParticleCollision = 1 << 9, 20 | OnJointBreak = 1 << 10, 21 | OnBecameInvisible = 1 << 11, 22 | OnBecameVisible = 1 << 12, 23 | OnTriggerEnter = 1 << 13, 24 | OnTriggerExit = 1 << 14, 25 | OnTriggerStay = 1 << 15, 26 | OnCollisionEnter = 1 << 16, 27 | OnCollisionExit = 1 << 17, 28 | OnCollisionStay = 1 << 18, 29 | OnTriggerEnter2D = 1 << 19, 30 | OnTriggerExit2D = 1 << 20, 31 | OnTriggerStay2D = 1 << 21, 32 | OnCollisionEnter2D = 1 << 22, 33 | OnCollisionExit2D = 1 << 23, 34 | OnCollisionStay2D = 1 << 24, 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/CheckMethod.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cbb75d1643c5a55439f8861a827f411b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb9e10c25f478c84f826ea85b03ec179 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ActionBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | public abstract class ActionBase : ScriptableObject 10 | { 11 | public GameObject go; 12 | protected object m_ObjVal; 13 | 14 | private MemberResolver m_MemberResolver; 15 | 16 | public string thisPropertyPath = ""; 17 | public virtual Type[] GetAccepatbleTypesForA() 18 | { 19 | return null; 20 | } 21 | public virtual int GetDepthOfSearch() { return 2; } 22 | 23 | public virtual string[] GetExcludedFieldNames() 24 | { 25 | return new string[] { }; 26 | } 27 | 28 | public bool Compare() 29 | { 30 | if (m_MemberResolver == null) 31 | m_MemberResolver = new MemberResolver(go, thisPropertyPath); 32 | m_ObjVal = m_MemberResolver.GetValue(UseCache); 33 | var result = Compare(m_ObjVal); 34 | return result; 35 | } 36 | 37 | protected abstract bool Compare(object objVal); 38 | 39 | virtual protected bool UseCache { get { return false; } } 40 | 41 | public virtual Type GetParameterType() { return typeof(object); } 42 | 43 | public virtual string GetConfigurationDescription() 44 | { 45 | string result = ""; 46 | #if !UNITY_METRO 47 | foreach (var prop in GetType().GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly) 48 | .Where(info => info.FieldType.IsSerializable)) 49 | { 50 | var value = prop.GetValue(this); 51 | if (value is double) 52 | value = ((double)value).ToString("0.########"); 53 | if (value is float) 54 | value = ((float)value).ToString("0.########"); 55 | result += value + " "; 56 | } 57 | #endif // if !UNITY_METRO 58 | return result; 59 | } 60 | 61 | IEnumerable GetFields(Type type) 62 | { 63 | #if !UNITY_METRO 64 | return type.GetFields(BindingFlags.Public | BindingFlags.Instance); 65 | #else 66 | return null; 67 | #endif 68 | } 69 | 70 | public ActionBase CreateCopy(GameObject oldGameObject, GameObject newGameObject) 71 | { 72 | #if !UNITY_METRO 73 | var newObj = CreateInstance(GetType()) as ActionBase; 74 | #else 75 | var newObj = (ActionBase) this.MemberwiseClone(); 76 | #endif 77 | var fields = GetFields(GetType()); 78 | foreach (var field in fields) 79 | { 80 | var value = field.GetValue(this); 81 | if (value is GameObject) 82 | { 83 | if (value as GameObject == oldGameObject) 84 | value = newGameObject; 85 | } 86 | field.SetValue(newObj, value); 87 | } 88 | return newObj; 89 | } 90 | 91 | public virtual void Fail(AssertionComponent assertion) 92 | { 93 | Debug.LogException(new AssertionException(assertion), assertion.GetFailureReferenceObject()); 94 | } 95 | 96 | public virtual string GetFailureMessage() 97 | { 98 | return GetType().Name + " assertion failed.\n(" + go + ")." + thisPropertyPath + " failed. Value: " + m_ObjVal; 99 | } 100 | } 101 | 102 | public abstract class ActionBaseGeneric : ActionBase 103 | { 104 | protected override bool Compare(object objVal) 105 | { 106 | return Compare((T)objVal); 107 | } 108 | protected abstract bool Compare(T objVal); 109 | 110 | public override Type[] GetAccepatbleTypesForA() 111 | { 112 | return new[] { typeof(T) }; 113 | } 114 | 115 | public override Type GetParameterType() 116 | { 117 | return typeof(T); 118 | } 119 | protected override bool UseCache { get { return true; } } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ActionBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b4995756bd539804e8143ff1e730f806 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/BoolComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class BoolComparer : ComparerBaseGeneric 8 | { 9 | protected override bool Compare(bool a, bool b) 10 | { 11 | return a == b; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/BoolComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2586c8e41f35d2f4fadde53020bf4207 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ColliderComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class ColliderComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | Intersects, 12 | DoesNotIntersect 13 | }; 14 | 15 | public CompareType compareType; 16 | 17 | protected override bool Compare(Bounds a, Bounds b) 18 | { 19 | switch (compareType) 20 | { 21 | case CompareType.Intersects: 22 | return a.Intersects(b); 23 | case CompareType.DoesNotIntersect: 24 | return !a.Intersects(b); 25 | } 26 | throw new Exception(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ColliderComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4eff45b2ac4067b469d7994298341db6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ComparerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Object = System.Object; 5 | 6 | namespace UnityTest 7 | { 8 | public abstract class ComparerBase : ActionBase 9 | { 10 | public enum CompareToType 11 | { 12 | CompareToObject, 13 | CompareToConstantValue, 14 | CompareToNull 15 | } 16 | 17 | public CompareToType compareToType = CompareToType.CompareToObject; 18 | 19 | public GameObject other; 20 | protected object m_ObjOtherVal; 21 | public string otherPropertyPath = ""; 22 | private MemberResolver m_MemberResolverB; 23 | 24 | protected abstract bool Compare(object a, object b); 25 | 26 | protected override bool Compare(object objValue) 27 | { 28 | if (compareToType == CompareToType.CompareToConstantValue) 29 | { 30 | m_ObjOtherVal = ConstValue; 31 | } 32 | else if (compareToType == CompareToType.CompareToNull) 33 | { 34 | m_ObjOtherVal = null; 35 | } 36 | else 37 | { 38 | if (other == null) 39 | m_ObjOtherVal = null; 40 | else 41 | { 42 | if (m_MemberResolverB == null) 43 | m_MemberResolverB = new MemberResolver(other, otherPropertyPath); 44 | m_ObjOtherVal = m_MemberResolverB.GetValue(UseCache); 45 | } 46 | } 47 | return Compare(objValue, m_ObjOtherVal); 48 | } 49 | 50 | public virtual Type[] GetAccepatbleTypesForB() 51 | { 52 | return null; 53 | } 54 | 55 | #region Const value 56 | 57 | public virtual object ConstValue { get; set; } 58 | public virtual object GetDefaultConstValue() 59 | { 60 | throw new NotImplementedException(); 61 | } 62 | 63 | #endregion 64 | 65 | public override string GetFailureMessage() 66 | { 67 | var message = GetType().Name + " assertion failed.\n" + go.name + "." + thisPropertyPath + " " + compareToType; 68 | switch (compareToType) 69 | { 70 | case CompareToType.CompareToObject: 71 | message += " (" + other + ")." + otherPropertyPath + " failed."; 72 | break; 73 | case CompareToType.CompareToConstantValue: 74 | message += " " + ConstValue + " failed."; 75 | break; 76 | case CompareToType.CompareToNull: 77 | message += " failed."; 78 | break; 79 | } 80 | message += " Expected: " + m_ObjOtherVal + " Actual: " + m_ObjVal; 81 | return message; 82 | } 83 | } 84 | 85 | [Serializable] 86 | public abstract class ComparerBaseGeneric : ComparerBaseGeneric 87 | { 88 | } 89 | 90 | [Serializable] 91 | public abstract class ComparerBaseGeneric : ComparerBase 92 | { 93 | public T2 constantValueGeneric = default(T2); 94 | 95 | public override Object ConstValue 96 | { 97 | get 98 | { 99 | return constantValueGeneric; 100 | } 101 | set 102 | { 103 | constantValueGeneric = (T2)value; 104 | } 105 | } 106 | 107 | public override Object GetDefaultConstValue() 108 | { 109 | return default(T2); 110 | } 111 | 112 | static bool IsValueType(Type type) 113 | { 114 | #if !UNITY_METRO 115 | return type.IsValueType; 116 | #else 117 | return false; 118 | #endif 119 | } 120 | 121 | protected override bool Compare(object a, object b) 122 | { 123 | var type = typeof(T2); 124 | if (b == null && IsValueType(type)) 125 | { 126 | throw new ArgumentException("Null was passed to a value-type argument"); 127 | } 128 | return Compare((T1)a, (T2)b); 129 | } 130 | 131 | protected abstract bool Compare(T1 a, T2 b); 132 | 133 | public override Type[] GetAccepatbleTypesForA() 134 | { 135 | return new[] { typeof(T1) }; 136 | } 137 | 138 | public override Type[] GetAccepatbleTypesForB() 139 | { 140 | return new[] {typeof(T2)}; 141 | } 142 | 143 | protected override bool UseCache { get { return true; } } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ComparerBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c86508f389d643b40b6e1d7dcc1d4df2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/FloatComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class FloatComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareTypes 10 | { 11 | Equal, 12 | NotEqual, 13 | Greater, 14 | Less 15 | } 16 | 17 | public CompareTypes compareTypes; 18 | public double floatingPointError = 0.0001f; 19 | 20 | protected override bool Compare(float a, float b) 21 | { 22 | switch (compareTypes) 23 | { 24 | case CompareTypes.Equal: 25 | return Math.Abs(a - b) < floatingPointError; 26 | case CompareTypes.NotEqual: 27 | return Math.Abs(a - b) > floatingPointError; 28 | case CompareTypes.Greater: 29 | return a > b; 30 | case CompareTypes.Less: 31 | return a < b; 32 | } 33 | throw new Exception(); 34 | } 35 | public override int GetDepthOfSearch() 36 | { 37 | return 3; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/FloatComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4928c6c2b973874c8d4e6c9a69bb5b4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/GeneralComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class GeneralComparer : ComparerBase 8 | { 9 | public enum CompareType { AEqualsB, ANotEqualsB } 10 | 11 | public CompareType compareType; 12 | 13 | protected override bool Compare(object a, object b) 14 | { 15 | if (compareType == CompareType.AEqualsB) 16 | return a.Equals(b); 17 | if (compareType == CompareType.ANotEqualsB) 18 | return !a.Equals(b); 19 | throw new Exception(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/GeneralComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 902961c69f102f4409c29b9e54258701 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IntComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class IntComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | Equal, 12 | NotEqual, 13 | Greater, 14 | GreaterOrEqual, 15 | Less, 16 | LessOrEqual 17 | }; 18 | 19 | public CompareType compareType; 20 | 21 | protected override bool Compare(int a, int b) 22 | { 23 | switch (compareType) 24 | { 25 | case CompareType.Equal: 26 | return a == b; 27 | case CompareType.NotEqual: 28 | return a != b; 29 | case CompareType.Greater: 30 | return a > b; 31 | case CompareType.GreaterOrEqual: 32 | return a >= b; 33 | case CompareType.Less: 34 | return a < b; 35 | case CompareType.LessOrEqual: 36 | return a <= b; 37 | } 38 | throw new Exception(); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IntComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da4a3a521c5c1494aae123742ca5c8f5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IsRenderedByCamera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class IsRenderedByCamera : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | IsVisible, 12 | IsNotVisible, 13 | }; 14 | 15 | public CompareType compareType; 16 | 17 | protected override bool Compare(Renderer renderer, Camera camera) 18 | { 19 | var planes = GeometryUtility.CalculateFrustumPlanes(camera); 20 | var isVisible = GeometryUtility.TestPlanesAABB(planes, renderer.bounds); 21 | switch (compareType) 22 | { 23 | case CompareType.IsVisible: 24 | return isVisible; 25 | case CompareType.IsNotVisible: 26 | return !isVisible; 27 | } 28 | throw new Exception(); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/IsRenderedByCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d45a1674f5e2e04485eafef922fac41 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/StringComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class StringComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType 10 | { 11 | Equal, 12 | NotEqual, 13 | Shorter, 14 | Longer 15 | } 16 | 17 | public CompareType compareType; 18 | public StringComparison comparisonType = StringComparison.Ordinal; 19 | public bool ignoreCase = false; 20 | 21 | protected override bool Compare(string a, string b) 22 | { 23 | if (ignoreCase) 24 | { 25 | a = a.ToLower(); 26 | b = b.ToLower(); 27 | } 28 | switch (compareType) 29 | { 30 | case CompareType.Equal: 31 | return String.Compare(a, b, comparisonType) == 0; 32 | case CompareType.NotEqual: 33 | return String.Compare(a, b, comparisonType) != 0; 34 | case CompareType.Longer: 35 | return String.Compare(a, b, comparisonType) > 0; 36 | case CompareType.Shorter: 37 | return String.Compare(a, b, comparisonType) < 0; 38 | } 39 | throw new Exception(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/StringComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58783f051e477fd4e93b42ec7a43bb64 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/TransformComparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class TransformComparer : ComparerBaseGeneric 8 | { 9 | public enum CompareType { Equals, NotEquals } 10 | 11 | public CompareType compareType; 12 | 13 | protected override bool Compare(Transform a, Transform b) 14 | { 15 | if (compareType == CompareType.Equals) 16 | { 17 | return a.position == b.position; 18 | } 19 | if (compareType == CompareType.NotEquals) 20 | { 21 | return a.position != b.position; 22 | } 23 | throw new Exception(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/TransformComparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 927f2d7e4f63632448b2a63d480e601a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ValueDoesNotChange.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class ValueDoesNotChange : ActionBase 8 | { 9 | private object m_Value; 10 | 11 | protected override bool Compare(object a) 12 | { 13 | if (m_Value == null) 14 | m_Value = a; 15 | if (!m_Value.Equals(a)) 16 | return false; 17 | return true; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/ValueDoesNotChange.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9d6d16a58a17940419a1dcbff3c60ca5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector2Comparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class Vector2Comparer : VectorComparerBase 8 | { 9 | public enum CompareType 10 | { 11 | MagnitudeEquals, 12 | MagnitudeNotEquals 13 | } 14 | 15 | public CompareType compareType; 16 | public float floatingPointError = 0.0001f; 17 | 18 | protected override bool Compare(Vector2 a, Vector2 b) 19 | { 20 | switch (compareType) 21 | { 22 | case CompareType.MagnitudeEquals: 23 | return AreVectorMagnitudeEqual(a.magnitude, 24 | b.magnitude, floatingPointError); 25 | case CompareType.MagnitudeNotEquals: 26 | return !AreVectorMagnitudeEqual(a.magnitude, 27 | b.magnitude, floatingPointError); 28 | } 29 | throw new Exception(); 30 | } 31 | public override int GetDepthOfSearch() 32 | { 33 | return 3; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector2Comparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a713db190443e814f8254a5a59014ec4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector3Comparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class Vector3Comparer : VectorComparerBase 8 | { 9 | public enum CompareType 10 | { 11 | MagnitudeEquals, 12 | MagnitudeNotEquals 13 | } 14 | 15 | public CompareType compareType; 16 | public double floatingPointError = 0.0001f; 17 | 18 | protected override bool Compare(Vector3 a, Vector3 b) 19 | { 20 | switch (compareType) 21 | { 22 | case CompareType.MagnitudeEquals: 23 | return AreVectorMagnitudeEqual(a.magnitude, 24 | b.magnitude, floatingPointError); 25 | case CompareType.MagnitudeNotEquals: 26 | return !AreVectorMagnitudeEqual(a.magnitude, 27 | b.magnitude, floatingPointError); 28 | } 29 | throw new Exception(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector3Comparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6febd2d5046657040b3da98b7010ee29 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector4Comparer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class Vector4Comparer : VectorComparerBase 8 | { 9 | public enum CompareType 10 | { 11 | MagnitudeEquals, 12 | MagnitudeNotEquals 13 | } 14 | 15 | public CompareType compareType; 16 | public double floatingPointError; 17 | 18 | protected override bool Compare(Vector4 a, Vector4 b) 19 | { 20 | switch (compareType) 21 | { 22 | case CompareType.MagnitudeEquals: 23 | return AreVectorMagnitudeEqual(a.magnitude, 24 | b.magnitude, 25 | floatingPointError); 26 | case CompareType.MagnitudeNotEquals: 27 | return !AreVectorMagnitudeEqual(a.magnitude, 28 | b.magnitude, 29 | floatingPointError); 30 | } 31 | throw new Exception(); 32 | } 33 | public override int GetDepthOfSearch() 34 | { 35 | return 3; 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/Vector4Comparer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 383a85a79f164d04b8a56b0ff4e04cb7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/VectorComparerBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public abstract class VectorComparerBase : ComparerBaseGeneric 8 | { 9 | protected bool AreVectorMagnitudeEqual(float a, float b, double floatingPointError) 10 | { 11 | if (Math.Abs(a) < floatingPointError && Math.Abs(b) < floatingPointError) 12 | return true; 13 | if (Math.Abs(a - b) < floatingPointError) 14 | return true; 15 | return false; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Comparers/VectorComparerBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7b35a237804d5eb42bd8c4e67568ae24 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a28bb39b4fb20514990895d9cb4eaea9 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionComponentEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fd1cabf2c45d0a8489635607a6048621 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionExplorerWindow.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a1e855053e7e2f46ace1dc93f2036f2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionListRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d83c02fb0f220344da42a8213ed36cb5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionStripper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor.Callbacks; 4 | using UnityEngine; 5 | using UnityTest; 6 | using Object = UnityEngine.Object; 7 | 8 | public class AssertionStripper 9 | { 10 | [PostProcessScene] 11 | public static void OnPostprocessScene() 12 | { 13 | if (Debug.isDebugBuild) return; 14 | RemoveAssertionsFromGameObjects(); 15 | } 16 | 17 | private static void RemoveAssertionsFromGameObjects() 18 | { 19 | var allAssertions = Resources.FindObjectsOfTypeAll(typeof(AssertionComponent)) as AssertionComponent[]; 20 | foreach (var assertion in allAssertions) 21 | { 22 | Object.DestroyImmediate(assertion); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/AssertionStripper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 95c9cd9570a6fba4198b6e4f15e11e5e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/DropDownControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | [Serializable] 9 | internal class DropDownControl 10 | { 11 | private readonly GUILayoutOption[] m_ButtonLayoutOptions = { GUILayout.ExpandWidth(true) }; 12 | public Func convertForButtonLabel = s => s.ToString(); 13 | public Func convertForGUIContent = s => s.ToString(); 14 | public Func ignoreConvertForGUIContent = t => t.Length <= 40; 15 | public Action printContextMenu = null; 16 | public string tooltip = ""; 17 | 18 | private object m_SelectedValue; 19 | 20 | 21 | public void Draw(T selected, T[] options, Action onValueSelected) 22 | { 23 | Draw(null, 24 | selected, 25 | options, 26 | onValueSelected); 27 | } 28 | 29 | public void Draw(string label, T selected, T[] options, Action onValueSelected) 30 | { 31 | Draw(label, selected, () => options, onValueSelected); 32 | } 33 | 34 | public void Draw(string label, T selected, Func loadOptions, Action onValueSelected) 35 | { 36 | if (!string.IsNullOrEmpty(label)) 37 | EditorGUILayout.BeginHorizontal(); 38 | var guiContent = new GUIContent(label); 39 | var labelSize = EditorStyles.label.CalcSize(guiContent); 40 | 41 | if (!string.IsNullOrEmpty(label)) 42 | GUILayout.Label(label, EditorStyles.label, GUILayout.Width(labelSize.x)); 43 | 44 | if (GUILayout.Button(new GUIContent(convertForButtonLabel(selected), tooltip), 45 | EditorStyles.popup, m_ButtonLayoutOptions)) 46 | { 47 | if (Event.current.button == 0) 48 | { 49 | PrintMenu(loadOptions()); 50 | } 51 | else if (printContextMenu != null && Event.current.button == 1) 52 | printContextMenu(selected); 53 | } 54 | 55 | if (m_SelectedValue != null) 56 | { 57 | onValueSelected((T)m_SelectedValue); 58 | m_SelectedValue = null; 59 | } 60 | if (!string.IsNullOrEmpty(label)) 61 | EditorGUILayout.EndHorizontal(); 62 | } 63 | 64 | public void PrintMenu(T[] options) 65 | { 66 | var menu = new GenericMenu(); 67 | foreach (var s in options) 68 | { 69 | var localS = s; 70 | menu.AddItem(new GUIContent((ignoreConvertForGUIContent(options) ? localS.ToString() : convertForGUIContent(localS))), 71 | false, 72 | () => { m_SelectedValue = localS; } 73 | ); 74 | } 75 | menu.ShowAsContext(); 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/DropDownControl.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 83ec3ed09f8f2f34ea7483e055f6d76d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByComparerRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByComparerRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | return assertionComponents.GroupBy(c => c.Action.GetType()); 13 | } 14 | 15 | protected override string GetStringKey(Type key) 16 | { 17 | return key.Name; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByComparerRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efab536803bd0154a8a7dc78e8767ad9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByExecutionMethodRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByExecutionMethodRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | var enumVals = Enum.GetValues(typeof(CheckMethod)).Cast(); 13 | var pairs = new List(); 14 | 15 | foreach (var checkMethod in enumVals) 16 | { 17 | var components = assertionComponents.Where(c => (c.checkMethods & checkMethod) == checkMethod); 18 | var componentPairs = components.Select(a => new CheckFunctionAssertionPair {checkMethod = checkMethod, assertionComponent = a}); 19 | pairs.AddRange(componentPairs); 20 | } 21 | return pairs.GroupBy(pair => pair.checkMethod, 22 | pair => pair.assertionComponent); 23 | } 24 | 25 | private class CheckFunctionAssertionPair 26 | { 27 | public AssertionComponent assertionComponent; 28 | public CheckMethod checkMethod; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByExecutionMethodRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 97340abf816b1424fa835a4f26bbdc78 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByGORenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | namespace UnityTest 8 | { 9 | public class GroupByGoRenderer : AssertionListRenderer 10 | { 11 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 12 | { 13 | return assertionComponents.GroupBy(c => c.gameObject); 14 | } 15 | 16 | protected override bool PrintFoldout(bool isFolded, GameObject key) 17 | { 18 | isFolded = base.PrintFoldout(isFolded, 19 | key); 20 | 21 | EditorGUILayout.ObjectField(key, 22 | typeof(GameObject), 23 | true, 24 | GUILayout.ExpandWidth(false)); 25 | 26 | return isFolded; 27 | } 28 | 29 | protected override string GetFoldoutDisplayName(GameObject key) 30 | { 31 | return key.name; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByGORenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb824de9146b42343a985aaf63beffd1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByNothingRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByNothingRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | return assertionComponents.GroupBy(c => ""); 13 | } 14 | 15 | protected override string GetStringKey(string key) 16 | { 17 | return ""; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByNothingRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33bf96aa461ea1d478bb757c52f51c95 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByTestsRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public class GroupByTestsRenderer : AssertionListRenderer 9 | { 10 | protected override IEnumerable> GroupResult(IEnumerable assertionComponents) 11 | { 12 | return assertionComponents.GroupBy(c => 13 | { 14 | var temp = c.transform; 15 | while (temp != null) 16 | { 17 | if (temp.GetComponent("TestComponent") != null) return c.gameObject; 18 | temp = temp.parent.transform; 19 | } 20 | return null; 21 | }); 22 | } 23 | 24 | protected override string GetFoldoutDisplayName(GameObject key) 25 | { 26 | return key.name; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/GroupByTestsRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e577f31e55208b4d8a1774b958e6ed5 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/PropertyPathSelector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6619da1897737044080bdb8bc60eff87 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/Editor/PropertyResolver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbbd193a27920d9478c2a766a7291d72 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/InvalidPathException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class InvalidPathException : Exception 8 | { 9 | public InvalidPathException(string path) 10 | : base("Invalid path part " + path) 11 | { 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/InvalidPathException.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b85786dfd1aef544bf8bb873d6a4ebb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Assertions/MemberResolver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 80df8ef907961e34dbcc7c89b22729b9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a2caba6436df568499c84c1c607ce766 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f4ab061d0035ee545a936bdf8f3f8620 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Icons.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | namespace UnityTest 9 | { 10 | public static class Icons 11 | { 12 | const string k_IconsFolderName = "icons"; 13 | private static readonly string k_IconsFolderPath = String.Format("UnityTestTools{0}Common{0}Editor{0}{1}", Path.DirectorySeparatorChar, k_IconsFolderName); 14 | 15 | private static readonly string k_IconsAssetsPath = ""; 16 | 17 | public static readonly Texture2D FailImg; 18 | public static readonly Texture2D IgnoreImg; 19 | public static readonly Texture2D SuccessImg; 20 | public static readonly Texture2D UnknownImg; 21 | public static readonly Texture2D InconclusiveImg; 22 | public static readonly Texture2D StopwatchImg; 23 | 24 | public static readonly GUIContent GUIUnknownImg; 25 | public static readonly GUIContent GUIInconclusiveImg; 26 | public static readonly GUIContent GUIIgnoreImg; 27 | public static readonly GUIContent GUISuccessImg; 28 | public static readonly GUIContent GUIFailImg; 29 | 30 | static Icons() 31 | { 32 | var dirs = Directory.GetDirectories("Assets", k_IconsFolderName, SearchOption.AllDirectories).Where(s => s.EndsWith(k_IconsFolderPath)); 33 | if (dirs.Any()) 34 | k_IconsAssetsPath = dirs.First(); 35 | else 36 | Debug.LogWarning("The UnityTestTools asset folder path is incorrect. If you relocated the tools please change the path accordingly (Icons.cs)."); 37 | 38 | FailImg = LoadTexture("failed.png"); 39 | IgnoreImg = LoadTexture("ignored.png"); 40 | SuccessImg = LoadTexture("passed.png"); 41 | UnknownImg = LoadTexture("normal.png"); 42 | InconclusiveImg = LoadTexture("inconclusive.png"); 43 | StopwatchImg = LoadTexture("stopwatch.png"); 44 | 45 | GUIUnknownImg = new GUIContent(UnknownImg); 46 | GUIInconclusiveImg = new GUIContent(InconclusiveImg); 47 | GUIIgnoreImg = new GUIContent(IgnoreImg); 48 | GUISuccessImg = new GUIContent(SuccessImg); 49 | GUIFailImg = new GUIContent(FailImg); 50 | } 51 | 52 | private static Texture2D LoadTexture(string fileName) 53 | { 54 | return (Texture2D)Resources.LoadAssetAtPath(k_IconsAssetsPath + Path.DirectorySeparatorChar + fileName, typeof(Texture2D)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Icons.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8571844b0c115b84cbe8b3f67e8dec04 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | namespace UnityTest 9 | { 10 | public abstract class ProjectSettingsBase : ScriptableObject 11 | { 12 | private static readonly string k_SettingsPath = Path.Combine("UnityTestTools", "Common"); 13 | const string k_SettingsFolder = "Settings"; 14 | 15 | public virtual void Save() 16 | { 17 | EditorUtility.SetDirty(this); 18 | } 19 | 20 | public static T Load() where T : ProjectSettingsBase, new () 21 | { 22 | var pathsInProject = Directory.GetDirectories("Assets", "*", SearchOption.AllDirectories) 23 | .Where(s => s.Contains(k_SettingsPath)); 24 | 25 | if (pathsInProject.Count() == 0) Debug.LogError("Can't find settings path: " + k_SettingsPath); 26 | 27 | string pathInProject = Path.Combine(pathsInProject.First(), k_SettingsFolder); 28 | var assetPath = Path.Combine(pathInProject, typeof(T).Name) + ".asset"; 29 | var settings = AssetDatabase.LoadAssetAtPath(assetPath, typeof(T)) as T; 30 | 31 | if (settings != null) return settings; 32 | 33 | settings = CreateInstance(); 34 | Directory.CreateDirectory(pathInProject); 35 | AssetDatabase.CreateAsset(settings, assetPath); 36 | return settings; 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ProjectSettingsBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ac961be07107124a88dcb81927143d4 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ffbf5a07740aa5479651bd415f52ebb 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs: -------------------------------------------------------------------------------- 1 | // **************************************************************** 2 | // Based on nUnit 2.6.2 (http://www.nunit.org/) 3 | // **************************************************************** 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using UnityEngine; 8 | 9 | namespace UnityTest 10 | { 11 | /// 12 | /// Summary description for ResultSummarizer. 13 | /// 14 | public class ResultSummarizer 15 | { 16 | private int m_ErrorCount; 17 | private int m_FailureCount; 18 | private int m_IgnoreCount; 19 | private int m_InconclusiveCount; 20 | private int m_NotRunnable; 21 | private int m_ResultCount; 22 | private int m_SkipCount; 23 | private int m_SuccessCount; 24 | private int m_TestsRun; 25 | 26 | private TimeSpan m_Duration; 27 | 28 | public ResultSummarizer(IEnumerable results) 29 | { 30 | foreach (var result in results) 31 | Summarize(result); 32 | } 33 | 34 | public bool Success 35 | { 36 | get { return m_FailureCount == 0; } 37 | } 38 | 39 | /// 40 | /// Returns the number of test cases for which results 41 | /// have been summarized. Any tests excluded by use of 42 | /// Category or Explicit attributes are not counted. 43 | /// 44 | public int ResultCount 45 | { 46 | get { return m_ResultCount; } 47 | } 48 | 49 | /// 50 | /// Returns the number of test cases actually run, which 51 | /// is the same as ResultCount, less any Skipped, Ignored 52 | /// or NonRunnable tests. 53 | /// 54 | public int TestsRun 55 | { 56 | get { return m_TestsRun; } 57 | } 58 | 59 | /// 60 | /// Returns the number of tests that passed 61 | /// 62 | public int Passed 63 | { 64 | get { return m_SuccessCount; } 65 | } 66 | 67 | /// 68 | /// Returns the number of test cases that had an error. 69 | /// 70 | public int Errors 71 | { 72 | get { return m_ErrorCount; } 73 | } 74 | 75 | /// 76 | /// Returns the number of test cases that failed. 77 | /// 78 | public int Failures 79 | { 80 | get { return m_FailureCount; } 81 | } 82 | 83 | /// 84 | /// Returns the number of test cases that failed. 85 | /// 86 | public int Inconclusive 87 | { 88 | get { return m_InconclusiveCount; } 89 | } 90 | 91 | /// 92 | /// Returns the number of test cases that were not runnable 93 | /// due to errors in the signature of the class or method. 94 | /// Such tests are also counted as Errors. 95 | /// 96 | public int NotRunnable 97 | { 98 | get { return m_NotRunnable; } 99 | } 100 | 101 | /// 102 | /// Returns the number of test cases that were skipped. 103 | /// 104 | public int Skipped 105 | { 106 | get { return m_SkipCount; } 107 | } 108 | 109 | public int Ignored 110 | { 111 | get { return m_IgnoreCount; } 112 | } 113 | 114 | public double Duration 115 | { 116 | get { return m_Duration.TotalSeconds; } 117 | } 118 | 119 | public int TestsNotRun 120 | { 121 | get { return m_SkipCount + m_IgnoreCount + m_NotRunnable; } 122 | } 123 | 124 | public void Summarize(ITestResult result) 125 | { 126 | m_Duration += TimeSpan.FromSeconds(result.Duration); 127 | m_ResultCount++; 128 | 129 | if(!result.Executed) 130 | { 131 | if(result.IsIgnored) 132 | { 133 | m_IgnoreCount++; 134 | return; 135 | } 136 | 137 | m_SkipCount++; 138 | return; 139 | } 140 | 141 | switch (result.ResultState) 142 | { 143 | case TestResultState.Success: 144 | m_SuccessCount++; 145 | m_TestsRun++; 146 | break; 147 | case TestResultState.Failure: 148 | m_FailureCount++; 149 | m_TestsRun++; 150 | break; 151 | case TestResultState.Error: 152 | case TestResultState.Cancelled: 153 | m_ErrorCount++; 154 | m_TestsRun++; 155 | break; 156 | case TestResultState.Inconclusive: 157 | m_InconclusiveCount++; 158 | m_TestsRun++; 159 | break; 160 | case TestResultState.NotRunnable: 161 | m_NotRunnable++; 162 | // errorCount++; 163 | break; 164 | case TestResultState.Ignored: 165 | m_IgnoreCount++; 166 | break; 167 | default: 168 | m_SkipCount++; 169 | break; 170 | } 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/ResultSummarizer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce89106be5bd4204388d58510e4e55da 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/StackTraceFilter.cs: -------------------------------------------------------------------------------- 1 | // **************************************************************** 2 | // Based on nUnit 2.6.2 (http://www.nunit.org/) 3 | // **************************************************************** 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using UnityEngine; 9 | 10 | namespace UnityTest 11 | { 12 | /// 13 | /// Summary description for StackTraceFilter. 14 | /// 15 | public class StackTraceFilter 16 | { 17 | public static string Filter(string stack) 18 | { 19 | if (stack == null) return null; 20 | var sw = new StringWriter(); 21 | var sr = new StringReader(stack); 22 | 23 | try 24 | { 25 | string line; 26 | while ((line = sr.ReadLine()) != null) 27 | { 28 | if (!FilterLine(line)) 29 | sw.WriteLine(line.Trim()); 30 | } 31 | } 32 | catch (Exception) 33 | { 34 | return stack; 35 | } 36 | return sw.ToString(); 37 | } 38 | 39 | static bool FilterLine(string line) 40 | { 41 | string[] patterns = 42 | { 43 | "NUnit.Core.TestCase", 44 | "NUnit.Core.ExpectedExceptionTestCase", 45 | "NUnit.Core.TemplateTestCase", 46 | "NUnit.Core.TestResult", 47 | "NUnit.Core.TestSuite", 48 | "NUnit.Framework.Assertion", 49 | "NUnit.Framework.Assert", 50 | "System.Reflection.MonoMethod" 51 | }; 52 | 53 | for (int i = 0; i < patterns.Length; i++) 54 | { 55 | if (line.IndexOf(patterns[i]) > 0) 56 | return true; 57 | } 58 | 59 | return false; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/StackTraceFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fe6b4d68575d4ba44b1d5c5c3f0e96d3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/ResultWriter/XmlResultWriter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e9bba41ace7686d4ab0c400d1e7f55b7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Styles.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | public static class Styles 9 | { 10 | public static GUIStyle info; 11 | public static GUIStyle testList; 12 | 13 | public static GUIStyle selectedFoldout; 14 | public static GUIStyle foldout; 15 | public static GUIStyle toolbarLabel; 16 | 17 | public static GUIStyle testName; 18 | 19 | private static readonly Color k_SelectedColor = new Color(0.3f, 0.5f, 0.85f); 20 | 21 | static Styles() 22 | { 23 | info = new GUIStyle(EditorStyles.wordWrappedLabel); 24 | info.wordWrap = false; 25 | info.stretchHeight = true; 26 | info.margin.right = 15; 27 | 28 | testList = new GUIStyle("CN Box"); 29 | testList.margin.top = 0; 30 | testList.padding.left = 3; 31 | 32 | foldout = new GUIStyle(EditorStyles.foldout); 33 | selectedFoldout = new GUIStyle(EditorStyles.foldout); 34 | selectedFoldout.onFocused.textColor = selectedFoldout.focused.textColor = 35 | selectedFoldout.onActive.textColor = selectedFoldout.active.textColor = 36 | selectedFoldout.onNormal.textColor = selectedFoldout.normal.textColor = k_SelectedColor; 37 | 38 | toolbarLabel = new GUIStyle(EditorStyles.toolbarButton); 39 | toolbarLabel.normal.background = null; 40 | toolbarLabel.contentOffset = new Vector2(0, -2); 41 | 42 | testName = new GUIStyle(EditorStyles.label); 43 | testName.padding.left += 12; 44 | testName.focused.textColor = testName.onFocused.textColor = k_SelectedColor; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/Styles.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a8b92379e11501742b1badcbb08da812 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | using System.Linq; 6 | 7 | namespace UnityTest 8 | { 9 | public class TestFilterSettings 10 | { 11 | public bool ShowSucceeded; 12 | public bool ShowFailed; 13 | public bool ShowIgnored; 14 | public bool ShowNotRun; 15 | 16 | public string FilterByName; 17 | public int FilterByCategory; 18 | 19 | private GUIContent _succeededBtn; 20 | private GUIContent _failedBtn; 21 | private GUIContent _ignoredBtn; 22 | private GUIContent _notRunBtn; 23 | 24 | public string[] AvailableCategories; 25 | 26 | private readonly string _prefsKey; 27 | 28 | public TestFilterSettings(string prefsKey) 29 | { 30 | _prefsKey = prefsKey; 31 | Load(); 32 | UpdateCounters(Enumerable.Empty()); 33 | } 34 | 35 | public void Load() 36 | { 37 | ShowSucceeded = EditorPrefs.GetBool(_prefsKey + ".ShowSucceeded", true); 38 | ShowFailed = EditorPrefs.GetBool(_prefsKey + ".ShowFailed", true); 39 | ShowIgnored = EditorPrefs.GetBool(_prefsKey + ".ShowIgnored", true); 40 | ShowNotRun = EditorPrefs.GetBool(_prefsKey + ".ShowNotRun", true); 41 | FilterByName = EditorPrefs.GetString(_prefsKey + ".FilterByName", string.Empty); 42 | FilterByCategory = EditorPrefs.GetInt(_prefsKey + ".FilterByCategory", 0); 43 | } 44 | 45 | public void Save() 46 | { 47 | EditorPrefs.SetBool(_prefsKey + ".ShowSucceeded", ShowSucceeded); 48 | EditorPrefs.SetBool(_prefsKey + ".ShowFailed", ShowFailed); 49 | EditorPrefs.SetBool(_prefsKey + ".ShowIgnored", ShowIgnored); 50 | EditorPrefs.SetBool(_prefsKey + ".ShowNotRun", ShowNotRun); 51 | EditorPrefs.SetString(_prefsKey + ".FilterByName", FilterByName); 52 | EditorPrefs.SetInt(_prefsKey + ".FilterByCategory", FilterByCategory); 53 | } 54 | 55 | public void UpdateCounters(IEnumerable results) 56 | { 57 | var summary = new ResultSummarizer(results); 58 | 59 | _succeededBtn = new GUIContent(summary.Passed.ToString(), Icons.SuccessImg, "Show tests that succeeded"); 60 | _failedBtn = new GUIContent((summary.Errors + summary.Failures + summary.Inconclusive).ToString(), Icons.FailImg, "Show tests that failed"); 61 | _ignoredBtn = new GUIContent((summary.Ignored + summary.NotRunnable).ToString(), Icons.IgnoreImg, "Show tests that are ignored"); 62 | _notRunBtn = new GUIContent((summary.TestsNotRun - summary.Ignored - summary.NotRunnable).ToString(), Icons.UnknownImg, "Show tests that didn't run"); 63 | } 64 | 65 | public string[] GetSelectedCategories() 66 | { 67 | if(AvailableCategories == null) return new string[0]; 68 | 69 | return AvailableCategories.Where ((c, i) => (FilterByCategory & (1 << i)) != 0).ToArray(); 70 | } 71 | 72 | public void OnGUI() 73 | { 74 | EditorGUI.BeginChangeCheck(); 75 | 76 | FilterByName = GUILayout.TextField(FilterByName, "ToolbarSeachTextField", GUILayout.MinWidth(100), GUILayout.MaxWidth(250), GUILayout.ExpandWidth(true)); 77 | if(GUILayout.Button (GUIContent.none, string.IsNullOrEmpty(FilterByName) ? "ToolbarSeachCancelButtonEmpty" : "ToolbarSeachCancelButton")) 78 | FilterByName = string.Empty; 79 | 80 | if (AvailableCategories != null && AvailableCategories.Length > 0) 81 | FilterByCategory = EditorGUILayout.MaskField(FilterByCategory, AvailableCategories, EditorStyles.toolbarDropDown, GUILayout.MaxWidth(90)); 82 | 83 | ShowSucceeded = GUILayout.Toggle(ShowSucceeded, _succeededBtn, EditorStyles.toolbarButton); 84 | ShowFailed = GUILayout.Toggle(ShowFailed, _failedBtn, EditorStyles.toolbarButton); 85 | ShowIgnored = GUILayout.Toggle(ShowIgnored, _ignoredBtn, EditorStyles.toolbarButton); 86 | ShowNotRun = GUILayout.Toggle(ShowNotRun, _notRunBtn, EditorStyles.toolbarButton); 87 | 88 | if(EditorGUI.EndChangeCheck()) Save (); 89 | } 90 | 91 | public RenderingOptions BuildRenderingOptions() 92 | { 93 | var options = new RenderingOptions(); 94 | options.showSucceeded = ShowSucceeded; 95 | options.showFailed = ShowFailed; 96 | options.showIgnored = ShowIgnored; 97 | options.showNotRunned = ShowNotRun; 98 | options.nameFilter = FilterByName; 99 | options.categories = GetSelectedCategories(); 100 | return options; 101 | } 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/TestFilterSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a2d025e58bff433e963d0a4cd7599ef 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8bb6eae11352f44da0d6d8a8959b69e 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/failed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Editor/icons/failed.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/failed.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 41488feb372865440b7c01773f04c0cf 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/ignored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Editor/icons/ignored.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/ignored.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0076bfa6073f17546b3535ac1b456b0b 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/inconclusive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Editor/icons/inconclusive.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/inconclusive.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e28761099904678488cdddf7b6be2ceb 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Editor/icons/normal.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/normal.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9f3c491f4c2f9f43ac33a27c16913dd 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/passed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Editor/icons/passed.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/passed.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31f7928179ee46d4690d274579efb037 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/stopwatch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Editor/icons/stopwatch.png -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Editor/icons/stopwatch.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f73f95ae19d51af47ad56044f2779aa1 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 1 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 1024 26 | textureSettings: 27 | filterMode: -1 28 | aniso: 1 29 | mipBias: -1 30 | wrapMode: 1 31 | nPOTScale: 0 32 | lightmap: 0 33 | compressionQuality: 50 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 1 42 | textureType: 2 43 | buildTargetSettings: [] 44 | spriteSheet: 45 | sprites: [] 46 | spritePackingTag: 47 | userData: 48 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/ITestResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityTest; 5 | 6 | public interface ITestResult 7 | { 8 | TestResultState ResultState { get; } 9 | 10 | string Message { get; } 11 | 12 | string Logs { get; } 13 | 14 | bool Executed { get; } 15 | 16 | string Name { get; } 17 | 18 | string FullName { get; } 19 | 20 | string Id { get; } 21 | 22 | bool IsSuccess { get; } 23 | 24 | double Duration { get; } 25 | 26 | string StackTrace { get; } 27 | 28 | bool IsIgnored { get; } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/ITestResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1e4e2c4d00b3f2469494fc0f67cdeae 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Settings.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74b1838ae1671a340925825369784f8f 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Settings/UnitTestsRunnerSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/Common/Settings/UnitTestsRunnerSettings.asset -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/Settings/UnitTestsRunnerSettings.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 252c3f12987dc194687d83b55ee2eb40 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/TestResultState.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public enum TestResultState : byte 8 | { 9 | Inconclusive = 0, 10 | 11 | /// 12 | /// The test was not runnable. 13 | /// 14 | NotRunnable = 1, 15 | 16 | /// 17 | /// The test has been skipped. 18 | /// 19 | Skipped = 2, 20 | 21 | /// 22 | /// The test has been ignored. 23 | /// 24 | Ignored = 3, 25 | 26 | /// 27 | /// The test succeeded 28 | /// 29 | Success = 4, 30 | 31 | /// 32 | /// The test failed 33 | /// 34 | Failure = 5, 35 | 36 | /// 37 | /// The test encountered an unexpected exception 38 | /// 39 | Error = 6, 40 | 41 | /// 42 | /// The test was cancelled by the user 43 | /// 44 | Cancelled = 7 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/Common/TestResultState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da3ca54ee4cce064989d27165f3081fb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/LICENSE.txt -------------------------------------------------------------------------------- /Assets/UnityTestTools/LICENSE.txt.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d5b4501bf773f349ad95ec34491dc61 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a87f1db904f1e948a2385ab9961e3aa 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59b47eb3fc62eb44cb73a329a1e6b6cb 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/Batch.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using UnityEditor; 6 | using UnityEngine; 7 | using UnityTest.UnitTestRunner; 8 | 9 | namespace UnityTest 10 | { 11 | public static partial class Batch 12 | { 13 | const string k_ResultFilePathParam = "-resultFilePath="; 14 | const string k_TestFilterParam = "-filter="; 15 | const string k_CategoryParam = "-categories="; 16 | const string k_DefaultResultFileName = "UnitTestResults.xml"; 17 | 18 | public static int returnCodeTestsOk = 0; 19 | public static int returnCodeTestsFailed = 2; 20 | public static int returnCodeRunError = 3; 21 | 22 | public static void RunUnitTests() 23 | { 24 | PlayerSettings.useMacAppStoreValidation = false; 25 | var filter = GetTestFilter(); 26 | var resultFilePath = GetParameterArgument(k_ResultFilePathParam) ?? Directory.GetCurrentDirectory(); 27 | if (Directory.Exists(resultFilePath)) 28 | resultFilePath = Path.Combine(resultFilePath, k_DefaultResultFileName); 29 | EditorApplication.NewScene(); 30 | var engine = new NUnitTestEngine(); 31 | UnitTestResult[] results; 32 | string[] categories; 33 | engine.GetTests(out results, out categories); 34 | engine.RunTests(filter, new TestRunnerEventListener(resultFilePath, results.ToList())); 35 | } 36 | 37 | private static TestFilter GetTestFilter() 38 | { 39 | var testFilterArg = GetParameterArgumentArray(k_TestFilterParam); 40 | var testCategoryArg = GetParameterArgumentArray(k_CategoryParam); 41 | var filter = new TestFilter 42 | { 43 | names = testFilterArg, 44 | categories = testCategoryArg 45 | }; 46 | return filter; 47 | } 48 | 49 | private static string[] GetParameterArgumentArray(string parameterName) 50 | { 51 | var arg = GetParameterArgument(parameterName); 52 | if (string.IsNullOrEmpty(arg)) return null; 53 | return arg.Split(',').Select(s => s.Trim()).ToArray(); 54 | } 55 | 56 | private static string GetParameterArgument(string parameterName) 57 | { 58 | foreach (var arg in Environment.GetCommandLineArgs()) 59 | { 60 | if (arg.ToLower().StartsWith(parameterName.ToLower())) 61 | { 62 | return arg.Substring(parameterName.Length); 63 | } 64 | } 65 | return null; 66 | } 67 | 68 | private class TestRunnerEventListener : ITestRunnerCallback 69 | { 70 | private readonly string m_ResultFilePath; 71 | private readonly List m_Results; 72 | 73 | public TestRunnerEventListener(string resultFilePath, List resultList) 74 | { 75 | m_ResultFilePath = resultFilePath; 76 | m_Results = resultList; 77 | } 78 | 79 | public void TestFinished(ITestResult test) 80 | { 81 | m_Results.Single(r => r.Id == test.Id).Update(test, false); 82 | } 83 | 84 | public void RunFinished() 85 | { 86 | var resultDestiantion = Application.dataPath; 87 | if (!string.IsNullOrEmpty(m_ResultFilePath)) 88 | resultDestiantion = m_ResultFilePath; 89 | var fileName = Path.GetFileName(resultDestiantion); 90 | if (!string.IsNullOrEmpty(fileName)) 91 | resultDestiantion = resultDestiantion.Substring(0, resultDestiantion.Length - fileName.Length); 92 | else 93 | fileName = "UnitTestResults.xml"; 94 | #if !UNITY_METRO 95 | var resultWriter = new XmlResultWriter("Unit Tests", "Editor", m_Results.ToArray()); 96 | resultWriter.WriteToFile(resultDestiantion, fileName); 97 | #endif 98 | var executed = m_Results.Where(result => result.Executed); 99 | if (!executed.Any()) 100 | { 101 | EditorApplication.Exit(returnCodeRunError); 102 | return; 103 | } 104 | var failed = executed.Where(result => !result.IsSuccess); 105 | EditorApplication.Exit(failed.Any() ? returnCodeTestsFailed : returnCodeTestsOk); 106 | } 107 | 108 | public void TestStarted(string fullName) 109 | { 110 | } 111 | 112 | public void RunStarted(string suiteName, int testCount) 113 | { 114 | } 115 | 116 | public void RunFinishedException(Exception exception) 117 | { 118 | EditorApplication.Exit(returnCodeRunError); 119 | throw exception; 120 | } 121 | } 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/Batch.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5401885870ebec84f8e9c6ee18d79695 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NSubstitute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92b38897656771f409e9235955975754 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NSubstitute/NSubstitute.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/UnitTesting/Editor/NSubstitute/NSubstitute.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NSubstitute/NSubstitute.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c5e1afc6e0d68849ae6639aff58cfc7 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a92d914a774b29f42906161a387d79f7 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e22ba039de7077c4aa95758ef723b803 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/Mono.Cecil.Mdb.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/Mono.Cecil.Mdb.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/Mono.Cecil.Mdb.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96c89cba541e8fa41acc13fcc8382878 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/Mono.Cecil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/Mono.Cecil.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/Mono.Cecil.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f8f4181eb51beb043a92433b1c807529 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.core.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.core.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8950b8b4aa418a458a503526c8a2f65 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.core.interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.core.interfaces.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.core.interfaces.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef8ce5f8e3e580349ac63ac38e87ee2f 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.framework.dll -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Libs/nunit.framework.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f54558e884607254ca91abc9038ac749 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f94e120956782c5498f559719ff38f2a 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/GroupLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using NUnit.Core; 5 | using UnityEditor; 6 | using UnityEngine; 7 | using Event = UnityEngine.Event; 8 | 9 | namespace UnityTest 10 | { 11 | public class GroupLine : UnitTestRendererLine 12 | { 13 | public static List FoldMarkers; 14 | 15 | protected static GUIContent s_GUIExpandAll = new GUIContent("Expand all"); 16 | protected static GUIContent s_GUICollapseAll = new GUIContent("Collapse all"); 17 | private readonly List m_Children = new List(); 18 | 19 | public GroupLine(TestSuite suite) 20 | : base(suite) 21 | { 22 | if (suite is NamespaceSuite) m_RenderedName = m_FullName; 23 | } 24 | 25 | private bool Folded 26 | { 27 | get { return FoldMarkers.Contains(m_FullName); } 28 | 29 | set 30 | { 31 | if (value) 32 | FoldMarkers.Add(m_FullName); 33 | else 34 | FoldMarkers.RemoveAll(s => s == m_FullName); 35 | } 36 | } 37 | 38 | public void AddChildren(UnitTestRendererLine[] children) 39 | { 40 | m_Children.AddRange(children); 41 | } 42 | 43 | protected internal override void Render(int indend, RenderingOptions options) 44 | { 45 | if (!AnyVisibleChildren(options)) return; 46 | base.Render(indend, options); 47 | if (!Folded) 48 | foreach (var child in m_Children) 49 | child.Render(indend + 1, options); 50 | } 51 | 52 | private bool AnyVisibleChildren(RenderingOptions options) 53 | { 54 | return m_Children.Any(l => l.IsVisible(options)); 55 | } 56 | 57 | protected internal override bool IsVisible(RenderingOptions options) 58 | { 59 | return AnyVisibleChildren(options); 60 | } 61 | 62 | protected override void DrawLine(bool isSelected, RenderingOptions options) 63 | { 64 | var resultIcon = GetResult().HasValue ? GuiHelper.GetIconForResult(GetResult().Value) : Icons.UnknownImg; 65 | 66 | var guiContent = new GUIContent(m_RenderedName, resultIcon, m_FullName); 67 | 68 | var rect = GUILayoutUtility.GetRect(guiContent, Styles.foldout, GUILayout.MaxHeight(16)); 69 | 70 | OnLeftMouseButtonClick(rect); 71 | OnContextClick(rect); 72 | 73 | EditorGUI.BeginChangeCheck(); 74 | var expanded = !EditorGUI.Foldout(rect, !Folded, guiContent, false, isSelected ? Styles.selectedFoldout : Styles.foldout); 75 | if (EditorGUI.EndChangeCheck()) Folded = expanded; 76 | } 77 | 78 | protected internal override TestResultState ? GetResult() 79 | { 80 | TestResultState? tempResult = null; 81 | 82 | foreach (var child in m_Children) 83 | { 84 | var childResultState = child.GetResult(); 85 | 86 | if (childResultState == TestResultState.Failure || childResultState == TestResultState.Error) 87 | { 88 | tempResult = TestResultState.Failure; 89 | break; 90 | } 91 | if (childResultState == TestResultState.Success) 92 | tempResult = TestResultState.Success; 93 | else if (childResultState == TestResultState.Ignored) 94 | tempResult = TestResultState.Ignored; 95 | } 96 | if (tempResult.HasValue) return tempResult.Value; 97 | 98 | return null; 99 | } 100 | 101 | private void OnLeftMouseButtonClick(Rect rect) 102 | { 103 | if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.mouseDown && Event.current.button == 0) 104 | { 105 | OnSelect(); 106 | } 107 | } 108 | 109 | private void OnContextClick(Rect rect) 110 | { 111 | if (rect.Contains(Event.current.mousePosition) && Event.current.type == EventType.ContextClick) 112 | { 113 | PrintGroupContextMenu(); 114 | } 115 | } 116 | 117 | private void PrintGroupContextMenu() 118 | { 119 | var multilineSelection = SelectedLines.Count() > 1; 120 | var m = new GenericMenu(); 121 | if (multilineSelection) 122 | { 123 | m.AddItem(s_GUIRunSelected, 124 | false, 125 | data => RunTests(SelectedLines.Select(line => line.m_Test.TestName).ToArray()), 126 | ""); 127 | } 128 | if (!string.IsNullOrEmpty(m_FullName)) 129 | { 130 | m.AddItem(s_GUIRun, 131 | false, 132 | data => RunTests(new[] { m_Test.TestName }), 133 | ""); 134 | } 135 | if (!multilineSelection) 136 | { 137 | m.AddSeparator(""); 138 | 139 | m.AddItem(Folded ? s_GUIExpandAll : s_GUICollapseAll, 140 | false, 141 | data => ExpandOrCollapseAll(Folded), 142 | ""); 143 | } 144 | m.ShowAsContext(); 145 | } 146 | 147 | private void ExpandOrCollapseAll(bool expand) 148 | { 149 | Folded = !expand; 150 | foreach (var child in m_Children) 151 | { 152 | if (child is GroupLine) (child as GroupLine).ExpandOrCollapseAll(expand); 153 | } 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/GroupLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4fcef1ec40255f14d827da8b0d742334 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/RenderingOptions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public class RenderingOptions 8 | { 9 | public string nameFilter; 10 | public bool showSucceeded; 11 | public bool showFailed; 12 | public bool showIgnored; 13 | public bool showNotRunned; 14 | public string[] categories; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/RenderingOptions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c0aec4b4a6d1b047a98e8cc213e1a36 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/TestLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cfe0c7d95a79d374e9121633c719241e 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/UnitTestRendererLine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using NUnit.Core; 5 | using UnityEditor; 6 | using UnityEngine; 7 | using Event = UnityEngine.Event; 8 | 9 | namespace UnityTest 10 | { 11 | public abstract class UnitTestRendererLine : IComparable 12 | { 13 | public static Action RunTest; 14 | public static List SelectedLines; 15 | 16 | protected static bool s_Refresh; 17 | 18 | protected static GUIContent s_GUIRunSelected = new GUIContent("Run Selected"); 19 | protected static GUIContent s_GUIRun = new GUIContent("Run"); 20 | protected static GUIContent s_GUITimeoutIcon = new GUIContent(Icons.StopwatchImg, "Timeout"); 21 | 22 | protected string m_UniqueId; 23 | protected internal string m_FullName; 24 | protected string m_RenderedName; 25 | protected internal Test m_Test; 26 | 27 | protected UnitTestRendererLine(Test test) 28 | { 29 | m_FullName = test.TestName.FullName; 30 | m_RenderedName = test.TestName.Name; 31 | m_UniqueId = test.TestName.UniqueName; 32 | 33 | m_Test = test; 34 | } 35 | 36 | public int CompareTo(UnitTestRendererLine other) 37 | { 38 | return m_UniqueId.CompareTo(other.m_UniqueId); 39 | } 40 | 41 | public bool Render(RenderingOptions options) 42 | { 43 | s_Refresh = false; 44 | EditorGUIUtility.SetIconSize(new Vector2(15, 15)); 45 | Render(0, options); 46 | EditorGUIUtility.SetIconSize(Vector2.zero); 47 | return s_Refresh; 48 | } 49 | 50 | protected internal virtual void Render(int indend, RenderingOptions options) 51 | { 52 | EditorGUILayout.BeginHorizontal(); 53 | GUILayout.Space(indend * 10); 54 | DrawLine(SelectedLines.Contains(this), options); 55 | EditorGUILayout.EndHorizontal(); 56 | } 57 | 58 | protected void OnSelect() 59 | { 60 | if (!Event.current.control && !Event.current.command) SelectedLines.Clear(); 61 | 62 | if ((Event.current.control || Event.current.command) && SelectedLines.Contains(this)) 63 | SelectedLines.Remove(this); 64 | else 65 | SelectedLines.Add(this); 66 | s_Refresh = true; 67 | } 68 | 69 | protected abstract void DrawLine(bool isSelected, RenderingOptions options); 70 | protected internal abstract TestResultState ? GetResult(); 71 | protected internal abstract bool IsVisible(RenderingOptions options); 72 | 73 | public void RunTests(object[] testObjectsList) 74 | { 75 | RunTest(new TestFilter { objects = testObjectsList }); 76 | } 77 | 78 | public void RunTests(string[] testList) 79 | { 80 | RunTest(new TestFilter {names = testList}); 81 | } 82 | 83 | public void RunSelectedTests() 84 | { 85 | RunTest(new TestFilter { objects = SelectedLines.Select(line => line.m_Test.TestName).ToArray() }); 86 | } 87 | 88 | public bool IsAnySelected 89 | { 90 | get 91 | { 92 | return SelectedLines.Count > 0; 93 | } 94 | } 95 | 96 | public virtual string GetResultText() 97 | { 98 | return m_RenderedName; 99 | } 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/NUnit/Renderer/UnitTestRendererLine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fddb568bfa3ed03438d5c482ea8c6aea 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 615921b0760fc0c4eaf10b7c88add37b 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/BackgroundRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEditor; 4 | using UnityEngine; 5 | 6 | namespace UnityTest 7 | { 8 | [InitializeOnLoad] 9 | public partial class UnitTestView 10 | { 11 | static UnitTestView() 12 | { 13 | if (s_Instance != null && s_Instance.m_Settings.runOnRecompilation) 14 | EnableBackgroundRunner(true); 15 | } 16 | 17 | #region Background runner 18 | 19 | private static float s_NextCheck; 20 | const string k_UttRecompile = "UTT-recompile"; 21 | 22 | public static void EnableBackgroundRunner(bool enable) 23 | { 24 | EditorApplication.update -= BackgroudRunner; 25 | 26 | if (enable) 27 | { 28 | EditorApplication.update += BackgroudRunner; 29 | s_NextCheck = 0; 30 | } 31 | } 32 | 33 | private static void BackgroudRunner() 34 | { 35 | if (EditorApplication.isPlayingOrWillChangePlaymode) return; 36 | if (!s_Instance.m_Settings.runOnRecompilation) EnableBackgroundRunner(false); 37 | if (EditorApplication.isCompiling) 38 | { 39 | EditorPrefs.SetString(k_UttRecompile, Application.dataPath); 40 | EditorApplication.update -= BackgroudRunner; 41 | return; 42 | } 43 | 44 | var t = Time.realtimeSinceStartup; 45 | if (t < s_NextCheck) return; 46 | s_NextCheck = t + 0.5f; 47 | 48 | if (EditorPrefs.HasKey(k_UttRecompile)) 49 | { 50 | var recompile = EditorPrefs.GetString(k_UttRecompile); 51 | if (recompile == Application.dataPath) 52 | { 53 | s_Instance.RunTests(); 54 | s_Instance.Repaint(); 55 | } 56 | EditorPrefs.DeleteKey(k_UttRecompile); 57 | s_NextCheck = 0; 58 | } 59 | } 60 | #endregion 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/BackgroundRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0ef055bc08798f448b1adba9948e351 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/GuiHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b0b95014154ef554485afc9c0316556d 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/ITestRunnerCallback.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest.UnitTestRunner 6 | { 7 | public interface ITestRunnerCallback 8 | { 9 | void TestStarted(string fullName); 10 | void TestFinished(ITestResult fullName); 11 | void RunStarted(string suiteName, int testCount); 12 | void RunFinished(); 13 | void RunFinishedException(Exception exception); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/ITestRunnerCallback.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45a983e950f22034ba987c6db2a8b216 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/IUnitTestEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityTest.UnitTestRunner; 5 | 6 | namespace UnityTest 7 | { 8 | public interface IUnitTestEngine 9 | { 10 | UnitTestRendererLine GetTests(out UnitTestResult[] results, out string[] categories); 11 | void RunTests(TestFilter filter, ITestRunnerCallback testRunnerEventListener); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/IUnitTestEngine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96615b7fd2cb32b4dbea04d84cc3f7fb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitExtensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | public static class NUnitExtensions 8 | { 9 | public static UnitTestResult UnitTestResult(this NUnit.Core.TestResult result, string logs) 10 | { 11 | return new UnitTestResult 12 | { 13 | Executed = result.Executed, 14 | ResultState = (TestResultState)result.ResultState, 15 | Message = result.Message, 16 | Logs = logs, 17 | StackTrace = result.StackTrace, 18 | Duration = result.Time, 19 | Test = new UnitTestInfo(result.Test.TestName.TestID.ToString()), 20 | IsIgnored = (result.ResultState == NUnit.Core.ResultState.Ignored) || result.Test.RunState == NUnit.Core.RunState.Ignored 21 | }; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitExtensions.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7df86c5f85b0f7d4096d6bc23e9a4e01 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/NUnitTestEngine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f313d48559bf30145b88ef7f173685c9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunner.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEditor; 5 | using UnityEngine; 6 | using UnityTest.UnitTestRunner; 7 | 8 | namespace UnityTest 9 | { 10 | public partial class UnitTestView 11 | { 12 | private void UpdateTestInfo(ITestResult result) 13 | { 14 | FindTestResult(result.Id).Update(result, false); 15 | m_FilterSettings.UpdateCounters(m_ResultList.Cast()); 16 | } 17 | 18 | private UnitTestResult FindTestResult(string resultId) 19 | { 20 | var idx = m_ResultList.FindIndex(testResult => testResult.Id == resultId); 21 | if (idx == -1) 22 | { 23 | Debug.LogWarning("Id not found for test: " + resultId); 24 | return null; 25 | } 26 | return m_ResultList.ElementAt(idx); 27 | } 28 | 29 | private void RunTests() 30 | { 31 | var filter = new TestFilter(); 32 | var categories = m_FilterSettings.GetSelectedCategories(); 33 | if (categories != null && categories.Length > 0) 34 | filter.categories = categories; 35 | RunTests(filter); 36 | } 37 | 38 | private void RunTests(TestFilter filter) 39 | { 40 | if (m_Settings.runTestOnANewScene) 41 | { 42 | if (m_Settings.autoSaveSceneBeforeRun) EditorApplication.SaveScene(); 43 | if (!EditorApplication.SaveCurrentSceneIfUserWantsTo()) return; 44 | } 45 | 46 | string currentScene = null; 47 | int undoGroup = -1; 48 | if (m_Settings.runTestOnANewScene) 49 | currentScene = OpenNewScene(); 50 | else 51 | undoGroup = RegisterUndo(); 52 | 53 | StartTestRun(filter, new TestRunnerEventListener(UpdateTestInfo)); 54 | 55 | if (m_Settings.runTestOnANewScene) 56 | LoadPreviousScene(currentScene); 57 | else 58 | PerformUndo(undoGroup); 59 | } 60 | 61 | private string OpenNewScene() 62 | { 63 | var currentScene = EditorApplication.currentScene; 64 | if (m_Settings.runTestOnANewScene) 65 | EditorApplication.NewScene(); 66 | return currentScene; 67 | } 68 | 69 | private void LoadPreviousScene(string currentScene) 70 | { 71 | if (!string.IsNullOrEmpty(currentScene)) 72 | EditorApplication.OpenScene(currentScene); 73 | else 74 | EditorApplication.NewScene(); 75 | 76 | if (Event.current != null) 77 | GUIUtility.ExitGUI(); 78 | } 79 | 80 | public void StartTestRun(TestFilter filter, ITestRunnerCallback eventListener) 81 | { 82 | var callbackList = new TestRunnerCallbackList(); 83 | if (eventListener != null) callbackList.Add(eventListener); 84 | k_TestEngine.RunTests(filter, callbackList); 85 | } 86 | 87 | private static int RegisterUndo() 88 | { 89 | #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 90 | Undo.RegisterSceneUndo("UnitTestRunSceneSave"); 91 | return -1; 92 | #else 93 | return Undo.GetCurrentGroup(); 94 | #endif 95 | } 96 | 97 | private static void PerformUndo(int undoGroup) 98 | { 99 | EditorUtility.DisplayProgressBar("Undo", "Reverting changes to the scene", 0); 100 | var undoStartTime = DateTime.Now; 101 | #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 102 | Undo.PerformUndo(); 103 | #else 104 | Undo.RevertAllDownToGroup(undoGroup); 105 | #endif 106 | if ((DateTime.Now - undoStartTime).Seconds > 1) 107 | Debug.LogWarning("Undo after unit test run took " + (DateTime.Now - undoStartTime).Seconds + " seconds. Consider running unit tests on a new scene for better performance."); 108 | EditorUtility.ClearProgressBar(); 109 | } 110 | 111 | public class TestRunnerEventListener : ITestRunnerCallback 112 | { 113 | private readonly Action m_UpdateCallback; 114 | 115 | public TestRunnerEventListener(Action updateCallback) 116 | { 117 | m_UpdateCallback = updateCallback; 118 | } 119 | 120 | public void TestStarted(string fullName) 121 | { 122 | EditorUtility.DisplayProgressBar("Unit Tests Runner", fullName, 1); 123 | } 124 | 125 | public void TestFinished(ITestResult result) 126 | { 127 | m_UpdateCallback(result); 128 | } 129 | 130 | public void RunStarted(string suiteName, int testCount) 131 | { 132 | } 133 | 134 | public void RunFinished() 135 | { 136 | EditorUtility.ClearProgressBar(); 137 | } 138 | 139 | public void RunFinishedException(Exception exception) 140 | { 141 | RunFinished(); 142 | } 143 | } 144 | 145 | [MenuItem("Unity Test Tools/Unit Test Runner %#&u")] 146 | public static void ShowWindow() 147 | { 148 | GetWindow(typeof(UnitTestView)).Show(); 149 | } 150 | } 151 | 152 | public class TestFilter 153 | { 154 | public string[] names; 155 | public string[] categories; 156 | public object[] objects; 157 | public static TestFilter Empty = new TestFilter(); 158 | } 159 | } 160 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbf567afda42eec43a7dbb052d318076 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunnerCallbackList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest.UnitTestRunner 6 | { 7 | public class TestRunnerCallbackList : ITestRunnerCallback 8 | { 9 | private readonly List m_CallbackList = new List(); 10 | 11 | public void TestStarted(string fullName) 12 | { 13 | foreach (var unitTestRunnerCallback in m_CallbackList) 14 | { 15 | unitTestRunnerCallback.TestStarted(fullName); 16 | } 17 | } 18 | 19 | public void TestFinished(ITestResult fullName) 20 | { 21 | foreach (var unitTestRunnerCallback in m_CallbackList) 22 | { 23 | unitTestRunnerCallback.TestFinished(fullName); 24 | } 25 | } 26 | 27 | public void RunStarted(string suiteName, int testCount) 28 | { 29 | foreach (var unitTestRunnerCallback in m_CallbackList) 30 | { 31 | unitTestRunnerCallback.RunStarted(suiteName, 32 | testCount); 33 | } 34 | } 35 | 36 | public void RunFinished() 37 | { 38 | foreach (var unitTestRunnerCallback in m_CallbackList) 39 | { 40 | unitTestRunnerCallback.RunFinished(); 41 | } 42 | } 43 | 44 | public void RunFinishedException(Exception exception) 45 | { 46 | foreach (var unitTestRunnerCallback in m_CallbackList) 47 | { 48 | unitTestRunnerCallback.RunFinishedException(exception); 49 | } 50 | } 51 | 52 | public void Add(ITestRunnerCallback callback) 53 | { 54 | m_CallbackList.Add(callback); 55 | } 56 | 57 | public void Remove(ITestRunnerCallback callback) 58 | { 59 | m_CallbackList.Remove(callback); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/TestRunnerCallbackList.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7a6cf1b9d1273d4187ba9d5bc91fc30 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text.RegularExpressions; 6 | using NUnit.Core; 7 | using UnityEngine; 8 | using Object = System.Object; 9 | 10 | namespace UnityTest 11 | { 12 | [Serializable] 13 | public class UnitTestInfo 14 | { 15 | public string ParamName { get; private set; } 16 | public string MethodName { get; private set; } 17 | public string FullMethodName { get; private set; } 18 | public string ClassName { get; private set; } 19 | public string FullClassName { get; private set; } 20 | public string Namespace { get; private set; } 21 | public string FullName { get; private set; } 22 | public string[] Categories { get; private set; } 23 | public string AssemblyPath { get; private set; } 24 | public string Id { get; private set; } 25 | public bool IsIgnored { get; private set; } 26 | 27 | public UnitTestInfo(TestMethod testMethod) 28 | { 29 | if (testMethod == null) 30 | throw new ArgumentException(); 31 | 32 | MethodName = testMethod.MethodName; 33 | FullMethodName = testMethod.Method.ToString(); 34 | ClassName = testMethod.FixtureType.Name; 35 | FullClassName = testMethod.ClassName; 36 | Namespace = testMethod.Method.ReflectedType.Namespace; 37 | FullName = testMethod.TestName.FullName; 38 | ParamName = ExtractMethodCallParametersString(FullName); 39 | Id = testMethod.TestName.TestID.ToString(); 40 | 41 | Categories = testMethod.Categories.Cast().ToArray(); 42 | 43 | AssemblyPath = GetAssemblyPath(testMethod); 44 | 45 | IsIgnored = (testMethod.RunState == RunState.Ignored); 46 | } 47 | 48 | private string GetAssemblyPath(TestMethod testMethod) 49 | { 50 | var parent = testMethod as Test; 51 | var assemblyPath = ""; 52 | while (parent != null) 53 | { 54 | parent = parent.Parent; 55 | if (!(parent is TestAssembly)) continue; 56 | var path = (parent as TestAssembly).TestName.FullName; 57 | if (!File.Exists(path)) continue; 58 | assemblyPath = path; 59 | break; 60 | } 61 | return assemblyPath; 62 | } 63 | 64 | public UnitTestInfo(string id) 65 | { 66 | Id = id; 67 | } 68 | 69 | public override bool Equals(Object obj) 70 | { 71 | if (!(obj is UnitTestInfo)) return false; 72 | 73 | var testInfo = (UnitTestInfo)obj; 74 | return Id == testInfo.Id; 75 | } 76 | 77 | public static bool operator ==(UnitTestInfo a, UnitTestInfo b) 78 | { 79 | if (((object)a == null) || ((object)b == null)) return false; 80 | return a.Id == b.Id; 81 | } 82 | 83 | public static bool operator !=(UnitTestInfo a, UnitTestInfo b) 84 | { 85 | return !(a == b); 86 | } 87 | 88 | public override int GetHashCode() 89 | { 90 | return Id.GetHashCode(); 91 | } 92 | 93 | static string ExtractMethodCallParametersString(string methodFullName) 94 | { 95 | var match = Regex.Match(methodFullName, @"\((.*)\)"); 96 | string result = ""; 97 | if (match.Groups[1].Success) 98 | { 99 | result = match.Groups[1].Captures[0].Value; 100 | } 101 | return result; 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestInfo.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39d532431356ff74cb5a51afef8cc308 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | [Serializable] 8 | public class UnitTestResult : ITestResult 9 | { 10 | public bool Executed { get; set; } 11 | public string Name { get { return Test.MethodName; } } 12 | public string FullName { get { return Test.FullName; } } 13 | public TestResultState ResultState { get; set; } 14 | public UnitTestInfo Test { get; set; } 15 | public string Id { get { return Test.Id; } } 16 | public double Duration { get; set; } 17 | public string Message { get; set; } 18 | public string StackTrace { get; set; } 19 | public bool IsIgnored { get; set; } 20 | 21 | public string Logs { get; set; } 22 | 23 | public bool Outdated { get; set; } 24 | 25 | public void Update(ITestResult source, bool outdated) 26 | { 27 | ResultState = source.ResultState; 28 | Duration = source.Duration; 29 | Message = source.Message; 30 | Logs = source.Logs; 31 | StackTrace = source.StackTrace; 32 | Executed = source.Executed; 33 | IsIgnored = source.IsIgnored || (Test != null && Test.IsIgnored); 34 | Outdated = outdated; 35 | } 36 | 37 | #region Helper methods 38 | 39 | public bool IsFailure 40 | { 41 | get { return ResultState == TestResultState.Failure; } 42 | } 43 | 44 | public bool IsError 45 | { 46 | get { return ResultState == TestResultState.Error; } 47 | } 48 | 49 | public bool IsSuccess 50 | { 51 | get { return ResultState == TestResultState.Success; } 52 | } 53 | 54 | public bool IsInconclusive 55 | { 56 | get { return ResultState == TestResultState.Inconclusive; } 57 | } 58 | 59 | #endregion 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestResult.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 925cf9f45ea32814da65f61c1ebd7e6f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/TestRunner/UnitTestView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ba152083ecc3cdb4a82881c6a9ae73c1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/UnitTestsRunnerSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | 5 | namespace UnityTest 6 | { 7 | 8 | public class UnitTestsRunnerSettings : ProjectSettingsBase 9 | { 10 | public bool runOnRecompilation; 11 | public bool horizontalSplit = true; 12 | public bool autoSaveSceneBeforeRun; 13 | public bool runTestOnANewScene; 14 | 15 | public void ToggleRunTestOnANewScene() { 16 | runTestOnANewScene = !runTestOnANewScene; 17 | Save (); 18 | } 19 | 20 | public void ToggleAutoSaveSceneBeforeRun() { 21 | autoSaveSceneBeforeRun = !autoSaveSceneBeforeRun; 22 | Save (); 23 | } 24 | 25 | public void ToggleHorizontalSplit() { 26 | horizontalSplit = !horizontalSplit; 27 | Save (); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/UnitTestsRunnerSettings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a24a0b0a24461a4ab99853f8b145e5c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/UnityUnitTest.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using NUnit.Framework; 4 | using UnityEditor; 5 | using UnityEngine; 6 | 7 | [TestFixture] 8 | public abstract class UnityUnitTest 9 | { 10 | public GameObject CreateGameObject() 11 | { 12 | return CreateGameObject(""); 13 | } 14 | 15 | public GameObject CreateGameObject(string name) 16 | { 17 | var go = string.IsNullOrEmpty(name) ? new GameObject() : new GameObject(name); 18 | Undo.RegisterCreatedObjectUndo(go, ""); 19 | return go; 20 | } 21 | 22 | public GameObject CreatePrimitive(PrimitiveType type) 23 | { 24 | var p = GameObject.CreatePrimitive(type); 25 | Undo.RegisterCreatedObjectUndo(p, ""); 26 | return p; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Assets/UnityTestTools/UnitTesting/Editor/UnityUnitTest.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ec01611d948e574c99a1bd24650a4a9 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/UnityVS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02fe78e962405814a83b8ba6c9471d32 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6e71a3e2fb5854e43823a9da25b68e21 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Bridge.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38d405c119fcc7c4e83d4a478a40ff2f 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/SyntaxTree.VisualStudio.Unity.Messaging.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4ad02dc83da735c4e8d945332b9202f6 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll -------------------------------------------------------------------------------- /Assets/UnityVS/Editor/UnityVS.VersionSpecific.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a29dcfc42dd8e83499985553565fe2ea 3 | MonoAssemblyImporter: 4 | serializedVersion: 1 5 | iconMap: {} 6 | executionOrder: {} 7 | userData: 8 | -------------------------------------------------------------------------------- /Info/1024x1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/1024x1024.png -------------------------------------------------------------------------------- /Info/128x128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/128x128.png -------------------------------------------------------------------------------- /Info/200x258.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/200x258.png -------------------------------------------------------------------------------- /Info/CaptureDeflate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/CaptureDeflate.png -------------------------------------------------------------------------------- /Info/CaptureGzip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/CaptureGzip.png -------------------------------------------------------------------------------- /Info/Gzip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/Gzip.png -------------------------------------------------------------------------------- /Info/icon.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/icon.psd -------------------------------------------------------------------------------- /Info/icon_promo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/icon_promo.psd -------------------------------------------------------------------------------- /Info/storebanner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/storebanner.png -------------------------------------------------------------------------------- /Info/storebanner.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/Info/storebanner.psd -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Microsoft Corporation 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PATENTS.TXT: -------------------------------------------------------------------------------- 1 | Microsoft Patent Promise for .NET Libraries and Runtime Components 2 | 3 | Microsoft Corporation and its affiliates ("Microsoft") promise not to assert 4 | any .NET Patents against you for making, using, selling, offering for sale, 5 | importing, or distributing Covered Code, as part of either a .NET Runtime or 6 | as part of any application designed to run on a .NET Runtime. 7 | 8 | If you file, maintain, or voluntarily participate in any claim in a lawsuit 9 | alleging direct or contributory patent infringement by any Covered Code, or 10 | inducement of patent infringement by any Covered Code, then your rights under 11 | this promise will automatically terminate. 12 | 13 | This promise is not an assurance that (i) any .NET Patents are valid or 14 | enforceable, or (ii) Covered Code does not infringe patents or other 15 | intellectual property rights of any third party. No rights except those 16 | expressly stated in this promise are granted, waived, or received by 17 | Microsoft, whether by implication, exhaustion, estoppel, or otherwise. 18 | This is a personal promise directly from Microsoft to you, and you agree as a 19 | condition of benefiting from it that no Microsoft rights are received from 20 | suppliers, distributors, or otherwise from any other person in connection with 21 | this promise. 22 | 23 | Definitions: 24 | 25 | "Covered Code" means those Microsoft .NET libraries and runtime components as 26 | made available by Microsoft at https://github.com/Microsoft/referencesource. 27 | 28 | ".NET Patents" are those patent claims, both currently owned by Microsoft and 29 | acquired in the future, that are necessarily infringed by Covered Code. .NET 30 | Patents do not include any patent claims that are infringed by any Enabling 31 | Technology, that are infringed only as a consequence of modification of 32 | Covered Code, or that are infringed only by the combination of Covered Code 33 | with third party code. 34 | 35 | ".NET Runtime" means any compliant implementation in software of (a) all of 36 | the required parts of the mandatory provisions of Standard ECMA-335 – Common 37 | Language Infrastructure (CLI); and (b) if implemented, any additional 38 | functionality in Microsoft's .NET Framework, as described in Microsoft's API 39 | documentation on its MSDN website. For example, .NET Runtimes include 40 | Microsoft's .NET Framework and those portions of the Mono Project compliant 41 | with (a) and (b). 42 | 43 | "Enabling Technology" means underlying or enabling technology that may be 44 | used, combined, or distributed in connection with Microsoft's .NET Framework 45 | or other .NET Runtimes, such as hardware, operating systems, and applications 46 | that run on .NET Framework or other .NET Runtimes. 47 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hitcents/Unity.IO.Compression/928b95b64a9598b42565ca0097b79d96fa608e67/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity.IO.Compression 2 | This is a port of Microsoft's code from [here](https://github.com/Microsoft/referencesource/tree/master/System/sys/system/IO/compression). 3 | 4 | The classes in System.IO.Compression in Unity 4.x [do not seem to work on Windows](http://answers.unity3d.com/questions/692250/gzipstream-and-deflatestream-give-entrypointnotfou.html) and perhaps several other platforms. 5 | 6 | Luckily, Microsoft has released much of the source code of the .NET BCL. We have ported Microsoft's code to work in Unity. This seems like the cleanest and most stable way to get the GZipStream and DeflateStream classes working in Unity. 7 | 8 | Find the plugin on the Unity Asset Store [here](https://www.assetstore.unity3d.com/#!/content/31902). 9 | 10 | Built by [Hitcents](http://hitcents.com/), contact us [here](http://hitcents.com/contact) for questions. 11 | -------------------------------------------------------------------------------- /build-helpers.fsx: -------------------------------------------------------------------------------- 1 | module BuildHelpers 2 | #r @"packages/FAKE.3.5.4/tools/FakeLib.dll" 3 | open Fake 4 | open Fake.XamarinHelper 5 | open System 6 | open System.IO 7 | open System.Linq 8 | 9 | let possibleUnityPaths = [ 10 | "/Applications/Unity/Unity.app/Contents/MacOS/Unity" 11 | @"C:\Program Files (x86)\Unity\Editor\Unity.exe" 12 | @"F:\Unity 4.6.1\Editor\Unity.exe" 13 | ] 14 | 15 | let Exec command args = 16 | let result = Shell.Exec(command, args) 17 | if result <> 0 then failwithf "%s exited with error %d" command result 18 | 19 | let RestorePackages solutionFile = 20 | Exec ".nuget/NuGet.exe" ("restore " + solutionFile) 21 | 22 | let RunNUnitTests dllPath xmlPath = 23 | Exec "/Library/Frameworks/Mono.framework/Versions/Current/bin/nunit-console4" (dllPath + " -xml=" + xmlPath) 24 | TeamCityHelper.sendTeamCityNUnitImport xmlPath 25 | 26 | let TestFlightUpload project apiToken teamToken distList = 27 | let binFolder = Path.Combine(project, "bin", "iPhone", "Ad-Hoc") 28 | let ipa = Path.Combine(binFolder, project + ".ipa") 29 | let notes = Path.Combine(project, "RELEASE-NOTES.txt") 30 | Exec "curl" ("https://testflightapp.com/api/builds.json -F file=@" + ipa + " -F api_token=" + apiToken + " -F team_token=" + teamToken + " -F notes=@" + notes + " -F notify=False -F distribution_lists='" + distList + "'") 31 | 32 | let UpdatePlist version project = 33 | let build = environVarOrDefault "BUILD_NUMBER" "" 34 | if not(String.IsNullOrEmpty(build)) then do 35 | let info = Path.Combine(project, "Info.plist") 36 | let finalVersion = version + "." + build 37 | Exec "/usr/libexec/PlistBuddy" ("-c 'Set :CFBundleVersion " + finalVersion + "' " + info) 38 | 39 | let UnityPath = 40 | (Seq.where(fun p -> File.Exists(p)) possibleUnityPaths).First() 41 | 42 | let Unity args = 43 | let fullPath = Path.GetFullPath(".") 44 | let result = Shell.Exec(UnityPath, "-quit -batchmode -logFile -projectPath \"" + fullPath + "\" " + args) 45 | if result < 0 then failwithf "Unity exited with error %d" result -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | .nuget\NuGet.exe install FAKE -Version 3.5.4 3 | packages\FAKE.3.5.4\tools\FAKE.exe build.fsx %1 4 | -------------------------------------------------------------------------------- /build.fsx: -------------------------------------------------------------------------------- 1 | #r @"packages/FAKE.3.5.4/tools/FakeLib.dll" 2 | #load "build-helpers.fsx" 3 | open Fake 4 | open System 5 | open System.IO 6 | open System.Linq 7 | open BuildHelpers 8 | open Fake.XamarinHelper 9 | 10 | let version = "1.0.0" 11 | let project = "Unity.IO.Compression" 12 | let package = project + ".unitypackage" 13 | let testResults = "TestResults.xml" 14 | 15 | Target "tests" (fun () -> 16 | Unity("-executeMethod UnityTest.Batch.RunUnitTests -resultFilePath=" + testResults) 17 | sendTeamCityNUnitImport testResults 18 | ) 19 | 20 | Target "unity" (fun () -> 21 | let folder = Path.Combine("Assets", project) 22 | Unity("-exportPackage " + folder + " " + package) 23 | TeamCityHelper.PublishArtifact package 24 | ) 25 | 26 | "tests" ==> "unity" 27 | 28 | RunTarget() 29 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | --------------------------------------------------------------------------------