Changeset 14332 in josm for trunk/test/unit/org/openstreetmap/josm/testutils/mockers
- Timestamp:
- 2018-10-14T17:30:28+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/testutils/mockers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/ExtendedDialogMocker.java
r14052 r14332 11 11 import java.util.WeakHashMap; 12 12 13 import org.openstreetmap.josm.TestUtils; 13 14 import org.openstreetmap.josm.gui.ExtendedDialog; 14 15 import org.openstreetmap.josm.tools.Logging; … … 108 109 } 109 110 111 /** 112 * Target for overriding, similar to {@link #getMockResult} except with the implication it will only 113 * be invoked once per dialog display, therefore ideal opportunity to perform any mutating actions, 114 * e.g. making a selection on a widget. 115 * @param instance dialog instance 116 */ 117 protected void act(final ExtendedDialog instance) { 118 // Override in sub-classes 119 } 120 110 121 protected Object[] getInvocationLogEntry(final ExtendedDialog instance, final int mockResult) { 111 122 return new Object[] { … … 114 125 instance.getTitle() 115 126 }; 127 } 128 129 /** 130 * A convenience method to access {@link ExtendedDialog#content} without exception-catching boilerplate 131 * @param instance dialog instance 132 * @return dialog content component 133 */ 134 protected Component getContent(final ExtendedDialog instance) { 135 try { 136 return (Component) TestUtils.getPrivateField(instance, "content"); 137 } catch (ReflectiveOperationException e) { 138 throw new RuntimeException(e); 139 } 116 140 } 117 141 … … 130 154 try { 131 155 final ExtendedDialog instance = invocation.getInvokedInstance(); 156 this.act(instance); 132 157 final int mockResult = this.getMockResult(instance); 133 158 // TODO check validity of mockResult? -
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/HelpAwareOptionPaneMocker.java
r14201 r14332 76 76 } 77 77 return this.getMockResultMap().get(messageString); 78 } 79 80 /** 81 * Target for overriding, similar to {@link #getMockResultForMessage} except with the implication it 82 * will only be invoked once per dialog display, therefore ideal opportunity to perform any mutating 83 * actions, e.g. making a selection on a widget. 84 * @param message message 85 */ 86 protected void act(final Object message) { 87 // Override in sub-classes 78 88 } 79 89 … … 134 144 ) { 135 145 try { 146 this.act(msg); 136 147 final Object result = this.getMockResultForMessage(msg); 137 148 -
trunk/test/unit/org/openstreetmap/josm/testutils/mockers/JOptionPaneSimpleMocker.java
r14052 r14332 134 134 } 135 135 136 /** 137 * Target for overriding, similar to {@link #getMockResultForMessage} except with the implication it 138 * will only be invoked once per dialog display, therefore ideal opportunity to perform any mutating 139 * actions, e.g. making a selection on a widget. 140 * @param message message 141 */ 142 protected void act(final Object message) { 143 // Override in sub-classes 144 } 145 136 146 protected Object[] getInvocationLogEntry( 137 147 final Object message, … … 162 172 ) { 163 173 try { 174 this.act(message); 164 175 final Object result = this.getMockResultForMessage(message); 165 176 if (selectionValues == null) { … … 216 227 ) { 217 228 try { 229 this.act(message); 218 230 // why look up a "result" for a message dialog which can only have one possible result? it's 219 231 // a good opportunity to assert its contents … … 263 275 ) { 264 276 try { 277 this.act(message); 265 278 final Object result = this.getMockResultForMessage(message); 266 279 if (!(result instanceof Integer && Ints.contains(optionTypePermittedResults.get(optionType), (int) result))) {
Note:
See TracChangeset
for help on using the changeset viewer.