swtbot: check syntax highlighting with filter bar
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Tue, 24 Mar 2015 13:26:00 +0000 (09:26 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 27 Mar 2015 01:09:09 +0000 (21:09 -0400)
This test will take a screen grab of the cell being highlighted
and compare it before and after highlighting.

Change-Id: Iae5fe05cc965b19aa5dec775c26e1b637901982b
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/44540
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
Tested-by: Patrick Tasse <patrick.tasse@gmail.com>
org.eclipse.tracecompass.tmf.ui.swtbot.tests/shared/org/eclipse/tracecompass/tmf/ui/swtbot/tests/shared/SWTBotUtils.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/AllTests.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CallsiteEventsInTableTest.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/CollapseEventsInTableTest.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java [new file with mode: 0644]
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FontEventEditorTest.java
org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/MovableColumnEventsEditorTest.java

index f5bfef8060a349828460d4fdfda26bf82eb2d5e9..ceccb7a22c0136f6342b3599d0e26548a13a4696 100644 (file)
@@ -24,18 +24,27 @@ import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.bindings.keys.IKeyLookup;
+import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.bindings.keys.ParseException;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
 import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableItem;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
 import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
 import org.eclipse.swtbot.swt.finder.results.VoidResult;
 import org.eclipse.swtbot.swt.finder.waits.Conditions;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+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.tracecompass.tmf.ui.editors.TmfEventsEditor;
@@ -52,7 +61,6 @@ import org.eclipse.ui.PlatformUI;
 import org.eclipse.ui.WorkbenchException;
 import org.hamcrest.Matcher;
 
-
 /**
  * SWTBot Helper functions
  *
@@ -60,7 +68,8 @@ import org.hamcrest.Matcher;
  */
 public final class SWTBotUtils {
 
-    private SWTBotUtils() {}
+    private SWTBotUtils() {
+    }
 
     private static final String TRACING_PERSPECTIVE_ID = TracingPerspectiveFactory.ID;
 
@@ -225,8 +234,7 @@ public final class SWTBotUtils {
      * @param tracePath
      *            the path of the trace file (absolute or relative)
      * @param traceType
-     *            the trace type id (eg:
-     *            org.eclipse.linuxtools.btf.trace)
+     *            the trace type id (eg: org.eclipse.linuxtools.btf.trace)
      */
     public static void openTrace(final String projectName, final String tracePath, final String traceType) {
         openTrace(projectName, tracePath, traceType, true);
@@ -240,8 +248,7 @@ public final class SWTBotUtils {
      * @param tracePath
      *            the path of the trace file (absolute or relative)
      * @param traceType
-     *            the trace type id (eg:
-     *            org.eclipse.linuxtools.btf.trace)
+     *            the trace type id (eg: org.eclipse.linuxtools.btf.trace)
      * @param delay
      *            delay and wait for jobs
      */
@@ -372,7 +379,8 @@ public final class SWTBotUtils {
      * @param bot
      *            a given workbench bot
      * @param projectName
-     *            the name of the project (it needs to exist or else it would time out)
+     *            the name of the project (it needs to exist or else it would
+     *            time out)
      * @return a {@link SWTBotTreeItem} of the "Traces" directory
      */
     public static SWTBotTreeItem selectTracesFolder(SWTWorkbenchBot bot, String projectName) {
@@ -415,4 +423,43 @@ public final class SWTBotUtils {
         }
         waitForJobs();
     }
+
+    /**
+     * Maximize a table
+     *
+     * @param tableBot
+     *            the {@link SWTBotTable} table
+     */
+    public static void maximizeTable(SWTBotTable tableBot) {
+        try {
+            tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
+        } catch (ParseException e) {
+            fail();
+        }
+    }
+
+    /**
+     * Get the bounds of a cell (SWT.Rectangle) for the specified row and column
+     * index in a table
+     *
+     * @param table
+     *            the table
+     * @param row
+     *            the row of the table to look up
+     * @param col
+     *            the column of the table to look up
+     * @return the bounds in display relative coordinates
+     */
+    public static Rectangle getCellBounds(final Table table, final int row, final int col) {
+        return UIThreadRunnable.syncExec(new Result<Rectangle>() {
+            @Override
+            public Rectangle run() {
+                TableItem item = table.getItem(row);
+                Rectangle bounds = item.getBounds(col);
+                Point p = table.toDisplay(bounds.x, bounds.y);
+                Rectangle rect = new Rectangle(p.x, p.y, bounds.width, bounds.height);
+                return rect;
+            }
+        });
+    }
 }
index 56001f93b1af54409cc406f9152acf03ce9c4e93..d42fc8e9790a8752c36934e7750a7d2c434fadf3 100644 (file)
@@ -23,6 +23,7 @@ import org.junit.runners.Suite;
         CallsiteEventsInTableTest.class,
         CollapseEventsInTableTest.class,
         ColorsViewTest.class,
+        FilterColorEditorTest.class,
         FilterViewerTest.class,
         FontEventEditorTest.class,
         MovableColumnEventsEditorTest.class,
index 7d5cf3b24cb5f10195d7a8fb4c5b4a57a9dc706f..90bb2601dfa246c0b7d96b78969ec4d204ff3b30 100644 (file)
@@ -29,14 +29,6 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.tracecompass.internal.tmf.core.Activator;
-import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -44,6 +36,11 @@ import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
 import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.tracecompass.internal.tmf.core.Activator;
+import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.eclipse.ui.IEditorReference;
 import org.hamcrest.Matcher;
 import org.junit.AfterClass;
@@ -159,7 +156,7 @@ public class CallsiteEventsInTableTest {
         SWTBotTable tableBot = editorBot.bot().table();
 
         // Maximize editor area
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
         tableBot.click(1, 0);
 
         // Open source code location
@@ -171,18 +168,9 @@ public class CallsiteEventsInTableTest {
         final SWTBotEditor sourceEditorBot = fBot.editor(matcher);
         assertTrue(sourceEditorBot.isActive());
 
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
 
         fBot.closeAllEditors();
         SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
     }
-
-    private static void maximizeTable(SWTBotTable tableBot) {
-        try {
-            tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
-        } catch (ParseException e) {
-            fail();
-        }
-    }
-
 }
index 2d87186f061dd569283abd1c1b6c8822fbfc1239..1307de8c29bf8129fee4991496d90270eece351d 100644 (file)
@@ -29,21 +29,18 @@ import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
 import org.eclipse.core.runtime.preferences.InstanceScope;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
-import org.eclipse.tracecompass.internal.tmf.core.Activator;
-import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
-import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
-import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
-import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 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.SWTBotMenu;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+import org.eclipse.tracecompass.internal.tmf.core.Activator;
+import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimePreferencesConstants;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ConditionHelpers;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -135,7 +132,7 @@ public class CollapseEventsInTableTest {
         SWTBotTable tableBot = editorBot.bot().table();
 
         /* Maximize editor area */
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
         tableBot.click(1, 0);
 
         /* Collapse Events */
@@ -184,18 +181,9 @@ public class CollapseEventsInTableTest {
         fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "Jan 1 01:01:01", 1, 1));
         assertEquals("Timestamp", "Jan 1 01:01:01", tableBot.cell(1, 1));
 
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
 
         fBot.closeAllEditors();
         SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
     }
-
-    private static void maximizeTable(SWTBotTable tableBot) {
-        try {
-            tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
-        } catch (ParseException e) {
-            fail();
-        }
-    }
-
 }
diff --git a/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java b/org.eclipse.tracecompass.tmf.ui.swtbot.tests/src/org/eclipse/tracecompass/tmf/ui/swtbot/tests/viewers/events/FilterColorEditorTest.java
new file mode 100644 (file)
index 0000000..794e025
--- /dev/null
@@ -0,0 +1,278 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *   Matthew Khouzam - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.ui.swtbot.tests.viewers.events;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assume.assumeTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Logger;
+import org.apache.log4j.SimpleLayout;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.Rectangle;
+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.SWTBotTable;
+import org.eclipse.tracecompass.tmf.core.tests.TmfCoreTestPlugin;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.ImageHelper;
+import org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import com.google.common.collect.HashMultiset;
+import com.google.common.collect.Multiset;
+
+/**
+ * SWTBot test for testing highlighting
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class FilterColorEditorTest {
+
+    private static final int TIMESTAMP_COLUMN = 1;
+    private static final int SOURCE_COLUMN = 2;
+    private static final int MESSAGE_COLUMN = 6;
+    private static final RGB YELLOW = new RGB(255, 255, 0);
+    private static final String TRACE_PROJECT_NAME = "test";
+    private static final String COLUMN_TRACE = "syslog_collapse";
+    private static final String COLUMN_TRACE_PATH = "testfiles/" + COLUMN_TRACE;
+    private static final String COLUMN_TRACE_TYPE = "org.eclipse.linuxtools.tmf.tests.stubs.trace.text.testsyslog";
+
+    private static File fTestFile = null;
+
+    private static SWTWorkbenchBot fBot;
+
+    /** The Log4j logger instance. */
+    private static final Logger fLogger = Logger.getRootLogger();
+    private SWTBotTable fTableBot;
+    private static final int ROW = 8;
+    private RGB fForeground;
+    private RGB fBackground;
+
+    /**
+     * Test Class setup
+     */
+    @BeforeClass
+    public static void init() {
+        SWTBotUtils.failIfUIThread();
+
+        /* set up test trace */
+        URL location = FileLocator.find(TmfCoreTestPlugin.getDefault().getBundle(), new Path(COLUMN_TRACE_PATH), null);
+        URI uri;
+        try {
+            uri = FileLocator.toFileURL(location).toURI();
+            fTestFile = new File(uri);
+        } catch (URISyntaxException | IOException e) {
+            fail(e.getMessage());
+        }
+
+        assumeTrue(fTestFile.exists());
+
+        /* Set up for swtbot */
+        SWTBotPreferences.TIMEOUT = 20000; /* 20 second timeout */
+        SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
+
+        fLogger.removeAllAppenders();
+        fLogger.addAppender(new ConsoleAppender(new SimpleLayout(), ConsoleAppender.SYSTEM_OUT));
+        fBot = new SWTWorkbenchBot();
+
+        /* Close welcome view */
+        SWTBotUtils.closeView("Welcome", fBot);
+
+        /* Switch perspectives */
+        SWTBotUtils.switchToTracingPerspective();
+
+        /* Finish waiting for eclipse to load */
+        SWTBotUtils.waitForJobs();
+    }
+
+    /**
+     * Test class tear down method.
+     */
+    @AfterClass
+    public static void tearDown() {
+        fLogger.removeAllAppenders();
+    }
+
+    /**
+     * Bring up the table
+     */
+    @Before
+    public void setup() {
+        SWTBotUtils.createProject(TRACE_PROJECT_NAME);
+
+        // Open the actual trace
+        SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), COLUMN_TRACE_TYPE);
+        SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
+
+        fTableBot = editorBot.bot().table();
+        fBackground = fTableBot.backgroundColor().getRGB();
+        fForeground = fTableBot.foregroundColor().getRGB();
+
+        SWTBotUtils.maximizeTable(fTableBot);
+    }
+
+    /**
+     * Remove the project
+     */
+    @After
+    public void cleanup() {
+        SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
+        SWTBotUtils.waitForJobs();
+    }
+
+    /**
+     * Test basic highlight
+     */
+    @Test
+    public void testHighlight() {
+        final Rectangle cellBounds = SWTBotUtils.getCellBounds(fTableBot.widget, ROW, SOURCE_COLUMN);
+
+        Multiset<RGB> colorBefore = ImageHelper.grabImage(cellBounds).getHistogram();
+        // Select source column and enter regex
+        fTableBot.click(0, SOURCE_COLUMN);
+        fBot.text().typeText("HostF\n", 100);
+        // make sure selected row is not matching row
+        fTableBot.select(ROW - 1);
+        Multiset<RGB> colorAfter = ImageHelper.grabImage(cellBounds).getHistogram();
+
+        assertTrue(colorBefore.contains(fBackground));
+        assertTrue(colorBefore.contains(fForeground));
+        assertFalse(colorBefore.contains(YELLOW));
+
+        assertTrue(colorAfter.contains(fBackground));
+        assertTrue(colorAfter.contains(fForeground));
+        assertTrue(colorAfter.contains(YELLOW));
+        Multiset<RGB> diff = HashMultiset.create();
+        /*
+         * make the histogram difference This will allow us to verify what has
+         * changed in the two images. Hopefully the sum will be zero
+         */
+        for (RGB entry : colorAfter.elementSet()) {
+            diff.add(entry, Math.abs(colorAfter.count(entry) - colorBefore.count(entry)));
+        }
+        /*
+         * Check that the background became yellow
+         */
+        assertEquals(diff.count(fBackground), (diff.count(YELLOW)));
+    }
+
+    /**
+     * Test highlighting multiple elements in a message
+     */
+    @Test
+    public void testMultiHighlightMessage() {
+        final Rectangle cellBounds = SWTBotUtils.getCellBounds(fTableBot.widget, ROW, MESSAGE_COLUMN);
+
+        ImageHelper before = ImageHelper.grabImage(cellBounds);
+        // enter regex in message column
+        fTableBot.click(0, MESSAGE_COLUMN);
+        fBot.text().typeText("e\n", 100);
+        // make sure matching item is not selected
+        fTableBot.select(ROW - 1);
+        ImageHelper after = ImageHelper.grabImage(cellBounds);
+
+        Multiset<RGB> colorBefore = before.getHistogram();
+        Multiset<RGB> colorAfter = after.getHistogram();
+
+        assertTrue(colorBefore.contains(fBackground));
+        assertTrue(colorBefore.contains(fForeground));
+        assertFalse(colorBefore.contains(YELLOW));
+
+        assertTrue(colorAfter.contains(fBackground));
+        assertTrue(colorAfter.contains(fForeground));
+        assertTrue(colorAfter.contains(YELLOW));
+
+        int start = -1;
+        int end;
+        List<Point> intervals = new ArrayList<>();
+        List<RGB> pixelRow = after.getPixelRow(2);
+        for (int i = 1; i < pixelRow.size(); i++) {
+            RGB prevPixel = pixelRow.get(i - 1);
+            RGB pixel = pixelRow.get(i);
+            if (prevPixel.equals(fBackground) && pixel.equals(YELLOW)) {
+                start = i;
+            }
+            if (prevPixel.equals(YELLOW) && pixel.equals(fBackground)) {
+                end = i;
+                if (start == -1) {
+                    fail();
+                }
+                intervals.add(new Point(start, end));
+            }
+        }
+        assertEquals(2, intervals.size());
+    }
+
+    /**
+     * Switch to filter and back
+     */
+    @Test
+    public void testSwitchToFilter() {
+        final Rectangle cellBounds = SWTBotUtils.getCellBounds(fTableBot.widget, ROW, TIMESTAMP_COLUMN);
+        ImageHelper before = ImageHelper.grabImage(cellBounds);
+        // enter regex in message column
+        fTableBot.click(0, TIMESTAMP_COLUMN);
+        fBot.text().typeText("00\n", 100);
+        // make sure matching column is not selected
+        fTableBot.select(ROW - 1);
+        ImageHelper after = ImageHelper.grabImage(cellBounds);
+        // toggle filter mode
+        fTableBot.click(0, 0);
+        ImageHelper afterFilter = ImageHelper.grabImage(cellBounds);
+        // toggle search mode
+        fTableBot.click(0, 0);
+
+        List<RGB> beforeLine = before.getPixelRow(2);
+        List<RGB> afterLine = after.getPixelRow(2);
+        List<RGB> afterFilterLine = afterFilter.getPixelRow(2);
+
+        assertEquals(beforeLine.size(), afterLine.size());
+        assertEquals(beforeLine.size(), afterFilterLine.size());
+        for (int i = 0; i < beforeLine.size(); i++) {
+            RGB afterFilterPixel = afterFilterLine.get(i);
+            RGB beforePixel = beforeLine.get(i);
+            RGB afterPixel = afterLine.get(i);
+
+            assertEquals(beforePixel, afterFilterPixel);
+            if (!afterPixel.equals(YELLOW)) {
+                assertEquals(beforePixel, afterPixel);
+            } else {
+                assertNotEquals(YELLOW, beforePixel);
+            }
+
+        }
+        assertEquals(beforeLine, afterFilterLine);
+        assertNotEquals(afterLine, beforeLine);
+    }
+}
index 5a9bc0a29c6008eb1bbad34b06af361ca0f0b35b..752d4497f162a06e5d5b37bc725c569708ca85dc 100644 (file)
@@ -28,9 +28,6 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.SimpleLayout;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
 import org.eclipse.swt.graphics.FontData;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -125,7 +122,7 @@ public class FontEventEditorTest {
         SWTBotTable tableBot = editorBot.bot().table();
 
         // Maximize editor area
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
         tableBot.contextMenu("Show Raw").click();
         tableBot.setFocus();
         tableBot.click(4, 1);
@@ -181,13 +178,4 @@ public class FontEventEditorTest {
             }
         });
     }
-
-    private static void maximizeTable(SWTBotTable tableBot) {
-        try {
-            tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
-        } catch (ParseException e) {
-            fail();
-        }
-    }
-
 }
index fcefdea79fa52ec7c37ca7ccdd05982f504a59db..6f0cbb40ec856e8b7992a3677ddcdca78f4a6f98 100644 (file)
@@ -28,9 +28,6 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.SimpleLayout;
 import org.eclipse.core.runtime.FileLocator;
 import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.bindings.keys.IKeyLookup;
-import org.eclipse.jface.bindings.keys.KeyStroke;
-import org.eclipse.jface.bindings.keys.ParseException;
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
@@ -126,7 +123,7 @@ public class MovableColumnEventsEditorTest {
         SWTBotTable tableBot = editorBot.bot().table();
 
         // Maximize editor area
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
 
         // Verify that source code was actually opened
         assertArrayEquals("Before reorder", BEFORE_COLS, tableBot.columns().toArray());
@@ -146,7 +143,7 @@ public class MovableColumnEventsEditorTest {
         editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
         tableBot = editorBot.bot().table();
         // Maximize editor area
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
         assertArrayEquals("After reorder", AFTER_COLS, tableBot.columns().toArray());
         // close and re-open
         editorBot.close();
@@ -156,19 +153,10 @@ public class MovableColumnEventsEditorTest {
         editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());
         tableBot = editorBot.bot().table();
         // Maximize editor area
-        maximizeTable(tableBot);
+        SWTBotUtils.maximizeTable(tableBot);
         assertNull("After reset", TmfTraceColumnManager.loadColumnOrder(COLUMN_TRACE_TYPE));
         assertArrayEquals("After reset", BEFORE_COLS, tableBot.columns().toArray());
         fBot.closeAllEditors();
         SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
     }
-
-    private static void maximizeTable(SWTBotTable tableBot) {
-        try {
-            tableBot.pressShortcut(KeyStroke.getInstance(IKeyLookup.CTRL_NAME + "+"), KeyStroke.getInstance("M"));
-        } catch (ParseException e) {
-            fail();
-        }
-    }
-
 }
This page took 0.034734 seconds and 5 git commands to generate.