[longomatch] Fix unit tests and errors they uncovered.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Fix unit tests and errors they uncovered.
- Date: Wed, 18 Mar 2015 14:37:50 +0000 (UTC)
commit c36ba98b549e6c6f5cd958445c9b9f37ce0ee89d
Author: Julien Moutte <julien fluendo com>
Date: Tue Mar 10 11:59:39 2015 +0100
Fix unit tests and errors they uncovered.
LongoMatch.Core/Store/MediaFileSet.cs | 18 ++++++++++++++----
Tests/Core/Store/TestMediaFileSet.cs | 18 ++++++++++--------
2 files changed, 24 insertions(+), 12 deletions(-)
---
diff --git a/LongoMatch.Core/Store/MediaFileSet.cs b/LongoMatch.Core/Store/MediaFileSet.cs
index 8e8d4d7..5d1cf03 100644
--- a/LongoMatch.Core/Store/MediaFileSet.cs
+++ b/LongoMatch.Core/Store/MediaFileSet.cs
@@ -62,8 +62,14 @@ namespace LongoMatch.Core.Store
case MediaFileAngle.Angle1:
File.Value.Name = Catalog.GetString ("Main camera
angle");
break;
- default:
- File.Value.Name = Catalog.GetString ("Camera angle");
+ case MediaFileAngle.Angle2:
+ File.Value.Name = Catalog.GetString ("Angle 2");
+ break;
+ case MediaFileAngle.Angle3:
+ File.Value.Name = Catalog.GetString ("Angle 3");
+ break;
+ case MediaFileAngle.Angle4:
+ File.Value.Name = Catalog.GetString ("Angle 4");
break;
}
// Add to list
@@ -91,12 +97,16 @@ namespace LongoMatch.Core.Store
}
/// <summary>
- /// Gets the total duration of all files in set.
+ /// Gets the maximum duration from all files in set.
/// </summary>
/// <value>The duration.</value>
public Time Duration {
get {
- return this.Max (mf => mf == null ? new Time (0) : mf.Duration);
+ if (Count != 0) {
+ return this.Max (mf => mf == null ? new Time (0) : mf.Duration);
+ } else {
+ return new Time (0);
+ }
}
}
diff --git a/Tests/Core/Store/TestMediaFileSet.cs b/Tests/Core/Store/TestMediaFileSet.cs
index 88f9a60..1bf5b7e 100644
--- a/Tests/Core/Store/TestMediaFileSet.cs
+++ b/Tests/Core/Store/TestMediaFileSet.cs
@@ -41,7 +41,7 @@ namespace Tests.Core.Store
[Test()]
public void TestMigration ()
{
- String old_json = @"""FileSet"": {
+ String old_json = @"{
""$id"": ""88"",
""$type"":
""LongoMatch.Core.Store.MediaFileSet, LongoMatch.Core"",
""Files"": {
@@ -72,7 +72,7 @@ namespace Tests.Core.Store
mf = newobj [1];
Assert.AreEqual ("test2.mp4", mf.FilePath);
- Assert.AreEqual ("Angle 1", mf.Name);
+ Assert.AreEqual ("Angle 2", mf.Name);
}
[Test()]
@@ -101,11 +101,11 @@ namespace Tests.Core.Store
MediaFileSet mf = new MediaFileSet ();
mf.Add (new MediaFile ("path1", 34000, 25, true, true, "mp4", "h264",
- "aac", 320, 240, 1.3, null, "Test asset"));
+ "aac", 320, 240, 1.3, null, "Test asset") { Offset = new Time (1) });
mf.Add (new MediaFile ("path2", 34000, 25, true, true, "mp4", "h264",
- "aac", 320, 240, 1.3, null, "Test asset 2"));
+ "aac", 320, 240, 1.3, null, "Test asset 2") { Offset = new Time (2) });
mf.Add (new MediaFile ("path3", 34000, 25, true, true, "mp4", "h264",
- "aac", 320, 240, 1.3, null, "Test asset 3"));
+ "aac", 320, 240, 1.3, null, "Test asset 3") { Offset = new Time (3) });
Assert.AreEqual (3, mf.Count);
Assert.AreEqual ("path1", mf [0].FilePath);
@@ -113,21 +113,23 @@ namespace Tests.Core.Store
Assert.AreEqual ("path3", mf [2].FilePath);
mf.Replace ("Test asset 2", new MediaFile ("path4", 34000, 25, true, true, "mp4",
"h264",
- "aac", 320, 240, 1.3, null, "Test asset 4"));
+ "aac", 320, 240, 1.3, null, "Test asset 4") { Offset = new Time (4) });
Assert.AreEqual (3, mf.Count);
Assert.AreEqual ("path1", mf [0].FilePath);
Assert.AreEqual ("path4", mf [1].FilePath);
Assert.AreEqual ("Test asset 2", mf [1].Name);
+ Assert.AreEqual (new Time (2), mf [1].Offset);
Assert.AreEqual ("path3", mf [2].FilePath);
mf.Replace (mf [1], new MediaFile ("path5", 34000, 25, true, true, "mp4", "h264",
- "aac", 320, 240, 1.3, null, "Test asset 5"));
+ "aac", 320, 240, 1.3, null, "Test asset 5") { Offset = new Time (5) });
Assert.AreEqual (3, mf.Count);
Assert.AreEqual ("path1", mf [0].FilePath);
- Assert.AreEqual ("path2", mf [1].FilePath);
+ Assert.AreEqual ("path5", mf [1].FilePath);
Assert.AreEqual ("Test asset 2", mf [1].Name);
+ Assert.AreEqual (new Time (2), mf [1].Offset);
Assert.AreEqual ("path3", mf [2].FilePath);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]