Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-06-15 00:17:14 +0000
committerKevin Sawicki2011-06-15 00:17:14 +0000
commit8c20a6e05dde5ce91ca82eb89573f3a72c9d040d (patch)
tree46c8d4f2daa8647590b94adcf34072dee431afc9 /org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit
parent25b6cc73931a02a9453103dd4c9a4533091ca5f4 (diff)
downloadegit-8c20a6e05dde5ce91ca82eb89573f3a72c9d040d.tar.gz
egit-8c20a6e05dde5ce91ca82eb89573f3a72c9d040d.tar.xz
egit-8c20a6e05dde5ce91ca82eb89573f3a72c9d040d.zip
Add unit test that opens commit viewer on valid commit.
Change-Id: Ib4f121e6aa515ae078a4470c6e33bc46d6bb203d Signed-off-by: Kevin Sawicki <kevin@github.com>
Diffstat (limited to 'org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit')
-rw-r--r--org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java93
1 files changed, 93 insertions, 0 deletions
diff --git a/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java
new file mode 100644
index 000000000..b3d77446f
--- /dev/null
+++ b/org.eclipse.egit.ui.test/src/org/eclipse/egit/ui/test/commit/CommitEditorTest.java
@@ -0,0 +1,93 @@
+/******************************************************************************
+ * Copyright (c) 2011 GitHub Inc.
+ * 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:
+ * Kevin Sawicki (GitHub Inc.) - initial API and implementation
+ *****************************************************************************/
+package org.eclipse.egit.ui.test.commit;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.egit.core.Activator;
+import org.eclipse.egit.ui.common.LocalRepositoryTestCase;
+import org.eclipse.egit.ui.internal.commit.CommitEditor;
+import org.eclipse.egit.ui.internal.commit.RepositoryCommit;
+import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.revwalk.RevWalk;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.PlatformUI;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit tests of {@link CommitEditor}
+ */
+public class CommitEditorTest extends LocalRepositoryTestCase {
+
+ private static Repository repository;
+
+ private static RevCommit commit;
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ closeWelcomePage();
+ File repoFile = createProjectAndCommitToRepository();
+ assertNotNull(repoFile);
+ repository = Activator.getDefault().getRepositoryCache()
+ .lookupRepository(repoFile);
+ assertNotNull(repository);
+
+ RevWalk walk = new RevWalk(repository);
+ try {
+ commit = walk.parseCommit(repository.resolve(Constants.HEAD));
+ assertNotNull(commit);
+ walk.parseBody(commit.getParent(0));
+ } finally {
+ walk.release();
+ }
+ }
+
+ @Test
+ public void openAllEditorPagesOnValidCommit() throws Exception {
+ final AtomicReference<IEditorPart> editorRef = new AtomicReference<IEditorPart>();
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+
+ public void run() {
+ RepositoryCommit repoCommit = new RepositoryCommit(repository,
+ commit);
+ editorRef.set(CommitEditor.openQuiet(repoCommit));
+ }
+ });
+ assertNotNull(editorRef.get());
+ IEditorPart editor = editorRef.get();
+ assertTrue(editor instanceof CommitEditor);
+ RepositoryCommit adaptedCommit = (RepositoryCommit) editor
+ .getAdapter(RepositoryCommit.class);
+ assertNotNull(adaptedCommit);
+ assertEquals(commit, adaptedCommit.getRevCommit());
+ assertEquals(repository.getDirectory(), adaptedCommit.getRepository()
+ .getDirectory());
+ IEditorInput input = editor.getEditorInput();
+ assertNotNull(input);
+ SWTBotMultiPageEditor botEditor = bot.multipageEditorByTitle(input
+ .getName());
+ assertNotNull(botEditor);
+ assertTrue(botEditor.getPageCount() > 1);
+ for (String name : botEditor.getPagesTitles())
+ botEditor.activatePage(name);
+ botEditor.close();
+ }
+}

Back to the top