Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-addins.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/Test
diff options
context:
space:
mode:
authorLluis Sanchez <lluis@xamarin.com>2022-10-27 20:44:01 +0300
committerLluis Sanchez <lluis@xamarin.com>2022-10-27 20:44:01 +0300
commit719779f42e582b02c023aa1b2bc3d5f1c4bc9ca4 (patch)
treeb8223add5be5cf55b655ff7c8af6e319c401199f /Test
parentee62ae03ad9571f44cb69f50380219b6524672cf (diff)
Fixed several exceptions that happen when unloading nodes
Moved notification queue from ExtensionContext to to add-in engine. The problem was that when a node is removed, it is not bound to a context anymore, but it may still need to make use of the event queue.
Diffstat (limited to 'Test')
-rw-r--r--Test/UnitTests/TestEvents.cs41
-rw-r--r--Test/UnitTests/TestExtensions.cs7
2 files changed, 47 insertions, 1 deletions
diff --git a/Test/UnitTests/TestEvents.cs b/Test/UnitTests/TestEvents.cs
index c0ca45a..3bedf9e 100644
--- a/Test/UnitTests/TestEvents.cs
+++ b/Test/UnitTests/TestEvents.cs
@@ -439,5 +439,44 @@ namespace UnitTests
{
counters[0].Update (args);
}
- }
+
+ [Test()]
+ public void TestUnloadedNode()
+ {
+ try
+ {
+ AddinManager.AddinLoadError += AddinManager_AddinLoadError;
+ Assert.AreEqual(4, AddinManager.GetExtensionNodes("/SimpleApp/Writers").Count, "count 1");
+ AddinManager.AddExtensionNodeHandler("/SimpleApp/Writers", OnExtensionChange2);
+ AddinManager.Registry.DisableAddin("SimpleApp.FileContentExtension,0.1.0");
+ Assert.AreEqual(3, AddinManager.GetExtensionNodes("/SimpleApp/Writers").Count, "count 2");
+ }
+ finally
+ {
+ AddinManager.AddinLoadError -= AddinManager_AddinLoadError;
+ AddinManager.Registry.EnableAddin("SimpleApp.FileContentExtension,0.1.0");
+ }
+ }
+
+ private void AddinManager_AddinLoadError (object sender, AddinErrorEventArgs args)
+ {
+ throw new Exception(args.Message);
+ }
+
+ void OnExtensionChange2(object s, ExtensionNodeEventArgs args)
+ {
+ if (args.Change == ExtensionChange.Add)
+ {
+ args.ExtensionNode.ExtensionNodeChanged += ExtensionNode_ExtensionNodeChanged;
+ }
+ else
+ {
+ args.ExtensionNode.ExtensionNodeChanged -= ExtensionNode_ExtensionNodeChanged;
+ }
+ }
+
+ private void ExtensionNode_ExtensionNodeChanged (object sender, ExtensionNodeEventArgs args)
+ {
+ }
+ }
}
diff --git a/Test/UnitTests/TestExtensions.cs b/Test/UnitTests/TestExtensions.cs
index 6e3812f..6befd43 100644
--- a/Test/UnitTests/TestExtensions.cs
+++ b/Test/UnitTests/TestExtensions.cs
@@ -247,5 +247,12 @@ namespace UnitTests
Assert.AreEqual ("n3", ids[6]);
Assert.AreEqual ("n4", ids[7]);
}
+
+ [Test]
+ public void TreeNodeHasAddin()
+ {
+ var node = AddinManager.GetExtensionNode("/SimpleApp/DefaultInsertBefore");
+ Assert.IsNotNull(node.Addin);
+ }
}
}