diff options
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java')
-rw-r--r-- | org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java | 66 |
1 files changed, 40 insertions, 26 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java index 7ef62d324f..d2328c1c85 100644 --- a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java +++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/history/HistoryViewTest.java @@ -22,6 +22,8 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.jobs.Job; +import org.eclipse.egit.ui.JobFamilies; import org.eclipse.egit.ui.UIText; import org.eclipse.egit.ui.common.LocalRepositoryTestCase; import org.eclipse.egit.ui.test.ContextMenuHelper; @@ -68,13 +70,14 @@ public class HistoryViewTest extends LocalRepositoryTestCase { repoFile = createProjectAndCommitToRepository(); perspective = bot.activePerspective(); bot.perspectiveById("org.eclipse.pde.ui.PDEPerspective").activate(); - IProject prj = ResourcesPlugin.getWorkspace().getRoot().getProject( - PROJ1); + IProject prj = ResourcesPlugin.getWorkspace().getRoot() + .getProject(PROJ1); IFolder folder2 = prj.getFolder(SECONDFOLDER); folder2.create(false, true, null); IFile addedFile = folder2.getFile(ADDEDFILE); - addedFile.create(new ByteArrayInputStream("More content".getBytes(prj - .getDefaultCharset())), false, null); + addedFile.create( + new ByteArrayInputStream("More content".getBytes(prj + .getDefaultCharset())), false, null); addAndCommit(addedFile, ADDEDMESSAGE); // TODO count the commits commitCount = 3; @@ -96,17 +99,18 @@ public class HistoryViewTest extends LocalRepositoryTestCase { getHistoryViewTable(PROJ1, FOLDER).rowCount()); assertEquals("Wrong number of commits", commitCount - 1, getHistoryViewTable(PROJ1, FOLDER, FILE1).rowCount()); - assertEquals("Wrong number of commits", 1, getHistoryViewTable(PROJ1, - FOLDER, FILE2).rowCount()); - assertEquals("Wrong number of commits", 1, getHistoryViewTable(PROJ1, - SECONDFOLDER).rowCount()); - assertEquals("Wrong number of commits", 1, getHistoryViewTable(PROJ1, - SECONDFOLDER, ADDEDFILE).rowCount()); + assertEquals("Wrong number of commits", 1, + getHistoryViewTable(PROJ1, FOLDER, FILE2).rowCount()); + assertEquals("Wrong number of commits", 1, + getHistoryViewTable(PROJ1, SECONDFOLDER).rowCount()); + assertEquals("Wrong number of commits", 1, + getHistoryViewTable(PROJ1, SECONDFOLDER, ADDEDFILE).rowCount()); assertEquals("Wrong number of commits", 1, getHistoryViewTable(PROJ2) .rowCount()); - assertEquals("Wrong commit message", ADDEDMESSAGE, getHistoryViewTable( - PROJ1, SECONDFOLDER, ADDEDFILE).getTableItem(0).getText(0)); + assertEquals("Wrong commit message", ADDEDMESSAGE, + getHistoryViewTable(PROJ1, SECONDFOLDER, ADDEDFILE) + .getTableItem(0).getText(0)); assertEquals("Wrong commit message", "Initial commit", getHistoryViewTable(PROJ1, FOLDER, FILE2).getTableItem(0) .getText(0)); @@ -163,8 +167,8 @@ public class HistoryViewTest extends LocalRepositoryTestCase { getHistoryViewTable(PROJ1, FOLDER, FILE2).rowCount()); assertEquals("Wrong number of commits", commitCount, getHistoryViewTable(PROJ1, SECONDFOLDER).rowCount()); - assertEquals("Wrong number of commits", 1, getHistoryViewTable(PROJ1, - SECONDFOLDER, ADDEDFILE).rowCount()); + assertEquals("Wrong number of commits", 1, + getHistoryViewTable(PROJ1, SECONDFOLDER, ADDEDFILE).rowCount()); assertEquals("Wrong number of commits", commitCount, getHistoryViewTable(PROJ2).rowCount()); } @@ -172,8 +176,9 @@ public class HistoryViewTest extends LocalRepositoryTestCase { /** * @param filter * 0: none, 1: repository, 2: project, 3: folder + * @throws Exception */ - private void initFilter(int filter) { + private void initFilter(int filter) throws Exception { getHistoryViewTable(PROJ1); SWTBotView view = bot .viewById("org.eclipse.team.ui.GenericHistoryView"); @@ -226,18 +231,19 @@ public class HistoryViewTest extends LocalRepositoryTestCase { waitInUI(); int countAfter = getHistoryViewTable(PROJ1).rowCount(); assertEquals("Wrong number of entries", countBefore + 1, countAfter); - assertEquals("Wrong comit message", commitMessage, getHistoryViewTable( - PROJ1).getTableItem(0).getText(0)); + assertEquals("Wrong comit message", commitMessage, + getHistoryViewTable(PROJ1).getTableItem(0).getText(0)); } /** * @param path * must be length 2 or three (folder or file) * @return the bale + * @throws Exception */ - private SWTBotTable getHistoryViewTable(String... path) { - SWTBotTree projectExplorerTree = bot.viewById( - "org.eclipse.jdt.ui.PackageExplorer").bot().tree(); + private SWTBotTable getHistoryViewTable(String... path) throws Exception { + SWTBotTree projectExplorerTree = bot + .viewById("org.eclipse.jdt.ui.PackageExplorer").bot().tree(); SWTBotTreeItem explorerItem; if (path.length == 1) explorerItem = getProjectItem(projectExplorerTree, path[0]); @@ -250,7 +256,15 @@ public class HistoryViewTest extends LocalRepositoryTestCase { explorerItem.select(); ContextMenuHelper.clickContextMenu(projectExplorerTree, "Show In", "History"); - // explorerItem.select(); + // join GenerateHistoryJob + Job.getJobManager().join(JobFamilies.GENERATE_HISTORY, null); + // join UI update triggered by GenerateHistoryJob + projectExplorerTree.widget.getDisplay().syncExec(new Runnable() { + + public void run() { + // empty + } + }); return bot.viewById("org.eclipse.team.ui.GenericHistoryView").bot() .table(); } @@ -294,10 +308,10 @@ public class HistoryViewTest extends LocalRepositoryTestCase { ContextMenuHelper.clickContextMenu(table, UIText.GitHistoryPage_CreateTagMenuLabel); SWTBotShell dialog = bot.shell(UIText.CreateTagDialog_NewTag); - dialog.bot().textWithLabel(UIText.CreateTagDialog_tagName).setText( - "NewTag"); - dialog.bot().textWithLabel(UIText.CreateTagDialog_tagMessage).setText( - "New Tag message"); + dialog.bot().textWithLabel(UIText.CreateTagDialog_tagName) + .setText("NewTag"); + dialog.bot().textWithLabel(UIText.CreateTagDialog_tagMessage) + .setText("New Tag message"); dialog.bot().button(IDialogConstants.OK_LABEL).click(); waitInUI(); assertNotNull(repo.resolve(Constants.R_TAGS + "NewTag")); @@ -332,7 +346,7 @@ public class HistoryViewTest extends LocalRepositoryTestCase { /** * Workaround to ensure that the TableItem of a SWT table with style * SWT_VIRTUAL is loaded. - * + * * @param item */ private static void ensureTableItemLoaded(TableItem item) { |