[longomatch] Add test for Next() and Previous()



commit 98ca0c64bb71a2a1ab34d4d2f6cf58ebd51b1675
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Mar 25 20:02:50 2015 +0100

    Add test for Next() and Previous()

 LongoMatch.Services/Services/PlayerController.cs |   15 ++++---
 Tests/Services/TestPlayerController.cs           |   47 ++++++++++++++++++++++
 2 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/LongoMatch.Services/Services/PlayerController.cs 
b/LongoMatch.Services/Services/PlayerController.cs
index 7418a7e..0794703 100644
--- a/LongoMatch.Services/Services/PlayerController.cs
+++ b/LongoMatch.Services/Services/PlayerController.cs
@@ -153,7 +153,11 @@ namespace LongoMatch.Services
 
                public Time CurrentTime {
                        get {
-                               return player.CurrentTime;
+                               if (StillImageLoaded) {
+                                       return imageLoadedTS;
+                               } else {
+                                       return player.CurrentTime;
+                               }
                        }
                }
 
@@ -276,7 +280,9 @@ namespace LongoMatch.Services
 
                public bool Seek (Time time, bool accurate, bool synchronous = false, bool throtlled = false)
                {
-                       if (!StillImageLoaded) {
+                       if (StillImageLoaded) {
+                               imageLoadedTS = time;
+                       } else {
                                EmitLoadDrawings (null);
                                if (readyToSeek) {
                                        if (throtlled) {
@@ -472,10 +478,7 @@ namespace LongoMatch.Services
                public void Previous ()
                {
                        Log.Debug ("Previous");
-                       if (StillImageLoaded) {
-                               imageLoadedTS = new Time (0);
-                               Tick ();
-                       } else if (loadedPlaylistElement != null) {
+                       if (loadedPlaylistElement != null) {
                                if (loadedPlaylist.HasPrev ()) {
                                        Config.EventsBroker.EmitPreviousPlaylistElement (loadedPlaylist);
                                }
diff --git a/Tests/Services/TestPlayerController.cs b/Tests/Services/TestPlayerController.cs
index e797b91..df84659 100644
--- a/Tests/Services/TestPlayerController.cs
+++ b/Tests/Services/TestPlayerController.cs
@@ -467,6 +467,53 @@ namespace Tests.Services
                        Assert.AreEqual ((double)1 / 25, player.Rate, 0.01);
                }
 
+               [Test ()]
+               public void TestNext ()
+               {
+                       int nextSent = 0;
+                       PreparePlayer ();
+                       Config.EventsBroker.NextPlaylistElementEvent += (p) => nextSent++;
+
+                       player.Next ();
+                       Assert.AreEqual (0, nextSent);
+
+                       player.LoadPlaylistEvent (playlist, plImage);
+                       player.Next ();
+                       Assert.AreEqual (1, nextSent);
+
+                       playlist.Next ();
+                       Assert.IsFalse (playlist.HasNext ());
+                       player.Next ();
+                       Assert.AreEqual (1, nextSent);
+               }
+
+               [Test ()]
+               public void TestPrevious ()
+               {
+                       int prevSent = 0;
+                       currentTime = new Time (4000);
+                       PreparePlayer ();
+                       Config.EventsBroker.PreviousPlaylistElementEvent += (p) => prevSent++;
+
+                       player.Previous ();
+                       playerMock.Verify (p => p.Seek (new Time (0), true, false));
+                       Assert.AreEqual (0, prevSent);
+       
+                       player.LoadEvent (mfs, evt, evt.Start, false);
+                       playerMock.ResetCalls ();
+                       player.Previous ();
+                       playerMock.Verify (p => p.Seek (evt.Start, true, false));
+                       Assert.AreEqual (0, prevSent);
+
+                       player.LoadPlaylistEvent (playlist, plImage);
+                       playerMock.ResetCalls ();
+                       player.Previous ();
+                       Assert.AreEqual (0, prevSent);
+                       playlist.Next ();
+                       player.Previous ();
+                       Assert.AreEqual (1, prevSent);
+               }
+
        }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]