blob: 4aa74d218ac429c797d84e94efd55aaf41a2e5b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
/*******************************************************************************
* Copyright (c) 2012, 2013 Matthias Sohn <matthias.sohn@sap.com> and others.
*
* 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.view.repositories;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.JobFamilies;
import org.eclipse.egit.ui.internal.UIText;
import org.eclipse.egit.ui.test.ContextMenuHelper;
import org.eclipse.egit.ui.test.TestUtil;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jgit.api.SubmoduleAddCommand;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.internal.storage.file.FileRepository;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* SWTBot Tests for the Git Repositories View (repository deletion)
*/
@RunWith(SWTBotJunit4ClassRunner.class)
public class GitRepositoriesViewRepoDeletionTest extends
GitRepositoriesViewTestBase {
private static final String DELETE_REPOSITORY_CONTEXT_MENU_LABEL = "RepoViewDeleteRepository.label";
private File repositoryFile;
@Before
public void before() throws Exception {
repositoryFile = createProjectAndCommitToRepository();
}
@Test
public void testDeleteRepositoryWithContentOk() throws Exception {
deleteAllProjects();
assertProjectExistence(PROJ1, false);
clearView();
Activator.getDefault().getRepositoryUtil().addConfiguredRepository(
repositoryFile);
shareProjects(repositoryFile);
assertProjectExistence(PROJ1, true);
refreshAndWait();
assertHasRepo(repositoryFile);
SWTBotTree tree = getOrOpenView().bot().tree();
tree.getAllItems()[0].select();
ContextMenuHelper.clickContextMenu(tree, myUtil
.getPluginLocalizedValue(DELETE_REPOSITORY_CONTEXT_MENU_LABEL));
SWTBotShell shell = bot.shell(UIText.DeleteRepositoryConfirmDialog_DeleteRepositoryWindowTitle);
shell.activate();
FileRepository repo = lookupRepository(repositoryFile);
String workDir=repo.getWorkTree().getPath();
String checkboxLabel = NLS
.bind(UIText.DeleteRepositoryConfirmDialog_DeleteWorkingDirectoryCheckbox,
workDir);
shell.bot().checkBox(checkboxLabel).select();
shell.bot().button(IDialogConstants.OK_LABEL).click();
TestUtil.joinJobs(JobFamilies.REPOSITORY_DELETE);
refreshAndWait();
assertEmpty();
assertProjectExistence(PROJ1, false);
assertFalse(repositoryFile.exists());
}
@Test
public void testDeleteSubmoduleRepository() throws Exception {
deleteAllProjects();
assertProjectExistence(PROJ1, false);
clearView();
Activator.getDefault().getRepositoryUtil()
.addConfiguredRepository(repositoryFile);
shareProjects(repositoryFile);
assertProjectExistence(PROJ1, true);
refreshAndWait();
assertHasRepo(repositoryFile);
Repository db = lookupRepository(repositoryFile);
SubmoduleAddCommand command = new SubmoduleAddCommand(db);
String path = "sub";
command.setPath(path);
String uri = db.getDirectory().toURI().toString();
command.setURI(uri);
Repository subRepo = command.call();
assertNotNull(subRepo);
subRepo.close();
refreshAndWait();
SWTBotTree tree = getOrOpenView().bot().tree();
tree.getAllItems()[0]
.expand()
.expandNode(
UIText.RepositoriesViewLabelProvider_SubmodulesNodeText)
.getItems()[0].select();
ContextMenuHelper.clickContextMenu(tree, myUtil
.getPluginLocalizedValue(DELETE_REPOSITORY_CONTEXT_MENU_LABEL));
SWTBotShell shell = bot
.shell(UIText.DeleteRepositoryConfirmDialog_DeleteRepositoryWindowTitle);
shell.activate();
String workDir = subRepo.getWorkTree().getPath();
String checkboxLabel = NLS
.bind(UIText.DeleteRepositoryConfirmDialog_DeleteWorkingDirectoryCheckbox,
workDir);
shell.bot().checkBox(checkboxLabel).select();
shell.bot().button(IDialogConstants.OK_LABEL).click();
TestUtil.joinJobs(JobFamilies.REPOSITORY_DELETE);
refreshAndWait();
assertFalse(subRepo.getDirectory().exists());
assertFalse(subRepo.getWorkTree().exists());
}
}
|