-
-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
176 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using Mediapipe; | ||
using NUnit.Framework; | ||
using System; | ||
|
||
namespace Tests { | ||
public class GlContextTest { | ||
#region .GetCurrent | ||
[Test, GpuOnly] | ||
public void GetCurrent_ShouldReturnNull_When_CalledOutOfGlContext() { | ||
var glContext = GlContext.GetCurrent(); | ||
|
||
Assert.Null(glContext); | ||
} | ||
|
||
[Test, GpuOnly] | ||
public void GetCurrent_ShouldReturnCurrentContext_When_CalledInGlContext() { | ||
var glCalculatorHelper = new GlCalculatorHelper(); | ||
glCalculatorHelper.InitializeForTest(GpuResources.Create().ConsumeValueOrDie()); | ||
|
||
glCalculatorHelper.RunInGlContext(() => { | ||
var glContext = GlContext.GetCurrent(); | ||
Assert.NotNull(glContext); | ||
Assert.True(glContext.IsCurrent()); | ||
return Status.Ok(); | ||
}).AssertOk(); | ||
} | ||
#endregion | ||
|
||
#region #IsCurrent | ||
public void IsCurrent_ShouldReturnFalse_When_CalledOutOfGlContext() { | ||
var glContext = GetGlContext(); | ||
|
||
Assert.False(glContext.IsCurrent()); | ||
} | ||
#endregion | ||
|
||
#region properties | ||
[Test, GpuOnly] | ||
public void ShouldReturnProperties() { | ||
var glContext = GetGlContext(); | ||
|
||
Assert.AreNotEqual(glContext.eglDisplay, IntPtr.Zero); | ||
Assert.AreNotEqual(glContext.eglConfig, IntPtr.Zero); | ||
Assert.AreNotEqual(glContext.eglContext, IntPtr.Zero); | ||
Assert.AreEqual(glContext.glMajorVersion, 3); | ||
Assert.AreEqual(glContext.glMinorVersion, 2); | ||
Assert.AreEqual(glContext.glFinishCount, 0); | ||
} | ||
#endregion | ||
|
||
private GlContext GetGlContext() { | ||
GlContext glContext = null; | ||
|
||
var glCalculatorHelper = new GlCalculatorHelper(); | ||
glCalculatorHelper.InitializeForTest(GpuResources.Create().ConsumeValueOrDie()); | ||
|
||
glCalculatorHelper.RunInGlContext(() => { | ||
glContext = GlContext.GetCurrent(); | ||
return Status.Ok(); | ||
}).AssertOk(); | ||
|
||
return glContext; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters