From c3cf7286a71489b56e28c33cd446ef1f1c80e271 Mon Sep 17 00:00:00 2001 From: Natasa Kapravelou Date: Mon, 14 Feb 2011 17:47:19 +0200 Subject: [PATCH] Added a new test class in order to test the 'Sharing' option for Folder. Also added some more id's to the FolderProperties dialog and to PermissionAddDialog --- src/gr/ebs/gss/client/FolderPropertiesDialog.java | 4 + src/gr/ebs/gss/client/PermissionsAddDialog.java | 13 ++ .../gss/client/selenium/folder/ActionUtils.java | 5 + .../{TestFolder.java => TestFolderBasics.java} | 159 ++++++++++++++------ 4 files changed, 136 insertions(+), 45 deletions(-) rename test/gr/ebs/gss/client/selenium/folder/{TestFolder.java => TestFolderBasics.java} (67%) diff --git a/src/gr/ebs/gss/client/FolderPropertiesDialog.java b/src/gr/ebs/gss/client/FolderPropertiesDialog.java index 13a1437..93c349a 100644 --- a/src/gr/ebs/gss/client/FolderPropertiesDialog.java +++ b/src/gr/ebs/gss/client/FolderPropertiesDialog.java @@ -217,6 +217,7 @@ public class FolderPropertiesDialog extends DialogBox { dlg.center(); } }); + add.getElement().setId("folderPropertiesDialog.button.addGroup"); permButtons.add(add); permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER); @@ -227,6 +228,7 @@ public class FolderPropertiesDialog extends DialogBox { dlg.center(); } }); + addUser.getElement().setId("folderPropertiesDialog.button.addUser"); permButtons.add(addUser); permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER); @@ -241,6 +243,7 @@ public class FolderPropertiesDialog extends DialogBox { readForAllNote.setStylePrimaryName("gss-readForAllNote"); readForAll = new CheckBox(); + readForAll.getElement().setId("folderPropertiesDialog.checkBox.public"); readForAll.setValue(folder.isReadForAll()); readForAll.addClickHandler(new ClickHandler() { @Override @@ -264,6 +267,7 @@ public class FolderPropertiesDialog extends DialogBox { permPanel.add(permForAll); } TextBox path = new TextBox(); + path.getElement().setId("folderPropertiesDialog.textBox.link"); path.setWidth("100%"); path.addClickHandler(new ClickHandler() { @Override diff --git a/src/gr/ebs/gss/client/PermissionsAddDialog.java b/src/gr/ebs/gss/client/PermissionsAddDialog.java index 4cef442..ff1bef8 100644 --- a/src/gr/ebs/gss/client/PermissionsAddDialog.java +++ b/src/gr/ebs/gss/client/PermissionsAddDialog.java @@ -78,6 +78,17 @@ public class PermissionsAddDialog extends DialogBox { groups = _groups; userAdd = _userAdd; permList = _permList; + + groupBox.getElement().setId("addPermission.dropDown"); + + suggestBox.getElement().setId("addPermission.textBox"); + + read.getElement().setId("addPermission.read"); + + write.getElement().setId("addPermission.write"); + + modifyACL.getElement().setId("addPermission.modify"); + for (GroupResource group : _groups) groupBox.addItem(group.getName(), group.getName()); final VerticalPanel panel = new VerticalPanel(); @@ -149,6 +160,7 @@ public class PermissionsAddDialog extends DialogBox { hide(); } }); + ok.getElement().setId("addPermission.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the @@ -160,6 +172,7 @@ public class PermissionsAddDialog extends DialogBox { hide(); } }); + cancel.getElement().setId("addPermission.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); diff --git a/test/gr/ebs/gss/client/selenium/folder/ActionUtils.java b/test/gr/ebs/gss/client/selenium/folder/ActionUtils.java index 50679be..a640617 100644 --- a/test/gr/ebs/gss/client/selenium/folder/ActionUtils.java +++ b/test/gr/ebs/gss/client/selenium/folder/ActionUtils.java @@ -88,5 +88,10 @@ public class ActionUtils { driver.quit(); } + + public void toggle(By locator){ + WebElement element = driver.findElement(locator); + element.toggle(); + } } diff --git a/test/gr/ebs/gss/client/selenium/folder/TestFolder.java b/test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java similarity index 67% rename from test/gr/ebs/gss/client/selenium/folder/TestFolder.java rename to test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java index 0c5d6ca..7b3bffe 100644 --- a/test/gr/ebs/gss/client/selenium/folder/TestFolder.java +++ b/test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java @@ -29,17 +29,19 @@ import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; -public class TestFolder { +public class TestFolderBasics { - ActionUtils action; + protected ActionUtils action; - WebDriver driver; + protected WebDriver driver; - String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/"; + protected String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/"; - String folderName = "Alderaan"; + protected String folderName = "Alderaan"; - String userName = "past@ebs.gr"; + protected String userName = "past@ebs.gr"; + + protected String folderDestination = "Naboo"; /** * Initialize the driver, the actionUtils, the application's url @@ -71,7 +73,7 @@ public class TestFolder { * * @param aUserName */ - private void selectHomeFolder(String aUserName){ + protected void selectHomeFolder(String aUserName){ action.click(By.id(aUserName)); } @@ -81,7 +83,7 @@ public class TestFolder { * @param aUserName * @param aFolderName */ - private void selectFolderBelowHome(String aUserName, String aFolderName){ + protected void selectFolderBelowHome(String aUserName, String aFolderName){ action.click(By.id(aUserName+ "." + aFolderName)); } @@ -116,7 +118,6 @@ public class TestFolder { // action.click(By.xpath("//div[@class='GK31MSKBCF GK31MSKBKF gwtQuery-draggable gwtQuery-droppable']")); action.click(By.xpath("/html/body/table/tbody/tr[4]/td/div/div/div/div/div/div/div/div[2]/div/div")); //selenium.click("//*/img[contains(@src,'telpfeil.gif')]"); - // return action.clickAndSendText(By.xpath("//span[@id='Trash']/..")); } @@ -205,27 +206,73 @@ public class TestFolder { } -// @Test -// public void testMakeNewFolder() throws InterruptedException{ -// //Create the folder with the given folderName -// makeNewFolder(userName, folderName); -// -// System.out.println(action.getText(By.id("past@ebs.gr."+folderName))); -// -// //the test is the folder exists -// Assert.assertEquals(folderName, action.getText(By.id("past@ebs.gr."+folderName))); -// -// } + private void refesh(String aUserName, String aFolderName){ + //Click a folder + selectFolderBelowHome(aUserName, aFolderName); + + //Click top edit menu + action.click(By.id("topMenu.file")); + + //Click move to trash option + action.click(By.id("topMenu.file.refresh")); + + } + + //TODO: upload file to a folder + private void upload(){ + + } + + /** + * Method that cuts a folder below home folder + * using the top Edit menu + * @param aUserName + */ + private void cutFolder(String aUserName, String aFolderName){ + + //Click a folder + selectFolderBelowHome(aUserName, aFolderName); + + //Click the top file menu + action.click(By.id("topMenu.edit")); + + //Click the New Folder option from the file menu + action.click(By.id("topMenu.edit.cut")); + + } + + /** + * Method that copies a folder name + * @param aUserName + * @param aFolderName + */ + private void copy(String aUserName, String aFolderName){ + //Click a folder + selectFolderBelowHome(aUserName, aFolderName); + + //Click the top file menu + action.click(By.id("topMenu.edit")); + + //Click the New Folder option from the file menu + action.click(By.id("topMenu.edit.copy")); + + } + + /** + * Method that pastes a folder of a user using @param aUserName + * to a @param aFolderDestination + */ + private void paste(String aUserName, String aFolderDestination){ + //Click on the folder destination which is below home folder + selectFolderBelowHome(aUserName, aFolderDestination); + + //Click the top file menu + action.click(By.id("topMenu.edit")); + + //Click the New Folder option from the file menu + action.click(By.id("topMenu.edit.paste")); + } -// @Test -// public void testDeleteFolder(){ -// -// selectFolderBelowHome(userName, folderName); -// -// //Delete the folder -// deleteFolder(userName, folderName); -// -// } // @Test (expected=org.openqa.selenium.NoSuchElementException.class) // public void testMakeNewFolderAndDelete() throws InterruptedException{ @@ -279,25 +326,47 @@ public class TestFolder { // emptyTrash(); // // /** -// * TODO: In order to confirm that -// * the new folder exists in Trash folder -// * trash folder should be expanded first -// * and then select the element +// * TODO: Confirm that the trash folder is empty +// */ +// +// } + +// /** +// * Method that tries to expand the '+' symbol +// * in order to reveal folder's containing folders +// * @throws InterruptedException +// */ +// @Test +// public void testExpand() throws InterruptedException{ +//// selectTrash(); +// expandTree(); +// Thread.sleep(3000); +// +// } + +// @Test +// public void testCutFolder(){ +// cutFolder(userName, folderName); +// +// paste(userName, folderDestination); +// +// /**TODO: In order to confirm successful paste of the folderName to folderDestination +// * we should expand folderDestination and see if the folder name is in it's sub folders +// */ +// +// } + +// @Test +// public void testCopyNPasteFolder(){ +// copy(userName, folderName); +// +// paste(userName, folderDestination); +// +// /**TODO: In order to confirm successful paste of the folderName to folderDestination +// * we should expand folderDestination and see if the folder name is in it's sub folders // */ // // } - /** - * Method that tries to expand the '+' symbol - * in order to reveal folder's containing folders - * @throws InterruptedException - */ - @Test - public void testExpand() throws InterruptedException{ -// selectTrash(); - expandTree(); - Thread.sleep(3000); - - } } -- 1.7.10.4