Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Hurne2012-05-23 20:34:04 +0000
committerJohn Arthorne2012-07-04 19:56:29 +0000
commitd2cd930a1e782fd81b73bc55a2c7799a92a02caf (patch)
tree401fcfe91099dfb839ca6f6bb01188b576a6e4f2
parent2e5c525b33b6b9514af5b4c198b663b0c65724a1 (diff)
downloadeclipse.platform.ui-d2cd930a1e782fd81b73bc55a2c7799a92a02caf.tar.gz
eclipse.platform.ui-d2cd930a1e782fd81b73bc55a2c7799a92a02caf.tar.xz
eclipse.platform.ui-d2cd930a1e782fd81b73bc55a2c7799a92a02caf.zip
Bug 144610 - Add test for import of nested projectsv20120704-195629
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java10
-rw-r--r--tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java98
-rw-r--r--tests/org.eclipse.ui.tests/data/workspaces/importExistingNestedTest.zipbin0 -> 8493 bytes
3 files changed, 95 insertions, 13 deletions
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java
index f493c01aadf..709c26d13b7 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java
@@ -1676,4 +1676,14 @@ public class WizardProjectsImportPage extends WizardPage implements
public Button getCopyCheckbox() {
return copyCheckbox;
}
+
+ /**
+ * Method used for test suite.
+ *
+ * @return Button nested projects checkbox
+ */
+ public Button getNestedProjectsCheckbox() {
+ return nestedProjectsCheckbox;
+ }
+
}
diff --git a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java
index de677674072..c5a4216ca87 100644
--- a/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java
+++ b/tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/datatransfer/ImportExistingProjectsWizardTest.java
@@ -60,6 +60,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
private static final String DATA_PATH_PREFIX = "data/org.eclipse.datatransferArchives/";
private static final String WS_DATA_PREFIX = "data/workspaces";
private static final String WS_DATA_LOCATION = "importExistingFromDirTest";
+ private static final String WS_NESTED_DATA_LOCATION = "importExistingNestedTest";
private static final String ARCHIVE_HELLOWORLD = "helloworld";
private static final String ARCHIVE_FILE_WITH_EMPTY_FOLDER = "EmptyFolderInArchive";
private static final String PROJECTS_ARCHIVE = "ProjectsArchive";
@@ -117,7 +118,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
super.doTearDown();
IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = wsRoot.getProjects();
- for (int i = 0; i < projects.length; i++) {
+ for (int i = projects.length - 1; i >= 0; i--) {
FileUtil.deleteProject(projects[i]);
}
// clean up any data directories created
@@ -226,7 +227,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
public void testFindSingleDirectory() {
try {
- dataLocation = copyDataLocation();
+ dataLocation = copyDataLocation(WS_DATA_LOCATION);
IPath wsPath = new Path(dataLocation).append("HelloWorld");
WizardProjectsImportPage wpip = getNewWizard();
HashSet projects = new HashSet();
@@ -251,7 +252,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
public void testDoNotShowProjectWithSameName() {
try {
- dataLocation = copyDataLocation();
+ dataLocation = copyDataLocation(WS_DATA_LOCATION);
IPath wsPath = new Path(dataLocation);
FileUtil.createProject("HelloWorld");
@@ -502,7 +503,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
for (int i = 0; i < workspaceProjects.length; i++)
FileUtil.deleteProject(workspaceProjects[i]);
- dataLocation = copyDataLocation();
+ dataLocation = copyDataLocation(WS_DATA_LOCATION);
wsPath = new Path(dataLocation).append("HelloWorld");
WizardProjectsImportPage wpip = getNewWizard();
HashSet projects = new HashSet();
@@ -551,7 +552,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
for (int i = 0; i < workspaceProjects.length; i++)
FileUtil.deleteProject(workspaceProjects[i]);
- dataLocation = copyDataLocation();
+ dataLocation = copyDataLocation(WS_DATA_LOCATION);
wsPath = new Path(dataLocation).append("HelloWorld");
WizardProjectsImportPage wpip = getNewWizard();
HashSet projects = new HashSet();
@@ -604,7 +605,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
for (int i = 0; i < workspaceProjects.length; i++)
FileUtil.deleteProject(workspaceProjects[i]);
- dataLocation = copyDataLocation();
+ dataLocation = copyDataLocation(WS_DATA_LOCATION);
wsPath = new Path(dataLocation).append("HelloWorld");
WizardProjectsImportPage wpip = getNewWizard();
HashSet projects = new HashSet();
@@ -802,12 +803,83 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
}
+ public void testImportDirectoryNested() {
+ IPath wsPath = null;
+ try {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+
+ IProject[] workspaceProjects = root.getProjects();
+ for (int i = 0; i < workspaceProjects.length; i++) {
+ FileUtil.deleteProject(workspaceProjects[i]);
+ }
+
+ dataLocation = copyDataLocation(WS_NESTED_DATA_LOCATION);
+ wsPath = new Path(dataLocation).append("A");
+ WizardProjectsImportPage wpip = getNewWizard();
+ HashSet projects = new HashSet();
+ projects.add("A");
+ projects.add("B");
+ projects.add("C");
+
+ wpip.getProjectFromDirectoryRadio().setSelection(true);
+ wpip.getNestedProjectsCheckbox().setSelection(true);
+ wpip.getCopyCheckbox().setSelection(false);
+ wpip.saveWidgetValues();
+ wpip.restoreWidgetValues();
+
+ wpip.updateProjectsList(wsPath.toOSString());
+ ProjectRecord[] selectedProjects = wpip.getProjectRecords();
+ ArrayList projectNames = new ArrayList();
+ for (int i = 0; i < selectedProjects.length; i++) {
+ projectNames.add(selectedProjects[i].getProjectName());
+ }
+
+ assertTrue("Not all projects were found correctly in directory",
+ projectNames.containsAll(projects));
+
+ CheckboxTreeViewer projectsList = wpip.getProjectsList();
+ projectsList.setCheckedElements(selectedProjects);
+ wpip.createProjects(); // Try importing all the projects we found
+ waitForRefresh();
+
+ // "A", "B", and "C" should be the only projects in the workspace
+ workspaceProjects = root.getProjects();
+ if (workspaceProjects.length != 3) {
+ fail("Incorrect number of projects imported");
+ }
+
+ IFolder aFolder = workspaceProjects[0].getFolder("A");
+ if (aFolder.exists()) {
+ fail("Project A was imported as a folder into itself");
+ }
+
+ IFolder bFolder = workspaceProjects[1].getFolder("B");
+ if (bFolder.exists()) {
+ fail("Project B was imported as a folder into itself");
+ }
+
+ IFolder cFolder = workspaceProjects[2].getFolder("C");
+ if (cFolder.exists()) {
+ fail("Project C was imported as a folder into itself");
+ }
+
+ workspaceProjects[0].refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ verifyProjectInWorkspace(false, workspaceProjects[0], FILE_LIST, true);
+ verifyProjectInWorkspace(false, workspaceProjects[1], FILE_LIST, true);
+ verifyProjectInWorkspace(false, workspaceProjects[2], FILE_LIST, true);
+ } catch (IOException e) {
+ fail(e.toString());
+ } catch (CoreException e) {
+ fail(e.toString());
+ }
+ }
public void testInitialValue() {
try {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- zipLocation = copyZipLocation();
+ zipLocation = copyZipLocation(WS_DATA_LOCATION);
IProject[] workspaceProjects = root.getProjects();
for (int i = 0; i < workspaceProjects.length; i++)
FileUtil.deleteProject(workspaceProjects[i]);
@@ -841,7 +913,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
public void testImportArchiveMultiProject() {
try {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- zipLocation = copyZipLocation();
+ zipLocation = copyZipLocation(WS_DATA_LOCATION);
IProject[] workspaceProjects = root.getProjects();
for (int i = 0; i < workspaceProjects.length; i++)
@@ -931,7 +1003,7 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
if (!res.exists())
filesNotImported.append(res.getName() + ", ");
}
- assertTrue("Files expected but not in workspace: "
+ assertTrue("Files expected but not in workspace for project \"" + project.getName() + "\": "
+ filesNotImported.toString(), filesNotImported.length() == 0);
}
@@ -940,14 +1012,14 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
*
* @return the location
*/
- private String copyDataLocation() throws IOException {
+ private String copyDataLocation(String dataLocation) throws IOException {
TestPlugin plugin = TestPlugin.getDefault();
if (plugin == null)
throw new IllegalStateException(
"TestPlugin default reference is null");
URL fullPathString = plugin.getDescriptor().find(
- new Path(WS_DATA_PREFIX).append(WS_DATA_LOCATION + ".zip"));
+ new Path(WS_DATA_PREFIX).append(dataLocation + ".zip"));
if (fullPathString == null)
throw new IllegalArgumentException();
@@ -966,14 +1038,14 @@ public class ImportExistingProjectsWizardTest extends UITestCase {
return destination.getAbsolutePath();
}
- private String copyZipLocation() throws IOException {
+ private String copyZipLocation(String zipLocation) throws IOException {
TestPlugin plugin = TestPlugin.getDefault();
if (plugin == null)
throw new IllegalStateException(
"TestPlugin default reference is null");
URL fullPathString = plugin.getDescriptor().find(
- new Path(WS_DATA_PREFIX).append(WS_DATA_LOCATION + ".zip"));
+ new Path(WS_DATA_PREFIX).append(zipLocation + ".zip"));
if (fullPathString == null)
throw new IllegalArgumentException();
diff --git a/tests/org.eclipse.ui.tests/data/workspaces/importExistingNestedTest.zip b/tests/org.eclipse.ui.tests/data/workspaces/importExistingNestedTest.zip
new file mode 100644
index 00000000000..ef6fb9b76bd
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/data/workspaces/importExistingNestedTest.zip
Binary files differ

Back to the top