From 0d8cfb8f0bbdd172a2811d5add29985b8345af71 Mon Sep 17 00:00:00 2001 From: Natasa Kapravelou Date: Wed, 16 Feb 2011 18:05:19 +0200 Subject: [PATCH] Added two new classes. The first 'TestFolderSharing' handles the 'Sharing' option for a folder (work in progress) and the second 'TestGroup' handles actions available in the application related to groups (lots of obstacles to overtake, still work in progress). Added also the action of renaming a folder in the TestFolderBasics. --- src/gr/ebs/gss/client/DeleteGroupDialog.java | 4 +- src/gr/ebs/gss/client/DeleteUserDialog.java | 4 +- src/gr/ebs/gss/client/GSS.java | 5 +- src/gr/ebs/gss/client/GroupContextMenu.java | 23 ++- src/gr/ebs/gss/client/GroupPropertiesDialog.java | 3 + src/gr/ebs/gss/client/Groups.java | 5 +- src/gr/ebs/gss/client/PermissionsAddDialog.java | 2 +- src/gr/ebs/gss/client/PermissionsList.java | 17 +- src/gr/ebs/gss/client/UserAddDialog.java | 3 + test/gr/ebs/gss/client/selenium/MakeNewFolder.java | 58 ------- .../client/selenium/folder/TestFolderBasics.java | 178 ++++++++++++-------- .../client/selenium/folder/TestFolderSharing.java | 138 +++++++++++++++ .../ebs/gss/client/selenium/group/TestGroup.java | 166 ++++++++++++++++++ 13 files changed, 461 insertions(+), 145 deletions(-) delete mode 100644 test/gr/ebs/gss/client/selenium/MakeNewFolder.java create mode 100644 test/gr/ebs/gss/client/selenium/folder/TestFolderSharing.java create mode 100644 test/gr/ebs/gss/client/selenium/group/TestGroup.java diff --git a/src/gr/ebs/gss/client/DeleteGroupDialog.java b/src/gr/ebs/gss/client/DeleteGroupDialog.java index 9462a11..a54cb12 100644 --- a/src/gr/ebs/gss/client/DeleteGroupDialog.java +++ b/src/gr/ebs/gss/client/DeleteGroupDialog.java @@ -73,7 +73,7 @@ public class DeleteGroupDialog extends DialogBox { hide(); } }); - ok.getElement().setId("confirmation.ok"); + ok.getElement().setId("deleteGroup.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the @@ -85,7 +85,7 @@ public class DeleteGroupDialog extends DialogBox { hide(); } }); - cancel.getElement().setId("confirmation.cancel"); + cancel.getElement().setId("deleteGroup.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); diff --git a/src/gr/ebs/gss/client/DeleteUserDialog.java b/src/gr/ebs/gss/client/DeleteUserDialog.java index e97ba35..601a4c1 100644 --- a/src/gr/ebs/gss/client/DeleteUserDialog.java +++ b/src/gr/ebs/gss/client/DeleteUserDialog.java @@ -75,7 +75,7 @@ public class DeleteUserDialog extends DialogBox { hide(); } }); - ok.getElement().setId("confirmation.ok"); + ok.getElement().setId("deleteUser.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the @@ -87,7 +87,7 @@ public class DeleteUserDialog extends DialogBox { hide(); } }); - cancel.getElement().setId("confirmation.cancel"); + cancel.getElement().setId("confirmation.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); diff --git a/src/gr/ebs/gss/client/GSS.java b/src/gr/ebs/gss/client/GSS.java index 5674086..08a029c 100644 --- a/src/gr/ebs/gss/client/GSS.java +++ b/src/gr/ebs/gss/client/GSS.java @@ -445,7 +445,10 @@ public class GSS implements EntryPoint, ResizeHandler { * @return the header HTML fragment */ private String createHeaderHTML(AbstractImagePrototype imageProto, String caption) { - String captionHTML = "" + "
" + imageProto.getHTML() + " " + caption + "
"; + String captionHTML = "" + "
" + imageProto.getHTML() + + " " + + caption + "
"; return captionHTML; } diff --git a/src/gr/ebs/gss/client/GroupContextMenu.java b/src/gr/ebs/gss/client/GroupContextMenu.java index 85efc7f..25bab11 100644 --- a/src/gr/ebs/gss/client/GroupContextMenu.java +++ b/src/gr/ebs/gss/client/GroupContextMenu.java @@ -55,13 +55,26 @@ public class GroupContextMenu extends PopupPanel { images=newImages; setAnimationEnabled(true); final MenuBar contextMenu = new MenuBar(true); - contextMenu.addItem("" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group", true, new NewGroupCommand(this)); - contextMenu.addItem("" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " Add User", true, new NewUserCommand(this)); - copy = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy User", true, new CopyCommand(this)); + MenuItem newGroup = new MenuItem("" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " New Group", true, new NewGroupCommand(this)); + newGroup.getElement().setId("groupContextMenu.newGroup"); + contextMenu.addItem(newGroup); + + MenuItem addUser = new MenuItem("" + AbstractImagePrototype.create(newImages.groupNew()).getHTML() + " Add User", true, new NewUserCommand(this)); + addUser.getElement().setId("groupContextMenu.addUser"); + contextMenu.addItem(addUser); + + copy = new MenuItem("" + AbstractImagePrototype.create(newImages.copy()).getHTML() + " Copy User", true, new CopyCommand(this)); + copy.getElement().setId("groupContextMenu.copyUser"); contextMenu.addItem(copy); - paste = new MenuItem("" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste User", true, new PasteCommand(this)); + + paste = new MenuItem("" + AbstractImagePrototype.create(newImages.paste()).getHTML() + " Paste User", true, new PasteCommand(this)); + paste.getElement().setId("groupContextMenu.pasteUser"); contextMenu.addItem(paste); - contextMenu.addItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteUserOrGroupCommand(this,images)); + + MenuItem delete = new MenuItem("" + AbstractImagePrototype.create(newImages.delete()).getHTML() + " Delete", true, new DeleteUserOrGroupCommand(this,images)); + delete.getElement().setId("groupContextMenu.delete"); + contextMenu.addItem(delete); + add(contextMenu); } diff --git a/src/gr/ebs/gss/client/GroupPropertiesDialog.java b/src/gr/ebs/gss/client/GroupPropertiesDialog.java index ead19f8..0645f8d 100644 --- a/src/gr/ebs/gss/client/GroupPropertiesDialog.java +++ b/src/gr/ebs/gss/client/GroupPropertiesDialog.java @@ -70,6 +70,7 @@ public class GroupPropertiesDialog extends DialogBox { setText("Group properties"); final VerticalPanel panel = new VerticalPanel(); setWidget(panel); + groupName.getElement().setId("groupDialog.textBox.name"); final Grid generalTable = new Grid(1, 2); generalTable.setText(0, 0, "Group Name"); generalTable.setWidget(0, 1, groupName); @@ -86,6 +87,7 @@ public class GroupPropertiesDialog extends DialogBox { hide(); } }); + ok.getElement().setId("groupDialog.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the @@ -97,6 +99,7 @@ public class GroupPropertiesDialog extends DialogBox { hide(); } }); + cancel.getElement().setId("groupDialog.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); diff --git a/src/gr/ebs/gss/client/Groups.java b/src/gr/ebs/gss/client/Groups.java index cab515d..d59a7ae 100644 --- a/src/gr/ebs/gss/client/Groups.java +++ b/src/gr/ebs/gss/client/Groups.java @@ -148,7 +148,8 @@ public class Groups extends Composite implements SelectionHandler, OpenHandler { for (int i = 0; i < groupList.size(); i++) { final TreeItem item = new TreeItem(); item.setWidget(imageItemHTML(images.groupImage(), groupList.get(i).getName(),item)); - item.setUserObject(groupList.get(i)); + item.setUserObject(groupList.get(i)); +// item.getElement().setId("groupsList."+ groupList.get(i).getName()); tree.addItem(item); updateUsers(item); } @@ -206,7 +207,7 @@ public class Groups extends Composite implements SelectionHandler, OpenHandler { * @return the resultant HTML */ private HTML imageItemHTML(final ImageResource imageProto, final String title,final TreeItem item) { - final HTML link = new HTML("" + "" + AbstractImagePrototype.create(imageProto).getHTML() + " " + title + "" + ""){ + final HTML link = new HTML("" + "" + AbstractImagePrototype.create(imageProto).getHTML() + " " + title + "" + ""){ @Override public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { diff --git a/src/gr/ebs/gss/client/PermissionsAddDialog.java b/src/gr/ebs/gss/client/PermissionsAddDialog.java index ff1bef8..532ed36 100644 --- a/src/gr/ebs/gss/client/PermissionsAddDialog.java +++ b/src/gr/ebs/gss/client/PermissionsAddDialog.java @@ -87,7 +87,7 @@ public class PermissionsAddDialog extends DialogBox { write.getElement().setId("addPermission.write"); - modifyACL.getElement().setId("addPermission.modify"); + modifyACL.getElement().setId("addpermission.modify"); for (GroupResource group : _groups) groupBox.addItem(group.getName(), group.getName()); diff --git a/src/gr/ebs/gss/client/PermissionsList.java b/src/gr/ebs/gss/client/PermissionsList.java index 06c548f..4ceb743 100644 --- a/src/gr/ebs/gss/client/PermissionsList.java +++ b/src/gr/ebs/gss/client/PermissionsList.java @@ -104,6 +104,11 @@ public class PermissionsList extends Composite { CheckBox r = (CheckBox) permTable.getWidget(i, 1); CheckBox w = (CheckBox) permTable.getWidget(i, 2); CheckBox m = (CheckBox) permTable.getWidget(i, 3); + + r.getElement().setId("permissionList.read"); + w.getElement().setId("permissionList.write"); + m.getElement().setId("permissionList.modify"); + if(dto.isRead() != r.getValue() || dto.isWrite() != w.getValue() || dto.isModifyACL() != m.getValue()) hasChanges = true; dto.setRead(r.getValue()); @@ -191,21 +196,27 @@ public class PermissionsList extends Composite { if(dto.getUser() != null){ if(dto.getUser() != null && dto.getUser().equals(owner)){ - permTable.setHTML(i, 0, "" + AbstractImagePrototype.create(images.permUser()).getHTML() + " Owner"); + permTable.setHTML(i, 0, "" + AbstractImagePrototype.create(images.permUser()).getHTML() + " Owner"); removeButton.setVisible(false); }else{ - permTable.setHTML(i, 0, "" + AbstractImagePrototype.create(images.permUser()).getHTML() + " "+ GSS.get().findUserFullName(dto.getUser()) + ""); + permTable.setHTML(i, 0, ""+ AbstractImagePrototype.create(images.permUser()).getHTML() + " "+ GSS.get().findUserFullName(dto.getUser()) + ""); } }else if(dto.getGroup() != null){ - permTable.setHTML(i, 0, "" + AbstractImagePrototype.create(images.permGroup()).getHTML() + " "+ dto.getGroup() + ""); + permTable.setHTML(i, 0, "" + AbstractImagePrototype.create(images.permGroup()).getHTML() + " "+ dto.getGroup() + ""); } CheckBox read = new CheckBox(); read.setValue(dto.isRead()); + read.getElement().setId("permissionList.read"); + CheckBox write = new CheckBox(); write.setValue(dto.isWrite()); + write.getElement().setId("permissionList.write"); + CheckBox modify = new CheckBox(); modify.setValue(dto.isModifyACL()); + modify.getElement().setId("permissionList.modify"); + if (dto.getUser()!=null && dto.getUser().equals(owner)) { read.setEnabled(false); write.setEnabled(false); diff --git a/src/gr/ebs/gss/client/UserAddDialog.java b/src/gr/ebs/gss/client/UserAddDialog.java index b7948eb..3d35522 100644 --- a/src/gr/ebs/gss/client/UserAddDialog.java +++ b/src/gr/ebs/gss/client/UserAddDialog.java @@ -105,6 +105,7 @@ public class UserAddDialog extends DialogBox { updateSuggestions(); } }); + suggestBox.getElement().setId("addUser.textBox"); userTable.setWidget(0, 1, suggestBox); panel.add(userTable); HorizontalPanel buttons = new HorizontalPanel(); @@ -115,6 +116,7 @@ public class UserAddDialog extends DialogBox { hide(); } }); + ok.getElement().setId("addUser.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the @@ -125,6 +127,7 @@ public class UserAddDialog extends DialogBox { hide(); } }); + cancel.getElement().setId("addUser.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); diff --git a/test/gr/ebs/gss/client/selenium/MakeNewFolder.java b/test/gr/ebs/gss/client/selenium/MakeNewFolder.java deleted file mode 100644 index b23eba2..0000000 --- a/test/gr/ebs/gss/client/selenium/MakeNewFolder.java +++ /dev/null @@ -1,58 +0,0 @@ -package gr.ebs.gss.client.selenium; - -import org.junit.Assert; -import org.openqa.selenium.By; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.firefox.FirefoxDriver; - -import junit.framework.TestCase; - - -public class MakeNewFolder extends TestCase { - public void testMakeNewFolder() throws InterruptedException { - WebDriver driver = new FirefoxDriver(); - driver.get("http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/"); - Thread.sleep(4000); - WebElement element1 = driver.findElement(By.id("past@ebs.gr")); - element1.click(); - try{ - if(driver.findElement(By.id("past@ebs.gr.Hoooray")) != null){ - WebElement element5 = driver.findElement(By.id("past@ebs.gr.Hoooray")); - String elemText = element5.getText(); - System.out.println("Found a folder named "+elemText); - Assert.assertEquals(elemText, "Hoooray"); - } -// else{ -// driver.findElement(By.id("topMenu.file")).click(); -// driver.findElement(By.id("topMenu.file.newFolder")).click(); -// WebElement element4 = driver.findElement(By.id("folderPropertiesDialog.textBox.name")); -// element4.click(); -// element4.sendKeys("Hoooray"); -// driver.findElement(By.id("folderPropertiesDialog.button.ok")).click(); -// -// Thread.sleep(3000); -// WebElement element5 = driver.findElement(By.id("past@ebs.gr.Hoooray")); -// String elemText = element5.getText(); -// System.out.println("Created a new folder named "+elemText); -// Assert.assertEquals(elemText, "Hoooray"); -// } - - }catch (Exception e) { - driver.findElement(By.id("topMenu.file")).click(); - driver.findElement(By.id("topMenu.file.newFolder")).click(); - WebElement element4 = driver.findElement(By.id("folderPropertiesDialog.textBox.name")); - element4.click(); - element4.sendKeys("Hoooray"); - driver.findElement(By.id("folderPropertiesDialog.button.ok")).click(); - - Thread.sleep(3000); - WebElement element5 = driver.findElement(By.id("past@ebs.gr.Hoooray")); - String elemText = element5.getText(); - System.out.println("Created a new folder named "+elemText); - Assert.assertEquals(elemText, "Hoooray"); - } - Thread.sleep(2000); - driver.quit(); - } -} diff --git a/test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java b/test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java index 7b3bffe..c1f7de1 100644 --- a/test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java +++ b/test/gr/ebs/gss/client/selenium/folder/TestFolderBasics.java @@ -42,6 +42,8 @@ public class TestFolderBasics { protected String userName = "past@ebs.gr"; protected String folderDestination = "Naboo"; + + private String newFolderName = "Mustafar"; /** * Initialize the driver, the actionUtils, the application's url @@ -61,6 +63,7 @@ public class TestFolderBasics { } /** + * Quit the driver * @throws java.lang.Exception */ @After @@ -273,63 +276,96 @@ public class TestFolderBasics { action.click(By.id("topMenu.edit.paste")); } + /** + * Method that clicks on the folder and the from the top menu File > Properties + * + * @param aUserName + * @param aFolderName + * @throws InterruptedException + */ + public void clickFolderProperties(String aUserName, String aFolderName) throws InterruptedException{ + //Click on a folder + selectFolderBelowHome(aUserName, aFolderName); + + action.click(By.id("topMenu.file")); + Thread.sleep(1000); + action.click(By.id("topMenu.file.properties")); + Thread.sleep(1000); + } +// @Test + public void testRenameFolder() throws InterruptedException{ + //select the folder you want to rename and click Properties + clickFolderProperties(userName, folderName); + + //in the input box add the new folderName + action.type(By.id("folderPropertiesDialog.textBox.name"), newFolderName); + + //click OK + action.click(By.id("folderPropertiesDialog.button.ok")); + + Thread.sleep(2000); + + Assert.assertEquals(newFolderName, action.getText(By.id("past@ebs.gr."+newFolderName))); + + } + // @Test (expected=org.openqa.selenium.NoSuchElementException.class) -// public void testMakeNewFolderAndDelete() throws InterruptedException{ -// -// //Create the folder with the given folderName -// makeNewFolder(userName, folderName); -// -// //Necessary delay -// Thread.sleep(2000); -// -// //Delete the folder -// deleteFolder(userName, folderName); -// -// //the test is successful if that condition fails -// Assert.assertEquals(folderName, action.getText(By.id("past@ebs.gr."+folderName))); -// -// } + public void testMakeNewFolderAndDelete() throws InterruptedException{ + + //Create the folder with the given folderName + makeNewFolder(userName, folderName); + + //Necessary delay + Thread.sleep(2000); + + //Delete the folder + deleteFolder(userName, folderName); + + //the test is successful if that condition fails + Assert.assertEquals(folderName, action.getText(By.id("past@ebs.gr."+folderName))); + + } // @Test -// public void testCreateFolderAndMoveToTrash() throws InterruptedException{ -// //Create a new folder -// makeNewFolder(userName, folderName); -// -// //Necessary delay -// Thread.sleep(2000); -// -// //Move to Trash -// moveToTrash(userName, folderName); -// -// /** -// * TODO: In order to confirm that -// * the new folder exists in Trash folder -// * trash folder should be expanded first -// * and then select the element -// */ -// -// } + public void testCreateFolderAndMoveToTrash() throws InterruptedException{ + //Create a new folder + makeNewFolder(userName, folderName); + + //Necessary delay + Thread.sleep(2000); + + //Move to Trash + moveToTrash(userName, folderName); + + /** + * TODO: In order to confirm that + * the new folder exists in Trash folder + * trash folder should be expanded first + * and then select the element + */ + + } // @Test -// public void testCreateFolderAndMoveToTrashAndEmptyTrash() throws InterruptedException{ -// -// //Create a new folder -// makeNewFolder(userName, folderName); -// -// //Necessary delay -// Thread.sleep(3000); -// -// //Move to Trash -// moveToTrash(userName, folderName); -// -// emptyTrash(); -// -// /** -// * TODO: Confirm that the trash folder is empty -// */ -// -// } + public void testCreateFolderAndMoveToTrashAndEmptyTrash() throws InterruptedException{ + + //Create a new folder + makeNewFolder(userName, folderName); + + //Necessary delay + Thread.sleep(3000); + + //Move to Trash + moveToTrash(userName, folderName); + + emptyTrash(); + + /** + * TODO: Confirm that the trash folder is empty + */ + + } // /** // * Method that tries to expand the '+' symbol @@ -345,28 +381,28 @@ public class TestFolderBasics { // } // @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 -// */ -// -// } + 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 -// */ -// -// } + 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 + */ + + } } diff --git a/test/gr/ebs/gss/client/selenium/folder/TestFolderSharing.java b/test/gr/ebs/gss/client/selenium/folder/TestFolderSharing.java new file mode 100644 index 0000000..9dd1b5a --- /dev/null +++ b/test/gr/ebs/gss/client/selenium/folder/TestFolderSharing.java @@ -0,0 +1,138 @@ +/* + * Copyright 2011 Electronic Business Systems Ltd. + * + * This file is part of GSS. + * + * GSS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GSS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GSS. If not, see . + */ +package gr.ebs.gss.client.selenium.folder; + + +import org.junit.Test; +import org.openqa.selenium.By; + + + +public class TestFolderSharing extends TestFolderBasics { + + String addUserName = "lakis@ebs.gr"; + + public void clickFolderSharing(String aUserName, String aFolderName) throws InterruptedException{ + //Click on a folder + selectFolderBelowHome(aUserName, aFolderName); + + action.click(By.id("topMenu.file")); + Thread.sleep(1000); + action.click(By.id("topMenu.file.sharing")); + Thread.sleep(1000); + } + + @Test + public void testAddGroupToPermissionFolder() throws InterruptedException{ + + //Click sharing option for the folder @folderName + clickFolderSharing(userName, folderName); + + //Click the "Add Group" option in the FolderProperties dialog box + action.click(By.id("folderPropertiesDialog.button.addGroup")); + + //Select from drop down menu the preferred group + //TODO: add an id in the elements in the dropDown menu in order this click in the droppDown to work +// action.click(By.id("addPermission.dropDown")); + + //Add a read permission to the group + action.click(By.id("addPermission.read")); + + //Press OK + action.click(By.id("addPermission.button.ok")); + + //Press ok to close the dialog box + + //Assert that the group name you added permission to is displayed to the permissions table + action.click(By.id("permissionsList.Wookiees")); + + } + /** + * TODO: Share a folder to a user + * > select a folder + * > select File > 'Sharing' + * > click Add User + * > Type a valid username (a full version e.g john@doe.com) + * > Add permissions to the selected user + * > click OK + * > click Update + */ +// @Test + public void testAddUserToPermissionFolder() throws InterruptedException{ + + //Click sharing option for the folder @folderName + clickFolderSharing(userName, folderName); + + //Click the "Add User" option in the FolderProperties dialog box + action.click(By.id("folderPropertiesDialog.button.addUser")); + + //type the username in the input textBox + action.type(By.id("addPermission.textBox"), addUserName); + + //Add a read permission to the group + //TODO: this should be toggle :( + action.click(By.id("addPermission.read")); + + //Press OK + action.click(By.id("addPermission.button.ok")); + + //Press ok to close the dialog box + + //Assert that the group name you added permission to is displayed to the permissions table + action.click(By.id("permissionsList." + addUserName)); + + //folderPropertiesDialog.button.ok + + } + + /** + * TODO: . Make a folder public for all + * > select a folder + * > select File > 'Sharing' + * > check 'Public' check box + * > click OK + * > click Update + */ + +// @Test + public void testMakePublicFolder() throws InterruptedException{ + + //Click sharing option for the folder @folderName + clickFolderSharing(userName, folderName); + + //Click the "Public" checkBox + //TODO: this should be toggle :( + action.click(By.id("folderPropertiesDialog.checkBox.public")); + + //Press OK + action.click(By.id("folderPropertiesDialog.button.ok")); + + /** + * TODO: Check public link validity + * > select a folder + * > select File > 'Sharing' + * > Select pubic link + * > click Cancel + * > Open a new browser with the above copied link + */ + + } + + +} diff --git a/test/gr/ebs/gss/client/selenium/group/TestGroup.java b/test/gr/ebs/gss/client/selenium/group/TestGroup.java new file mode 100644 index 0000000..ea184aa --- /dev/null +++ b/test/gr/ebs/gss/client/selenium/group/TestGroup.java @@ -0,0 +1,166 @@ +/* + * Copyright 2011 Electronic Business Systems Ltd. + * + * This file is part of GSS. + * + * GSS is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GSS is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GSS. If not, see . + */ +package gr.ebs.gss.client.selenium.group; + + +import gr.ebs.gss.client.selenium.folder.ActionUtils; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; + +public class TestGroup { + + ActionUtils action; + + WebDriver driver; + + String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/"; + + String groupName = "Wookiees"; + + String userName = "past@ebs.gr"; + + String addUserName = "lakis@ebs.gr"; + + + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + driver = new FirefoxDriver(); + + action = new ActionUtils(driver); + + action.getUrl(url); + + // Necessary delay in order all dom elements to be created + Thread.sleep(4000); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + action.quit(); + } + + @Test + public void createNewGroup() throws InterruptedException{ + + action.click(By.id(userName)); + + Thread.sleep(1000); + + //Select Group option from top menu + action.click(By.id("topMenu.group")); + + Thread.sleep(1000); + + //Select New Group option + action.click(By.id("topMenu.group.newGroup")); + + Thread.sleep(1000); + + //type the group name in the input box of the group dialog + action.type(By.id("groupDialog.textBox.name"), groupName); + + //click ok button + action.click(By.id("groupDialog.button.ok")); + + Thread.sleep(2000); + + //assert that the newly created group has been created + Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName))); +// action.click(By.id("permissionsList."+groupName)); + + } + + public void selectGroupsTab(){ + //select the Group tab + action.click(By.id("Groups")); + } + + public void deleteGroup(String aGroupName) throws InterruptedException{ + + selectGroupsTab(); + + //right click on the groupName + //TODO: Problem on displaying the context menu + action.sendRightClick(By.id("groupsList." + aGroupName)); + + Thread.sleep(1000); + + //select 'Delete' option from right click context menu + action.click(By.id("groupContextMenu.delete")); + + //click ok + action.click(By.id("deleteGroup.button.ok")); + + } + +// @Test(expected=org.openqa.selenium.NoSuchElementException.class) + public void testDeleteGroup() throws InterruptedException{ + + deleteGroup(groupName); + //TODO: test assertion + Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName))); + + } + + public void addUserToGroup(String aGroupName, String aUserName) throws InterruptedException{ + //select an existing group + action.click(By.id("groupsList." + aGroupName)); + + //right click on it + //TODO: Problem on displaying the context menu + action.sendRightClick(By.id("groupsList."+groupName)); + + Thread.sleep(1000); + + //select 'Add User' option from right click context menu + action.click(By.id("groupContextMenu.addUser")); + + //type a username + action.type(By.id("addUser.textBox"), aUserName); + + //click ok + action.click(By.id("deleteGroup.button.ok")); + } + +// @Test + public void testAddUserToGroup() throws InterruptedException{ + selectGroupsTab(); + + Thread.sleep(1000); + + addUserToGroup(groupName, addUserName); + + //TODO: test assert addition + Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName))); + } + +} -- 1.7.10.4