diff options
| author | Alexander Kurtakov | 2018-02-16 13:09:05 +0000 |
|---|---|---|
| committer | Alexander Kurtakov | 2018-02-16 13:09:05 +0000 |
| commit | 3ebd8079d2aace97e79c02763a7dd6d653c6c315 (patch) | |
| tree | af1ce95c65a5766affbb79d0ed3b3a028ca21ece | |
| parent | b9b641adfd3978edc0f3717ec5b87c7b7772c1f4 (diff) | |
| download | eclipse.platform.ui-3ebd8079d2aace97e79c02763a7dd6d653c6c315.tar.gz eclipse.platform.ui-3ebd8079d2aace97e79c02763a7dd6d653c6c315.tar.xz eclipse.platform.ui-3ebd8079d2aace97e79c02763a7dd6d653c6c315.zip | |
Bug 464474 - move UA browser tests to o.e.ui.tests.browserI20180218-2000I20180217-1500I20180216-2000
Move tests to o.e.ui.tests.browser.
Change-Id: I777fae38602e2964ad1e103ddee217743b18fcd3
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
3 files changed, 178 insertions, 3 deletions
diff --git a/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/AllTests.java b/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/AllTests.java index 1d204cc401e..3208e644d2f 100644 --- a/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/AllTests.java +++ b/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2017 IBM Corporation and others. + * Copyright (c) 2004, 2018 IBM Corporation and others. * 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 @@ -18,7 +18,8 @@ import org.junit.runners.Suite; @Suite.SuiteClasses({ ExistenceTestCase.class, InternalBrowserViewTestCase.class, InternalBrowserEditorTestCase.class, // ExternalBrowserTestCase.class); - DialogsTestCase.class, PreferencesTestCase.class, ToolbarBrowserTestCase.class, WebBrowserUtilTestCase.class + DialogsTestCase.class, PreferencesTestCase.class, TestInput.class, ToolbarBrowserTestCase.class, + WebBrowserUtilTestCase.class }) public class AllTests { }
\ No newline at end of file diff --git a/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/TestInput.java b/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/TestInput.java new file mode 100644 index 00000000000..d559d2e648f --- /dev/null +++ b/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/TestInput.java @@ -0,0 +1,114 @@ +/******************************************************************************* + * Copyright (c) 2009, 2018 IBM Corporation and others. + * 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ + +package org.eclipse.ui.tests.browser.internal; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.net.MalformedURLException; +import java.net.URL; + +import org.eclipse.ui.browser.IWorkbenchBrowserSupport; +import org.eclipse.ui.internal.browser.WebBrowserEditorInput; +import org.junit.Test; + +public class TestInput { + + private final String URL1 = "http://www.eclipse.org"; + private final String URL2 = "http://bugs.eclipse.org"; + private static final String ID1 = "browser.id1"; + private static final String ID2 = "browser.id2"; + + @Test + public void testCompareWithNull() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + assertFalse(input.equals(null)); + } + + @Test + public void testCompareWithNullURL() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + WebBrowserEditorInput input2 = new WebBrowserEditorInput(null, + 0, ID1); + assertFalse(input.equals(input2)); + assertFalse(input2.equals(input)); + } + + @Test + public void testCompareWithSelf() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + assertTrue(input.equals(input)); + } + + @Test + public void testCompareWithSimilar() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + assertTrue(input.equals(input2)); + assertTrue(input.hashCode() == input2.hashCode()); + } + + @Test + public void testCompareWithDifferentUrl() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL2), + 0, ID1); + assertFalse(input.equals(input2)); + } + + @Test + public void testCompareWithDifferentId() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), + 0, ID2); + assertFalse(input.equals(input2)); + } + + @Test + public void testCompareWithDifferentStyle() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), + 1, ID1); + assertTrue(input.equals(input2)); + assertTrue(input.hashCode() == input2.hashCode()); + } + + @Test + public void testCompareWithStatusbarVisible() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1), + 0, ID1); + WebBrowserEditorInput input2 = new WebBrowserEditorInput(new URL(URL1), + IWorkbenchBrowserSupport.STATUS, ID1); + assertFalse(input.equals(input2)); + } + + @Test + public void testHashWithNullURL() { + WebBrowserEditorInput input = new WebBrowserEditorInput(null,0, ID1); + input.hashCode(); // Fails if exception thrown + } + + @Test + public void testHashWithNullID() throws MalformedURLException { + WebBrowserEditorInput input = new WebBrowserEditorInput(new URL(URL1),0, null); + input.hashCode(); // Fails if exception thrown + } + +} diff --git a/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/WebBrowserUtilTestCase.java b/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/WebBrowserUtilTestCase.java index 36cbfd3b9bf..94bd8012471 100644 --- a/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/WebBrowserUtilTestCase.java +++ b/tests/org.eclipse.ui.tests.browser/src/org/eclipse/ui/tests/browser/internal/WebBrowserUtilTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2017 Tasktop Technologies and others. + * Copyright (c) 2015, 2018 Tasktop Technologies and others. * 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 @@ -13,12 +13,72 @@ package org.eclipse.ui.tests.browser.internal; import static org.eclipse.ui.internal.browser.IBrowserDescriptor.URL_PARAMETER; import static org.eclipse.ui.internal.browser.WebBrowserUtil.createParameterArray; import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import org.eclipse.ui.internal.browser.WebBrowserUtil; import org.junit.Test; @SuppressWarnings("restriction") public class WebBrowserUtilTestCase { + private static final String URL = "http://127.0.0.1:3873/help/index.jsp"; + + @SuppressWarnings("deprecation") + @Test + public void testNullParameters() { + assertEquals(URL, WebBrowserUtil.createParameterString(null, URL)); + } + + @SuppressWarnings("deprecation") + @Test + public void testEmptyParameters() { + assertEquals(URL, WebBrowserUtil.createParameterString("", URL)); + } + + @SuppressWarnings("deprecation") + @Test + public void testNullURL() { + assertEquals("", WebBrowserUtil.createParameterString("", null)); + } + + @SuppressWarnings("deprecation") + @Test + public void testNoSubstitution() { + assertEquals("-console " + URL, WebBrowserUtil.createParameterString("-console", URL)); + } + + @SuppressWarnings("deprecation") + @Test + public void testSubstitution() { + assertEquals("-url " + URL + " -console", WebBrowserUtil.createParameterString("-url %URL% -console", URL)); + } + + @Test + public void testArrayNullParameters() { + assertArrayEquals(new String[] { URL }, WebBrowserUtil.createParameterArray(null, URL)); + } + + @Test + public void testArrayEmptyParameters() { + assertArrayEquals(new String[] { URL }, WebBrowserUtil.createParameterArray("", URL)); + } + + @Test + public void testArrayNullURL() { + assertArrayEquals(new String[0], WebBrowserUtil.createParameterArray("", null)); + } + + @Test + public void testArrayNoSubstitution() { + assertArrayEquals(new String[] { "-console", URL }, WebBrowserUtil.createParameterArray("-console", URL)); + } + + @Test + public void testArraySubstitution() { + assertArrayEquals(new String[] { "-url", URL, "-console" }, + WebBrowserUtil.createParameterArray("-url %URL% -console", URL)); + } + @Test public void testCreateParameterArray() { assertArrayEquals(new String[0], createParameterArray(null, null)); |
