Search in sources :

Example 1 with GitScopeOperationFactory

use of org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory in project egit by eclipse.

the class GitScopeUtilTest method setup.

@Before
public void setup() throws Exception {
    SWTBotView view = TestUtil.showExplorerView();
    part = view.getViewReference().getPart(false);
    repositoryFile = createProjectAndCommitToRepository();
    GitScopeOperationFactory.setFactory(new GitScopeOperationFactory() {

        @Override
        public GitScopeOperation createGitScopeOperation(IWorkbenchPart workbenchPart, SubscriberScopeManager manager) {
            return new GitScopeOperation(workbenchPart, manager) {

                @Override
                protected boolean promptForInputChange(String requestPreviewMessage, IProgressMonitor monitor) {
                    // we will avoid the confirmation prompt in the tests
                    return false;
                }
            };
        }
    });
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GitScopeOperationFactory(org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SubscriberScopeManager(org.eclipse.team.core.subscribers.SubscriberScopeManager) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) GitScopeOperation(org.eclipse.egit.ui.internal.operations.GitScopeOperation) Before(org.junit.Before)

Example 2 with GitScopeOperationFactory

use of org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory in project egit by eclipse.

the class GitScopeUtilTest method relatedChangesWithPrompt.

@Test
public void relatedChangesWithPrompt() throws Exception {
    GitScopeOperationFactory.setFactory(new GitScopeOperationFactory());
    final IFile modelFile = createModelFiles();
    Repository repository = lookupRepository(repositoryFile);
    Activator.getDefault().getIndexDiffCache().getIndexDiffCacheEntry(repository);
    TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
    final IResource[] selectedResources = new IResource[] { modelFile };
    UIThreadRunnable.asyncExec(new VoidResult() {

        @Override
        public void run() {
            try {
                GitScopeUtil.getRelatedChanges(part, selectedResources);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    });
    // Prompt because the files are untracked
    SWTBotShell dialog = bot.shell("Selection Adjustment Required");
    dialog.bot().button(IDialogConstants.OK_LABEL).click();
    IFile modelExtensionsFile = modelFile.getProject().getFile(MODEL_EXTENSIONS_FILE);
    addAndCommit(modelExtensionsFile, "add model extensions file");
    addAndCommit(modelFile, "add model file");
    TestUtil.joinJobs(JobFamilies.INDEX_DIFF_CACHE_UPDATE);
    // Both files are committed, should no longer prompt now
    IResource[] relatedChanges = getRelatedChangesInUIThread(selectedResources);
    assertEquals(2, relatedChanges.length);
    assertContainsResourceByName(relatedChanges, MODEL_FILE);
    assertContainsResourceByName(relatedChanges, MODEL_EXTENSIONS_FILE);
}
Also used : Repository(org.eclipse.jgit.lib.Repository) IFile(org.eclipse.core.resources.IFile) GitScopeOperationFactory(org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory) VoidResult(org.eclipse.swtbot.swt.finder.results.VoidResult) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) IResource(org.eclipse.core.resources.IResource) CoreException(org.eclipse.core.runtime.CoreException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Test(org.junit.Test)

Aggregations

GitScopeOperationFactory (org.eclipse.egit.ui.internal.operations.GitScopeOperationFactory)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 GitScopeOperation (org.eclipse.egit.ui.internal.operations.GitScopeOperation)1 Repository (org.eclipse.jgit.lib.Repository)1 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)1 VoidResult (org.eclipse.swtbot.swt.finder.results.VoidResult)1 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)1 SubscriberScopeManager (org.eclipse.team.core.subscribers.SubscriberScopeManager)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 Before (org.junit.Before)1 Test (org.junit.Test)1