summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorDariusz Luksza2010-06-15 13:30:54 (EDT)
committer Matthias Sohn2010-06-18 05:31:25 (EDT)
commit4fec29460f0cd3d3a507fc5118815d991afd44cb (patch)
treec90889512ad428f89733ff0777969e8690f4a20e
parent6a4218ebd200b139c292807fe41b4d05bf9284ff (diff)
downloadegit-4fec29460f0cd3d3a507fc5118815d991afd44cb.zip
egit-4fec29460f0cd3d3a507fc5118815d991afd44cb.tar.gz
egit-4fec29460f0cd3d3a507fc5118815d991afd44cb.tar.bz2
Refactored UI testsrefs/changes/73/873/8
All common classes moved into org.eclipse.egit.ui.common package. Created EGitTestCase class, a base class for EGit SWTBoot tests. CQ: 4270 Bug: 316954 Change-Id: I4575638c11456d6621b6f9831fab60fd2efa9f71 Signed-off-by: Dariusz Luksza <dariusz@luksza.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/EGitTestCase.java41
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/ExistingOrNewPage.java (renamed from org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/ExistingOrNewPage.java)2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/GitImportRepoWizard.java (renamed from org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java)7
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java (renamed from org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java)4
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java (renamed from org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java)10
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/SharingWizard.java (renamed from org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizard.java)2
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/WorkingCopyPage.java (renamed from org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java)11
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java64
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java2
9 files changed, 92 insertions, 51 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/EGitTestCase.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/EGitTestCase.java
new file mode 100644
index 0000000..56ba1eb
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/EGitTestCase.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
+ * Copyright (C) 2010, Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
+ * Copyright (C) 2010, Dariusz Luksza <dariusz@luksza.org>
+ *
+ * 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
+ *******************************************************************************/
+package org.eclipse.egit.ui.common;
+
+import org.eclipse.egit.ui.test.Eclipse;
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.junit.After;
+import org.junit.BeforeClass;
+
+public abstract class EGitTestCase {
+
+ static {
+ System.setProperty("org.eclipse.swtbot.playback.delay", "50");
+ }
+
+ protected static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+
+ @BeforeClass
+ public static void closeWelcomePage() {
+ try {
+ bot.viewByTitle("Welcome").close();
+ } catch (WidgetNotFoundException e) {
+ // somebody else probably closed it, lets not feel bad about it.
+ }
+ }
+
+ @After
+ public void resetWorkbench() {
+ new Eclipse().reset();
+ }
+
+}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/ExistingOrNewPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/ExistingOrNewPage.java
index 08fa5ec..6ceaf17 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/ExistingOrNewPage.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/ExistingOrNewPage.java
@@ -9,7 +9,7 @@
* Contributors:
* Stefan Lay (SAP AG) - initial implementation
*******************************************************************************/
-package org.eclipse.egit.ui.wizards.share;
+package org.eclipse.egit.ui.common;
import static org.junit.Assert.assertEquals;
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/GitImportRepoWizard.java
index e484151..0a0da09 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitImportRepoWizard.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/GitImportRepoWizard.java
@@ -1,13 +1,14 @@
/*******************************************************************************
* Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2010, Ketan Padegaonkar <KetanPadegaonkar@gmail.com>
+ * Copyright (C) 2010, Dariusz Luksza <dariusz@luksza.org>
*
* 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
*******************************************************************************/
-package org.eclipse.egit.ui.wizards.clone;
+package org.eclipse.egit.ui.common;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
@@ -16,14 +17,16 @@ public class GitImportRepoWizard {
private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
// TODO: speed it up by calling the wizard using direct eclipse API.
- public RepoPropertiesPage openWizard() {
+ public void openWizard() {
bot.menu("File").menu("Import...").click();
bot.shell("Import").activate();
bot.tree().expandNode("Git").select("Projects from Git");
bot.button("Next >").click();
+ }
+ public RepoPropertiesPage openCloneWizard() {
bot.shell("Import Projects from Git").activate();
bot.button("Clone...").click();
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java
index 27f4a04..c384bed 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoPropertiesPage.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoPropertiesPage.java
@@ -7,7 +7,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui.wizards.clone;
+package org.eclipse.egit.ui.common;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertEnabled;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertNotEnabled;
@@ -68,6 +68,6 @@ public class RepoPropertiesPage {
public RepoRemoteBranchesPage nextToRemoteBranches(String string) {
setURI(string);
bot.button("Next >").click();
- return new RepoRemoteBranchesPage();
+ return new RepoRemoteBranchesPage(string);
}
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java
index cfa9fc8..5ac9fed 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/RepoRemoteBranchesPage.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/RepoRemoteBranchesPage.java
@@ -7,7 +7,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui.wizards.clone;
+package org.eclipse.egit.ui.common;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertEnabled;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertNotEnabled;
@@ -19,6 +19,12 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
public class RepoRemoteBranchesPage {
private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ private final String cloneUrl;
+
+ public RepoRemoteBranchesPage(String cloneUrl) {
+ this.cloneUrl = cloneUrl;
+ }
+
public void assertRemoteBranches(String... branches) {
SWTBotTable table = bot.table();
bot.waitUntil(widgetIsEnabled(table));
@@ -37,7 +43,7 @@ public class RepoRemoteBranchesPage {
public WorkingCopyPage nextToWorkingCopy() {
bot.button("Next >").click();
- return new WorkingCopyPage();
+ return new WorkingCopyPage(cloneUrl);
}
public void deselectAllBranches() {
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizard.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/SharingWizard.java
index 40a7e2c..dbbac55 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizard.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/SharingWizard.java
@@ -9,7 +9,7 @@
* Contributors:
* Stefan Lay (SAP AG) - initial implementation
*******************************************************************************/
-package org.eclipse.egit.ui.wizards.share;
+package org.eclipse.egit.ui.common;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/WorkingCopyPage.java
index 2a627c5..965ceff 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/WorkingCopyPage.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/common/WorkingCopyPage.java
@@ -7,7 +7,7 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
-package org.eclipse.egit.ui.wizards.clone;
+package org.eclipse.egit.ui.common;
import static org.eclipse.swtbot.swt.finder.SWTBotAssert.assertText;
import static org.eclipse.swtbot.swt.finder.waits.Conditions.shellCloses;
@@ -19,6 +19,12 @@ public class WorkingCopyPage {
private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+ private final String cloneUrl;
+
+ public WorkingCopyPage(String cloneUrl) {
+ this.cloneUrl = cloneUrl;
+ }
+
public void assertDirectory(String localDir) {
assertText(localDir, bot.textWithLabel("Directory:"));
}
@@ -34,8 +40,7 @@ public class WorkingCopyPage {
public void waitForCreate() {
bot.button("Finish").click();
- // TODO: pass the repo url in via the constructor from the first page.
- SWTBotShell shell = bot.shell("Cloning from git://repo.or.cz/egit.git");
+ SWTBotShell shell = bot.shell("Cloning from " + cloneUrl);
// This is not a performance test. Allow lots of time to complete
bot.waitUntil(shellCloses(shell), 120000);
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
index 7c0539f..603fdc2 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/clone/GitCloneWizardTest.java
@@ -19,25 +19,20 @@ import java.io.File;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.egit.ui.test.Eclipse;
+import org.eclipse.egit.ui.common.EGitTestCase;
+import org.eclipse.egit.ui.common.GitImportRepoWizard;
+import org.eclipse.egit.ui.common.RepoPropertiesPage;
+import org.eclipse.egit.ui.common.RepoRemoteBranchesPage;
+import org.eclipse.egit.ui.common.WorkingCopyPage;
import org.eclipse.jgit.lib.Repository;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.junit.After;
import org.junit.Before;
-import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
-public class GitCloneWizardTest {
- static {
- System.setProperty("org.eclipse.swtbot.playback.delay", "50");
- }
-
- private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
+public class GitCloneWizardTest extends EGitTestCase {
private GitImportRepoWizard importWizard;
@@ -45,7 +40,8 @@ public class GitCloneWizardTest {
public void updatesParameterFieldsInImportDialogWhenURIIsUpdated()
throws Exception {
- RepoPropertiesPage propertiesPage = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage propertiesPage = importWizard.openCloneWizard();
propertiesPage.setURI("git://www.jgit.org/EGIT");
propertiesPage.assertSourceParams(null, "www.jgit.org", "/EGIT", "git",
@@ -177,10 +173,11 @@ public class GitCloneWizardTest {
@SuppressWarnings("boxing")
@Test
public void canCloneARemoteRepo() throws Exception {
- File destRepo = new File(ResourcesPlugin.getWorkspace()
- .getRoot().getLocation().toFile(), "egit");
+ File destRepo = new File(ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation().toFile(), "egit");
- RepoPropertiesPage propertiesPage = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage propertiesPage = importWizard.openCloneWizard();
RepoRemoteBranchesPage remoteBranches = propertiesPage
.nextToRemoteBranches("git://repo.or.cz/egit.git");
@@ -223,7 +220,8 @@ public class GitCloneWizardTest {
@Test
public void clonedRepositoryShouldExistOnFileSystem() throws Exception {
- RepoPropertiesPage repoProperties = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage repoProperties = importWizard.openCloneWizard();
RepoRemoteBranchesPage remoteBranches = repoProperties
.nextToRemoteBranches("git://repo.or.cz/egit.git");
WorkingCopyPage workingCopy = remoteBranches.nextToWorkingCopy();
@@ -233,10 +231,11 @@ public class GitCloneWizardTest {
@Test
public void alteringSomeParametersDuringClone() throws Exception {
- File destRepo = new File(ResourcesPlugin.getWorkspace()
- .getRoot().getLocation().toFile(), "egit2");
+ File destRepo = new File(ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation().toFile(), "egit2");
- RepoPropertiesPage repoProperties = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage repoProperties = importWizard.openCloneWizard();
RepoRemoteBranchesPage remoteBranches = repoProperties
.nextToRemoteBranches("git://repo.or.cz/egit.git");
remoteBranches.deselectAllBranches();
@@ -273,7 +272,8 @@ public class GitCloneWizardTest {
@Test
public void invalidHostnameFreezesDialog() throws Exception {
- RepoPropertiesPage repoProperties = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage repoProperties = importWizard.openCloneWizard();
RepoRemoteBranchesPage remoteBranches = repoProperties
.nextToRemoteBranches("git://no.example.com/EGIT");
remoteBranches
@@ -286,7 +286,8 @@ public class GitCloneWizardTest {
// an error. Perhaps set a higher timeout for this test ?
@Ignore
public void invalidPortFreezesDialog() throws Exception {
- RepoPropertiesPage repoProperties = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage repoProperties = importWizard.openCloneWizard();
RepoRemoteBranchesPage remoteBranches = repoProperties
.nextToRemoteBranches("git://localhost:80/EGIT");
remoteBranches
@@ -299,7 +300,8 @@ public class GitCloneWizardTest {
// an error. Perhaps set a higher timeout for this test ?
@Ignore
public void timeoutToASocketFreezesDialog() throws Exception {
- RepoPropertiesPage repoProperties = importWizard.openWizard();
+ importWizard.openWizard();
+ RepoPropertiesPage repoProperties = importWizard.openCloneWizard();
RepoRemoteBranchesPage remoteBranches = repoProperties
.nextToRemoteBranches("git://www.example.com/EGIT");
remoteBranches
@@ -315,22 +317,4 @@ public class GitCloneWizardTest {
importWizard = new GitImportRepoWizard();
}
- // TODO: push this in the junit class runner. This can then be shared across
- // all tests.
- @BeforeClass
- public static void closeWelcomePage() {
- try {
- bot.viewByTitle("Welcome").close();
- } catch (WidgetNotFoundException e) {
- // somebody else probably closed it, lets not feel bad about it.
- }
- }
-
- // TODO: push this in the junit class runner. This can then be shared across
- // all tests.
- @After
- public void resetWorkbench() {
- new Eclipse().reset();
- }
-
}
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
index e5b84d9..f9ecb46 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/wizards/share/SharingWizardTest.java
@@ -19,6 +19,8 @@ import java.io.File;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.egit.ui.common.ExistingOrNewPage;
+import org.eclipse.egit.ui.common.SharingWizard;
import org.eclipse.egit.ui.test.Eclipse;
import org.eclipse.jgit.junit.MockSystemReader;
import org.eclipse.jgit.lib.Constants;