Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Ferrazzutti2014-09-11 18:22:05 +0000
committerAlexander Kurtakov2014-09-15 06:59:23 +0000
commit037b2548c046fd30dd1d39e38195b2e1da8be83e (patch)
treedee1c5a3f36b208614557c88f0861850538c32af /systemtap
parent628528e233ab31b030dc05b46b5687d73b378b8d (diff)
downloadorg.eclipse.linuxtools-037b2548c046fd30dd1d39e38195b2e1da8be83e.tar.gz
org.eclipse.linuxtools-037b2548c046fd30dd1d39e38195b2e1da8be83e.tar.xz
org.eclipse.linuxtools-037b2548c046fd30dd1d39e38195b2e1da8be83e.zip
Systemtap: Attempt to stabilize UI tests; log4j.
Add log4j logging to TestCreateSystemtapScript to better identify & diagnose SWTBot failures/errors. Also, in an attempt to prevent test failures, increase the default SWTBot wait time and manually re-apply focus to shells in critital (ie fail-prone) locations. Change-Id: I6a46455dbf6944da95c95cfaa33a6a5b160fd540 Signed-off-by: Andrew Ferrazzutti <aferrazz@redhat.com> Reviewed-on: https://git.eclipse.org/r/33274 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'systemtap')
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java56
1 files changed, 40 insertions, 16 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
index cb1a15dee3..8bc9f6ed87 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide.tests/src/org/eclipse/linuxtools/systemtap/ui/ide/test/swtbot/TestCreateSystemtapScript.java
@@ -9,12 +9,12 @@
* Red Hat - initial implementation
*******************************************************************************/
-
package org.eclipse.linuxtools.systemtap.ui.ide.test.swtbot;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
+import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withText;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -27,6 +27,9 @@ import java.io.PrintWriter;
import java.text.MessageFormat;
import java.util.List;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.handlers.ImportDataSetHandler;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.launcher.Messages;
import org.eclipse.linuxtools.internal.systemtap.ui.ide.structures.TapsetLibrary;
@@ -49,6 +52,7 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
@@ -61,6 +65,7 @@ import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.results.BoolResult;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
+import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
@@ -90,6 +95,7 @@ import org.swtchart.Range;
@RunWith(SWTBotJunit4ClassRunner.class)
public class TestCreateSystemtapScript {
private static final String SYSTEMTAP_PROJECT_NAME = "SystemtapTest";
+ private static final Logger fLogger = Logger.getRootLogger();
private static SWTWorkbenchBot bot;
private static SWTBotView projectExplorer;
@@ -240,8 +246,29 @@ public class TestCreateSystemtapScript {
}
}
+ /**
+ * Click an item from the main Eclipse menu, with a guarantee that the main
+ * shell will be in focus.
+ * @param items The names of each item in the path to the target item to click.
+ * For example, to click "File->New->Project...", the items would be "File",
+ * "New", and "Project...".
+ */
+ public static void clickMainMenu(String... items) {
+ if (items.length == 0) {
+ return;
+ }
+ mainShell.setFocus();
+ SWTBotMenu menu = bot.menu(items[0]);
+ for (int i = 1; i < items.length; i++) {
+ menu = menu.menu(items[i]);
+ }
+ menu.click();
+ }
+
@BeforeClass
public static void beforeClass() {
+ SWTBotPreferences.TIMEOUT = 20000;
+ fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
bot = new SWTWorkbenchBot();
try {
@@ -279,11 +306,7 @@ public class TestCreateSystemtapScript {
}
// Create a Systemtap project.
- SWTBotMenu fileMenu = bot.menu("File");
- SWTBotMenu newMenu = fileMenu.menu("New");
- SWTBotMenu projectMenu = newMenu.menu("Project...");
- projectMenu.click();
-
+ clickMainMenu("File", "New", "Project...");
SWTBotShell shell = bot.shell("New Project");
shell.setFocus();
shell.bot().text().setText("Project");
@@ -374,11 +397,7 @@ public class TestCreateSystemtapScript {
}
public static void createScript(SWTWorkbenchBot bot, String scriptName) {
- SWTBotMenu fileMenu = bot.menu("File");
- SWTBotMenu newMenu = fileMenu.menu("New");
- SWTBotMenu projectMenu = newMenu.menu("Other...");
- projectMenu.click();
-
+ clickMainMenu("File", "New", "Other...");
SWTBotShell shell = bot.shell("New");
shell.setFocus();
shell.bot().text().setText("SystemTap");
@@ -392,7 +411,6 @@ public class TestCreateSystemtapScript {
bot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(shell));
-
assertEquals(scriptName, bot.activeEditor().getTitle());
}
@@ -450,10 +468,7 @@ public class TestCreateSystemtapScript {
// Open a non-stap file and add a probe. This should bring up a dialog
// asking if the function should be added to the only open .stp file.
- SWTBotMenu fileMenu = bot.menu("File");
- SWTBotMenu newMenu = fileMenu.menu("New");
- SWTBotMenu projectMenu = newMenu.menu("Other...");
- projectMenu.click();
+ clickMainMenu("File", "New", "Other...");
SWTBotShell shell = bot.shell("New");
shell.setFocus();
shell.bot().text().setText("Untitled Text File");
@@ -474,6 +489,12 @@ public class TestCreateSystemtapScript {
bot.waitUntil(new TreeItemPopulated(item));
item = item.getNode(0);
item.doubleClick();
+
+ {
+ Matcher<Shell> withText = withText(dialogTitle);
+ bot.waitUntil(Conditions.waitForShell(withText));
+ }
+
shell = bot.shell(dialogTitle);
shell.setFocus();
bot.button("Yes").click();
@@ -509,6 +530,7 @@ public class TestCreateSystemtapScript {
table.select(scriptName);
bot.button("OK").click();
bot.waitUntil(Conditions.shellCloses(shell));
+
bot.waitUntil(new EditorIsActive(scriptName));
assertTrue(wasProbeInserted(bot.activeEditor().toTextEditor(), item, false));
}
@@ -1386,6 +1408,7 @@ public class TestCreateSystemtapScript {
bot.radioWithTooltip(GraphFactory.getGraphName(graphID) + "\n\n" +
GraphFactory.getGraphDescription(graphID)).click();
+ shell.setFocus();
SWTBotText text = bot.textWithLabel("Title:");
text.setText(title);
@@ -1472,4 +1495,5 @@ public class TestCreateSystemtapScript {
}
});
}
+
}

Back to the top