X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=tmf%2Forg.eclipse.tracecompass.tmf.ui.swtbot.tests%2Fsrc%2Forg%2Feclipse%2Ftracecompass%2Ftmf%2Fui%2Fswtbot%2Ftests%2Fviewers%2Fevents%2FFilterColorEditorTest.java;h=7233b9595680492df8d17950fac1a2c2fa81a030;hb=fd7909d20fe4531f549a30dfef788162aa5ef9b5;hp=5ce5f348ee788ea65198af23e5cb86b1d492d1ff;hpb=46e33318259bca332f7628024a4cee06bb4dbdea;p=deliverable%2Ftracecompass.git diff --git a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java index 5ce5f348ee..7233b95956 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java @@ -44,6 +44,8 @@ import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes; import org.eclipse.swtbot.swt.finder.results.Result; import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences; import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCLabel; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin; import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers; @@ -338,6 +340,57 @@ public class FilterColorEditorTest { colorRegistry.put(HIGHLIGHT_COLOR_DEFINITION_ID, fHighlight); } + /** + * Test the header bar + */ + @Test + public void testHeaderBar() { + // Add search filter on Timestamp column + fTableBot.click(0, TIMESTAMP_COLUMN); + fBot.text().typeText("2"); + fBot.text().pressShortcut(Keystrokes.CR); + // Add search filter on Message column and Add as Filter + fTableBot.click(0, MESSAGE_COLUMN); + fBot.text().typeText("F"); + fBot.text().pressShortcut(Keystrokes.CTRL, Keystrokes.CR); + fBot.waitUntil(ConditionHelpers.isTableCellFilled(fTableBot, "2/22", 1, 1)); + fBot.waitUntil(ConditionHelpers.isTableCellFilled(fTableBot, "Message F", 3, MESSAGE_COLUMN)); + fBot.clabel("Timestamp matches \"2\""); + fBot.clabel("Message matches \"F\""); + waitForHighlightState(3, TIMESTAMP_COLUMN, true); + waitForHighlightState(3, MESSAGE_COLUMN, true); + // Clear all filter highlighting + fTableBot.pressShortcut(Keystrokes.DELETE); + waitForHighlightState(3, TIMESTAMP_COLUMN, false); + waitForHighlightState(3, MESSAGE_COLUMN, false); + // Click filter label to set the filter highlighting on Message filter + SWTBotCLabel filterCLabel = fBot.clabel("Message matches \"F\""); + SWTBotCanvas filterCanvas = new SWTBotCanvas(filterCLabel.widget); + filterCanvas.click(); + waitForHighlightState(3, TIMESTAMP_COLUMN, false); + waitForHighlightState(3, MESSAGE_COLUMN, true); + // Click filter icon to remove the Message filter + Rectangle imageBounds = filterCLabel.image().getBounds(); + filterCanvas.click(filterCLabel.widget.getLeftMargin() + imageBounds.width / 2, filterCLabel.widget.getTopMargin() + imageBounds.height / 2); + fBot.waitUntil(ConditionHelpers.isTableCellFilled(fTableBot, "5/22", 1, 1)); + } + + private void waitForHighlightState(int row, int column, boolean highlight) { + fBot.waitUntil(new DefaultCondition() { + @Override + public boolean test() throws Exception { + Rectangle cellBounds = SWTBotUtils.getCellBounds(fTableBot.widget, row, column); + ImageHelper imageHelper = ImageHelper.grabImage(cellBounds); + return imageHelper.getHistogram().contains(fHighlight) == highlight; + } + + @Override + public String getFailureMessage() { + return String.format("Cell (%d, %d) did not have highlight state: %s", row, column, Boolean.toString(highlight)); + } + }); + } + private static ImageHelper waitForNewImage(Rectangle bounds, ImageHelper currentImage) { ImageHelper[] newImage = new ImageHelper[1]; fBot.waitUntil(new DefaultCondition() {