diff options
| author | Mickael Istria | 2015-12-08 09:35:40 +0000 |
|---|---|---|
| committer | Markus Keller | 2015-12-09 14:31:20 +0000 |
| commit | a8f41948cb35fc8c2f8032d80697b991c0b4a951 (patch) | |
| tree | a35842f854792112d96b7f149666493b403f3426 | |
| parent | b041aa7c8d4a929164db4a3c54e1e10cc3d3a5b9 (diff) | |
| download | eclipse.platform.ui-a8f41948cb35fc8c2f8032d80697b991c0b4a951.tar.gz eclipse.platform.ui-a8f41948cb35fc8c2f8032d80697b991c0b4a951.tar.xz eclipse.platform.ui-a8f41948cb35fc8c2f8032d80697b991c0b4a951.zip | |
Bug 483882: Fix test on OSX
The initial font value was hardcoded to a size that isn't default on
OSX. Replace hardcoded value by the right one, retrieved at runtime.
Change-Id: Ib4a6d865c896d2fead33595e8e634c1fa834d95b
Signed-off-by: Mickael Istria <mistria@redhat.com>
| -rw-r--r-- | tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java | 34 |
1 files changed, 11 insertions, 23 deletions
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java index 8b375879ee9..a2ebd7a7629 100644 --- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java +++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/preferences/ZoomAndPreferencesFontTest.java @@ -31,7 +31,6 @@ import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.internal.themes.ColorsAndFontsPreferencePage; -import org.eclipse.ui.intro.IIntroPart; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AbstractTextEditor; import org.junit.After; @@ -49,14 +48,10 @@ public class ZoomAndPreferencesFontTest { private static IProject project; private static IFile file; + private StyledText text; private AbstractTextEditor editor; - - /** - * @param testName - */ - public ZoomAndPreferencesFontTest() { - } + private int initialFontHeight; @BeforeClass public static void createFilesAndOpenEditor() throws Exception { @@ -69,19 +64,14 @@ public class ZoomAndPreferencesFontTest { } @Before - public void restoreDefaultFontAndOpenEditor() throws Exception { - IIntroPart intro = PlatformUI.getWorkbench().getIntroManager().getIntro(); - if (intro != null) { - PlatformUI.getWorkbench().getIntroManager().closeIntro(intro); - } - + public void openEditor() throws Exception { IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName()); editor = (AbstractTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow() .getActivePage().openEditor(new FileEditorInput(file), desc.getId()); editor.setFocus(); text = (StyledText) editor.getAdapter(Control.class); - // make sure we start from a clean state - Assert.assertEquals(10, text.getFont().getFontData()[0].getHeight()); + // assume we start on a clean state + initialFontHeight = text.getFont().getFontData()[0].getHeight(); } @After @@ -95,7 +85,7 @@ public class ZoomAndPreferencesFontTest { page.performOk(); dialog.close(); // make sure we land on a clean state - Assert.assertEquals(10, text.getFont().getFontData()[0].getHeight()); + Assert.assertEquals(initialFontHeight, text.getFont().getFontData()[0].getHeight()); editor.close(false); } @@ -119,13 +109,11 @@ public class ZoomAndPreferencesFontTest { Assume.assumeNotNull(command); Assume.assumeTrue("Command must be defined for this test to run", command.isDefined()); - command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); - command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); - command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); - command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); - command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); - command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); - Assert.assertEquals(22, text.getFont().getFontData()[0].getHeight()); + int times = 6; + for (int i = 0; i < times; i++) { + command.executeWithChecks(new ExecutionEvent(command, Collections.EMPTY_MAP, null, null)); + } + Assert.assertEquals(initialFontHeight + times * 2, text.getFont().getFontData()[0].getHeight()); } } |
