Lines 49-54
Link Here
|
49 |
import javax.swing.*; |
49 |
import javax.swing.*; |
50 |
import javax.swing.JLabel; |
50 |
import javax.swing.JLabel; |
51 |
import javax.swing.event.ChangeListener; |
51 |
import javax.swing.event.ChangeListener; |
|
|
52 |
import static junit.framework.Assert.assertTrue; |
52 |
import org.netbeans.junit.RandomlyFails; |
53 |
import org.netbeans.junit.RandomlyFails; |
53 |
import org.openide.util.*; |
54 |
import org.openide.util.*; |
54 |
import org.openide.util.HelpCtx; |
55 |
import org.openide.util.HelpCtx; |
Lines 85-95
Link Here
|
85 |
public void testAsynchronousLazyValidation () throws Exception { |
86 |
public void testAsynchronousLazyValidation () throws Exception { |
86 |
Panel panels[] = new Panel[3]; |
87 |
Panel panels[] = new Panel[3]; |
87 |
|
88 |
|
88 |
class MyPanel extends Panel implements WizardDescriptor.AsynchronousValidatingPanel<WizardDescriptor> { |
89 |
class MyPanel extends Panel implements WizardDescriptor.ExtendedAsynchronousValidatingPanel<WizardDescriptor> { |
89 |
public String validateMsg; |
90 |
public String validateMsg; |
90 |
public String failedMsg; |
91 |
public String failedMsg; |
91 |
public boolean running; |
92 |
public boolean running; |
92 |
public boolean wasEnabled; |
93 |
public boolean wasEnabled; |
|
|
94 |
public boolean validationFinished; |
93 |
|
95 |
|
94 |
public MyPanel () { |
96 |
public MyPanel () { |
95 |
super ("enhanced panel"); |
97 |
super ("enhanced panel"); |
Lines 97-109
Link Here
|
97 |
|
99 |
|
98 |
public void prepareValidation () { |
100 |
public void prepareValidation () { |
99 |
running = true; |
101 |
running = true; |
|
|
102 |
validationFinished = false; |
100 |
} |
103 |
} |
101 |
|
104 |
|
102 |
public synchronized void validate () throws WizardValidationException { |
105 |
public synchronized void validate () throws WizardValidationException { |
103 |
err.log ("validate() entry."); |
106 |
err.log ("validate() entry."); |
104 |
wasEnabled = wd.isNextEnabled () || wd.isFinishEnabled (); |
107 |
wasEnabled = wd.isNextEnabled () || wd.isFinishEnabled (); |
105 |
running = false; |
108 |
running = false; |
106 |
notifyAll (); |
|
|
107 |
if (validateMsg != null) { |
109 |
if (validateMsg != null) { |
108 |
failedMsg = validateMsg; |
110 |
failedMsg = validateMsg; |
109 |
err.log ("Throw WizardValidationException."); |
111 |
err.log ("Throw WizardValidationException."); |
Lines 112-118
Link Here
|
112 |
err.log ("validate() exit."); |
114 |
err.log ("validate() exit."); |
113 |
return; |
115 |
return; |
114 |
} |
116 |
} |
|
|
117 |
|
118 |
public synchronized void finishValidation() { |
119 |
assert SwingUtilities.isEventDispatchThread(); |
120 |
validationFinished = true; |
121 |
notifyAll (); |
115 |
} |
122 |
} |
|
|
123 |
} |
116 |
|
124 |
|
117 |
class MyFinishPanel extends MyPanel implements WizardDescriptor.FinishablePanel<WizardDescriptor> { |
125 |
class MyFinishPanel extends MyPanel implements WizardDescriptor.FinishablePanel<WizardDescriptor> { |
118 |
@Override |
126 |
@Override |
Lines 149-154
Link Here
|
149 |
} |
157 |
} |
150 |
assertFalse ("Finish is disabled during validation.", mp.wasEnabled); |
158 |
assertFalse ("Finish is disabled during validation.", mp.wasEnabled); |
151 |
assertTrue ("Wizard is ready to next validation however previous failed.", wd.isForwardEnabled ()); |
159 |
assertTrue ("Wizard is ready to next validation however previous failed.", wd.isForwardEnabled ()); |
|
|
160 |
assertTrue ("finishValidation() was called even when validation failed.", mp.validationFinished); |
152 |
assertEquals ("The lazy validation failed on Next.", mp.validateMsg, mp.failedMsg); |
161 |
assertEquals ("The lazy validation failed on Next.", mp.validateMsg, mp.failedMsg); |
153 |
assertNull ("The lazy validation failed, still no initialiaation", panels[1].component); |
162 |
assertNull ("The lazy validation failed, still no initialiaation", panels[1].component); |
154 |
assertNull ("The lazy validation failed, still no initialiaation", panels[2].component); |
163 |
assertNull ("The lazy validation failed, still no initialiaation", panels[2].component); |
Lines 174-179
Link Here
|
174 |
assertNull ("Validation on Next passes", mp.failedMsg); |
183 |
assertNull ("Validation on Next passes", mp.failedMsg); |
175 |
assertNotNull ("Now we switched to another panel", panels[1].component); |
184 |
assertNotNull ("Now we switched to another panel", panels[1].component); |
176 |
assertNull ("The lazy validation failed, still no initialiaation", panels[2].component); |
185 |
assertNull ("The lazy validation failed, still no initialiaation", panels[2].component); |
|
|
186 |
assertTrue ("finishValidation() was called when validation finished.", mp.validationFinished); |
177 |
|
187 |
|
178 |
// remember previous state |
188 |
// remember previous state |
179 |
Object state = wd.getValue(); |
189 |
Object state = wd.getValue(); |