コード例 #1
0
        public void TestLeapPlayerLoop()
        {
            for (int i = 0; i < 3; i++)
            {
                var testOver = new ManualResetEventSlim();
                var timeoutTimer = new Timer(10000);

                var player = new LeapPlayer(@"frames\rotate_1.frames");
                player.LoopOutput = true;

                var bytesExpected = player.FileSizeInBytes * 3;

                Action<Frame> frameListener = frame =>
                    {
                        timeoutTimer.Stop();
                        timeoutTimer.Start();
                        if (player.TotalBytesRead >= bytesExpected)
                        {
                            testOver.Set();
                        }
                    };
                player.FrameReady += frameListener;

                timeoutTimer.Elapsed += (sender, args) => testOver.Set();
                player.StartConnection();

                timeoutTimer.Start();
                
                testOver.Wait();

                player.StopConnection();

                Assert.IsTrue(player.TotalBytesRead >= bytesExpected);
            }
        }
コード例 #2
0
 public void TestLeftHandGrab()
 {
     var grabDetected = new ManualResetEvent(false);
     var leftHand = false;
     var player = new LeapPlayer(@"frames\left_hand_grab.frames");
     var gestureRecognition = GestureRecognitionFactory.Create(new LeapGestureController(player));
     gestureRecognition.SubscribeToCommand<GrabCommand>(x =>
     {
         leftHand = x.LeftHand;
         grabDetected.Set();
     });
     player.StartConnection();
     Assert.IsTrue(grabDetected.WaitOne(6000), "Grab Command of left hand should be detected");
     player.StopConnection();
     Assert.IsTrue(leftHand, "Left hand should be provided by command");
 }
コード例 #3
0
 public void TestRotate()
 {
     var rotated = false;
     var rotateDetected = new ManualResetEvent(false);
     var player = new LeapPlayer(@"frames\rotate_1.frames");
     var gestureRecognition = GestureRecognitionFactory.Create(new LeapGestureController(player));
     gestureRecognition.SubscribeToCommand<ScaleAndRotate>(x =>
     {
         rotated = Math.Abs(x.Rotation.X) > 0.001;
         rotateDetected.Set();
     });
     player.StartConnection();
     Assert.IsTrue(rotateDetected.WaitOne(2000), "Scale And Rotate Command should be detected");
     player.StopConnection();
     Assert.IsTrue(rotated, "Rotation should be true.");
 }
コード例 #4
0
 public void TestThumbsHasNoIntermediate()
 {
     var hasMetacarpal = true;
     var commandFired = new ManualResetEvent(false);
     var player = new LeapPlayer(@"frames\right_hand_grab.frames");
     var gestureRecognition = GestureRecognitionFactory.Create(new LeapGestureController(player));
     gestureRecognition.SubscribeToCommand<PhysicCommand>(x =>
     {
         hasMetacarpal = x.BodyParts.Any(part => part.Id == 20611 || part.Id == 22611);
         commandFired.Set();
     });
     player.StartConnection();
     Assert.IsTrue(commandFired.WaitOne(2000), "Physics command should be fired");
     player.StopConnection();
     Assert.IsFalse(hasMetacarpal, "Thumbs should not have an metacarpal bone");
 }
コード例 #5
0
 public void ScaleUpTest()
 {
     var scale = false;
     var scaleDetected = new ManualResetEvent(false);
     var player = new LeapPlayer(@"frames\scale_up.frames");
     var gestureRecognition = GestureRecognitionFactory.Create(new LeapGestureController(player));
     gestureRecognition.SubscribeToCommand<ScaleAndRotate>(x =>
     {
         scale = Math.Abs(x.Scale - 1.0) > 0.001;
         scaleDetected.Set();
     });
     player.StartConnection();
     Assert.IsTrue(scaleDetected.WaitOne(2000), "Scale And Rotate Command should be detected");
     player.StopConnection();
     Assert.IsTrue(scale, "Scale should be true.");
 }