[longomatch] More test project creation and deletion to utils.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] More test project creation and deletion to utils.
- Date: Wed, 18 Mar 2015 14:47:00 +0000 (UTC)
commit aadbd733b080653cc0227a4bdf6e38ddbbae9172
Author: Julien Moutte <julien fluendo com>
Date: Tue Mar 17 17:55:32 2015 +0100
More test project creation and deletion to utils.
Indeed we will probably use it in a lot of tests...
Tests/Core/Store/TestPlaysFilter.cs | 314 +++++++++++++++++------------------
Tests/Utils.cs | 44 +++++
2 files changed, 197 insertions(+), 161 deletions(-)
---
diff --git a/Tests/Core/Store/TestPlaysFilter.cs b/Tests/Core/Store/TestPlaysFilter.cs
index 39fdf6f..b9ac856 100644
--- a/Tests/Core/Store/TestPlaysFilter.cs
+++ b/Tests/Core/Store/TestPlaysFilter.cs
@@ -23,193 +23,185 @@ using LongoMatch.Core.Common;
namespace Tests.Core.Store
{
- [TestFixture()]
+ [TestFixture ()]
public class TestPlaysFilter
{
- Project CreateProject () {
- TimelineEvent pl;
- Project p = new Project ();
- p.Dashboard = Dashboard.DefaultTemplate (10);
- p.LocalTeamTemplate = Team.DefaultTemplate (5);
- p.VisitorTeamTemplate = Team.DefaultTemplate (5);
- MediaFile mf = new MediaFile ("path", 34000, 25, true, true, "mp4", "h264",
- "aac", 320, 240, 1.3, null, "Test asset");
- ProjectDescription pd = new ProjectDescription ();
- pd.FileSet = new MediaFileSet ();
- pd.FileSet.Add (mf);
- p.Description = pd;
- p.UpdateEventTypesAndTimers ();
-
- AnalysisEventButton b = p.Dashboard.List[0] as AnalysisEventButton;
-
- /* No tags, no players */
- pl = new TimelineEvent {EventType = b.EventType};
- p.Timeline.Add (pl);
- /* tags, but no players */
- b = p.Dashboard.List[1] as AnalysisEventButton;
- pl = new TimelineEvent {EventType = b.EventType};
- pl.Tags.Add (b.AnalysisEventType.Tags[0]);
- p.Timeline.Add (pl);
- /* tags and players */
- b = p.Dashboard.List[2] as AnalysisEventButton;
- pl = new TimelineEvent {EventType = b.EventType};
- pl.Tags.Add (b.AnalysisEventType.Tags[1]);
- pl.Players.Add (p.LocalTeamTemplate.List[0]);
- p.Timeline.Add (pl);
- return p;
- }
-
- [Test()]
+ [Test ()]
public void TestEmptyFilter ()
{
- Project p = CreateProject ();
- EventsFilter filter = new EventsFilter (p);
-
- Assert.AreEqual (13, filter.VisibleEventTypes.Count);
- Assert.AreEqual (10, filter.VisiblePlayers.Count);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ Project p = Utils.CreateProject ();
+
+ try {
+ EventsFilter filter = new EventsFilter (p);
+
+ Assert.AreEqual (13, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (10, filter.VisiblePlayers.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ } finally {
+ Utils.DeleteProject (p);
+ }
}
-
- [Test()]
+
+ [Test ()]
public void TestFilterCategory ()
{
- Project p = CreateProject ();
- EventsFilter filter = new EventsFilter (p);
+ Project p = Utils.CreateProject ();
+
+ try {
+ EventsFilter filter = new EventsFilter (p);
- filter.FilterEventType (p.EventTypes[0], true);
- Assert.AreEqual (1, filter.VisibleEventTypes.Count);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
+ filter.FilterEventType (p.EventTypes [0], true);
+ Assert.AreEqual (1, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
- filter.FilterEventType (p.EventTypes[1], true);
- Assert.AreEqual (2, filter.VisibleEventTypes.Count);
- Assert.AreEqual (2, filter.VisiblePlays.Count);
+ filter.FilterEventType (p.EventTypes [1], true);
+ Assert.AreEqual (2, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (2, filter.VisiblePlays.Count);
- filter.FilterEventType (p.EventTypes[2], true);
- Assert.AreEqual (3, filter.VisibleEventTypes.Count);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ filter.FilterEventType (p.EventTypes [2], true);
+ Assert.AreEqual (3, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
- filter.FilterEventType (p.EventTypes[0], true);
- Assert.AreEqual (3, filter.VisibleEventTypes.Count);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ filter.FilterEventType (p.EventTypes [0], true);
+ Assert.AreEqual (3, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
- filter.FilterEventType (p.EventTypes[0], false);
- Assert.AreEqual (2, filter.VisibleEventTypes.Count);
- Assert.AreEqual (2, filter.VisiblePlays.Count);
+ filter.FilterEventType (p.EventTypes [0], false);
+ Assert.AreEqual (2, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (2, filter.VisiblePlays.Count);
- filter.FilterEventType (p.EventTypes[1], false);
- Assert.AreEqual (1, filter.VisibleEventTypes.Count);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
-
- filter.FilterEventType (p.EventTypes[2], false);
- Assert.AreEqual (13, filter.VisibleEventTypes.Count);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ filter.FilterEventType (p.EventTypes [1], false);
+ Assert.AreEqual (1, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+
+ filter.FilterEventType (p.EventTypes [2], false);
+ Assert.AreEqual (13, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ } finally {
+ Utils.DeleteProject (p);
+ }
}
-
- [Test()]
+
+ [Test ()]
public void TestFilterCategoryTags ()
{
- Project p = CreateProject ();
- EventsFilter filter = new EventsFilter (p);
- AnalysisEventType a;
-
- Assert.AreEqual (3, filter.VisiblePlays.Count);
-
- a = p.EventTypes[0] as AnalysisEventType;
- filter.FilterEventTag (a, a.Tags[0], true);
- Assert.AreEqual (1, filter.VisibleEventTypes.Count);
- Assert.AreEqual (0, filter.VisiblePlays.Count);
-
- a = p.EventTypes[1] as AnalysisEventType;
- filter.FilterEventTag (a, a.Tags[0], true);
- Assert.AreEqual (2, filter.VisibleEventTypes.Count);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
-
- a = p.EventTypes[2] as AnalysisEventType;
- filter.FilterEventTag (a, a.Tags[0], true);
- Assert.AreEqual (3, filter.VisibleEventTypes.Count);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
+ Project p = Utils.CreateProject ();
- filter.FilterEventTag (a, a.Tags[1], true);
- Assert.AreEqual (2, filter.VisiblePlays.Count);
+ try {
+ EventsFilter filter = new EventsFilter (p);
+ AnalysisEventType a;
- a = p.EventTypes[0] as AnalysisEventType;
- filter.FilterEventTag (a, a.Tags[0], false);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
- a = p.EventTypes[1] as AnalysisEventType;
- filter.FilterEventTag (a, a.Tags[0], false);
- filter.FilterEventTag (a, a.Tags[1], true);
- Assert.AreEqual (2, filter.VisiblePlays.Count);
- Assert.AreEqual (p.Timeline[0], filter.VisiblePlays[0]);
- Assert.AreEqual (p.Timeline[2], filter.VisiblePlays[1]);
-
- /* One tag filtered now, but not the one of this play */
- a = p.EventTypes[2] as AnalysisEventType;
- filter.FilterEventTag (a, a.Tags[1], false);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
- Assert.AreEqual (p.Timeline[0], filter.VisiblePlays[0]);
- /* No more tags filtered, if the category matches we are ok */
- filter.FilterEventTag (a, a.Tags[0], false);
- Assert.AreEqual (2, filter.VisiblePlays.Count);
- Assert.AreEqual (p.Timeline[0], filter.VisiblePlays[0]);
- Assert.AreEqual (p.Timeline[2], filter.VisiblePlays[1]);
-
- filter.ClearAll ();
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ a = p.EventTypes [0] as AnalysisEventType;
+ filter.FilterEventTag (a, a.Tags [0], true);
+ Assert.AreEqual (1, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (0, filter.VisiblePlays.Count);
+
+ a = p.EventTypes [1] as AnalysisEventType;
+ filter.FilterEventTag (a, a.Tags [0], true);
+ Assert.AreEqual (2, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+
+ a = p.EventTypes [2] as AnalysisEventType;
+ filter.FilterEventTag (a, a.Tags [0], true);
+ Assert.AreEqual (3, filter.VisibleEventTypes.Count);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+
+ filter.FilterEventTag (a, a.Tags [1], true);
+ Assert.AreEqual (2, filter.VisiblePlays.Count);
+
+ a = p.EventTypes [0] as AnalysisEventType;
+ filter.FilterEventTag (a, a.Tags [0], false);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+
+ a = p.EventTypes [1] as AnalysisEventType;
+ filter.FilterEventTag (a, a.Tags [0], false);
+ filter.FilterEventTag (a, a.Tags [1], true);
+ Assert.AreEqual (2, filter.VisiblePlays.Count);
+ Assert.AreEqual (p.Timeline [0], filter.VisiblePlays [0]);
+ Assert.AreEqual (p.Timeline [2], filter.VisiblePlays [1]);
+
+ /* One tag filtered now, but not the one of this play */
+ a = p.EventTypes [2] as AnalysisEventType;
+ filter.FilterEventTag (a, a.Tags [1], false);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+ Assert.AreEqual (p.Timeline [0], filter.VisiblePlays [0]);
+ /* No more tags filtered, if the category matches we are ok */
+ filter.FilterEventTag (a, a.Tags [0], false);
+ Assert.AreEqual (2, filter.VisiblePlays.Count);
+ Assert.AreEqual (p.Timeline [0], filter.VisiblePlays [0]);
+ Assert.AreEqual (p.Timeline [2], filter.VisiblePlays [1]);
+
+ filter.ClearAll ();
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ } finally {
+ Utils.DeleteProject (p);
+ }
}
-
- [Test()]
+
+ [Test ()]
public void TestFilterPlayers ()
{
- Project p = CreateProject ();
- EventsFilter filter = new EventsFilter (p);
-
- Assert.AreEqual (10, filter.VisiblePlayers.Count);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
- filter.FilterPlayer (p.LocalTeamTemplate.List[4], true);
- Assert.AreEqual (0, filter.VisiblePlays.Count);
- Assert.AreEqual (1, filter.VisiblePlayers.Count);
- filter.FilterPlayer (p.LocalTeamTemplate.List[0], true);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
- Assert.AreEqual (2, filter.VisiblePlayers.Count);
- filter.FilterPlayer (p.LocalTeamTemplate.List[0], true);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
- Assert.AreEqual (2, filter.VisiblePlayers.Count);
- filter.FilterPlayer (p.LocalTeamTemplate.List[0], false);
- Assert.AreEqual (0, filter.VisiblePlays.Count);
- Assert.AreEqual (1, filter.VisiblePlayers.Count);
- filter.FilterPlayer (p.LocalTeamTemplate.List[4], false);
- Assert.AreEqual (10, filter.VisiblePlayers.Count);
- Assert.AreEqual (3, filter.VisiblePlays.Count);
+ Project p = Utils.CreateProject ();
+
+ try {
+ EventsFilter filter = new EventsFilter (p);
+
+ Assert.AreEqual (10, filter.VisiblePlayers.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ filter.FilterPlayer (p.LocalTeamTemplate.List [4], true);
+ Assert.AreEqual (0, filter.VisiblePlays.Count);
+ Assert.AreEqual (1, filter.VisiblePlayers.Count);
+ filter.FilterPlayer (p.LocalTeamTemplate.List [0], true);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+ Assert.AreEqual (2, filter.VisiblePlayers.Count);
+ filter.FilterPlayer (p.LocalTeamTemplate.List [0], true);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+ Assert.AreEqual (2, filter.VisiblePlayers.Count);
+ filter.FilterPlayer (p.LocalTeamTemplate.List [0], false);
+ Assert.AreEqual (0, filter.VisiblePlays.Count);
+ Assert.AreEqual (1, filter.VisiblePlayers.Count);
+ filter.FilterPlayer (p.LocalTeamTemplate.List [4], false);
+ Assert.AreEqual (10, filter.VisiblePlayers.Count);
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ } finally {
+ Utils.DeleteProject (p);
+ }
}
-
- [Test()]
+
+ [Test ()]
public void TestClearAll ()
{
- Project p = CreateProject ();
- EventsFilter filter = new EventsFilter (p);
-
- filter.FilterPlayer (p.LocalTeamTemplate.List[0], true);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
- Assert.AreEqual (1, filter.VisiblePlayers.Count);
- filter.ClearAll();
- Assert.AreEqual (3, filter.VisiblePlays.Count);
- Assert.AreEqual (10, filter.VisiblePlayers.Count);
-
- filter.FilterEventType (p.EventTypes[0], true);
- Assert.AreEqual (1, filter.VisiblePlays.Count);
- Assert.AreEqual (1, filter.VisibleEventTypes.Count);
- filter.ClearAll ();
- Assert.AreEqual (3, filter.VisiblePlays.Count);
- Assert.AreEqual (13, filter.VisibleEventTypes.Count);
-
- filter.FilterEventTag (p.EventTypes[0], (p.EventTypes[0] as
AnalysisEventType).Tags[0], true);
- Assert.AreEqual (0, filter.VisiblePlays.Count);
- Assert.AreEqual (1, filter.VisibleEventTypes.Count);
- filter.ClearAll ();
- Assert.AreEqual (3, filter.VisiblePlays.Count);
- Assert.AreEqual (13, filter.VisibleEventTypes.Count);
+ Project p = Utils.CreateProject ();
+
+ try {
+ EventsFilter filter = new EventsFilter (p);
+
+ filter.FilterPlayer (p.LocalTeamTemplate.List [0], true);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+ Assert.AreEqual (1, filter.VisiblePlayers.Count);
+ filter.ClearAll ();
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ Assert.AreEqual (10, filter.VisiblePlayers.Count);
+
+ filter.FilterEventType (p.EventTypes [0], true);
+ Assert.AreEqual (1, filter.VisiblePlays.Count);
+ Assert.AreEqual (1, filter.VisibleEventTypes.Count);
+ filter.ClearAll ();
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ Assert.AreEqual (13, filter.VisibleEventTypes.Count);
+
+ filter.FilterEventTag (p.EventTypes [0], (p.EventTypes [0] as
AnalysisEventType).Tags [0], true);
+ Assert.AreEqual (0, filter.VisiblePlays.Count);
+ Assert.AreEqual (1, filter.VisibleEventTypes.Count);
+ filter.ClearAll ();
+ Assert.AreEqual (3, filter.VisiblePlays.Count);
+ Assert.AreEqual (13, filter.VisibleEventTypes.Count);
+ } finally {
+ Utils.DeleteProject (p);
+ }
}
}
}
diff --git a/Tests/Utils.cs b/Tests/Utils.cs
index 739d399..8f00109 100644
--- a/Tests/Utils.cs
+++ b/Tests/Utils.cs
@@ -18,6 +18,8 @@
using System;
using System.IO;
using LongoMatch.Core.Common;
+using LongoMatch.Core.Store;
+using LongoMatch.Core.Store.Templates;
using NUnit.Framework;
using System.Reflection;
@@ -91,6 +93,48 @@ namespace Tests
}
return img;
}
+
+ public static Project CreateProject ()
+ {
+ TimelineEvent pl;
+ Project p = new Project ();
+ p.Dashboard = Dashboard.DefaultTemplate (10);
+ p.LocalTeamTemplate = Team.DefaultTemplate (5);
+ p.VisitorTeamTemplate = Team.DefaultTemplate (5);
+ ProjectDescription pd = new ProjectDescription ();
+ pd.FileSet = new MediaFileSet ();
+ pd.FileSet.Add (new MediaFile (Path.GetTempFileName (), 34000, 25, true, true, "mp4",
"h264",
+ "aac", 320, 240, 1.3, null, "Test asset 1"));
+ pd.FileSet.Add (new MediaFile (Path.GetTempFileName (), 34000, 25, true, true, "mp4",
"h264",
+ "aac", 320, 240, 1.3, null, "Test asset 2"));
+ p.Description = pd;
+ p.UpdateEventTypesAndTimers ();
+
+ AnalysisEventButton b = p.Dashboard.List [0] as AnalysisEventButton;
+
+ /* No tags, no players */
+ pl = new TimelineEvent { EventType = b.EventType, Start = new Time (0), Stop = new
Time (100) };
+ p.Timeline.Add (pl);
+ /* tags, but no players */
+ b = p.Dashboard.List [1] as AnalysisEventButton;
+ pl = new TimelineEvent { EventType = b.EventType, Start = new Time (0), Stop = new
Time (100) };
+ pl.Tags.Add (b.AnalysisEventType.Tags [0]);
+ p.Timeline.Add (pl);
+ /* tags and players */
+ b = p.Dashboard.List [2] as AnalysisEventButton;
+ pl = new TimelineEvent { EventType = b.EventType, Start = new Time (0), Stop = new
Time (100) };
+ pl.Tags.Add (b.AnalysisEventType.Tags [1]);
+ pl.Players.Add (p.LocalTeamTemplate.List [0]);
+ p.Timeline.Add (pl);
+ return p;
+ }
+
+ public static void DeleteProject (Project p)
+ {
+ foreach (MediaFile mf in p.Description.FileSet) {
+ File.Delete (mf.FilePath);
+ }
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]