|
Lines 38-62
Link Here
|
| 38 |
[Test] |
38 |
[Test] |
| 39 |
public void OpenFileDialog () |
39 |
public void OpenFileDialog () |
| 40 |
{ |
40 |
{ |
| 41 |
TestDialog (new SWF.OpenFileDialog ()); |
41 |
using (var runner = new DialogRunner (new SWF.OpenFileDialog ())) { |
|
|
42 |
VerifyBasicProperties (runner.Dialog); |
| 43 |
|
| 44 |
UiaAtkBridge.Window dialogAdapter = |
| 45 |
BridgeTester.GetAdapterForWidget (runner.Dialog) as UiaAtkBridge.Window; |
| 46 |
|
| 47 |
Atk.Object popupButtonPanelAdapter = dialogAdapter.RefAccessibleChild (10); |
| 48 |
Assert.AreEqual (6, popupButtonPanelAdapter.NAccessibleChildren, "PopupButtonPanel (toolbar) should have 6 children"); |
| 49 |
|
| 50 |
Atk.Object popupButtonAdapter1 = popupButtonPanelAdapter.RefAccessibleChild (0).RefAccessibleChild (0); |
| 51 |
AtkTester.States (popupButtonAdapter1, |
| 52 |
Atk.StateType.Enabled, |
| 53 |
Atk.StateType.Selectable, |
| 54 |
Atk.StateType.Focusable, |
| 55 |
Atk.StateType.Sensitive, |
| 56 |
Atk.StateType.Showing, |
| 57 |
Atk.StateType.Visible); |
| 58 |
// TODO: Simulate selecting so we can teset Selected/Focused |
| 59 |
} |
| 42 |
} |
60 |
} |
| 43 |
|
61 |
|
| 44 |
[Test] |
62 |
[Test] |
| 45 |
public void SaveFileDialog () |
63 |
public void SaveFileDialog () |
| 46 |
{ |
64 |
{ |
| 47 |
TestDialog (new SWF.SaveFileDialog ()); |
65 |
using (var runner = new DialogRunner (new SWF.SaveFileDialog ())) { |
|
|
66 |
VerifyBasicProperties (runner.Dialog); |
| 67 |
} |
| 48 |
} |
68 |
} |
| 49 |
|
69 |
|
| 50 |
[Test] |
70 |
[Test] |
| 51 |
public void ColorDialog () |
71 |
public void ColorDialog () |
| 52 |
{ |
72 |
{ |
| 53 |
TestDialog (new SWF.ColorDialog ()); |
73 |
using (var runner = new DialogRunner (new SWF.ColorDialog ())) { |
|
|
74 |
VerifyBasicProperties (runner.Dialog); |
| 75 |
} |
| 54 |
} |
76 |
} |
| 55 |
|
77 |
|
| 56 |
[Test] |
78 |
[Test] |
| 57 |
public void FontDialog () |
79 |
public void FontDialog () |
| 58 |
{ |
80 |
{ |
| 59 |
TestDialog (new SWF.FontDialog ()); |
81 |
using (var runner = new DialogRunner (new SWF.FontDialog ())) { |
|
|
82 |
VerifyBasicProperties (runner.Dialog); |
| 83 |
} |
| 60 |
} |
84 |
} |
| 61 |
|
85 |
|
| 62 |
[Test] |
86 |
[Test] |
|
Lines 70-123
Link Here
|
| 70 |
} catch (System.Exception e) { |
94 |
} catch (System.Exception e) { |
| 71 |
exception = e; |
95 |
exception = e; |
| 72 |
} |
96 |
} |
| 73 |
TestDialog (new SWF.ThreadExceptionDialog (exception)); |
97 |
|
|
|
98 |
using (var runner = new DialogRunner (new SWF.ThreadExceptionDialog (exception))) { |
| 99 |
VerifyBasicProperties (runner.Dialog); |
| 100 |
} |
| 74 |
} |
101 |
} |
| 75 |
|
102 |
|
| 76 |
|
103 |
|
| 77 |
static void TestDialog (System.ComponentModel.Component dialog) |
104 |
private void VerifyBasicProperties (System.ComponentModel.Component dialog) |
| 78 |
{ |
105 |
{ |
| 79 |
new DialogTesterInner (dialog).Test (); |
106 |
UiaAtkBridge.Window dialogAdapter = BridgeTester.GetAdapterForWidget (dialog) as UiaAtkBridge.Window; |
|
|
107 |
Assert.IsNotNull (dialogAdapter, "dialogAdapter has a different type than Window"); |
| 108 |
Assert.AreEqual (dialogAdapter.Role, Atk.Role.Dialog, "dialog should have dialog role"); |
| 109 |
Assert.IsTrue (dialogAdapter.NAccessibleChildren > 0, "dialog should have children"); |
| 80 |
} |
110 |
} |
| 81 |
|
111 |
} |
| 82 |
private class DialogTesterInner { |
|
|
| 83 |
System.ComponentModel.Component dialog; |
| 84 |
Thread th; |
| 85 |
|
112 |
|
| 86 |
internal DialogTesterInner (System.ComponentModel.Component dialog) |
113 |
public class DialogRunner : IDisposable |
| 87 |
{ |
114 |
{ |
| 88 |
this.dialog = dialog; |
115 |
private SWF.CommonDialog commonDialog; |
| 89 |
} |
116 |
private SWF.ThreadExceptionDialog threadExceptionDialog; |
|
|
117 |
private Thread dialogThread; |
| 118 |
|
| 119 |
public DialogRunner (System.ComponentModel.Component dialog) |
| 120 |
{ |
| 121 |
commonDialog = dialog as SWF.CommonDialog; |
| 122 |
if (commonDialog == null) |
| 123 |
threadExceptionDialog = dialog as SWF.ThreadExceptionDialog; |
| 124 |
if (commonDialog == null && threadExceptionDialog == null) |
| 125 |
throw new ArgumentException ("Unsupported dialog type: " + dialog); |
| 90 |
|
126 |
|
| 91 |
internal void Test () |
127 |
dialogThread = new Thread (new ThreadStart (Show)); |
| 92 |
{ |
128 |
dialogThread.Start (); |
| 93 |
th = new Thread (new ThreadStart (Show)); |
129 |
Thread.Sleep (10000); |
| 94 |
th.SetApartmentState (ApartmentState.STA); |
130 |
} |
| 95 |
try { |
131 |
|
| 96 |
th.Start (); |
132 |
public void Dispose () |
| 97 |
Thread.Sleep (10000); |
133 |
{ |
| 98 |
UiaAtkBridge.Window dialogAdapter = BridgeTester.GetAdapterForWidget (dialog) as UiaAtkBridge.Window; |
134 |
if (commonDialog != null) |
| 99 |
Assert.IsNotNull (dialogAdapter, "dialogAdapter has a different type than Window"); |
135 |
commonDialog.Dispose (); |
| 100 |
Assert.AreEqual (dialogAdapter.Role, Atk.Role.Dialog, "dialog should have dialog role"); |
136 |
else if (threadExceptionDialog != null) { |
| 101 |
Assert.IsTrue (dialogAdapter.NAccessibleChildren > 0, "dialog should have children"); |
137 |
if (threadExceptionDialog.InvokeRequired) { |
|
|
138 |
threadExceptionDialog.BeginInvoke (new SWF.MethodInvoker (Dispose)); |
| 139 |
return; |
| 102 |
} |
140 |
} |
| 103 |
finally { |
141 |
threadExceptionDialog.Close (); |
| 104 |
dialog.Dispose (); |
142 |
threadExceptionDialog.Dispose (); |
| 105 |
th.Abort (); |
|
|
| 106 |
} |
| 107 |
} |
143 |
} |
| 108 |
|
144 |
|
| 109 |
private void Show () |
145 |
if (dialogThread != null) |
| 110 |
{ |
146 |
dialogThread.Abort (); |
| 111 |
if (dialog is SWF.CommonDialog) |
147 |
} |
| 112 |
((SWF.CommonDialog)dialog).ShowDialog (); |
148 |
|
| 113 |
else if (dialog is SWF.ThreadExceptionDialog) |
149 |
private void Show () |
| 114 |
((SWF.ThreadExceptionDialog)dialog).ShowDialog (); |
150 |
{ |
| 115 |
else |
151 |
if (commonDialog != null) |
| 116 |
throw new NotSupportedException ("Unsupported dialog type: " + dialog); |
152 |
commonDialog.ShowDialog (); |
|
|
153 |
else if (threadExceptionDialog != null) |
| 154 |
threadExceptionDialog.ShowDialog (); |
| 155 |
} |
| 156 |
|
| 157 |
public System.ComponentModel.Component Dialog { |
| 158 |
get { |
| 159 |
return (System.ComponentModel.Component) commonDialog ?? |
| 160 |
(System.ComponentModel.Component) threadExceptionDialog; |
| 117 |
} |
161 |
} |
| 118 |
} |
162 |
} |
| 119 |
} |
163 |
} |
| 120 |
|
|
|
| 121 |
|
| 122 |
|
| 123 |
} |
164 |
} |