import org.apache.log4j.ConsoleAppender;
import org.apache.log4j.Logger;
import org.apache.log4j.SimpleLayout;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.annotation.NonNull;
/**
* Test that the expected context menu items are there
+ * <p>
+ * Action : Trace menu
+ * <p>
+ * Procedure :Select an LTTng trace and open its context menu
+ * <p>
+ * Expected Results: Correct menu opens (Open , Copy, Rename, …)
+ *
*/
@Test
public void test4_01ContextMenuPresence() {
SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);
final List<String> EXPECTED_MENU_LABELS = ImmutableList.of(
- "&Open\tShift+Ctrl+R", "Open With", "&Copy...\tCtrl+C", "Rena&me...\tF2", "&Delete\tDelete", "Delete &Supplementary Files...", "&Export Trace Package...", "Select &Trace Type...", "Apply Time Offset...", "Clear Time Offset", "Refresh\tF5");
+ "&Open\tShift+Ctrl+R", "Open With", "&Copy...\tCtrl+C", "Rena&me...\tF2", "&Delete\tDelete", "Delete &Supplementary Files...", "&Export Trace Package...", "Select &Trace Type...", "Apply Time Offset...", "Clear Time Offset",
+ "Refresh\tF5");
// TODO: SWTBot needs a better way to do this
ContextMenuFinder finder = new ContextMenuFinder(fBot.tree().widget);
/**
* Test that the trace opens with the context menu
+ * <p>
+ * Action : Open trace
+ * <p>
+ * Procedure :Select the Open menu
+ * <p>
+ * Expected Results: Trace is opened and views are populated
+ *
*/
@Test
public void test4_02Open() {
/**
* Test that the trace can be copied with the context menu
+ * <p>
+ * Action : Copy trace
+ * <p>
+ * Procedure :Select the Copy menu and provide a new name. Open.
+ * <p>
+ * Expected Results: Trace is replicated under the new name
+ *
*/
@Test
public void test4_03Copy() {
/**
* Test that the trace can be renamed with the context menu
+ * <p>
+ * Action : Rename trace
+ * <p>
+ * Procedure :Select the Rename menu and provide a new name. Reopen.
+ * <p>
+ * Expected Results: Trace is renamed. The trace editor is closed.
*/
@Test
public void test4_04Rename() {
/**
* Test that the trace can be deleted with the context menu
+ * <p>
+ * Action : Delete trace
+ * <p>
+ * Procedure :Select the Delete menu and confirm deletion
+ * <p>
+ * Expected Results: Trace is deleted. The trace editor is closed.
+ *
*/
@Test
public void test4_05Delete() {
shell.bot().button("Yes").click();
fBot.waitUntil(Conditions.shellCloses(shell));
fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));
+ fBot.waitUntil(new TraceDeletedCondition());
}
/**
* Test that the trace opens with the keyboard
+ * <p>
+ * Action : Open Trace (Accelerator)
+ * <p>
+ * Procedure :Select trace and press Enter
+ * <p>
+ * Expected Results: Trace is opened
+ *
*
* @throws WidgetNotFoundException
* when a widget is not found
/**
* Test that the trace can be deleted with the keyboard
+ * <p>
+ * Action : Delete Trace (Accelerator)
+ * <p>
+ * Procedure :Select trace and press Delete and confirm deletion
+ * <p>
+ * Expected Results: Trace is deleted. The trace editor is closed.
*/
@Test
public void test4_07DeleteKeyboard() {
shell.bot().button("Yes").click();
fBot.waitUntil(Conditions.shellCloses(shell));
fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));
+ fBot.waitUntil(new TraceDeletedCondition());
}
/**
* Test that the trace opens with double-click
+ * <p>
+ * Action : Open Trace (double click)
+ * <p>
+ * Procedure :Double-click a trace
+ * <p>
+ * Expected Results: Trace is opened
*
* @throws WidgetNotFoundException
* when a widget is not found
/**
* Test that the trace is brought to top if already opened
+ * <p>
+ * Action : Open Trace (already open)
+ * <p>
+ * Procedure :Open two traces. Open the first trace again.
+ * <p>
+ * Expected Results: The first trace editor is simply brought to front.
*/
@Test
public void test4_09BringToTop() {
assertTrue(view.bot().tree().hasItems());
view.bot().tree().cell(0, 1).equals(Long.toString(NB_EVENTS));
}
+
+ private final class TraceDeletedCondition extends DefaultCondition {
+ @Override
+ public boolean test() throws Exception {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).findMember(new Path("Traces/" + TRACE_NAME)) == null;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return TRACE_NAME + " was not deleted successfully.";
+ }
+ }
}