banshee r3877 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Streaming src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue src/Libraries/Hyena/Hyena.Data.Sqlite tests tests/Banshee.Core tests/Banshee.ThickClient
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3877 - in trunk/banshee: . src/Core/Banshee.Core/Banshee.Streaming src/Core/Banshee.Services/Banshee.Sources src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue src/Libraries/Hyena/Hyena.Data.Sqlite tests tests/Banshee.Core tests/Banshee.ThickClient
- Date: Mon, 5 May 2008 17:09:54 +0100 (BST)
Author: gburt
Date: Mon May 5 16:09:54 2008
New Revision: 3877
URL: http://svn.gnome.org/viewvc/banshee?rev=3877&view=rev
Log:
2008-05-05 Gabriel Burt <gabriel burt gmail com>
* src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs: Fix
up disposing.
* src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs:
* src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs:
* src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs: Get rid of
IDisposable in DatabaseSource, reflect changes in subclasses.
* src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs: When the
SourceManager is being disposed, recursively dispose any extension
sources. Also dispose them when their extension goes away. Do not
dispose other sources; leave that to whoever created them.
* src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs: Remove
WriteLines.
* src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs: Add public
static LogAll property that can be enabled/disabled at run time to turn on
logging/timing for every single SQL command.
* tests/ConsoleUi.cs: Modified to not use a separate test AppDomain,
allowing us to fully load Banshee from within a unit test.
* tests/Banshee.ThickClient/GuiTests.cs: Still commented out, some tweaks
though.
* tests/Makefile.am: Put the assemblies into DIR_BIN, and run from there;
simplifies the MONO_PATH and mono.addins business when running tests.
* tests/Banshee.Core/TaglibReadWriteTests.cs: Update paths.
* tests/BansheeTests.cs: Tweaks to the StartBanshee stuff, not used yet.
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
trunk/banshee/tests/Banshee.Core/TaglibReadWriteTests.cs
trunk/banshee/tests/Banshee.ThickClient/GuiTests.cs
trunk/banshee/tests/BansheeTests.cs
trunk/banshee/tests/ConsoleUi.cs
trunk/banshee/tests/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs (original)
+++ trunk/banshee/src/Core/Banshee.Core/Banshee.Streaming/SaveTrackMetadataJob.cs Mon May 5 16:09:54 2008
@@ -49,17 +49,14 @@
public void Run ()
{
- Console.WriteLine ("in metadata write");
if (!LibrarySchema.WriteMetadata.Get ()) {
Console.WriteLine ("Skipping scheduled metadata write, preference disabled after scheduling");
return;
}
- Console.WriteLine ("doing metadata write, artist = {0}", track.ArtistName);
// Note: this should be kept in sync with the metadata read in StreamTagger.cs
TagLib.File file = StreamTagger.ProcessUri (track.Uri);
file.Tag.Performers = new string [] { track.ArtistName };
- Console.WriteLine ("Performers is set to {0}", file.Tag.Performers[0]);
file.Tag.Album = track.AlbumTitle;
file.Tag.Genres = new string [] { track.Genre };
file.Tag.Title = track.TrackTitle;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/DatabaseSource.cs Mon May 5 16:09:54 2008
@@ -47,7 +47,7 @@
namespace Banshee.Sources
{
- public abstract class DatabaseSource : Source, ITrackModelSource, IDurationAggregator, IFileSizeAggregator, IDisposable
+ public abstract class DatabaseSource : Source, ITrackModelSource, IDurationAggregator, IFileSizeAggregator
{
protected delegate void TrackRangeHandler (DatabaseTrackListModel model, RangeCollection.Range range);
@@ -74,11 +74,6 @@
public abstract void Save ();
- public virtual void Dispose ()
- {
- //Save ();
- }
-
protected override void Initialize ()
{
base.Initialize ();
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/PrimarySource.cs Mon May 5 16:09:54 2008
@@ -151,10 +151,8 @@
{
}
- public override void Dispose ()
+ public virtual void Dispose ()
{
- base.Dispose ();
-
if (Application.ShuttingDown)
return;
Modified: trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs (original)
+++ trunk/banshee/src/Core/Banshee.Services/Banshee.Sources/SourceManager.cs Mon May 5 16:09:54 2008
@@ -82,25 +82,27 @@
public void Dispose ()
{
lock (this) {
- // Do not dispose extension sources
+ try {
+ AddinManager.RemoveExtensionNodeHandler ("/Banshee/SourceManager/Source", OnExtensionChanged);
+ } catch {}
+
+ active_source = null;
+ default_source = null;
+ music_library = null;
+ video_library = null;
+
+ // Do dispose extension sources
foreach (Source source in extension_sources.Values) {
- // Only dispose extension sources that explicitly tell us to, otherwise
- // assume their Service or somesuch will Dispose them.
- RemoveSource (source, source.Properties.Get<bool> ("SourceManager.Dispose"));
+ RemoveSource (source, true);
}
- // But do dispose non-extension sources
+ // But do not dispose non-extension sources
while (sources.Count > 0) {
- RemoveSource (sources[0], true);
+ RemoveSource (sources[0], false);
}
sources.Clear ();
extension_sources.Clear ();
- active_source = default_source = null;
- music_library = null;
- video_library = null;
-
- AddinManager.RemoveExtensionNodeHandler ("/Banshee/SourceManager/Source", OnExtensionChanged);
}
}
@@ -116,7 +118,7 @@
} else if (args.Change == ExtensionChange.Remove && extension_sources.ContainsKey (node.Id)) {
Source source = extension_sources[node.Id];
extension_sources.Remove (node.Id);
- RemoveSource (source);
+ RemoveSource (source, true);
}
}
}
@@ -173,7 +175,7 @@
RemoveSource (source, false);
}
- public void RemoveSource (Source source, bool dispose)
+ public void RemoveSource (Source source, bool recursivelyDispose)
{
if(source == null || !ContainsSource (source)) {
return;
@@ -190,10 +192,10 @@
sources.Remove(source);
foreach(Source child_source in source.Children) {
- RemoveSource (child_source, dispose);
+ RemoveSource (child_source, recursivelyDispose);
}
- if (dispose) {
+ if (recursivelyDispose) {
IDisposable disposable = source as IDisposable;
if (disposable != null) {
disposable.Dispose ();
Modified: trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.Lastfm/Banshee.Lastfm.Radio/LastfmSource.cs Mon May 5 16:09:54 2008
@@ -99,8 +99,6 @@
Connection.StateChanged += HandleConnectionStateChanged;
UpdateUI ();
- Properties.Set<bool> ("SourceManager.Dispose", true);
-
Properties.SetString ("ActiveSourceUIResource", "ActiveSourceUI.xml");
Properties.SetString ("GtkActionPath", "/LastfmSourcePopup");
Properties.SetString ("Icon.Name", "lastfm-audioscrobbler");
@@ -118,21 +116,12 @@
public void Dispose ()
{
Connection.StateChanged -= HandleConnectionStateChanged;
+ Connection.Dispose ();
actions.Dispose ();
- ClearChildSources ();
- }
-
- public override void ClearChildSources ()
- {
- lock (Children) {
- foreach (StationSource child in Children) {
- //if (SourceManager.ContainsSource (child))
- // SourceManager.RemoveSource (child);
- child.Dispose ();
- }
- }
-
- base.ClearChildSources ();
+
+ actions = null;
+ connection = null;
+ account = null;
}
/*public override void AddChildSource (ChildSource source)
Modified: trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs (original)
+++ trunk/banshee/src/Extensions/Banshee.PlayQueue/Banshee.PlayQueue/PlayQueueSource.cs Mon May 5 16:09:54 2008
@@ -131,10 +131,8 @@
}
}
- public override void Dispose ()
+ public void Dispose ()
{
- base.Dispose ();
-
ServiceManager.PlayerEngine.DisconnectEvent (OnPlayerEvent);
if (ClearOnQuitSchema.Get ()) {
Modified: trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs (original)
+++ trunk/banshee/src/Libraries/Hyena/Hyena.Data.Sqlite/HyenaSqliteCommand.cs Mon May 5 16:09:54 2008
@@ -51,9 +51,16 @@
private string command_formatted = null;
private int parameter_count = 0;
private object [] current_values;
+ private int ticks;
#region Properties
+ private static bool log_all = false;
+ public static bool LogAll {
+ get { return log_all; }
+ set { log_all = value; }
+ }
+
public string Text {
get { return command; }
}
@@ -88,10 +95,13 @@
SqliteCommand sql_command = new SqliteCommand (CurrentSqlText);
sql_command.Connection = connection;
- //Log.DebugFormat ("Executing {0}", sql_command.CommandText);
+
hconnection.OnExecuting (sql_command);
try {
+ if (log_all)
+ ticks = System.Environment.TickCount;
+
switch (command_type) {
case HyenaCommandType.Reader:
result = sql_command.ExecuteReader ();
@@ -107,6 +117,9 @@
result = sql_command.LastInsertRowID ();
break;
}
+
+ if (log_all)
+ Log.DebugFormat ("Executed SQL in {0} ms: {1}", System.Environment.TickCount - ticks, sql_command.CommandText);
} catch (Exception e) {
Log.DebugFormat (String.Format ("Exception executing command: {0}", sql_command.CommandText), e.ToString ());
execution_exception = e;
Modified: trunk/banshee/tests/Banshee.Core/TaglibReadWriteTests.cs
==============================================================================
--- trunk/banshee/tests/Banshee.Core/TaglibReadWriteTests.cs (original)
+++ trunk/banshee/tests/Banshee.Core/TaglibReadWriteTests.cs Mon May 5 16:09:54 2008
@@ -29,7 +29,6 @@
using System;
using NUnit.Framework;
-using Mono.Addins;
using Banshee.Base;
using Banshee.Collection;
using Banshee.Streaming;
@@ -41,9 +40,8 @@
static string [] files;
static TaglibReadWriteTests () {
- AddinManager.Initialize (Pwd + "/../bin/");
files = new string [] {
- Pwd + "/data/test.mp3",
+ Pwd + "/../tests/data/test.mp3",
};
}
@@ -69,7 +67,7 @@
try {
AssertForEach<string> (files, delegate (string uri) {
string extension = System.IO.Path.GetExtension (uri);
- newuri = new SafeUri (Pwd + "/data/test_write." + extension);
+ newuri = new SafeUri (Pwd + "/../tests/data/test_write." + extension);
Banshee.IO.File.Copy (new SafeUri (uri), newuri, true);
Modified: trunk/banshee/tests/Banshee.ThickClient/GuiTests.cs
==============================================================================
--- trunk/banshee/tests/Banshee.ThickClient/GuiTests.cs (original)
+++ trunk/banshee/tests/Banshee.ThickClient/GuiTests.cs Mon May 5 16:09:54 2008
@@ -41,11 +41,9 @@
{
Log.InformationFormat ("About to start Banshee from unit test, this thread = {0}", System.Threading.Thread.CurrentThread.ManagedThreadId);
StartBanshee ();
- Log.Information ("Started Banshee from unit test, sleeping 5 seconds");
+ Log.Information ("Started Banshee from unit test");
- System.Threading.Thread.Sleep (5000);
-
- Log.Information ("Shutting down Banshee");
- StopBanshee ();
+ //Log.Information ("Shutting down Banshee");
+ //StopBanshee ();
}*/
}
Modified: trunk/banshee/tests/BansheeTests.cs
==============================================================================
--- trunk/banshee/tests/BansheeTests.cs (original)
+++ trunk/banshee/tests/BansheeTests.cs Mon May 5 16:09:54 2008
@@ -28,15 +28,20 @@
using System;
using System.Reflection;
+using System.Threading;
+
using NUnit.Framework;
+using Hyena;
+using Mono.Addins;
+
public abstract class BansheeTests
{
public static string Pwd;
static BansheeTests () {
Hyena.Log.Debugging = true;
Pwd = Mono.Unix.UnixDirectoryInfo.GetCurrentDirectory ();
- //AddinManager.Initialize (Pwd + "/../bin/");
+ AddinManager.Initialize (Pwd + "/../bin/");
}
public delegate void TestRunner<T> (T item);
@@ -53,20 +58,36 @@
Assert.Fail ("\n" + sb.ToString ());
}
+ private static Thread main_loop;
public static void StartBanshee ()
{
+ if (main_loop != null) {
+ Hyena.Log.Debug ("Main loop not null, not starting");
+ return;
+ }
+
System.IO.Directory.CreateDirectory (Pwd + "/tmp");
Banshee.Base.ApplicationContext.CommandLine["db"] = Pwd + "/tmp/banshee.db";
Banshee.Base.ApplicationContext.CommandLine["uninstalled"] = String.Empty;
- System.Threading.ThreadPool.QueueUserWorkItem (delegate {
- Banshee.Gui.GtkBaseClient.Entry<Nereid.Client> ();
- });
+ main_loop = new Thread (StartNereid);
+ main_loop.IsBackground = false;
+ main_loop.Start ();
+ }
+
+ private static void StartNereid ()
+ {
+ Banshee.Gui.GtkBaseClient.Entry<Nereid.Client> ();
}
public static void StopBanshee ()
{
- Banshee.ServiceStack.Application.Shutdown ();
- Banshee.IO.Directory.Delete (Pwd + "/tmp", true);
+ Banshee.Base.ThreadAssist.ProxyToMain (delegate {
+ Banshee.ServiceStack.Application.Shutdown ();
+ Banshee.IO.Directory.Delete (Pwd + "/tmp", true);
+ });
+
+ main_loop.Join ();
+ main_loop = null;
}
}
Modified: trunk/banshee/tests/ConsoleUi.cs
==============================================================================
--- trunk/banshee/tests/ConsoleUi.cs (original)
+++ trunk/banshee/tests/ConsoleUi.cs Mon May 5 16:09:54 2008
@@ -25,6 +25,14 @@
' 3. This notice may not be removed or altered from any source distribution.
'
'***********************************************************************************/
+
+/* NOTE: This is an altered copy of the original file from the NUnit team. It
+ * has been modified to not use a separate test AppDomain. It was altered by
+ * Gabriel Burt. See Banshee's svn history for the exact changes. These changes
+ * will probably not be needed if/when we use NUnit 2.4 and after, since they have
+ * a command line option to not use the separate AppDomain.
+ */
+
#endregion
namespace NUnit.Console
@@ -160,7 +168,7 @@
Console.WriteLine();
}
- private static Test MakeTestFromCommandLine(TestDomain testDomain, ConsoleOptions parser)
+ private static Test MakeTestFromCommandLine(TestRunner runner, ConsoleOptions parser)
{
NUnitProject project;
@@ -174,7 +182,9 @@
else
project = NUnitProject.FromAssemblies( (string[])parser.Parameters.ToArray( typeof( string ) ) );
- return testDomain.Load( project, parser.fixture );
+ //return testDomain.Load( project, parser.fixture );
+ //return runner.Load (project.ActiveConfig.Assemblies[0].FullPath, parser.fixture);
+ return runner.Load (project.ProjectPath, project.ActiveConfig.TestAssemblies);//, parser.fixture);
}
public ConsoleUi()
@@ -194,10 +204,17 @@
? new ConsoleWriter( new StreamWriter( options.err ) )
: new ConsoleWriter(Console.Error);
- TestDomain testDomain = new TestDomain(outStream, errorStream);
- if ( options.noshadow ) testDomain.ShadowCopyFiles = false;
+ // Mostly copied from TestDomain.cs
+ object obj = System.AppDomain.CurrentDomain.CreateInstanceAndUnwrap(
+ typeof(RemoteTestRunner).Assembly.FullName,
+ typeof(RemoteTestRunner).FullName,
+ false, BindingFlags.Default,null,null,null,null,null);
+
+ RemoteTestRunner runner = (RemoteTestRunner) obj;
+ runner.Out = outStream;
+ runner.Error = errorStream;
- Test test = MakeTestFromCommandLine(testDomain, options);
+ Test test = MakeTestFromCommandLine(runner, options);
if(test == null)
{
@@ -211,7 +228,7 @@
string savedDirectory = Environment.CurrentDirectory;
- if (options.HasInclude)
+ /*if (options.HasInclude)
{
Console.WriteLine( "Included categories: " + options.include );
testDomain.SetFilter( new CategoryFilter( options.IncludedCategories ) );
@@ -220,19 +237,23 @@
{
Console.WriteLine( "Excluded categories: " + options.exclude );
testDomain.SetFilter( new CategoryFilter( options.ExcludedCategories, true ) );
- }
+ }*/
TestResult result = null;
- if ( options.thread )
+ /*if ( options.thread )
{
testDomain.RunTest( collector );
testDomain.Wait();
result = testDomain.Result;
}
else
- {
- result = testDomain.Run( collector );
- }
+ {*/
+ using( new TestExceptionHandler(delegate(object o, UnhandledExceptionEventArgs e) {
+ collector.UnhandledException( (Exception)e.ExceptionObject );
+ }) ) {
+ result = runner.Run( collector );
+ }
+ //}
Directory.SetCurrentDirectory( savedDirectory );
@@ -258,9 +279,6 @@
outStream.Flush();
errorStream.Flush();
- if ( testDomain != null )
- testDomain.Unload();
-
return result.IsFailure ? 1 : 0;
}
Modified: trunk/banshee/tests/Makefile.am
==============================================================================
--- trunk/banshee/tests/Makefile.am (original)
+++ trunk/banshee/tests/Makefile.am Mon May 5 16:09:54 2008
@@ -4,7 +4,7 @@
NUNIT_FLAGS = @MONO_NUNIT_LIBS@
ASSEMBLY_NAME = banshee-tests
-ASSEMBLY = $(ASSEMBLY_NAME).dll
+ASSEMBLY = $(DIR_BIN)/$(ASSEMBLY_NAME).dll
ASSEMBLY_CSFILES = \
$(srcdir)/BansheeTests.cs \
$(srcdir)/Hyena/CryptoUtilTests.cs \
@@ -24,13 +24,15 @@
# Banshee.Services/Xspf/Xspf.cs
NUNIT_TESTER_NAME = ConsoleUi
-NUNIT_TESTER = $(NUNIT_TESTER_NAME).exe
+NUNIT_TESTER = $(DIR_BIN)/$(NUNIT_TESTER_NAME).exe
NUNIT_TESTER_CSFILES = \
AssemblyInfo.cs \
ConsoleUi.cs
+REF_BANSHEE_NUNIT = $(LINK_HYENA_DEPS) $(LINK_BANSHEE_CORE_DEPS) $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_NEREID_DEPS) $(ASSEMBLY_CSFILES) $(REF_BACKEND_UNIX)
+
$(ASSEMBLY): $(ASSEMBLY_CSFILES)
- $(MCS) $(MCS_FLAGS) $(NUNIT_FLAGS) -out:$@ -target:library -r:System.Xml $(LINK_HYENA_DEPS) $(LINK_BANSHEE_CORE_DEPS) $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_NEREID_DEPS) $(ASSEMBLY_CSFILES) $(REF_BACKEND_UNIX) -r:$(DIR_BIN)/Banshee.Unix.dll
+ $(MCS) $(MCS_FLAGS) $(NUNIT_FLAGS) -out:$@ -target:library -r:System.Xml $(REF_BANSHEE_NUNIT) -r:$(DIR_BIN)/Banshee.Unix.dll
$(NUNIT_TESTER): $(NUNIT_TESTER_CSFILES)
$(MCS) $(MCS_FLAGS) -out:$@ $(NUNIT_FLAGS) $(NUNIT_TESTER_CSFILES)
@@ -39,12 +41,14 @@
all: $(ASSEMBLY)
test: $(NUNIT_TESTER) $(ASSEMBLY)
- LANG=it_IT MONO_PATH="$(top_builddir)/bin" mono --debug $(NUNIT_TESTER) $(ASSEMBLY)
+ @pushd $(top_builddir)/bin; \
+ LANG=it_IT MONO_PATH="$(DIR_BIN)" mono --debug $(NUNIT_TESTER) $(ASSEMBLY)
+ popd;
endif
EXTRA_DIST = $(ASSEMBLY_CSFILES)
-CLEANFILES = $(ASSEMBLY) $(NUNIT_TESTER) TestResult.xml
+CLEANFILES = $(ASSEMBLY) $(NUNIT_TESTER) $(DIR_BIN)/TestResult.xml
DISTCLEANFILES = *.mdb *.dll *.exe
MAINTAINERCLEANFILES = Makefile.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]