Changeset 1813 for trunk/org.modelica.mdt.test
- Timestamp:
- 09/09/13 20:53:09 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/org.modelica.mdt.test/src/org/modelica/mdt/test/TestNewClassWizard.java
r1046 r1813 42 42 package org.modelica.mdt.test; 43 43 44 import static org.junit.Assert.assertEquals; 45 import static org.junit.Assert.assertFalse; 46 import static org.junit.Assert.assertNotNull; 47 import static org.junit.Assert.assertTrue; 48 44 49 import org.eclipse.core.resources.IProject; 45 50 import org.eclipse.core.resources.ResourcesPlugin; … … 49 54 import org.eclipse.swt.widgets.Combo; 50 55 import org.eclipse.swt.widgets.Text; 56 import org.junit.Before; 57 import org.junit.Test; 51 58 import org.modelica.mdt.core.IModelicaProject; 52 59 import org.modelica.mdt.core.ModelicaCore; … … 59 66 import abbot.tester.swt.TextTester; 60 67 61 import junit.framework.Assert;62 import junit.framework.TestCase;63 64 68 /** 65 69 * @author Elmir Jagudin … … 67 71 * Test the New Class Wizard functionality 68 72 */ 69 public class TestNewClassWizard extends TestCase 70 { 71 private static final String PROJECT_NAME_1 = 72 TestNewClassWizard.class.getName() + "1"; 73 74 /* a project name that is guaranteed to be nonexistent */ 75 private static final String NON_EXSITING_PROJECT_NAME = 76 TestNewClassWizard.class.getName() + "non_existing_project"; 77 78 private StructuredSelection fileDestination; 79 73 public class TestNewClassWizard { 74 private static final String PROJECT_NAME_1 = TestNewClassWizard.class.getName() + "1"; 75 76 // A project name that is guaranteed to be nonexistent. 77 private static final String NON_EXSITING_PROJECT_NAME = TestNewClassWizard.class.getName() + "non_existing_project"; 78 79 private StructuredSelection fileDestination; 80 80 81 private IProject project; 81 82 82 83 private TextTester ttester; 83 84 private ButtonTester btester; … … 90 91 private Button partialClass; 91 92 private Button externalBody; 92 93 93 94 private Button finish; 94 95 private Button cancel; 95 96 97 @Override 98 protected void setUp() throws Exception 99 { 100 /* 101 * setup project 102 */ 103 project = 104 ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_1); 105 106 /* create project only if it does not exist yet */ 107 if (!project.exists()) 108 { 109 IModelicaProject mproj = 110 ModelicaCore.getModelicaRoot().createProject(project);//PROJECT_NAME_1); 111 Assert.assertNotNull("failed to create project", mproj); 112 96 97 @Before 98 public void setUp() throws Exception { 99 project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME_1); 100 101 // Create project only if it does not exist yet. 102 if (!project.exists()) { 103 IModelicaProject mproj = ModelicaCore.getModelicaRoot().createProject(project); 104 assertNotNull("failed to create project", mproj); 105 113 106 project = mproj.getWrappedProject(); 114 107 } 115 116 /* 117 * create the selection that points at the root of the created project 118 */ 108 109 // Create the selection that points at the root of the created project. 119 110 fileDestination = new StructuredSelection(project); 120 121 /* 122 * setup testing support objects 123 */ 111 112 // Setup testing support objects. 124 113 ttester = TextTester.getTextTester(); 125 114 btester = ButtonTester.getButtonTester(); 126 115 ctester = new ComboTester(); 127 128 } 129 130 public void openWizardAndFetchWidgets() { 131 /* 132 * pop-up the wizard 133 */ 134 IWizard wizard = Utility.openWizard(org.modelica.mdt.ui.constants.Constants.MDT_UI_WIZARD_NEW_CLASS, fileDestination); 116 } 117 118 // Don't make this into a test-case of its own since almost every other test case will call this method. 119 private void openWizardAndFetchWidgets() { 120 // Pop-up the wizard. 121 IWizard wizard = Utility.openWizard(org.modelica.mdt.ui.constants.Constants.MDT_UI_WIZARD_NEW_CLASS, fileDestination); 135 122 assertFalse(wizard.canFinish()); 136 137 /* fetch widgets */ 138 className = 139 TextTester.getInstrumentedText(NewClassWizard.CLASS_NAME_TAG); 140 sourceFolder = 141 TextTester.getInstrumentedText(NewTypePage.SOURCE_FOLDER_TAG); 142 initialEquation = 143 ButtonTester.getInstrumentedButton(NewClassWizard.INITIAL_EQUATION_TAG); 144 externalBody = 145 ButtonTester.getInstrumentedButton(NewClassWizard.EXTERNAL_BODY_TAG); 146 partialClass = 147 ButtonTester.getInstrumentedButton(NewClassWizard.PARTIAL_CLASS_TAG); 148 finish = 149 Utility.findButtonByText("&Finish"); 123 124 // Fetch widgets. 125 className = TextTester.getInstrumentedText(NewClassWizard.CLASS_NAME_TAG); 126 sourceFolder = TextTester.getInstrumentedText(NewTypePage.SOURCE_FOLDER_TAG); 127 initialEquation = ButtonTester.getInstrumentedButton(NewClassWizard.INITIAL_EQUATION_TAG); 128 externalBody = ButtonTester.getInstrumentedButton(NewClassWizard.EXTERNAL_BODY_TAG); 129 partialClass = ButtonTester.getInstrumentedButton(NewClassWizard.PARTIAL_CLASS_TAG); 130 finish = Utility.findButtonByText("&Finish"); 150 131 assertNotNull("Problems finding finish button", finish); 151 152 cancel = 153 Utility.findButtonByText("Cancel"); 132 cancel = Utility.findButtonByText("Cancel"); 154 133 assertNotNull("Problems finding cancel button", cancel); 155 134 156 157 /* find classType combo by tag */ 158 classType = 159 (Combo) 160 Utility.getInstrumentedWidget(NewClassWizard.CLASS_TYPE_TAG); 135 // Find classType combo by tag. 136 classType = (Combo)Utility.getInstrumentedWidget(NewClassWizard.CLASS_TYPE_TAG); 161 137 assertNotNull("Problems finding classType widget", classType); 162 163 /* make some checks on the state of the wizards */ 164 assertEquals("Wrong source folder selected", 165 PROJECT_NAME_1, sourceFolder.getText()); 166 assertEquals("Junk present in class name field", 167 "", className.getText()); 168 assertFalse("initial equation unexpectedly selected", 169 initialEquation.getSelection()); 170 assertFalse("partial class unexpectedly selected", 171 partialClass.getSelection()); 172 assertFalse("Finish button not disabled", 173 finish.getEnabled()); 174 } 175 138 139 // Make some checks on the state of the wizards. 140 assertEquals("Wrong source folder selected", PROJECT_NAME_1, sourceFolder.getText()); 141 assertEquals("Junk present in class name field", "", className.getText()); 142 assertFalse("initial equation unexpectedly selected", initialEquation.getSelection()); 143 assertFalse("partial class unexpectedly selected", partialClass.getSelection()); 144 assertFalse("Finish button not disabled", finish.getEnabled()); 145 } 146 176 147 /** 177 * This test makes wizard to display a warning and error messages148 * This test makes wizard to display a warning and error messages 178 149 * by entering invalid data into the fields. 179 * 150 * 180 151 * The test checks that the state of finish button is right, 181 152 * it should be enabled for warnings and disabled for errors. 182 *183 * Test for BUG #1, se bugs database184 153 */ 185 public void testFinishButtonState() 186 { 187 /* 188 * open dialog and set a legal source folder and an illegal class name, 189 * which should display a warning 190 */ 191 openWizardAndFetchWidgets(); 192 154 @Test 155 public void testFinishButtonState() { 156 // open dialog and set a legal source folder and an illegal class name, 157 // which should display a warning 158 openWizardAndFetchWidgets(); 159 193 160 ttester.actionEnterText(sourceFolder, PROJECT_NAME_1); 194 161 ttester.actionEnterText(className, "#�%&"); 195 assertFalse("Finish button should be disabled when an illegal class " + 196 "name is entered", finish.getEnabled()); 197 198 /* 199 * set legal class name and non-existing source folder, 200 * which should display an error 201 */ 162 assertFalse("Finish button should be disabled when an illegal class name is entered", finish.getEnabled()); 163 164 // set legal class name and non-existing source folder, 165 // which should display an error 202 166 ttester.actionEnterText(className, "legal_class_name"); 203 ttester.actionEnterText(sourceFolder, NON_EXSITING_PROJECT_NAME); 204 assertFalse("Finish button should not be enabled for an error", 205 finish.getEnabled()); 206 207 /* close the dialog */ 208 btester.actionClick(cancel); 209 } 210 167 ttester.actionEnterText(sourceFolder, NON_EXSITING_PROJECT_NAME); 168 assertFalse("Finish button should not be enabled for an error", finish.getEnabled()); 169 170 // close the dialog 171 btester.actionClick(cancel); 172 } 173 211 174 /** 212 * check if the wizard 'remebers' it's class type selection 213 * between different invocations 175 * Check if the wizard 'remembers' its class type selection between different invocations. 214 176 */ 215 public void testSelectionRetention() 216 { 217 /* 218 * pop-up wizard, change class restriction to 'type', 219 * check that check boxes were updated and close wizard 220 */ 221 openWizardAndFetchWidgets(); 177 @Test 178 public void testSelectionRetention() { 179 // Pop-up wizard, change class restriction to 'type', 180 // check that check boxes were updated and close wizard. 181 openWizardAndFetchWidgets(); 222 182 ctester.actionSelectItem(classType, "type"); 223 assertFalse("initial equation check box should be disabled", 224 initialEquation.getEnabled()); 225 assertFalse("partial class check box should be disabled", 226 partialClass.getEnabled()); 227 assertFalse("external body check box should be disabled", 228 externalBody.getEnabled()); 183 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 184 assertFalse("partial class check box should be disabled", partialClass.getEnabled()); 185 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 229 186 btester.actionClick(cancel); 230 231 /* 232 * pup-up wizard again and check that the selection is 'type' 233 * and that the satus of other widgets is correctly set 234 */ 187 188 // Pop-up wizard again and check that the selection is 'type' 189 // and that the status of other widgets is correctly set 235 190 openWizardAndFetchWidgets(); 236 191 assertEquals("wrong class type selection", "type", classType.getText()); 237 assertFalse("initial equation check box should be disabled", 238 initialEquation.getEnabled()); 239 assertFalse("partial class check box should be disabled", 240 partialClass.getEnabled()); 241 assertFalse("external body check box should be disabled", 242 externalBody.getEnabled()); 243 244 /* 245 * change class restriction to 'model', 246 * check that check boxes were updated and close dialog 247 */ 192 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 193 assertFalse("partial class check box should be disabled", partialClass.getEnabled()); 194 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 195 196 // Change class restriction to 'model' and check that check boxes were 197 // updated and close dialog. 248 198 ctester.actionSelectItem(classType, "model"); 249 assertTrue("initial equation check box should be enabled", 250 initialEquation.getEnabled()); 251 assertTrue("partial class check box should be enabled", 252 partialClass.getEnabled()); 253 assertFalse("external body check box should be disabled", 254 externalBody.getEnabled()); 255 btester.actionClick(cancel); 256 257 /* 258 * pup-up wizard again and check that the selection is 'model' 259 * and that the satus of other widgets is correctly set 260 */ 199 assertTrue("initial equation check box should be enabled", initialEquation.getEnabled()); 200 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 201 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 202 btester.actionClick(cancel); 203 204 // Pop-up wizard again and check that the selection is 'model' 205 // and that the status of other widgets is correctly set. 261 206 openWizardAndFetchWidgets(); 262 207 assertEquals("wrong class type selection", "model", classType.getText()); 263 assertTrue("initial equation check box should be enabled", 264 initialEquation.getEnabled()); 265 assertTrue("partial class check box should be enabled", 266 partialClass.getEnabled()); 267 assertFalse("external body check box should be disabled", 268 externalBody.getEnabled()); 269 270 /* 271 * change class restriction to 'connector', 272 * check that check boxes were updated and close dialog 273 */ 208 assertTrue("initial equation check box should be enabled", initialEquation.getEnabled()); 209 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 210 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 211 212 // Change class restriction to 'connector', and check that check boxes 213 // were updated and close dialog. 274 214 ctester.actionSelectItem(classType, "connector"); 275 assertFalse("initial equation check box should be disabled", 276 initialEquation.getEnabled()); 277 assertTrue("partial class check box should be enabled", 278 partialClass.getEnabled()); 279 assertFalse("external body check box should be disabled", 280 externalBody.getEnabled()); 281 btester.actionClick(cancel); 282 283 /* 284 * pup-up wizard again and check that the selection is 'connector' 285 * and that the satus of other widgets is correctly set 286 */ 287 openWizardAndFetchWidgets(); 288 assertEquals("wrong class type selection", "connector", 289 classType.getText()); 290 assertFalse("initial equation check box should be disabled", 291 initialEquation.getEnabled()); 292 assertTrue("partial class check box should be enabled", 293 partialClass.getEnabled()); 294 assertFalse("external body check box should be disabled", 295 externalBody.getEnabled()); 296 297 /* 298 * change class restriction to 'block', 299 * check that check boxes were updated and close dialog 300 */ 215 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 216 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 217 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 218 btester.actionClick(cancel); 219 220 // Pop-up wizard again and check that the selection is 'connector' 221 // and that the status of other widgets is correctly set. 222 openWizardAndFetchWidgets(); 223 assertEquals("wrong class type selection", "connector", classType.getText()); 224 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 225 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 226 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 227 228 // Change class restriction to 'block', and check that check boxes 229 // were updated and close dialog. 301 230 ctester.actionSelectItem(classType, "block"); 302 assertTrue("initial equation check box should be enabled", 303 initialEquation.getEnabled()); 304 assertTrue("partial class check box should be enabled", 305 partialClass.getEnabled()); 306 assertFalse("external body check box should be disabled", 307 externalBody.getEnabled()); 308 btester.actionClick(cancel); 309 310 /* 311 * pup-up wizard again and check that the selection is 'block' 312 * and that the satus of other widgets is correctly set 313 */ 314 openWizardAndFetchWidgets(); 315 assertEquals("wrong class type selection", "block", 316 classType.getText()); 317 assertTrue("initial equation check box should be enabled", 318 initialEquation.getEnabled()); 319 assertTrue("partial class check box should be enabled", 320 partialClass.getEnabled()); 321 assertFalse("external body check box should be disabled", 322 externalBody.getEnabled()); 323 324 /* 325 * change class restriction to 'record', 326 * check that check boxes were updated and close dialog 327 */ 231 assertTrue("initial equation check box should be enabled", initialEquation.getEnabled()); 232 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 233 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 234 btester.actionClick(cancel); 235 236 // Pop-up wizard again and check that the selection is 'block' 237 // and that the status of other widgets is correctly set. 238 openWizardAndFetchWidgets(); 239 assertEquals("wrong class type selection", "block", classType.getText()); 240 assertTrue("initial equation check box should be enabled", initialEquation.getEnabled()); 241 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 242 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 243 244 // Change class restriction to 'record', 245 // check that check boxes were updated and close dialog. 328 246 ctester.actionSelectItem(classType, "record"); 329 assertFalse("initial equation check box should be disabled", 330 initialEquation.getEnabled()); 331 assertTrue("partial class check box should be enabled", 332 partialClass.getEnabled()); 333 assertFalse("external body check box should be disabled", 334 externalBody.getEnabled()); 335 btester.actionClick(cancel); 336 337 /* 338 * pup-up wizard again and check that the selection is 'record' 339 * and that the satus of other widgets is correctly set 340 */ 341 openWizardAndFetchWidgets(); 342 assertEquals("wrong class type selection", "record", 343 classType.getText()); 344 assertFalse("initial equation check box should be disabled", 345 initialEquation.getEnabled()); 346 assertTrue("partial class check box should be enabled", 347 partialClass.getEnabled()); 348 assertFalse("external body check box should be disabled", 349 externalBody.getEnabled()); 350 351 /* 352 * change class restriction to 'class', 353 * check that check boxes were updated and close dialog 354 */ 247 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 248 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 249 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 250 btester.actionClick(cancel); 251 252 // Pop-up wizard again and check that the selection is 'record' 253 // and that the status of other widgets is correctly set. 254 openWizardAndFetchWidgets(); 255 assertEquals("wrong class type selection", "record", classType.getText()); 256 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 257 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 258 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 259 260 // Change class restriction to 'class', 261 // check that check boxes were updated and close dialog. 355 262 ctester.actionSelectItem(classType, "class"); 356 assertTrue("initial equation check box should be enabled", 357 initialEquation.getEnabled()); 358 assertTrue("partial class check box should be enabled", 359 partialClass.getEnabled()); 360 assertFalse("external body check box should be disabled", 361 externalBody.getEnabled()); 263 assertTrue("initial equation check box should be enabled", initialEquation.getEnabled()); 264 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 265 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 362 266 btester.actionClick(cancel); 363 364 /* 365 * pup-up wizard again and check that the selection is 'class', 366 * check that check boxes were updated 367 * and that the satus of other widgets is correctly set 368 */ 369 openWizardAndFetchWidgets(); 370 assertEquals("wrong class type selection", "class", 371 classType.getText()); 372 assertTrue("initial equation check box should be enabled", 373 initialEquation.getEnabled()); 374 assertTrue("partial class check box should be enabled", 375 partialClass.getEnabled()); 376 assertFalse("external body check box should be disabled", 377 externalBody.getEnabled()); 378 379 /* 380 * change class restriction to 'function', check that 381 * check boxes were updated and close dialog 382 */ 267 268 // Pop-up wizard again and check that the selection is 'class', 269 // check that check boxes were updated and that the status of 270 // other widgets is correctly set. 271 openWizardAndFetchWidgets(); 272 assertEquals("wrong class type selection", "class", classType.getText()); 273 assertTrue("initial equation check box should be enabled", initialEquation.getEnabled()); 274 assertTrue("partial class check box should be enabled", partialClass.getEnabled()); 275 assertFalse("external body check box should be disabled", externalBody.getEnabled()); 276 277 // Change class restriction to 'function', check that 278 // check boxes were updated and close dialog 383 279 ctester.actionSelectItem(classType, "function"); 384 assertFalse("initial equation check box should be disabled", 385 initialEquation.getEnabled()); 386 assertFalse("partial class check box should be disabled", 387 partialClass.getEnabled()); 388 assertTrue("external body check box should be enabled", 389 externalBody.getEnabled()); 280 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 281 assertFalse("partial class check box should be disabled", partialClass.getEnabled()); 282 assertTrue("external body check box should be enabled", externalBody.getEnabled()); 390 283 btester.actionClick(cancel); 391 284 392 /* 393 * pup-up wizard again and check that the selection is 'function' 394 * and that the satus of other widgets is correctly set 395 */ 396 openWizardAndFetchWidgets(); 397 assertEquals("wrong class type selection", "function", 398 classType.getText()); 399 assertFalse("initial equation check box should be disabled", 400 initialEquation.getEnabled()); 401 assertFalse("partial class check box should be disabled", 402 partialClass.getEnabled()); 403 assertTrue("external body check box should be enabled", 404 externalBody.getEnabled()); 405 406 /* close dialog */ 285 // Pop-up wizard again and check that the selection is 'function' 286 // and that the status of other widgets is correctly set. 287 openWizardAndFetchWidgets(); 288 assertEquals("wrong class type selection", "function", classType.getText()); 289 assertFalse("initial equation check box should be disabled", initialEquation.getEnabled()); 290 assertFalse("partial class check box should be disabled", partialClass.getEnabled()); 291 assertTrue("external body check box should be enabled", externalBody.getEnabled()); 292 293 // Close dialog 407 294 btester.actionClick(cancel); 408 295 } 409 410 public void testCreateModel() 411 { 412 openWizardAndFetchWidgets(); 413 296 297 @Test 298 public void testCreateModel() { 299 openWizardAndFetchWidgets(); 300 301 // Create model 414 302 String name = "m1"; 415 /*416 * create model417 */418 303 ttester.actionEnterText(className, name); 419 304 ctester.actionSelectItem(classType, "model"); 420 305 assertTrue(finish.getEnabled()); 421 306 422 /* wait for the name change to propogate to enable the finish button */ 423 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 424 btester.actionClick(finish); 425 426 while(!project.isOpen()){ Utility.sleep(this, 100); } 427 428 /* 429 * check that the generated source code is sane 430 */ 431 boolean same = 432 Utility.compareContent(project.getFile(name + ".mo"), 433 "model " + name + "\n"+ 434 "\n"+ 435 "equation\n"+ 436 "\n"+ 437 "end " + name + ";"); 438 assertTrue("unexpected conted created in the source file", same); 439 440 } 441 442 public void testCreateModelWithInitEquation() 443 { 444 openWizardAndFetchWidgets(); 445 446 String name = "m2"; 447 448 /* 449 * create model 450 */ 307 // Wait for the name change to propagate to enable the finish button. 308 while (!finish.getEnabled()) { 309 Utility.sleep(this, 100); 310 } 311 312 btester.actionClick(finish); 313 314 while (!project.isOpen()) { 315 Utility.sleep(this, 100); 316 } 317 318 // Check that the generated source code is sane. 319 boolean same = 320 Utility.compareContent(project.getFile(name + ".mo"), 321 "model " + name + "\n"+ 322 "\n"+ 323 "equation\n"+ 324 "\n"+ 325 "end " + name + ";"); 326 assertTrue("unexpected content created in the source file", same); 327 } 328 329 @Test 330 public void testCreateModelWithInitEquation() { 331 openWizardAndFetchWidgets(); 332 333 // Create model 334 String name = "m2"; 451 335 ttester.actionEnterText(className, name); 452 336 ctester.actionSelectItem(classType, "model"); 453 337 assertTrue(finish.getEnabled()); 454 338 455 339 btester.actionClick(initialEquation); 456 340 457 341 assertTrue(initialEquation.getSelection()); 458 342 459 /* wait for the name change to propogate to enable the finish button */ 460 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 461 btester.actionClick(finish); 462 463 464 while(!project.isOpen()){ Utility.sleep(this, 100); } 465 466 /* 467 * check that the generated source code is sane 468 */ 469 boolean same = 470 Utility.compareContent(project.getFile(name + ".mo"), 471 "model "+ name +"\n"+ 472 "\n"+ 473 "equation\n"+ 474 "\n"+ 475 "initial equation\n"+ 476 "\n"+ 477 "end " + name + ";"); 478 assertTrue("unexpected conted created in the source file", same); 479 } 480 481 public void testCreatePartialModel() 482 { 483 openWizardAndFetchWidgets(); 484 343 // Wait for the name change to propagate to enable the finish button. 344 while (!finish.getEnabled()) { 345 Utility.sleep(this, 100); 346 } 347 348 btester.actionClick(finish); 349 350 while (!project.isOpen()) { 351 Utility.sleep(this, 100); 352 } 353 354 // Check that the generated source code is sane. 355 boolean same = 356 Utility.compareContent(project.getFile(name + ".mo"), 357 "model "+ name +"\n"+ 358 "\n"+ 359 "equation\n"+ 360 "\n"+ 361 "initial equation\n"+ 362 "\n"+ 363 "end " + name + ";"); 364 assertTrue("unexpected content created in the source file", same); 365 } 366 367 @Test 368 public void testCreatePartialModel() { 369 openWizardAndFetchWidgets(); 370 371 // Create model 485 372 String name = "m3"; 486 /*487 * create model488 */489 373 ttester.actionEnterText(className, name); 490 374 ctester.actionSelectItem(classType, "model"); 491 375 assertTrue(finish.getEnabled()); 492 376 493 377 btester.actionClick(partialClass); 494 378 495 379 assertTrue(partialClass.getSelection()); 496 380 497 /* wait for the name change to propogate to enable the finish button */ 498 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 499 btester.actionClick(finish); 500 501 502 while(!project.isOpen()){ Utility.sleep(this, 100); } 503 504 /* 505 * check that the generated source code is sane 506 */ 507 boolean same = 508 Utility.compareContent(project.getFile(name + ".mo"), 509 "partial model "+ name +"\n"+ 510 "\n"+ 511 "equation\n"+ 512 "\n"+ 513 "end "+ name + ";"); 514 assertTrue("unexpected conted created in the source file", same); 515 516 } 517 518 public void testCreatePartialModelWithInitBlock() 519 { 520 openWizardAndFetchWidgets(); 521 381 // Wait for the name change to propagate to enable the finish button. 382 while (!finish.getEnabled()) { 383 Utility.sleep(this, 100); 384 } 385 386 btester.actionClick(finish); 387 388 while (!project.isOpen()) { 389 Utility.sleep(this, 100); 390 } 391 392 // Check that the generated source code is sane. 393 boolean same = 394 Utility.compareContent(project.getFile(name + ".mo"), 395 "partial model "+ name +"\n"+ 396 "\n"+ 397 "equation\n"+ 398 "\n"+ 399 "end "+ name + ";"); 400 assertTrue("unexpected content created in the source file", same); 401 } 402 403 @Test 404 public void testCreatePartialModelWithInitBlock() { 405 openWizardAndFetchWidgets(); 406 407 // Create model 522 408 String name = "m4"; 523 /*524 * create model525 */526 409 ttester.actionEnterText(className, name); 527 410 ctester.actionSelectItem(classType, "model"); 528 411 assertTrue(finish.getEnabled()); 529 530 btester.actionClick(partialClass); 412 413 btester.actionClick(partialClass); 531 414 assertTrue(partialClass.getSelection()); 532 415 533 btester.actionClick(initialEquation); 416 btester.actionClick(initialEquation); 534 417 assertTrue(initialEquation.getSelection()); 535 536 537 /* wait for the name change to propogate to enable the finish button */ 538 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 539 btester.actionClick(finish); 540 541 542 while(!project.isOpen()){ Utility.sleep(this, 100); } 543 544 /* 545 * check that the generated source code is sane 546 */ 547 boolean same = 548 Utility.compareContent(project.getFile(name + ".mo"), 549 "partial model "+ name +"\n"+ 550 "\n"+ 551 "equation\n"+ 552 "\n"+ 553 "initial equation\n"+ 554 "\n"+ 555 "end "+ name + ";"); 556 assertTrue("unexpected conted created in the source file", same); 557 } 558 559 public void testCreateClass() 560 { 561 openWizardAndFetchWidgets(); 562 418 419 // Wait for the name change to propagate to enable the finish button. 420 while (!finish.getEnabled()) { 421 Utility.sleep(this, 100); 422 } 423 424 btester.actionClick(finish); 425 426 while (!project.isOpen()) { 427 Utility.sleep(this, 100); 428 } 429 430 // Check that the generated source code is sane. 431 boolean same = 432 Utility.compareContent(project.getFile(name + ".mo"), 433 "partial model "+ name +"\n"+ 434 "\n"+ 435 "equation\n"+ 436 "\n"+ 437 "initial equation\n"+ 438 "\n"+ 439 "end "+ name + ";"); 440 assertTrue("unexpected content created in the source file", same); 441 } 442 443 @Test 444 public void testCreateClass() { 445 openWizardAndFetchWidgets(); 446 447 // Create class 563 448 String name = "c1"; 564 565 /*566 * create class567 */568 449 ttester.actionEnterText(className, name); 569 450 ctester.actionSelectItem(classType, "class"); 570 571 572 /* wait for the name change to propogate to enable the finish button */ 573 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 574 btester.actionClick(finish); 575 576 577 while(!project.isOpen()){ Utility.sleep(this, 100); } 578 579 /* 580 * check that the generated source code is sane 581 */ 582 boolean same = 583 Utility.compareContent(project.getFile(name + ".mo"), 584 "class "+ name +"\n"+ 585 "\n"+ 586 "equation\n"+ 587 "\n"+ 588 "end "+ name + ";"); 589 assertTrue("unexpected conted created in the source file", same); 590 } 591 592 public void testCreateClassWithInitBlock() 593 { 594 openWizardAndFetchWidgets(); 595 451 452 // Wait for the name change to propagate to enable the finish button. 453 while (!finish.getEnabled()) { 454 Utility.sleep(this, 100); 455 } 456 457 btester.actionClick(finish); 458 459 while (!project.isOpen()) { 460 Utility.sleep(this, 100); 461 } 462 463 // Check that the generated source code is sane. 464 boolean same = 465 Utility.compareContent(project.getFile(name + ".mo"), 466 "class "+ name +"\n"+ 467 "\n"+ 468 "equation\n"+ 469 "\n"+ 470 "end "+ name + ";"); 471 assertTrue("unexpected content created in the source file", same); 472 } 473 474 @Test 475 public void testCreateClassWithInitBlock() { 476 openWizardAndFetchWidgets(); 477 478 // Create class 596 479 String name = "c2"; 597 598 /*599 * create class600 */601 480 ttester.actionEnterText(className, name); 602 481 ctester.actionSelectItem(classType, "class"); 603 482 btester.actionClick(initialEquation); 604 605 606 /* wait for the name change to propogate to enable the finish button */ 607 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 608 btester.actionClick(finish); 609 610 611 while(!project.isOpen()){ Utility.sleep(this, 100); } 612 613 /* 614 * check that the generated source code is sane 615 */ 616 boolean same = 617 Utility.compareContent(project.getFile(name + ".mo"), 618 "class "+ name +"\n"+ 619 "\n"+ 620 "equation\n"+ 621 "\n"+ 622 "initial equation\n"+ 623 "\n"+ 624 "end "+ name + ";"); 625 assertTrue("unexpected conted created in the source file", same); 626 627 } 628 629 public void testCreatePartialClass() 630 { 631 openWizardAndFetchWidgets(); 632 483 484 // Wait for the name change to propagate to enable the finish button. 485 while (!finish.getEnabled()) { 486 Utility.sleep(this, 100); 487 } 488 489 btester.actionClick(finish); 490 491 while (!project.isOpen()) { 492 Utility.sleep(this, 100); 493 } 494 495 // Check that the generated source code is sane. 496 boolean same = 497 Utility.compareContent(project.getFile(name + ".mo"), 498 "class "+ name +"\n"+ 499 "\n"+ 500 "equation\n"+ 501 "\n"+ 502 "initial equation\n"+ 503 "\n"+ 504 "end "+ name + ";"); 505 assertTrue("unexpected content created in the source file", same); 506 } 507 508 @Test 509 public void testCreatePartialClass() { 510 openWizardAndFetchWidgets(); 511 512 // Create class 633 513 String name = "c3"; 634 635 /*636 * create class637 */638 514 ttester.actionEnterText(className, name); 639 515 ctester.actionSelectItem(classType, "class"); 640 516 btester.actionClick(partialClass); 641 642 643 /* wait for the name change to propogate to enable the finish button */ 644 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 645 btester.actionClick(finish); 646 647 648 while(!project.isOpen()){ Utility.sleep(this, 100); } 649 650 /* 651 * check that the generated source code is sane 652 */ 653 boolean same = 654 Utility.compareContent(project.getFile(name + ".mo"), 655 "partial class "+ name +"\n"+ 656 "\n"+ 657 "equation\n"+ 658 "\n"+ 659 "end "+ name + ";"); 660 assertTrue("unexpected conted created in the source file", same); 661 } 662 663 public void testCreatePartialClassWithInitBlock() 664 { 665 openWizardAndFetchWidgets(); 666 517 518 // Wait for the name change to propagate to enable the finish button. 519 while (!finish.getEnabled()) { 520 Utility.sleep(this, 100); 521 } 522 523 btester.actionClick(finish); 524 525 while (!project.isOpen()) { 526 Utility.sleep(this, 100); 527 } 528 529 // Check that the generated source code is sane. 530 boolean same = 531 Utility.compareContent(project.getFile(name + ".mo"), 532 "partial class "+ name +"\n"+ 533 "\n"+ 534 "equation\n"+ 535 "\n"+ 536 "end "+ name + ";"); 537 assertTrue("unexpected content created in the source file", same); 538 } 539 540 @Test 541 public void testCreatePartialClassWithInitBlock() { 542 openWizardAndFetchWidgets(); 543 544 // Create class 667 545 String name = "c4"; 668 669 /*670 * create class671 */672 546 ttester.actionEnterText(className, name); 673 547 ctester.actionSelectItem(classType, "class"); 674 548 btester.actionClick(partialClass); 675 549 btester.actionClick(initialEquation); 676 677 678 /* wait for the name change to propogate to enable the finish button */679 while (!finish.getEnabled()) { Utility.sleep(this, 100); }680 btester.actionClick(finish);681 682 683 while(!project.isOpen()){ Utility.sleep(this, 100); } 684 685 /*686 * check that the generated source code is sane687 */ 688 boolean same =689 Utility.compareContent(project.getFile(name + ".mo"),690 "partial class "+ name +"\n"+691 "\n"+692 "equation\n"+693 "\n"+694 "initial equation\n"+695 "\n"+696 "end "+ name + ";");697 assertTrue("unexpected conted created in the source file", same);698 699 } 700 701 702 public void testCreateConnector() 703 {704 openWizardAndFetchWidgets(); 705 550 551 // Wait for the name change to propagate to enable the finish button. 552 while (!finish.getEnabled()) { 553 Utility.sleep(this, 100); 554 } 555 556 btester.actionClick(finish); 557 558 while (!project.isOpen()) { 559 Utility.sleep(this, 100); 560 } 561 562 // Check that the generated source code is sane. 563 boolean same = 564 Utility.compareContent(project.getFile(name + ".mo"), 565 "partial class "+ name +"\n"+ 566 "\n"+ 567 "equation\n"+ 568 "\n"+ 569 "initial equation\n"+ 570 "\n"+ 571 "end "+ name + ";"); 572 assertTrue("unexpected content created in the source file", same); 573 } 574 575 @Test 576 public void testCreateConnector() { 577 openWizardAndFetchWidgets(); 578 579 // Create class 706 580 String name = "con1"; 707 708 /*709 * create class710 */711 581 ttester.actionEnterText(className, name); 712 582 ctester.actionSelectItem(classType, "connector"); 713 714 715 /* wait for the name change to propogate to enable the finish button */ 716 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 717 btester.actionClick(finish); 718 719 720 while(!project.isOpen()){ Utility.sleep(this, 100); } 721 722 /* 723 * check that the generated source code is sane 724 */ 725 boolean same = 726 Utility.compareContent(project.getFile(name + ".mo"), 727 "connector "+ name +"\n" + 728 "\n" + 729 "end "+ name + ";"); 730 assertTrue("unexpected conted created in the source file", same); 731 } 732 733 public void testCreatePartialConnector() 734 { 735 openWizardAndFetchWidgets(); 736 583 584 // Wait for the name change to propagate to enable the finish button. 585 while (!finish.getEnabled()) { 586 Utility.sleep(this, 100); 587 } 588 589 btester.actionClick(finish); 590 591 while (!project.isOpen()) { 592 Utility.sleep(this, 100); 593 } 594 595 // Check that the generated source code is sane. 596 boolean same = 597 Utility.compareContent(project.getFile(name + ".mo"), 598 "connector "+ name +"\n" + 599 "\n" + 600 "end "+ name + ";"); 601 assertTrue("unexpected content created in the source file", same); 602 } 603 604 @Test 605 public void testCreatePartialConnector() { 606 openWizardAndFetchWidgets(); 607 608 // Create class 737 609 String name = "con2"; 738 739 /*740 * create class741 */742 610 ttester.actionEnterText(className, name); 743 611 ctester.actionSelectItem(classType, "connector"); 744 btester.actionClick(partialClass); 745 746 747 /* wait for the name change to propogate to enable the finish button */ 748 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 749 btester.actionClick(finish); 750 751 752 while(!project.isOpen()){ Utility.sleep(this, 100); } 753 754 /* 755 * check that the generated source code is sane 756 */ 757 boolean same = 758 Utility.compareContent(project.getFile(name + ".mo"), 759 "partial connector "+ name +"\n" + 760 "\n" + 761 "end "+ name + ";"); 762 assertTrue("unexpected conted created in the source file", same); 763 764 } 765 766 public void testCreateRecord() 767 { 768 openWizardAndFetchWidgets(); 769 612 btester.actionClick(partialClass); 613 614 // Wait for the name change to propagate to enable the finish button. 615 while (!finish.getEnabled()) { 616 Utility.sleep(this, 100); 617 } 618 619 btester.actionClick(finish); 620 621 while (!project.isOpen()) { 622 Utility.sleep(this, 100); 623 } 624 625 // Check that the generated source code is sane. 626 boolean same = 627 Utility.compareContent(project.getFile(name + ".mo"), 628 "partial connector "+ name +"\n" + 629 "\n" + 630 "end "+ name + ";"); 631 assertTrue("unexpected content created in the source file", same); 632 } 633 634 @Test 635 public void testCreateRecord() { 636 openWizardAndFetchWidgets(); 637 638 // Create class 770 639 String name = "rec1"; 771 772 /*773 * create class774 */775 640 ttester.actionEnterText(className, name); 776 641 ctester.actionSelectItem(classType, "record"); 777 642 778 779 780 /* wait for the name change to propogate to enable the finish button */781 while (!finish.getEnabled()) { Utility.sleep(this, 100);}782 btester.actionClick(finish); 783 784 785 while (!project.isOpen()){ Utility.sleep(this, 100); }786 787 /*788 * check that the generated source code is sane 789 */790 boolean same = 791 Utility.compareContent(project.getFile(name + ".mo"),792 "record "+ name +"\n" +793 "\n" +794 "end "+ name + ";");795 assertTrue("unexpected conte dcreated in the source file", same);796 797 } 798 799 public void testCreatePartialRecord() 800 {801 openWizardAndFetchWidgets(); 802 643 // Wait for the name change to propagate to enable the finish button. 644 while (!finish.getEnabled()) { 645 Utility.sleep(this, 100); 646 } 647 648 btester.actionClick(finish); 649 650 while (!project.isOpen()) { 651 Utility.sleep(this, 100); 652 } 653 654 // Check that the generated source code is sane. 655 boolean same = 656 Utility.compareContent(project.getFile(name + ".mo"), 657 "record "+ name +"\n" + 658 "\n" + 659 "end "+ name + ";"); 660 assertTrue("unexpected content created in the source file", same); 661 } 662 663 @Test 664 public void testCreatePartialRecord() { 665 openWizardAndFetchWidgets(); 666 667 // Create class 803 668 String name = "rec2"; 804 805 /*806 * create class807 */808 669 ttester.actionEnterText(className, name); 809 670 ctester.actionSelectItem(classType, "record"); 810 671 btester.actionClick(partialClass); 811 812 813 /* wait for the name change to propogate to enable the finish button */ 814 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 815 btester.actionClick(finish); 816 817 818 while(!project.isOpen()){ Utility.sleep(this, 100); } 819 820 /* 821 * check that the generated source code is sane 822 */ 823 boolean same = 824 Utility.compareContent(project.getFile(name + ".mo"), 825 "partial record "+ name +"\n" + 826 "\n" + 827 "end "+ name + ";"); 828 assertTrue("unexpected conted created in the source file", same); 829 } 830 831 public void testCreateBlock() 832 { 833 openWizardAndFetchWidgets(); 834 672 673 // Wait for the name change to propagate to enable the finish button. 674 while (!finish.getEnabled()) { 675 Utility.sleep(this, 100); 676 } 677 678 btester.actionClick(finish); 679 680 while (!project.isOpen()) { 681 Utility.sleep(this, 100); 682 } 683 684 // Check that the generated source code is sane. 685 boolean same = 686 Utility.compareContent(project.getFile(name + ".mo"), 687 "partial record "+ name +"\n" + 688 "\n" + 689 "end "+ name + ";"); 690 assertTrue("unexpected content created in the source file", same); 691 } 692 693 @Test 694 public void testCreateBlock() { 695 openWizardAndFetchWidgets(); 696 697 // Create class 835 698 String name = "b1"; 836 837 /*838 * create class839 */840 699 ttester.actionEnterText(className, name); 841 700 ctester.actionSelectItem(classType, "block"); 842 701 843 844 845 /* wait for the name change to propogate to enable the finish button */ 846 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 847 btester.actionClick(finish); 848 849 850 while(!project.isOpen()){ Utility.sleep(this, 100); } 851 852 /* 853 * check that the generated source code is sane 854 */ 855 boolean same = 856 Utility.compareContent(project.getFile(name + ".mo"), 857 "block "+ name +"\n" + 858 "\n" + 859 "equation\n"+ 860 "\n"+ 861 "end "+ name + ";"); 862 assertTrue("unexpected conted created in the source file", same); 863 864 } 865 public void testCreateBlockWithInitBlock() 866 { 867 openWizardAndFetchWidgets(); 868 702 // Wait for the name change to propagate to enable the finish button. 703 while (!finish.getEnabled()) { 704 Utility.sleep(this, 100); 705 } 706 707 btester.actionClick(finish); 708 709 while (!project.isOpen()) { 710 Utility.sleep(this, 100); 711 } 712 713 // Check that the generated source code is sane. 714 boolean same = 715 Utility.compareContent(project.getFile(name + ".mo"), 716 "block "+ name +"\n" + 717 "\n" + 718 "equation\n"+ 719 "\n"+ 720 "end "+ name + ";"); 721 assertTrue("unexpected content created in the source file", same); 722 } 723 724 @Test 725 public void testCreateBlockWithInitBlock() { 726 openWizardAndFetchWidgets(); 727 728 // Create class 869 729 String name = "b2"; 870 871 /*872 * create class873 */874 730 ttester.actionEnterText(className, name); 875 731 ctester.actionSelectItem(classType, "block"); 876 btester.actionClick(initialEquation); 877 878 879 880 /* wait for the name change to propogate to enable the finish button */881 while (!finish.getEnabled()) { Utility.sleep(this, 100);}882 btester.actionClick(finish); 883 884 885 while (!project.isOpen()){ Utility.sleep(this, 100); }886 887 /*888 * check that the generated source code is sane 889 */890 boolean same = 891 Utility.compareContent(project.getFile(name + ".mo"),892 "block "+ name +"\n" +893 "\n" +894 "equation\n"+895 "\n"+896 "initial equation\n"+897 "\n"+898 "end "+ name + ";");899 assertTrue("unexpected conte dcreated in the source file", same);900 901 } 902 903 public void testCreatePartialBlock() 904 {905 openWizardAndFetchWidgets(); 906 732 btester.actionClick(initialEquation); 733 734 // Wait for the name change to propagate to enable the finish button. 735 while (!finish.getEnabled()) { 736 Utility.sleep(this, 100); 737 } 738 739 btester.actionClick(finish); 740 741 while (!project.isOpen()) { 742 Utility.sleep(this, 100); 743 } 744 745 // Check that the generated source code is sane. 746 boolean same = 747 Utility.compareContent(project.getFile(name + ".mo"), 748 "block "+ name +"\n" + 749 "\n" + 750 "equation\n"+ 751 "\n"+ 752 "initial equation\n"+ 753 "\n"+ 754 "end "+ name + ";"); 755 assertTrue("unexpected content created in the source file", same); 756 } 757 758 @Test 759 public void testCreatePartialBlock() { 760 openWizardAndFetchWidgets(); 761 762 // Create class 907 763 String name = "b3"; 908 909 /*910 * create class911 */912 ttester.actionEnterText(className, name);913 ctester.actionSelectItem(classType, "block");914 btester.actionClick(partialClass);915 916 917 918 /* wait for the name change to propogate to enable the finish button */919 while (!finish.getEnabled()) { Utility.sleep(this, 100); }920 btester.actionClick(finish);921 922 923 while(!project.isOpen()){ Utility.sleep(this, 100); }924 925 /*926 * check that the generated source code is sane927 */928 boolean same =929 Utility.compareContent(project.getFile(name + ".mo"),930 "partial block "+ name +"\n" +931 "\n" +932 "equation\n"+933 "\n"+934 "end "+ name + ";");935 assertTrue("unexpected conted created in the source file", same);936 937 }938 public void testCreatePartialBlockWithInitBlock()939 {940 openWizardAndFetchWidgets();941 942 String name = "b4";943 944 /*945 * create class946 */947 764 ttester.actionEnterText(className, name); 948 765 ctester.actionSelectItem(classType, "block"); 949 766 btester.actionClick(partialClass); 950 btester.actionClick(initialEquation); 951 952 953 954 /* wait for the name change to propogate to enable the finish button */ 955 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 956 btester.actionClick(finish); 957 958 959 while(!project.isOpen()){ Utility.sleep(this, 100); } 960 961 /* 962 * check that the generated source code is sane 963 */ 964 boolean same = 965 Utility.compareContent(project.getFile(name + ".mo"), 966 "partial block "+ name +"\n" + 967 "\n" + 968 "equation\n"+ 969 "\n"+ 970 "initial equation\n"+ 971 "\n"+ 972 "end "+ name + ";"); 973 assertTrue("unexpected conted created in the source file", same); 974 } 975 976 public void testCreateType() 977 { 978 openWizardAndFetchWidgets(); 979 767 768 // Wait for the name change to propagate to enable the finish button. 769 while (!finish.getEnabled()) { 770 Utility.sleep(this, 100); 771 } 772 773 btester.actionClick(finish); 774 775 while (!project.isOpen()) { 776 Utility.sleep(this, 100); 777 } 778 779 // Check that the generated source code is sane. 780 boolean same = 781 Utility.compareContent(project.getFile(name + ".mo"), 782 "partial block "+ name +"\n" + 783 "\n" + 784 "equation\n"+ 785 "\n"+ 786 "end "+ name + ";"); 787 assertTrue("unexpected content created in the source file", same); 788 } 789 790 @Test 791 public void testCreatePartialBlockWithInitBlock() { 792 openWizardAndFetchWidgets(); 793 794 // Create class 795 String name = "b4"; 796 ttester.actionEnterText(className, name); 797 ctester.actionSelectItem(classType, "block"); 798 btester.actionClick(partialClass); 799 btester.actionClick(initialEquation); 800 801 // Wait for the name change to propagate to enable the finish button. 802 while (!finish.getEnabled()) { 803 Utility.sleep(this, 100); 804 } 805 806 btester.actionClick(finish); 807 808 while (!project.isOpen()) { 809 Utility.sleep(this, 100); 810 } 811 812 // Check that the generated source code is sane. 813 boolean same = 814 Utility.compareContent(project.getFile(name + ".mo"), 815 "partial block "+ name +"\n" + 816 "\n" + 817 "equation\n"+ 818 "\n"+ 819 "initial equation\n"+ 820 "\n"+ 821 "end "+ name + ";"); 822 assertTrue("unexpected content created in the source file", same); 823 } 824 825 @Test 826 public void testCreateType() { 827 openWizardAndFetchWidgets(); 828 829 // Create class 980 830 String name = "t1"; 981 982 /*983 * create class984 */985 831 ttester.actionEnterText(className, name); 986 832 ctester.actionSelectItem(classType, "type"); 987 833 988 989 990 /* wait for the name change to propogate to enable the finish button */991 while (!finish.getEnabled()) { Utility.sleep(this, 100);}992 btester.actionClick(finish); 993 994 995 while (!project.isOpen()){ Utility.sleep(this, 100); }996 997 /*998 * check that the generated source code is sane 999 */1000 boolean same = 1001 Utility.compareContent(project.getFile(name + ".mo"),1002 "type "+ name +"\n" +1003 ";");1004 assertTrue("unexpected conte dcreated in the source file", same);1005 1006 } 1007 1008 public void testCreateFunction() 1009 {1010 openWizardAndFetchWidgets(); 1011 834 // Wait for the name change to propagate to enable the finish button. 835 while (!finish.getEnabled()) { 836 Utility.sleep(this, 100); 837 } 838 839 btester.actionClick(finish); 840 841 while (!project.isOpen()) { 842 Utility.sleep(this, 100); 843 } 844 845 // Check that the generated source code is sane. 846 boolean same = 847 Utility.compareContent(project.getFile(name + ".mo"), 848 "type "+ name +"\n" + 849 ";"); 850 assertTrue("unexpected content created in the source file", same); 851 } 852 853 @Test 854 public void testCreateFunction() { 855 openWizardAndFetchWidgets(); 856 857 // Create class 1012 858 String name = "f1"; 1013 1014 /*1015 * create class1016 */1017 859 ctester.actionSelectItem(classType, "function"); 1018 860 ttester.actionEnterText(className, name); 1019 1020 1021 /* wait for the name change to propogate to enable the finish button */ 1022 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 1023 btester.actionClick(finish); 1024 1025 1026 while(!project.isOpen()){ Utility.sleep(this, 100); } 1027 1028 /* 1029 * check that the generated source code is sane 1030 */ 1031 boolean same = 1032 Utility.compareContent(project.getFile(name + ".mo"), 1033 "function "+ name +"\n" + 1034 "\n" + 1035 "algorithm\n"+ 1036 "\n"+ 1037 "end "+ name + ";"); 1038 assertTrue("unexpected conted created in the source file", same); 1039 } 1040 1041 public void testCreateFunctionWithExternalBody() 1042 { 1043 openWizardAndFetchWidgets(); 1044 861 862 // Wait for the name change to propagate to enable the finish button. 863 while (!finish.getEnabled()) { 864 Utility.sleep(this, 100); 865 } 866 867 btester.actionClick(finish); 868 869 while (!project.isOpen()) { 870 Utility.sleep(this, 100); 871 } 872 873 // Check that the generated source code is sane. 874 boolean same = 875 Utility.compareContent(project.getFile(name + ".mo"), 876 "function "+ name +"\n" + 877 "\n" + 878 "algorithm\n"+ 879 "\n"+ 880 "end "+ name + ";"); 881 assertTrue("unexpected content created in the source file", same); 882 } 883 884 @Test 885 public void testCreateFunctionWithExternalBody() { 886 openWizardAndFetchWidgets(); 887 888 // Create class 1045 889 String name = "f2"; 1046 1047 /*1048 * create class1049 */1050 890 ctester.actionSelectItem(classType, "function"); 1051 891 ttester.actionEnterText(className, name); 1052 892 1053 /* 1054 * wait for the class type change to propogate to the 1055 * external body checkboc 1056 */ 1057 while (!externalBody.getEnabled()) { Utility.sleep(this, 100); } 1058 1059 btester.actionClick(externalBody); 1060 1061 /* wait for the name change to propogate to enable the finish button */ 1062 while (!finish.getEnabled()) { Utility.sleep(this, 100); } 1063 btester.actionClick(finish); 1064 1065 1066 while(!project.isOpen()){ Utility.sleep(this, 100); } 1067 1068 /* 1069 * check that the generated source code is sane 1070 */ 1071 boolean same = 1072 Utility.compareContent(project.getFile(name + ".mo"), 1073 "function "+ name +"\n" + 1074 "\n" + 1075 "external\n"+ 1076 "end "+ name + ";"); 1077 assertTrue("unexpected conted created in the source file", same); 1078 1079 } 1080 1081 //some ideas for more tests 1082 /* 1083 * TODO enter some text into source folder field and 1084 * check the error/warning messages 1085 */ 1086 1087 /* 1088 * TODO test to create a class in a sub-directory 1089 */ 893 // Wait for the class type change to propagate to the 894 // external body checkbox. 895 while (!externalBody.getEnabled()) { 896 Utility.sleep(this, 100); 897 } 898 899 btester.actionClick(externalBody); 900 901 // Wait for the name change to propagate to enable the finish button. 902 while (!finish.getEnabled()) { 903 Utility.sleep(this, 100); 904 } 905 906 btester.actionClick(finish); 907 908 while (!project.isOpen()) { 909 Utility.sleep(this, 100); 910 } 911 912 // Check that the generated source code is sane. 913 boolean same = 914 Utility.compareContent(project.getFile(name + ".mo"), 915 "function "+ name +"\n" + 916 "\n" + 917 "external\n"+ 918 "end "+ name + ";"); 919 assertTrue("unexpected content created in the source file", same); 920 } 921 922 /* 923 * Some ideas for more tests: 924 * TODO enter some text into source folder field and 925 * check the error/warning messages 926 * 927 * TODO test to create a class in a sub-directory 928 */ 1090 929 }
Note: See TracChangeset
for help on using the changeset viewer.