Try when running an Iterate thread.
Fix some tests.

svn path=/trunk/at-spi-sharp/; revision=146845
This commit is contained in:
Mike Gorse 2009-11-24 17:20:03 +00:00
Родитель 94cfbe359c
Коммит 520e1f446a
7 изменённых файлов: 103 добавлений и 41 удалений

Просмотреть файл

@ -141,15 +141,18 @@ namespace Atspi
if (!(children is UncachedChildren))
children = new UncachedChildren (this);
} else {
List<Accessible> oldChildren = children as List<Accessible>;
if (!(children is List<Accessible>))
Accessible [] oldChildren = null;
if (children is List<Accessible>) {
oldChildren = new Accessible [children.Count];
children.CopyTo (oldChildren, 0);
children = new List<Accessible> ();
}
children.Clear ();
foreach (AccessiblePath path in e.children) {
Accessible child = Registry.GetElement (path, this, true);
if (!initializing &&
(oldChildren == null ||
oldChildren.IndexOf (child) == -1))
Array.IndexOf (oldChildren, child) == -1))
Desktop.RaiseChildAdded (this, child);
children.Add (child);
}

Просмотреть файл

@ -1,3 +1,10 @@
2009-11-24 Mike Gorse <mgorse@novell.com>
* Accessible.cs: Fix firing of ChildAdded.
* Registry.cs: Try when iterating so that the thread does not
silently abort on an exception.
2009-11-19 Mike Gorse <mgorse@novell.com>
* Accessible.cs, Desktop.cs: Set Desktop role.

Просмотреть файл

@ -150,8 +150,15 @@ namespace Atspi
private void Iterate ()
{
// TODO: Make try optional; could affect performance
for (;;)
bus.Iterate ();
{
try {
bus.Iterate ();
} catch (Exception e) {
Console.WriteLine ("at-spi-sharp: Exception in Iterate: " + e);
}
}
}
}

Просмотреть файл

@ -1,3 +1,13 @@
2009-11-24 Mike Gorse <mgorse@novell.com>
* apps/Document.cs, at-spi-sharp/EventTest.cs: Improve ChildAdded and
ChildRemoved tests; stop ignore ChildRemoved.
* at-spi-sharp/EventTest.cs: Stop ignoring BoundsChanged.
* at-spi-sharp/ComponentTest.cs: Fix GetAccessibleAtPoint and stop
ignoring.
2009-11-23 Mike Gorse <mgorse@novell.com>
* apps/Document.cs: Fix to build with newest gtk-sharp 2-12 changes.

Просмотреть файл

@ -90,32 +90,47 @@ namespace TestDocument
class TestWindow: Gtk.Window
{
public TestWindow (string name) : base (name) { }
private Gtk.Button button;
private Gtk.Button button1;
private Gtk.Button button2;
private Gtk.HBox box;
public bool AddChild ()
{
if (button != null)
if (box == null) {
box = new Gtk.HBox ();
Add (box);
}
if (box.Children.Length == 0) {
if (button1 == null)
button1 = new Gtk.Button ("button1");
box.Add (button1);
return true;
} else if (box.Children.Length == 1) {
if (button2 == null)
button2 = new Gtk.Button ("button2");
box.Add (button2);
return true;
} else
return false;
button = new Gtk.Button ("button");
Add (button);
GLib.Signal.Emit (Accessible,
"children_changed::add",
0u,
Accessible.RefAccessibleChild (0).Handle);
return true;
}
public bool RemoveChild ()
{
if (button == null)
if (box.Children.Length == 2) {
box.Remove (button2);
return true;
} else if (box.Children.Length == 1) {
box.Remove (button1);
return true;
} else
return false;
GLib.Signal.Emit (Accessible,
"children_changed::remove",
(uint)0,
Accessible.RefAccessibleChild (0).Handle);
Remove (button);
button = null;
return true;
}
public void ToggleButton ()
{
if (button1 == null)
AddChild ();
button1.Sensitive = !button1.Sensitive;
}
}
@ -401,7 +416,7 @@ namespace TestDocument
break;
case "StateChanged":
window.Children [0].Sensitive = false;
window.ToggleButton ();
break;
case "TextCaretMoved":

Просмотреть файл

@ -77,14 +77,16 @@ namespace AtSpiTest
}
[Test]
[Ignore ("crash")]
public void GetAccessibleAtPoint ()
{
Component component = frame.QueryComponent ();
BoundingBox buttonExtents;
buttonExtents = pushButton.QueryComponent().GetExtents (CoordType.Screen);
Accessible accessibleResult = component.GetAccessibleAtPoint (buttonExtents.X, buttonExtents.Y, CoordType.Screen);
Assert.AreEqual (accessibleResult, pushButton, "GetAccessibleAtPoint");
Accessible child = frame.Children [0];
BoundingBox childExtents;
childExtents = child.QueryComponent().GetExtents (CoordType.Screen);
Accessible accessibleResult = component.GetAccessibleAtPoint (childExtents.X, childExtents.Y, CoordType.Screen);
Assert.AreEqual (accessibleResult, child, "GetAccessibleAtPoint");
accessibleResult = component.GetAccessibleAtPoint (childExtents.X + childExtents.Width + 1, childExtents.Y, CoordType.Screen);
Assert.IsNull (accessibleResult, "GetAccessibleAtPoint OOR");
}
[Test]

Просмотреть файл

@ -35,6 +35,8 @@ namespace AtSpiTest
Accessible frame = null;
EditableText et = null;
int eventCount = 0;
int addEventCount = 0;
int removeEventCount = 0;
string detail;
int v1, v2;
object any;
@ -54,7 +56,6 @@ namespace AtSpiTest
// Object event tests
[Test]
[Ignore ("Hangs with ndesk-dbus 0.6")]
public void BoundsChanged ()
{
frame.ObjectEvents.BoundsChanged += OnEvent;
@ -305,26 +306,41 @@ namespace AtSpiTest
}
[Test]
[Ignore ("TODO: Figure out why ChildRemove fails")]
public void ChildRemoved ()
{
Desktop.OnChildRemoved += OnStructureChanged;
addEventCount = removeEventCount = 0;
Desktop.OnChildAdded += OnChildAdded;
Desktop.OnChildRemoved += OnChildRemoved;
et.SetTextContents ("RemoveChild");
Desktop.OnChildRemoved -= OnStructureChanged;
Sync ();
Assert.AreEqual (0, addEventCount, "addEvents when removing");
Assert.AreEqual (1, removeEventCount, "removeEvents");
Desktop.OnChildRemoved -= OnChildRemoved;
Desktop.OnChildAdded -= OnChildAdded;
et.SetTextContents ("AddChild");
AssertEvent ();
}
[Test]
public void ChildAdded ()
{
et.SetTextContents ("RemoveChild");
Desktop.OnChildAdded += OnStructureChanged;
et.SetTextContents ("AddChild");
Desktop.OnChildAdded -= OnStructureChanged;
Sync ();
AssertEvent ();
addEventCount = removeEventCount = 0;
Desktop.OnChildAdded += OnChildAdded;
Desktop.OnChildRemoved += OnChildRemoved;
et.SetTextContents ("AddChild");
Sync ();
Assert.AreEqual (1, addEventCount, "addEvents");
Assert.AreEqual (0, removeEventCount, "removeEvents when adding");
// Add a second child; ensure we don't get extra events
addEventCount = removeEventCount = 0;
et.SetTextContents ("AddChild");
Desktop.OnChildAdded -= OnChildAdded;
Sync ();
Assert.AreEqual (1, addEventCount, "addEvents #2");
Assert.AreEqual (0, removeEventCount, "removeEvents when adding #2");
Desktop.OnChildRemoved -= OnChildRemoved;
Desktop.OnChildAdded -= OnChildAdded;
}
private void OnEvent (string detail, int v1, int v2, object any)
@ -366,18 +382,20 @@ namespace AtSpiTest
eventCount++;
}
private void OnStructureChanged (Accessible parent, Accessible child)
private void OnChildAdded (Accessible parent, Accessible child)
{
eventCount++;
addEventCount++;
}
private void OnChildRemoved (Accessible parent, Accessible child)
{
removeEventCount++;
}
#endregion
private void Sync ()
{
System.Threading.Thread.Sleep (500);
// Hack to force signal popping; we really
// shouldn't need this
frame.QueryText().GetText ();
}
private void AssertEvent ()