@Test public void testCreateNewDawnEditorSetName() throws Exception { getBot().menu("File").menu("New").menu("Other...").click(); SWTBotShell shell = getBot().shell("New"); shell.activate(); getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); getBot().button("Next >").click(); shell = getBot().shell("New"); shell.activate(); SWTBotText fileSemanticNameLabel = getBot().textWithLabel(resourceFieldLabel); fileSemanticNameLabel.setText("test.acore"); assertEquals("test.acore", fileSemanticNameLabel.getText()); getBot().button("Next >").click(); SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0); comboBox.setFocus(); comboBox.setSelection("ACore Root"); getBot().button("Finish").click(); SWTBotEditor editor = getBot().editorByTitle("test.acore"); assertNotNull(editor); editor.close(); }
@Test public void testCreateNewDawnAcoreEditor() throws Exception { getBot().menu("File").menu("New").menu("Other...").click(); SWTBotShell shell = getBot().shell("New"); shell.activate(); getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); getBot().button("Next >").click(); getBot().button("Next >").click(); shell = getBot().shell("New"); shell.activate(); SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0); comboBox.setFocus(); comboBox.setSelection("ACore Root"); getBot().button("Finish").click(); sleep(500); SWTBotEditor editor = getBot().editorByTitle("default.acore"); assertNotNull(editor); editor.close(); { assertEquals(true, resourceExists("/default.acore")); } }
// Verify we can do a double rename of configurations, renaming one // configuration to // another and then cancel without changing configuration settings. @Test public void t4doubleRenameCancel() throws Exception { openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); // Rename "debug" to "release" and rename "default" to "debug". // The settings should follow the rename operation. renameConfiguration("debug", "release"); renameConfiguration("default", "debug"); bot.button("OK").click(); // Verify that "release" has --enable-jeff set and that // the new "debug" configuration has no user setting. SWTBotShell shell = bot.shell("Properties for " + projectName); shell.activate(); configs = bot.comboBoxWithLabel("Configuration: "); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); SWTBotText text = bot.textWithLabel("Additional command-line options"); String setting = text.getText(); assertEquals("--enable-jeff", setting); configs.setFocus(); configs.setSelection("debug"); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); text = bot.textWithLabel("Additional command-line options"); setting = text.getText(); assertEquals("", setting); bot.button("Cancel").click(); // Cancel and then verify that "debug" is back to normal with // --enable-jeff set and that "default" is back to normal with // no user setting. openProperties("Autotools", "Configure Settings"); configs = bot.comboBoxWithLabel("Configuration: "); configs.setSelection("debug"); assertTrue(configs.getText().contains("debug")); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); text = bot.textWithLabel("Additional command-line options"); setting = text.getText(); assertEquals("--enable-jeff", setting); configs.setFocus(); configs.setSelection("default"); assertTrue(configs.getText().contains("default")); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); text = bot.textWithLabel("Additional command-line options"); setting = text.getText(); assertEquals("", setting); bot.button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); }
// Verify we can do a double rename of configurations, renaming one // configuration to // another and inheriting the settings properly. @Test public void t5doubleRenameOk() throws Exception { openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); shell.activate(); bot.table().select("debug"); bot.button("Set Active").click(); // Rename "debug" to "release" and rename "default" to "debug". // The settings should follow the rename operation. renameConfiguration("debug", "release"); renameConfiguration("default", "debug"); bot.button("OK").click(); shell = bot.shell("Properties for " + projectName); shell.activate(); bot.button("OK").click(); // Verify changes have taken effect permanently openProperties("Autotools", "Configure Settings"); configs = bot.comboBoxWithLabel("Configuration: "); assertTrue(configs.getText().contains("release")); assertTrue(configs.getText().contains("Active")); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); SWTBotText text = bot.textWithLabel("Additional command-line options"); String setting = text.getText(); assertEquals("--enable-jeff", setting); configs.setFocus(); configs.setSelection("debug"); assertTrue(configs.getText().contains("debug")); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); text = bot.textWithLabel("Additional command-line options"); setting = text.getText(); assertEquals("", setting); // Undo the changes made by this test configs = bot.comboBoxWithLabel("Configuration: "); bot.button("Manage Configurations...").click(); shell = bot.shell(projectName + ": Manage Configurations"); shell.activate(); bot.table().select("Build (GNU)"); bot.button("Set Active").click(); renameConfiguration("debug", "default"); renameConfiguration("release", "debug"); bot.button("OK").click(); shell = bot.shell("Properties for " + projectName); shell.activate(); bot.button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); }
@Test public void testCreateNewDawnDiagramTypeFolder() throws Exception { { CDOSession session = openSession(); ResourceSet resourceSet = new ResourceSetImpl(); CDOTransaction transaction = session.openTransaction(resourceSet); final URI uri = URI.createURI("cdo:/folder/dummy"); resourceSet.createResource(uri); transaction.commit(); } getBot().menu("File").menu("New").menu("Other...").click(); SWTBotShell shell = getBot().shell("New"); shell.activate(); getBot().tree().expandNode("Dawn Examples").select(DawnAcoreTestUtil.CREATION_WIZARD_NAME_EMF); getBot().button("Next >").click(); shell = getBot().shell("New"); shell.activate(); SWTBotText fileNameLabel = getBot().textWithLabel(resourceFieldLabel); fileNameLabel.setText("test.acore"); SWTBotText folder = getBot().textWithLabel("Enter or select the parent folder: "); folder.setText("/folder"); SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US"; getBot().button("Next >").click(); SWTBotCombo comboBox = getBot().comboBox(0); // bot.ccomboBox(0); comboBox.setFocus(); comboBox.setSelection("ACore Root"); getBot().button("Finish").click(); SWTBotEditor editor = getBot().editorByTitle("test.acore"); assertNotNull(editor); editor.close(); { assertEquals(true, resourceExists("/folder/test.acore")); } }
// Verify a new configuration will copy the configuration parameters // of its base configuration. @Test public void t3newConfigCopiesParms() throws Exception { projectExplorer.bot().tree().select(projectName); clickContextMenu( projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); SWTBotShell shell = bot.shell(projectName + ": Manage Configurations"); shell.activate(); shell = bot.shell(projectName + ": Manage Configurations"); shell.activate(); SWTBotTable table = bot.table(); assertTrue(table.containsItem("debug")); table.getTableItem("debug").select(); bot.button("Set Active").click(); bot.button("OK").click(); // Verify the debug configuration is active and has a user parameter: // --enable-jeff openProperties("Autotools", "Configure Settings"); SWTBotCombo configs = bot.comboBoxWithLabel("Configuration: "); configs.setFocus(); String[] items = configs.items(); for (int i = 0; i < items.length; ++i) { if (items[i].contains("debug") && items[i].contains("Active")) { configs.setSelection(i); } } assertTrue(configs.getText().contains("debug")); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); SWTBotText text = bot.textWithLabel("Additional command-line options"); String val = text.getText(); assertEquals("--enable-jeff", val); // Verify that the build directory for the new configuration has been // switched to build-debug shell = bot.shell("Properties for " + projectName); shell.activate(); bot.text().setText(""); bot.tree().select("C/C++ Build"); String buildDir = bot.textWithLabel("Build directory:").getText(); assertTrue(buildDir.endsWith("build-debug")); // Verify the default configuration has no user setting bot.tree().expandNode("Autotools").select("Configure Settings"); configs = bot.comboBoxWithLabel("Configuration: "); configs.setSelection("default"); bot.treeWithLabel("Configure Settings").expandNode("configure").select("Advanced"); text = bot.textWithLabel("Additional command-line options"); val = text.getText(); assertEquals("", val); bot.button("OK").click(); // Build the project again and verify we get a build-debug directory projectExplorer.bot().tree().select(projectName); clickContextMenu(projectExplorer.bot().tree().select(projectName), "Build Project"); IWorkspace workspace = ResourcesPlugin.getWorkspace(); assertNotNull(workspace); IWorkspaceRoot root = workspace.getRoot(); assertNotNull(root); IProject project = root.getProject(projectName); assertNotNull(project); IPath path = project.getLocation(); // We need to wait until the config.status file is created so // sleep a bit and look for it...give up after 20 seconds File f = null; for (int i = 0; i < 40; ++i) { bot.sleep(500); f = new File(path.append("build-debug/src/a.out").toOSString()); if (f.exists()) { break; } } assertTrue(f.exists()); f = new File(path.append("build-debug/config.status").toOSString()); assertTrue(f.exists()); try (BufferedReader r = new BufferedReader(new FileReader(f))) { int ch; boolean optionFound = false; // Read config.status and look for the string --enable-jeff // which is a simple verification that the option was used in the // configure step. while ((ch = r.read()) != -1) { if (ch == '-') { char[] buf = new char[12]; r.mark(100); int count = r.read(buf); if (count < 12) { break; } String s = new String(buf); if (s.equals("-enable-jeff")) { optionFound = true; break; } else { r.reset(); } } } assertTrue(optionFound); } // Verify we cleaned out the top-level build directory (i.e. that there // is no config.status there anymore). path = project.getLocation().append("config.status"); f = new File(path.toOSString()); assertTrue(!f.exists()); path = project.getLocation().append(".autotools"); f = new File(path.toOSString()); assertTrue(f.exists()); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document d = db.parse(f); Element e = d.getDocumentElement(); // Get the stored configuration data NodeList cfgs = e.getElementsByTagName("configuration"); // $NON-NLS-1$ assertEquals(3, cfgs.getLength()); int foundUser = 0; for (int x = 0; x < cfgs.getLength(); ++x) { Node n = cfgs.item(x); NodeList l = n.getChildNodes(); // Verify two of the user fields in .autotools file are set to // --enable-jeff for (int y = 0; y < l.getLength(); ++y) { Node child = l.item(y); if (child.getNodeName().equals("option")) { // $NON-NLS-1$ NamedNodeMap optionAttrs = child.getAttributes(); Node idNode = optionAttrs.getNamedItem("id"); // $NON-NLS-1$ Node valueNode = optionAttrs.getNamedItem("value"); // $NON-NLS-1$ assertNotNull(idNode); assertNotNull(valueNode); String id = idNode.getNodeValue(); String value = valueNode.getNodeValue(); if (id.equals("user")) { if (value.equals("--enable-jeff")) { ++foundUser; } } } } } assertEquals(2, foundUser); clickContextMenu( projectExplorer.bot().tree().select(projectName), "Build Configurations", "Manage..."); shell = bot.shell(projectName + ": Manage Configurations"); shell.activate(); table = bot.table(); assertTrue(table.containsItem("Build (GNU)")); table.getTableItem("Build (GNU)").select(); bot.button("Set Active").click(); bot.button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); }