Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
ButtonPusher
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Button Pusher
ButtonPusher
Commits
b5ddc19c
Commit
b5ddc19c
authored
Jan 16, 2018
by
16이상민
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for class 'CooridnateMapperManager'
parent
5e177f3a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
164 additions
and
29 deletions
+164
-29
CoordinateMapperManager.cs
Assets/Script/CoordinateMapperManager.cs
+10
-8
CoordinateMapperView.cs
Assets/Script/CoordinateMapperView.cs
+13
-8
CoordinateMapperManagerTests.cs
Assets/Script/Tests/CoordinateMapperManagerTests.cs
+140
-12
CoordinateMapperViewTests.cs
Assets/Script/Tests/CoordinateMapperViewTests.cs
+1
-1
No files found.
Assets/Script/CoordinateMapperManager.cs
View file @
b5ddc19c
...
@@ -19,13 +19,6 @@ public class CoordinateMapperManager : MonoBehaviour
...
@@ -19,13 +19,6 @@ public class CoordinateMapperManager : MonoBehaviour
Texture2D
_ColorRGBX
;
Texture2D
_ColorRGBX
;
// In play mode, GUI for Null frame should show when Kinect cannot access.
// In play mode, GUI for FPS always show.
// In play mode, ColorTexture should not be null value.
// In play mode, BodyIndexBuffer should not be null value.
// In play mode, DepthCoordinates should not be null value.
// In play mode, BodyBuffer should not be null value.
public
Texture2D
ColorTexture
public
Texture2D
ColorTexture
{
get
{
return
_ColorRGBX
;
}
}
{
get
{
return
_ColorRGBX
;
}
}
public
byte
[]
BodyIndexBuffer
public
byte
[]
BodyIndexBuffer
...
@@ -47,10 +40,19 @@ public class CoordinateMapperManager : MonoBehaviour
...
@@ -47,10 +40,19 @@ public class CoordinateMapperManager : MonoBehaviour
_SourceBuffer
=
new
KinectModule
.
SourceBuffer
();
_SourceBuffer
=
new
KinectModule
.
SourceBuffer
();
_KinectAccessManager
=
new
KinectModule
.
KinectAccessManager
();
_KinectAccessManager
=
new
KinectModule
.
KinectAccessManager
();
}
void
OnEnable
()
{
_KinectAccessManager
.
Access
();
_KinectAccessManager
.
Access
();
}
}
void
OnGUI
()
void
OnDisable
()
{
_KinectAccessManager
.
Dispose
();
}
void
OnGUI
()
{
{
GUI
.
Box
(
new
Rect
(
10
,
10
,
200
,
30
),
"FPS: "
+
fps
.
ToString
(
"0.00"
));
GUI
.
Box
(
new
Rect
(
10
,
10
,
200
,
30
),
"FPS: "
+
fps
.
ToString
(
"0.00"
));
...
...
Assets/Script/CoordinateMapperView.cs
View file @
b5ddc19c
...
@@ -12,18 +12,23 @@ public class CoordinateMapperView : MonoBehaviour
...
@@ -12,18 +12,23 @@ public class CoordinateMapperView : MonoBehaviour
void
Start
()
void
Start
()
{
{
CoordinateMapperManager
CoordinateMapperManager
=
GameObject
.
Find
(
"Managers"
).
GetComponent
<
CoordinateMapperManager
>();
var
CoordinateMapperManager
=
GameObject
.
Find
(
"Managers"
).
GetComponent
<
CoordinateMapperManager
>();
CoordinateMapperManager
.
enabled
=
true
;
GetComponent
<
Renderer
>().
material
.
SetTexture
(
"_MainTex"
,
CoordinateMapperManager
.
ColorTexture
);
var
material
=
GetComponent
<
Renderer
>().
material
;
material
.
SetTexture
(
"_MainTex"
,
CoordinateMapperManager
.
ColorTexture
);
DepthBuffer
=
GenerateBuffer
(
"depthCoordinates"
,
sizeof
(
float
)
*
2
,
(
DepthPoints
=
CoordinateMapperManager
.
DepthCoordinates
));
DepthBuffer
=
GenerateBuffer
(
"depthCoordinates"
,
sizeof
(
float
)
*
2
,
BodyIndexBuffer
=
GenerateBuffer
(
"BodyIndexBuffer"
,
sizeof
(
float
),
(
BodyIndexPoints
=
CoordinateMapperManager
.
BodyIndexBuffer
));
(
DepthPoints
=
CoordinateMapperManager
.
DepthCoordinates
),
material
);
BodyIndexBuffer
=
GenerateBuffer
(
"BodyIndexBuffer"
,
sizeof
(
float
),
(
BodyIndexPoints
=
CoordinateMapperManager
.
BodyIndexBuffer
),
material
);
}
}
ComputeBuffer
GenerateBuffer
(
string
name
,
int
stride
,
Array
points
)
ComputeBuffer
GenerateBuffer
(
string
name
,
int
stride
,
Array
points
,
Material
material
)
{
{
var
buffer
=
new
ComputeBuffer
(
points
.
Length
,
stride
);
var
buffer
=
new
ComputeBuffer
(
points
.
Length
,
stride
);
GetComponent
<
Renderer
>().
material
.
SetBuffer
(
name
,
buffer
);
material
.
SetBuffer
(
name
,
buffer
);
return
buffer
;
return
buffer
;
}
}
...
@@ -32,7 +37,7 @@ public class CoordinateMapperView : MonoBehaviour
...
@@ -32,7 +37,7 @@ public class CoordinateMapperView : MonoBehaviour
//TODO: fix perf on this call.
//TODO: fix perf on this call.
DepthBuffer
.
SetData
(
DepthPoints
);
DepthBuffer
.
SetData
(
DepthPoints
);
BodyIndexBuffer
.
SetData
(
System
.
Array
.
ConvertAll
(
BodyIndexPoints
,
System
.
Convert
.
ToSingle
));
BodyIndexBuffer
.
SetData
(
Array
.
ConvertAll
(
BodyIndexPoints
,
Convert
.
ToSingle
));
}
}
void
OnDisable
()
void
OnDisable
()
...
...
Assets/Script/Tests/CoordinateMapperManagerTests.cs
View file @
b5ddc19c
...
@@ -6,25 +6,153 @@ using Windows.Kinect;
...
@@ -6,25 +6,153 @@ using Windows.Kinect;
using
System.Runtime.InteropServices
;
using
System.Runtime.InteropServices
;
using
System
;
using
System
;
public
class
CoordinateMapperManagerTests
{
// TODO: Change IMGUI to uGUI
public
class
CoordinateMapperManagerTests
[
Test
]
{
public
void
CoordinateMapperManagerTestsSimplePasses
()
{
// Use the Assert class to test conditions.
}
// A UnityTest behaves like a coroutine in PlayMode
// A UnityTest behaves like a coroutine in PlayMode
// and allows you to yield null to skip a frame in EditMode
// and allows you to yield null to skip a frame in EditMode
[
UnityTest
]
[
UnityTest
]
public
IEnumerator
Interface
Test
()
{
public
IEnumerator
Empty
Test
()
{
// Use the Assert class to test conditions.
// Use the Assert class to test conditions.
// yield to skip a frame
// yield to skip a frame
yield
return
null
;
yield
return
null
;
}
}
[
UnityTest
]
[
UnityTest
]
public
IEnumerator
FPSTest
()
public
IEnumerator
NullFrame_GUI_Show_When_Kinect_Disconnected
()
{
yield
return
null
;
}
[
UnityTest
]
public
IEnumerator
FPS_GUI_Show_When_Kinect_Disconnected
()
{
yield
return
null
;
}
[
UnityTest
]
public
IEnumerator
FPS_GUI_Show_When_Kinect_Connected
()
{
yield
return
null
;
}
[
UnityTest
]
public
IEnumerator
ColorTexture_Not_Equal_Null_When_Kinect_Disconnected
()
{
var
comp
=
InactiveComponent
();
yield
return
null
;
var
expected
=
null
as
Texture2D
;
var
actual
=
comp
.
ColorTexture
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"ColorTexture should not be null value when kinect disconnected."
);
}
[
UnityTest
]
public
IEnumerator
ColorTexture_Not_Equal_Null_When_Kinect_Connected
()
{
var
comp
=
ActiveComponent
();
yield
return
null
;
var
expected
=
null
as
Texture2D
;
var
actual
=
comp
.
ColorTexture
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"ColorTexture should not be null value when kinect connected."
);
}
[
UnityTest
]
public
IEnumerator
BodyIndexBuffer_Not_Equal_Null_When_Kinect_Disconnected
()
{
var
comp
=
InactiveComponent
();
yield
return
null
;
var
expected
=
null
as
byte
[];
var
actual
=
comp
.
BodyIndexBuffer
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"BodyIndexBuffer should not be null value when kinect disconnected."
);
}
[
UnityTest
]
public
IEnumerator
BodyIndexBuffer_Not_Equal_Null_When_Kinect_Connected
()
{
{
var
comp
=
ActiveComponent
();
yield
return
null
;
var
expected
=
null
as
byte
[];
var
actual
=
comp
.
BodyIndexBuffer
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"BodyIndexBuffer should not be null value when kinect connected."
);
}
[
UnityTest
]
public
IEnumerator
DepthCoordinates_Not_Equal_Null_When_Kinect_Disconnected
()
{
var
comp
=
InactiveComponent
();
yield
return
null
;
var
expected
=
null
as
DepthSpacePoint
[];
var
actual
=
comp
.
DepthCoordinates
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"DepthCoordinates should not be null value when kinect disconnected."
);
}
[
UnityTest
]
public
IEnumerator
DepthCoordinates_Not_Equal_Null_When_Kinect_Connected
()
{
var
comp
=
ActiveComponent
();
yield
return
null
;
yield
return
null
;
var
expected
=
null
as
DepthSpacePoint
[];
var
actual
=
comp
.
DepthCoordinates
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"DepthCoordinates should not be null value when kinect connected."
);
}
[
UnityTest
]
public
IEnumerator
BodyBuffer_Not_Null_Equal_When_Kinect_Disconnected
()
{
var
comp
=
InactiveComponent
();
yield
return
null
;
var
expected
=
null
as
KinectModule
.
IBody
[];
var
actual
=
comp
.
BodyBuffer
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"BodyBuffer should not be null value when kinect disconnected."
);
}
[
UnityTest
]
public
IEnumerator
BodyBuffer_Not_Null_Equal_When_Kinect_Connected
()
{
var
comp
=
ActiveComponent
();
yield
return
null
;
var
expected
=
null
as
KinectModule
.
IBody
[];
var
actual
=
comp
.
BodyBuffer
;
Assert
.
AreNotEqual
(
expected
,
actual
,
"BodyBuffer should not be null value when kinect connected."
);
}
CoordinateMapperManager
ActiveComponent
()
{
var
tmpObj
=
new
GameObject
();
return
tmpObj
.
AddComponent
<
CoordinateMapperManager
>();
}
CoordinateMapperManager
InactiveComponent
()
{
var
tmpObj
=
new
GameObject
();
var
comp
=
tmpObj
.
GetComponent
<
CoordinateMapperManager
>();
tmpObj
.
SetActive
(
false
);
return
comp
;
}
}
}
}
Assets/Script/Tests/CoordinateMapperViewTests.cs
View file @
b5ddc19c
...
@@ -27,7 +27,7 @@ class CoordinateMapperViewTests
...
@@ -27,7 +27,7 @@ class CoordinateMapperViewTests
var
expected
=
new
Texture
();
var
expected
=
new
Texture
();
Graphics
.
CopyTexture
(
material
.
mainTexture
,
expected
);
Graphics
.
CopyTexture
(
material
.
mainTexture
,
expected
);
UnityEngine
.
Object
.
Destroy
(
tmpObj
);
Object
.
Destroy
(
tmpObj
);
var
actual
=
CoordinateMapperView
.
GetComponent
<
Renderer
>().
material
.
mainTexture
;
var
actual
=
CoordinateMapperView
.
GetComponent
<
Renderer
>().
material
.
mainTexture
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment