Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Wolf2016-06-12 19:29:20 +0000
committerThomas Wolf2016-06-12 19:37:39 +0000
commit53d89e34a754a01b596a25e845282b63715816de (patch)
tree4846f5fb641bdd1f0dca0b6e973dd3263a78aa88 /org.eclipse.egit.ui.test/src/org/eclipse/egit
parentaa41a50a62201417338161715855623cc64116e3 (diff)
downloadegit-53d89e34a754a01b596a25e845282b63715816de.tar.gz
egit-53d89e34a754a01b596a25e845282b63715816de.tar.xz
egit-53d89e34a754a01b596a25e845282b63715816de.zip
Test stability: try to fix three frequently failing tests
* Wait for shells to close after having clicked finish button * Wait for add to/remove from index jobs * Open global git config preference page differently, and move opening the page into the test methods to get at least screenshots in case it fails. Change-Id: Iea78d6053fc5b554ce1b25eacfd29bdb0b473007 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java7
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/prefpages/configuration/GlobalConfigurationPageTest.java39
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java3
3 files changed, 38 insertions, 11 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java
index 45fcfd0f17..0bee09f47d 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/internal/submodules/SubmoduleFolderTest.java
@@ -8,7 +8,9 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.submodules;
+import static org.eclipse.egit.ui.JobFamilies.ADD_TO_INDEX;
import static org.eclipse.egit.ui.JobFamilies.GENERATE_HISTORY;
+import static org.eclipse.egit.ui.JobFamilies.REMOVE_FROM_INDEX;
import static org.eclipse.swtbot.eclipse.finder.waits.Conditions.waitForEditor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -203,10 +205,10 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
node.select();
ContextMenuHelper.clickContextMenuSync(projectExplorerTree, "Team",
util.getPluginLocalizedValue("AddToIndexAction_label"));
+ TestUtil.joinJobs(ADD_TO_INDEX);
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
IndexDiffCacheEntry cache = Activator.getDefault().getIndexDiffCache()
.getIndexDiffCacheEntry(subRepository);
- TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
IResourceState state = ResourceStateFactory.getInstance()
.get(cache.getIndexDiff(), file);
assertTrue("File should be staged", state.isStaged());
@@ -214,6 +216,7 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
assertFalse(node.getText().startsWith("> "));
ContextMenuHelper.clickContextMenuSync(projectExplorerTree, "Team",
util.getPluginLocalizedValue("RemoveFromIndexAction_label"));
+ TestUtil.joinJobs(REMOVE_FROM_INDEX);
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
state = ResourceStateFactory.getInstance().get(cache.getIndexDiff(),
file);
@@ -273,6 +276,8 @@ public class SubmoduleFolderTest extends LocalRepositoryTestCase {
.getPluginLocalizedValue("DisconnectAction_label");
ContextMenuHelper.clickContextMenuSync(projectExplorerTree, "Team",
menuString);
+ TestUtil.waitForJobs(500, 5000);
+ TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
ResourcesPlugin.getWorkspace().getRoot()
.refreshLocal(IResource.DEPTH_INFINITE, null);
// Access the session property directly: RepositoryMapping.getMapping()
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/prefpages/configuration/GlobalConfigurationPageTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/prefpages/configuration/GlobalConfigurationPageTest.java
index 41fee09def..2581e45140 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/prefpages/configuration/GlobalConfigurationPageTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/prefpages/configuration/GlobalConfigurationPageTest.java
@@ -20,6 +20,7 @@ import java.util.Set;
import org.eclipse.egit.ui.common.EGitTestCase;
import org.eclipse.egit.ui.internal.UIText;
+import org.eclipse.egit.ui.internal.preferences.GlobalConfigurationPreferencePage;
import org.eclipse.egit.ui.test.Eclipse;
import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -29,9 +30,12 @@ import org.eclipse.jgit.util.SystemReader;
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.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -50,8 +54,6 @@ public class GlobalConfigurationPageTest {
private static final SWTWorkbenchBot bot = new SWTWorkbenchBot();
- private static final TestUtil util = new TestUtil();
-
private static FileBasedConfig config;
private SWTBotShell preferencePage;
@@ -68,23 +70,34 @@ public class GlobalConfigurationPageTest {
config.unsetSection(TESTSECTION, TESTSUBSECTION);
config.unsetSection(TESTSECTION, null);
config.save();
- getGitConfigurationPreferencePage();
}
private void getGitConfigurationPreferencePage() {
- preferencePage = new Eclipse().openPreferencePage(preferencePage);
- SWTBotTreeItem team = preferencePage.bot().tree().getTreeItem("Team");
- team = TestUtil.expandAndWaitFor(team,
- util.getPluginLocalizedValue("GitPreferences_name"));
- team = TestUtil.expandAndWaitFor(team,
- util.getPluginLocalizedValue("ConfigurationPage.name"));
- team.select();
+ if (preferencePage != null) {
+ preferencePage.close();
+ bot.waitUntil(Conditions.shellCloses(preferencePage));
+ }
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+
+ @Override
+ public void run() {
+ PreferencesUtil.createPreferenceDialogOn(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell(),
+ GlobalConfigurationPreferencePage.ID, null, null)
+ .open();
+ }
+ });
+ bot.waitUntil(Conditions.shellIsActive("Preferences"));
+ preferencePage = bot.shell("Preferences");
}
@After
public void after() throws Exception {
if (preferencePage != null) {
preferencePage.close();
+ bot.waitUntil(Conditions.shellCloses(preferencePage));
+ preferencePage = null;
}
TestUtil.processUIEvents();
}
@@ -100,6 +113,7 @@ public class GlobalConfigurationPageTest {
@Test
public void testNodes() throws Exception {
+ getGitConfigurationPreferencePage();
SWTBotTree configTree = preferencePage.bot().tree(1);
for (String section : config.getSections()) {
SWTBotTreeItem sectionItem = configTree.getTreeItem(section);
@@ -124,6 +138,7 @@ public class GlobalConfigurationPageTest {
@Test
public void testAddSectionEntry() throws Exception {
+ getGitConfigurationPreferencePage();
preferencePage.bot().button(
UIText.ConfigurationEditorComponent_AddButton).click();
SWTBotShell addDialog = bot
@@ -149,6 +164,7 @@ public class GlobalConfigurationPageTest {
@Test
public void testAddSubSectionEntry() throws Exception {
+ getGitConfigurationPreferencePage();
preferencePage.bot().button(
UIText.ConfigurationEditorComponent_AddButton).click();
SWTBotShell addDialog = bot
@@ -213,6 +229,7 @@ public class GlobalConfigurationPageTest {
@Test
public void testChecksForKey() throws Exception {
+ getGitConfigurationPreferencePage();
preferencePage.bot().button(
UIText.ConfigurationEditorComponent_AddButton).click();
SWTBotShell addDialog = bot
@@ -245,6 +262,7 @@ public class GlobalConfigurationPageTest {
@Test
public void testSubsectionWithDot() throws Exception {
+ getGitConfigurationPreferencePage();
preferencePage.bot()
.button(UIText.ConfigurationEditorComponent_AddButton).click();
SWTBotShell addDialog = bot
@@ -345,6 +363,7 @@ public class GlobalConfigurationPageTest {
@Test
public void testOpenEditor() throws Exception {
+ getGitConfigurationPreferencePage();
try {
preferencePage.bot().button(
UIText.ConfigurationEditorComponent_OpenEditorButton)
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java
index 5c69e84c29..6e092f4a21 100644
--- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/team/actions/DisconnectConnectTest.java
@@ -27,6 +27,7 @@ import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -64,6 +65,7 @@ public class DisconnectConnectTest extends LocalRepositoryTestCase {
.select();
connectDialog.bot().tree().getAllItems()[0].select();
connectDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
+ bot.waitUntil(Conditions.shellCloses(connectDialog));
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(
IResource.DEPTH_INFINITE, null);
TestUtil.waitForJobs(500, 5000);
@@ -93,6 +95,7 @@ public class DisconnectConnectTest extends LocalRepositoryTestCase {
.contains("["));
SWTBotShell connectDialog = openConnectDialog();
connectDialog.bot().button(IDialogConstants.FINISH_LABEL).click();
+ bot.waitUntil(Conditions.shellCloses(connectDialog));
TestUtil.waitForJobs(500, 5000);
TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
TestUtil.waitForDecorations();

Back to the top