* Contributors:
* Matthew Khouzam - Initial API and implementation
* Alexandre Montplaisir - Replaced separate Condition objects by anonymous classes
- * Patrick Tasse - Add projectElementHasChild condition
+ * Patrick Tasse - Add projectElementHasChild and isEditorOpened conditions
*******************************************************************************/
package org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared;
+import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withPartName;
+
import org.eclipse.jface.wizard.IWizardContainer;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.IEditorReference;
+import org.hamcrest.Matcher;
/**
* Is a tree node available
return fItem;
}
}
-}
\ No newline at end of file
+
+ /**
+ * Condition to check if an editor with the specified title is opened.
+ *
+ * @param bot
+ * a workbench bot
+ * @param title
+ * the editor title
+ * @return ICondition for verification
+ */
+ public static ICondition isEditorOpened(final SWTWorkbenchBot bot, final String title) {
+ return new SWTBotTestCondition() {
+ @Override
+ public boolean test() throws Exception {
+ Matcher<IEditorReference> withPartName = withPartName(title);
+ return !bot.editors(withPartName).isEmpty();
+ }
+ };
+ }
+}
*
* Contributors:
* Matthew Khouzam - Initial API and implementation
+ * Patrick Tasse - Fix editor handling
*******************************************************************************/
package org.eclipse.tracecompass.tmf.ui.swtbot.tests.viewers.events;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.tracecompass.tmf.core.io.BufferedRandomAccessFile;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* Test trace offsetting
*
* @author Matthew Khouzam
*/
+@RunWith(SWTBotJunit4ClassRunner.class)
public class TestTraceOffsetting {
private static final String TRACE_START = "<trace>";
@Test
public void testOffsetting() {
SWTBotUtils.createProject(PROJET_NAME);
+ SWTBotTreeItem traceFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
- SWTBotTreeItem treeItem = SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
- SWTBotTable eventsTableBot = fBot.activeEditor().bot().table();
+ SWTBotEditor editor = fBot.editorByTitle(fLocation.getName());
+ SWTBotTable eventsTableBot = editor.bot().table();
String timestamp = eventsTableBot.cell(1, 1);
assertEquals("19:00:00.000 000 000", timestamp);
- treeItem.select();
- treeItem.getItems()[0].contextMenu("Apply Time Offset...").click();
+ SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, traceFolderItem, fLocation.getName());
+ traceItem.select();
+ traceItem.contextMenu("Apply Time Offset...").click();
SWTBotUtils.waitForJobs();
// set offset to 99 ns
SWTBotShell shell = fBot.shell("Apply time offset");
final SWTBotTreeItem swtBotTreeItem = allItems[0];
swtBotTreeItem.select();
swtBotTreeItem.click(1);
- KeyStroke[] keyStrokes = new KeyStroke[1];
- keyStrokes[0] = KeyStroke.getInstance('9');
- swtBotTreeItem.pressShortcut(keyStrokes);
- keyStrokes[0] = KeyStroke.getInstance('9');
- swtBotTreeItem.pressShortcut(keyStrokes);
- keyStrokes[0] = KeyStroke.getInstance(SWT.CR);
- swtBotTreeItem.pressShortcut(keyStrokes);
+ swtBotTreeItem.pressShortcut(KeyStroke.getInstance('9'));
+ swtBotTreeItem.pressShortcut(KeyStroke.getInstance('9'));
+ swtBotTreeItem.pressShortcut(KeyStroke.getInstance('\n'));
SWTBotUtils.waitForJobs();
fBot.button("OK").click();
+
+ // wait for trace to close
+ fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, fLocation.getName()));
+
// re-open trace
SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
- SWTBotUtils.waitForJobs();
-
+ editor = fBot.editorByTitle(fLocation.getName());
+ eventsTableBot = editor.bot().table();
timestamp = eventsTableBot.cell(1, 1);
- assertEquals("19:00:00.000 000 000", timestamp);
+ assertEquals("19:00:00.000 000 099", timestamp);
SWTBotUtils.deleteProject(PROJET_NAME, fBot);
}