f-spot r3550 - in trunk: . Tests Tests/src



Author: sdelcroix
Date: Wed Jan 16 15:55:02 2008
New Revision: 3550
URL: http://svn.gnome.org/viewvc/f-spot?rev=3550&view=rev

Log:
2008-01-16  Stephane Delcroix  <sdelcroix novell com>

	* Tests/: new folder for test suite and test images


Added:
   trunk/Tests/
   trunk/Tests/src/
   trunk/Tests/src/ChangeLog
   trunk/Tests/src/IBrowsableItem.cs
   trunk/Tests/src/Makefile
   trunk/Tests/src/TagStore.cs
Modified:
   trunk/ChangeLog

Added: trunk/Tests/src/IBrowsableItem.cs
==============================================================================
--- (empty file)
+++ trunk/Tests/src/IBrowsableItem.cs	Wed Jan 16 15:55:02 2008
@@ -0,0 +1,84 @@
+#if ENABLE_NUNIT
+using NUnit.Framework;
+
+namespace FSpot.Tests
+{
+	[TestFixture]
+	public class IBrowsableItemTests
+	{
+		BrowsablePointer item;
+		UriCollection collection;
+		bool changed;
+
+		public IBrowsableItemTests ()
+		{
+			Gnome.Vfs.Vfs.Initialize ();
+
+			collection = new FSpot.UriCollection ();
+			item = new BrowsablePointer (collection, 0);
+			item.Changed += delegate {
+				changed = true;
+			};
+		}
+		
+		[Test]
+	        public void ChangeNotification ()
+		{
+			collection.Clear ();
+			item.Index = 0;
+
+			collection.Add (new System.Uri ("file:///blah.jpg"));
+			Assert.IsTrue (item.IsValid);
+			Assert.IsTrue (changed);
+			
+			changed = false;
+			collection.Add (new System.Uri ("file:///test.png"));
+			Assert.IsFalse (changed);
+
+			collection.MarkChanged (0);
+			Assert.IsTrue (changed);
+		       
+			changed = false;
+			item.MoveNext ();
+			Assert.IsTrue (changed);
+			Assert.AreEqual (item.Index, 1);
+
+			changed = false;
+			collection.Add (new System.Uri ("file:///bill.png"));
+			Assert.IsFalse (changed);
+		}
+
+		[Test]
+		public void Motion ()
+		{
+			collection.Clear ();
+			item.Index = 0;
+
+			collection.Add (new System.Uri ("file:///fake.png"));
+			collection.Add (new System.Uri ("file:///mynameisedd.jpg"));
+			Assert.AreEqual (item.Index, 0);
+
+			changed = false;
+			item.MoveNext ();
+			Assert.IsTrue (changed);
+
+			Assert.AreEqual (item.Index, 1);
+			item.MoveNext ();
+			Assert.AreEqual (item.Index, 1);
+			item.MoveNext (true);
+			Assert.AreEqual (item.Index, 0);
+
+			changed = false;
+			item.MovePrevious (true);
+			Assert.IsTrue (changed);
+
+			Assert.AreEqual (item.Index, 1);
+			item.MovePrevious ();
+			Assert.AreEqual (item.Index, 0);
+			item.MovePrevious ();
+			Assert.AreEqual (item.Index, 0);
+		}
+	}
+}
+#endif
+

Added: trunk/Tests/src/Makefile
==============================================================================
--- (empty file)
+++ trunk/Tests/src/Makefile	Wed Jan 16 15:55:02 2008
@@ -0,0 +1,23 @@
+all: test
+
+TESTASSEMBLY = f-spot.tests.dll
+
+SOURCES = 				\
+	IBrowsableItem.cs		\
+	TagStore.cs
+
+PKG = 					\
+	-pkg:mono-nunit			\
+	-pkg:gnome-vfs-sharp-2.0	\
+	-pkg:gtk-sharp-2.0
+
+MCSFLAGS = -t:library $(PKG) -r:../../src/f-spot.exe -d:ENABLE_NUNIT
+
+$(TESTASSEMBLY): $(SOURCES)
+	gmcs $(MCSFLAGS) $(SOURCES) -out:$(TESTASSEMBLY)
+
+test: $(TESTASSEMBLY)
+	export MONO_PATH=../../src:../../semweb:$MONO_PATH; nunit-console2 $(TESTASSEMBLY)
+
+clean:
+	rm -f *~ *.dll TestResult.xml *.db

Added: trunk/Tests/src/TagStore.cs
==============================================================================
--- (empty file)
+++ trunk/Tests/src/TagStore.cs	Wed Jan 16 15:55:02 2008
@@ -0,0 +1,84 @@
+#if ENABLE_NUNIT
+using NUnit.Framework;
+using System;
+using System.IO;
+using System.Collections.Generic;
+
+namespace FSpot.Tests
+{
+	[TestFixture]
+	public class TagStoreTests
+	{
+		Db db;
+		const string path = "./TagStoreTest.db";
+
+		[SetUp]
+		public void SetUp ()
+		{
+			Gtk.Application.Init ();
+			try {
+				File.Delete (path);
+			} catch {}
+
+			db = new Db ();
+			db.Init (path, true);
+		}
+
+		[TearDown]
+		public void TearDown ()
+		{
+			db.Dispose ();
+		}
+
+		[Test]
+		public void InsertCloseAndCheck ()
+		{
+			Category people_category = db.Tags.GetTagByName ("People") as Category;
+			db.Tags.CreateTag (people_category, "Anna");
+			db.Tags.CreateTag (people_category, "Ettore");
+			Tag miggy_tag = db.Tags.CreateTag (people_category, "Miggy");
+			miggy_tag.SortPriority = -1;
+			db.Tags.Commit (miggy_tag);
+	
+			Category places_category = db.Tags.GetTagByName ("Places") as Category;
+			db.Tags.CreateTag (places_category, "Milan");
+			db.Tags.CreateTag (places_category, "Boston");
+	
+			Category exotic_category = db.Tags.CreateCategory (places_category, "Exotic");
+			db.Tags.CreateTag (exotic_category, "Bengalore");
+			db.Tags.CreateTag (exotic_category, "Manila");
+			Tag tokyo_tag = db.Tags.CreateTag (exotic_category, "Tokyo");
+	
+			tokyo_tag.Category = places_category;
+			tokyo_tag.Name = "Paris";
+			db.Tags.Commit (tokyo_tag);
+	
+			db.Dispose ();
+	
+			db.Init (path, false);
+			Category cat = db.Tags.GetTagByName ("People") as Category;
+			Assert.AreEqual ("People", cat.Name);
+			List<Tag> list = new List<Tag> (cat.Children);
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Anna")));
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Ettore")));
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Miggy")));
+
+			cat = db.Tags.GetTagByName ("Places") as Category;
+			Assert.AreEqual ("Places", cat.Name);
+			list = new List<Tag> (cat.Children);
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Milan")));
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Boston")));
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Exotic")));
+			Assert.IsTrue (db.Tags.GetTagByName ("Exotic") is Category);
+
+			cat = db.Tags.GetTagByName ("Exotic") as Category;
+			Assert.AreEqual ("Exotic", cat.Name);
+			list = new List<Tag> (cat.Children);
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Bengalore")));
+			Assert.IsTrue (list.Contains (db.Tags.GetTagByName ("Manila")));
+		}
+
+	}
+}
+#endif
+



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