Do not trust StateSet cache for StateType.Enabled (bug 596801)
Also fix NRE in GetText in the test app. svn path=/trunk/at-spi-sharp/; revision=155839
This commit is contained in:
Родитель
0d11a60ab6
Коммит
4607cc9b3a
|
@ -259,7 +259,7 @@ namespace Atspi
|
|||
foreach (string iface in e.interfaces)
|
||||
AddInterface (iface);
|
||||
|
||||
stateSet = new StateSet (e.states);
|
||||
stateSet = new StateSet (this, e.states);
|
||||
// Using at-spi StateChanged events to broadcast
|
||||
// changes for now; needed for gail Focused handling
|
||||
UpdateChildren (e.children);
|
||||
|
@ -432,7 +432,7 @@ namespace Atspi
|
|||
stateSet.Add (StateType.Defunct);
|
||||
return stateSet;
|
||||
}
|
||||
stateSet = new StateSet (states);
|
||||
stateSet = new StateSet (this, states);
|
||||
}
|
||||
return stateSet;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2010-04-20 Mike Gorse <mgorse@novell.com>
|
||||
|
||||
* Accessible.cs, StateSet.cs: Make StateSet cache its accessible and
|
||||
do not trust cache for StateType.Enabled (bug 596801)
|
||||
|
||||
2010-03-17 Mike Gorse <mgorse@novell.com>
|
||||
|
||||
* Accessible.cs: Recognize Application interface, and warn rather
|
||||
|
|
|
@ -33,14 +33,17 @@ namespace Atspi
|
|||
public class StateSet
|
||||
{
|
||||
private ulong states;
|
||||
private Accessible accessible;
|
||||
|
||||
public StateSet ()
|
||||
{
|
||||
accessible = null;
|
||||
states = 0;
|
||||
}
|
||||
|
||||
public StateSet (uint [] states)
|
||||
public StateSet (Accessible accessible, uint [] states)
|
||||
{
|
||||
this.accessible = accessible;
|
||||
if (states.Length != 2)
|
||||
throw new ArgumentException ("Expecting int [2]");
|
||||
this.states = (ulong)(states [1] << (sizeof (int) * 8)) | (ulong)states [0];
|
||||
|
@ -48,12 +51,24 @@ namespace Atspi
|
|||
|
||||
public bool Contains (StateType state)
|
||||
{
|
||||
// Do not trust cache for Enabled; see BNC#596801
|
||||
// TODO: Eventually remove this work-around
|
||||
if (accessible != null && state == StateType.Enabled && (states & (ulong)StateType.Defunct) == 0) {
|
||||
try {
|
||||
uint [] data = accessible.proxy.GetState ();
|
||||
states = (ulong)(data [1] << (sizeof (int) * 8)) | (ulong)data [0];
|
||||
} catch (System.Exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return (states & (ulong)state) != 0? true: false;
|
||||
}
|
||||
|
||||
public void Add (StateType state)
|
||||
{
|
||||
states |= (ulong)state;
|
||||
if (state == StateType.Defunct)
|
||||
accessible = null;
|
||||
}
|
||||
|
||||
public void Remove (StateType state)
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2010-04-20 Mike Gorse <mgorse@novell.com>
|
||||
|
||||
* apps/Document.cs: Fix NRE in GetText.
|
||||
|
||||
* at-spi-sharp/AccessibleTest.cs: Add test for bug 596801.
|
||||
|
||||
2010-03-01 Mike Gorse <mgorse@novell.com>
|
||||
|
||||
* at-spi-sharp/Base.cs: Allow a fixture to open multiple apps.
|
||||
|
|
|
@ -245,7 +245,11 @@ namespace TestDocument
|
|||
{
|
||||
if (end_offset == -1)
|
||||
end_offset = text.Length - start_offset;
|
||||
return text.Substring (start_offset, end_offset);
|
||||
if (end_offset > text.Length)
|
||||
end_offset = text.Length;
|
||||
if (end_offset < start_offset)
|
||||
end_offset = start_offset;
|
||||
return text.Substring (start_offset, end_offset - start_offset);
|
||||
}
|
||||
|
||||
public string GetTextAfterOffset (int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset)
|
||||
|
|
|
@ -60,6 +60,16 @@ namespace AtSpiTest
|
|||
);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug596801 ()
|
||||
{
|
||||
EditableText et = documentFrame.QueryEditableText ();
|
||||
Accessible child = documentFrame.Children [0].Children [0];
|
||||
Assert.IsTrue (child.StateSet.Contains (StateType.Enabled), "Enabled");
|
||||
et.SetTextContents ("StateChanged");
|
||||
Assert.IsFalse (child.StateSet.Contains (StateType.Enabled), "Not enabled after disabling");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Relations ()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче