f-spot r4708 - in trunk: . Tests/src/Imaging src/Imaging
- From: sdelcroix svn gnome org
- To: svn-commits-list gnome org
- Subject: f-spot r4708 - in trunk: . Tests/src/Imaging src/Imaging
- Date: Thu, 12 Feb 2009 14:32:55 +0000 (UTC)
Author: sdelcroix
Date: Thu Feb 12 14:32:55 2009
New Revision: 4708
URL: http://svn.gnome.org/viewvc/f-spot?rev=4708&view=rev
Log:
2009-02-12 Stephane Delcroix <sdelcroix novell com>
* src/Imaging/PngFile.cs: move the tests to Test/
Added:
trunk/Tests/src/Imaging/PngFile.cs
Modified:
trunk/ChangeLog
trunk/src/Imaging/PngFile.cs
Added: trunk/Tests/src/Imaging/PngFile.cs
==============================================================================
--- (empty file)
+++ trunk/Tests/src/Imaging/PngFile.cs Thu Feb 12 14:32:55 2009
@@ -0,0 +1,119 @@
+//Author: Larry
+
+#if ENABLE_NUNIT
+ [TestFixture]
+ public class Tests {
+ public Tests ()
+ {
+ Gnome.Vfs.Vfs.Initialize ();
+ Gtk.Application.Init ();
+ }
+
+ [Test]
+ public void Save ()
+ {
+ Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png");
+ string path = ImageFile.TempPath ("joe.png");
+ test.Save (path, "png");
+ PngFile pimg = new PngFile (path);
+
+ string desc = "this is a png test";
+ string desc2 = "\000xa9 Novell Inc.";
+ pimg.SetDescription (desc);
+ using (Stream stream = File.OpenWrite (path)) {
+ pimg.Save (stream);
+ }
+ PngFile mod = new PngFile (path);
+ Assert.AreEqual (mod.Orientation, PixbufOrientation.TopLeft);
+ Assert.AreEqual (mod.Description, desc);
+ pimg.SetDescription (desc2);
+
+ using (Stream stream = File.OpenWrite (path)) {
+ pimg.Save (stream);
+ }
+ mod = new PngFile (path);
+ Assert.AreEqual (mod.Description, desc2);
+
+ File.Delete (path);
+ }
+
+ [Test]
+ public void Load ()
+ {
+ string desc = "(c) 2004 Jakub Steiner\n\nCreated with The GIMP";
+ Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly ();
+ string path = ImageFile.TempPath ("maddy.png");
+ using (Stream output = File.OpenWrite (path)) {
+ using (Stream source = assembly.GetManifestResourceStream ("f-spot-adjust-colors.png")) {
+ byte [] buffer = new byte [256];
+ while (source.Read (buffer, 0, buffer.Length) > 0) {
+ output.Write (buffer, 0, buffer.Length);
+ }
+ }
+ }
+ PngFile pimg = new PngFile (path);
+ Assert.AreEqual (pimg.Description, desc);
+
+ File.Delete (path);
+ }
+ }
+#endif
+
+#if false
+ public class ImageFile {
+ string Path;
+ public ImageFile (string path)
+ {
+ this.Path = path;
+ }
+ }
+
+ public static void Main (string [] args)
+ {
+ System.Collections.ArrayList failed = new System.Collections.ArrayList ();
+ Gtk.Application.Init ();
+ foreach (string path in args) {
+ Gtk.Window win = new Gtk.Window (path);
+ Gtk.HBox box = new Gtk.HBox ();
+ box.Spacing = 12;
+ win.Add (box);
+ Gtk.Image image;
+ image = new Gtk.Image ();
+
+ System.DateTime start = System.DateTime.Now;
+ System.TimeSpan one = start - start;
+ System.TimeSpan two = start - start;
+ try {
+ start = System.DateTime.Now;
+ image.Pixbuf = new Gdk.Pixbuf (path);
+ one = System.DateTime.Now - start;
+ } catch (System.Exception e) {
+ }
+ box.PackStart (image);
+
+ image = new Gtk.Image ();
+ try {
+ start = System.DateTime.Now;
+ PngFile png = new PngFile (path);
+ image.Pixbuf = png.GetPixbuf ();
+ two = System.DateTime.Now - start;
+ } catch (System.Exception e) {
+ failed.Add (path);
+ //System.Console.WriteLine ("Error loading {0}", path);
+ System.Console.WriteLine (e.ToString ());
+ }
+
+ System.Console.WriteLine ("{2} Load Time {0} vs {1}", one.TotalMilliseconds, two.TotalMilliseconds, path);
+ box.PackStart (image);
+ win.ShowAll ();
+ }
+
+ System.Console.WriteLine ("{0} Failed to Load", failed.Count);
+ foreach (string fail_path in failed) {
+ System.Console.WriteLine (fail_path);
+ }
+
+ Gtk.Application.Run ();
+ }
+#endif
+
Modified: trunk/src/Imaging/PngFile.cs
==============================================================================
--- trunk/src/Imaging/PngFile.cs (original)
+++ trunk/src/Imaging/PngFile.cs Thu Feb 12 14:32:55 2009
@@ -6,10 +6,6 @@
using System.Collections;
using System.Reflection;
-#if ENABLE_NUNIT
-using NUnit.Framework;
-#endif
-
namespace FSpot.Png {
public class PngFile : ImageFile, SemWeb.StatementSource {
PngHeader header;
@@ -1428,121 +1424,5 @@
}
}
-#if ENABLE_NUNIT
- [TestFixture]
- public class Tests {
- public Tests ()
- {
- Gnome.Vfs.Vfs.Initialize ();
- Gtk.Application.Init ();
- }
-
- [Test]
- public void Save ()
- {
- Gdk.Pixbuf test = new Gdk.Pixbuf (null, "f-spot-32.png");
- string path = ImageFile.TempPath ("joe.png");
- test.Save (path, "png");
- PngFile pimg = new PngFile (path);
-
- string desc = "this is a png test";
- string desc2 = "\000xa9 Novell Inc.";
- pimg.SetDescription (desc);
- using (Stream stream = File.OpenWrite (path)) {
- pimg.Save (stream);
- }
- PngFile mod = new PngFile (path);
- Assert.AreEqual (mod.Orientation, PixbufOrientation.TopLeft);
- Assert.AreEqual (mod.Description, desc);
- pimg.SetDescription (desc2);
-
- using (Stream stream = File.OpenWrite (path)) {
- pimg.Save (stream);
- }
- mod = new PngFile (path);
- Assert.AreEqual (mod.Description, desc2);
-
- File.Delete (path);
- }
-
- [Test]
- public void Load ()
- {
- string desc = "(c) 2004 Jakub Steiner\n\nCreated with The GIMP";
- Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly ();
- string path = ImageFile.TempPath ("maddy.png");
- using (Stream output = File.OpenWrite (path)) {
- using (Stream source = assembly.GetManifestResourceStream ("f-spot-adjust-colors.png")) {
- byte [] buffer = new byte [256];
- while (source.Read (buffer, 0, buffer.Length) > 0) {
- output.Write (buffer, 0, buffer.Length);
- }
- }
- }
- PngFile pimg = new PngFile (path);
- Assert.AreEqual (pimg.Description, desc);
-
- File.Delete (path);
- }
- }
-#endif
-
-#if false
- public class ImageFile {
- string Path;
- public ImageFile (string path)
- {
- this.Path = path;
- }
- }
-
- public static void Main (string [] args)
- {
- System.Collections.ArrayList failed = new System.Collections.ArrayList ();
- Gtk.Application.Init ();
- foreach (string path in args) {
- Gtk.Window win = new Gtk.Window (path);
- Gtk.HBox box = new Gtk.HBox ();
- box.Spacing = 12;
- win.Add (box);
- Gtk.Image image;
- image = new Gtk.Image ();
-
- System.DateTime start = System.DateTime.Now;
- System.TimeSpan one = start - start;
- System.TimeSpan two = start - start;
- try {
- start = System.DateTime.Now;
- image.Pixbuf = new Gdk.Pixbuf (path);
- one = System.DateTime.Now - start;
- } catch (System.Exception e) {
- }
- box.PackStart (image);
-
- image = new Gtk.Image ();
- try {
- start = System.DateTime.Now;
- PngFile png = new PngFile (path);
- image.Pixbuf = png.GetPixbuf ();
- two = System.DateTime.Now - start;
- } catch (System.Exception e) {
- failed.Add (path);
- //System.Console.WriteLine ("Error loading {0}", path);
- System.Console.WriteLine (e.ToString ());
- }
-
- System.Console.WriteLine ("{2} Load Time {0} vs {1}", one.TotalMilliseconds, two.TotalMilliseconds, path);
- box.PackStart (image);
- win.ShowAll ();
- }
-
- System.Console.WriteLine ("{0} Failed to Load", failed.Count);
- foreach (string fail_path in failed) {
- System.Console.WriteLine (fail_path);
- }
-
- Gtk.Application.Run ();
- }
-#endif
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]