Added new test classes for handling test on file resources. Added ids to file context...
authorNatasa Kapravelou <akapravelou@gmail.com>
Thu, 17 Feb 2011 15:58:46 +0000 (17:58 +0200)
committerNatasa Kapravelou <akapravelou@gmail.com>
Thu, 17 Feb 2011 15:58:46 +0000 (17:58 +0200)
src/gr/ebs/gss/client/FileContextMenu.java
src/gr/ebs/gss/client/FileList.java
src/gr/ebs/gss/client/Groups.java
test/gr/ebs/gss/client/selenium/file/TestFileBasics.java [new file with mode: 0644]
test/gr/ebs/gss/client/selenium/file/TestFileProperties.java [new file with mode: 0644]
test/gr/ebs/gss/client/selenium/file/TestFileSharing.java [new file with mode: 0644]
test/gr/ebs/gss/client/selenium/group/TestGroup.java

index ed2cb64..0a3a8d6 100644 (file)
@@ -129,6 +129,7 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                };
 
                pasteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.paste()).getHTML() + "&nbsp;Paste</span>", true, new PasteCommand(this));
+               pasteItem.getElement().setId("FileContextMenu.paste");
                RestResource sel = GSS.get().getTreeView().getSelection();
                MenuBar contextMenu = new MenuBar(true);
                if (isEmpty) {
@@ -146,13 +147,22 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                                                contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
                        */
                        if(sel instanceof RestResourceWrapper && !(sel instanceof TrashFolderResource)){
-                               contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
+                               MenuItem upload = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
+                               upload.getElement().setId("fileContextMenu.upload");
+                               contextMenu.addItem(upload);
                        }
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       refresh.getElement().setId("fileContextMenu.refresh");
+                       contextMenu.addItem(refresh);
                        
                } else if (isTrash) {
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
+                       MenuItem restore = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.versions()).getHTML() + "&nbsp;Restore</span>", true, new RestoreTrashCommand(this));
+                       restore.getElement().setId("fileContextMenu.restore");
+                       contextMenu.addItem(restore);
+                       
+                       MenuItem delete = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
+                       delete.getElement().setId("fileContextMenu.delete");
+                       contextMenu.addItem(delete);
                } else {
                        final Command unselectAllCommand = new Command() {
 
@@ -166,15 +176,25 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                                }
                        };
                        cutItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.cut()).getHTML() + "&nbsp;Cut</span>", true, new CutCommand(this));
+                       cutItem.getElement().setId("fileContextMenu.cut");
+                       
                        copyItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.copy()).getHTML() + "&nbsp;Copy</span>", true, new CopyCommand(this));
-
+                       copyItem.getElement().setId("fileContextMenu.copy");
+                       
                        updateItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
+                       updateItem.getElement().setId("fileContextMenu.upload");
 
                        trashItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.emptyTrash()).getHTML() + "&nbsp;Move to Trash</span>", true, new ToTrashCommand(this));
+                       trashItem.getElement().setId("fileContextMenu.moveToTrash");
+                       
                        deleteItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.delete()).getHTML() + "&nbsp;Delete</span>", true, new DeleteCommand(this, images));
+                       deleteItem.getElement().setId("fileContextMenu.delete");
 
                        sharingItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.sharing()).getHTML() + "&nbsp;Sharing</span>", true, new PropertiesCommand(this, images, 1));
+                       sharingItem.getElement().setId("fileContextMenu.sharing");
+                       
                        propItem = new MenuItem("<span>" + AbstractImagePrototype.create(newImages.viewText()).getHTML() + "&nbsp;Properties</span>", true, new PropertiesCommand(this, images, 0));
+                       propItem.getElement().setId("fileContextMenu.properties");
 
                        
                        if(sel!=null && sel instanceof FolderResource)
@@ -182,18 +202,28 @@ public class FileContextMenu extends PopupPanel implements ClickHandler {
                        String[] link = {"", ""};
                        gss.getTopPanel().getFileMenu().createDownloadLink(link, false);
                        downloadItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Download" + link[1] + "</span>", true, downloadCmd);
+                       downloadItem.getElement().setId("fileContextMenu.download");
                        contextMenu.addItem(downloadItem);
+                       
                        gss.getTopPanel().getFileMenu().createDownloadLink(link, true);
                        saveAsItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(newImages.download()).getHTML() + " Save As" + link[1] + "</span>", true, downloadCmd);
+                       saveAsItem.getElement().setId("fileContextMenu.saveAs");
                        contextMenu.addItem(saveAsItem);
                        contextMenu.addItem(cutItem);
                        contextMenu.addItem(copyItem);
                        if(sel!=null && sel instanceof FolderResource)
                                contextMenu.addItem(pasteItem);
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, unselectAllCommand);
+                       MenuItem unSelect = new MenuItem("<span>" + AbstractImagePrototype.create(images.unselectAll()).getHTML() + "&nbsp;Unselect</span>", true, unselectAllCommand);
+                       unSelect.getElement().setId("fileContextMenu.unSelect");
+                       contextMenu.addItem(unSelect);
+                       
                        contextMenu.addItem(trashItem);
                        contextMenu.addItem(deleteItem);
-                       contextMenu.addItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       
+                       MenuItem refresh = new MenuItem("<span>" + AbstractImagePrototype.create(images.refresh()).getHTML() + "&nbsp;Refresh</span>", true, new RefreshCommand(this, images));
+                       refresh.getElement().setId("fileContextMenu.refresh");
+                       contextMenu.addItem(refresh);
+                       
                        contextMenu.addItem(sharingItem);
                        contextMenu.addItem(propItem);
                }
index 173ec68..6cf7ab2 100644 (file)
@@ -239,7 +239,8 @@ public class FileList extends Composite {
              sb.appendHtmlConstant("</td>");
 
              // Add the name and address.
-             sb.appendHtmlConstant("<td style='font-size:95%;'>");
+             DisplayHelper.log("value.getName()");
+             sb.appendHtmlConstant("<td style='font-size:95%;' id='"+value.getName()+"'>");
              sb.appendEscaped(value.getName());
              sb.appendHtmlConstant("</td></tr><tr><td>");
              sb.appendEscaped(value.getFileSizeAsString());
@@ -332,9 +333,10 @@ public class FileList extends Composite {
                        @Override
                        public SafeHtml getValue(FileResource object) {
                                SafeHtmlBuilder sb = new SafeHtmlBuilder();
-                               if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg") ){
-                                       
+                               if (object.getContentType().endsWith("png") || object.getContentType().endsWith("gif") || object.getContentType().endsWith("jpeg") ){                                   
+                                       sb.appendHtmlConstant("<span id='fileList."+ object.getName() +"'>");
                                        sb.appendEscaped(object.getName());
+                                       sb.appendHtmlConstant("</span>");
                                        sb.appendHtmlConstant(" <a href='" +
                                 GSS.get().getTopPanel().getFileMenu().getDownloadURL(object) +
                                 "' title='" + object.getOwner() + " : " + object.getPath() + object.getName() +
@@ -344,8 +346,11 @@ public class FileList extends Composite {
                                        
                                        
                                }
-                               else
+                               else{                                   
+                                       sb.appendHtmlConstant("<span id='fileList."+ object.getName() +"'>");
                                        sb.appendEscaped(object.getName());
+                                       sb.appendHtmlConstant("</span>");
+                               }
                                return sb.toSafeHtml();
                        }
                        
@@ -370,6 +375,7 @@ public class FileList extends Composite {
                        com.google.gwt.dom.client.Element helper = event.getHelper();
                        SafeHtmlBuilder sb = new SafeHtmlBuilder();
                        sb.appendHtmlConstant("<b>");
+                       DisplayHelper.log(value.getName());
                        sb.appendEscaped(value.getName());
                        sb.appendHtmlConstant("</b>");
                        helper.setInnerHTML(sb.toSafeHtml().asString());
index d59a7ae..380f9c8 100644 (file)
@@ -118,6 +118,7 @@ public class Groups extends Composite implements SelectionHandler, OpenHandler {
 \r
                        }\r
                }, ContextMenuEvent.getType());\r
+               tree.getElement().setId("groupsList.tree");\r
                tree.addSelectionHandler(this);\r
                tree.addOpenHandler(this);\r
                tree.setAnimationEnabled(true);\r
@@ -148,8 +149,7 @@ public class Groups extends Composite implements SelectionHandler, OpenHandler {
                                                for (int i = 0; i < groupList.size(); i++) {\r
                                                        final TreeItem item = new TreeItem();\r
                                                        item.setWidget(imageItemHTML(images.groupImage(), groupList.get(i).getName(),item));\r
-                                                       item.setUserObject(groupList.get(i));   \r
-//                                                     item.getElement().setId("groupsList."+ groupList.get(i).getName());\r
+                                                       item.setUserObject(groupList.get(i));\r
                                                        tree.addItem(item);\r
                                                        updateUsers(item);\r
                                                }\r
@@ -219,8 +219,11 @@ public class Groups extends Composite implements SelectionHandler, OpenHandler {
                                super.onBrowserEvent(event);\r
 \r
                        }\r
-               };\r
+               };              \r
                link.sinkEvents(Event.ONMOUSEDOWN);\r
+               link.sinkEvents(Event.ONCONTEXTMENU);\r
+               link.sinkEvents(Event.ONCLICK);\r
+               link.sinkEvents(Event.ONKEYDOWN);\r
                return link;\r
        }\r
 \r
diff --git a/test/gr/ebs/gss/client/selenium/file/TestFileBasics.java b/test/gr/ebs/gss/client/selenium/file/TestFileBasics.java
new file mode 100644 (file)
index 0000000..0555990
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client.selenium.file;
+
+
+import gr.ebs.gss.client.selenium.folder.ActionUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+
+/**
+ * @author natasa
+ *
+ */
+public class TestFileBasics {
+       
+       ActionUtils action;
+       
+       WebDriver driver;
+       
+       String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/";
+       
+       String fileName = "";
+       
+       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(3000);
+       }
+
+       /**
+        * @throws java.lang.Exception
+        */
+       @After
+       public void tearDown() throws Exception {
+               action.quit();
+       }
+       
+       public void clickAFile(String aFileName){
+               action.click(By.id(""));
+       }
+       public void selectFileMenu(){
+               
+       }
+       
+       /**
+        * TODO: Download a file below in a folder
+        * > select a file
+        * > select File > 'Download'
+        * > save file from the popup window to your hdd
+        *      
+        */
+       
+       /** TODO: Save As
+        * **** This action performs the same results to the above 'Download' option
+        */
+        
+       /** TODO:Empty Trash
+        * > select a file
+        * > select File > 'Empty Trash' 
+        * *** Notice: There is no confirmation before performing this action
+        */
+          
+
+       /** TODO:. Refresh
+        * > select a file
+        * > select File > 'Refresh'
+        */
+       
+       /**
+        * TODO: . Cut file
+        * > select a file
+        * > select Edit > 'Cut'
+        * > select a destination folder
+        * > click Edit > Paste on the destination folder 
+        */
+       
+       /** TODO: . Copy file
+        * > select a file
+        * > select Edit > 'Copy'
+        * > select a destination folder
+        * > click Edit > 'Paste' on the destination folder
+        * 
+        */
+          
+       /** TODO: . Move to Trash
+        * > select a file
+        * > select Edit > 'Move to Trash'
+        * > select Trash folder and your file is in the Trash
+        */
+       /**. Delete
+        * > select a file
+        * > select Edit > 'Move to Trash'
+        * > click Delete to confirm
+        * */
+
+       /** TODO:. Select All
+        * > select a file
+        * > select Edit > 'Select All' this action results to select all files that are inside home folder
+        */
+          
+       /** TODO:. Unselect All
+        * > select a file
+        * > select Edit > 'Unselect All'     this action results to unselect all files that are inside home folder
+        */
+
+}
diff --git a/test/gr/ebs/gss/client/selenium/file/TestFileProperties.java b/test/gr/ebs/gss/client/selenium/file/TestFileProperties.java
new file mode 100644 (file)
index 0000000..70c9a76
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client.selenium.file;
+
+
+
+/**
+ * @author natasa
+ *
+ */
+public class TestFileProperties extends TestFileBasics{
+       
+       /** TODO:. Rename a file
+        * > select a file
+        * > select File > 'Properties'
+        * > type a new file name in the Name input box
+        * > click 'Ok'
+        */
+          
+       /** TODO:. Add a Tag to a file
+        * > select a file
+        * > select File > 'Properties'
+        * > type a word that represents a tag to the tag input box
+        * > click 'Ok'
+        */             
+          
+       /** TODO:. Add a Version to a file
+        * > select a file
+        * > select File > 'Properties'
+        * > select the 'Versions' tab
+        * > click on the Versioned check box
+        * > click 'Ok'
+        */
+       
+       /** TODO: 
+        * . Add a new version in an already versioned file
+        */
+       
+       /** TODO:. Remove a Version from a file
+        * 
+        */
+       
+}
diff --git a/test/gr/ebs/gss/client/selenium/file/TestFileSharing.java b/test/gr/ebs/gss/client/selenium/file/TestFileSharing.java
new file mode 100644 (file)
index 0000000..f5a1183
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client.selenium.file;
+
+
+
+/**
+ * @author natasa
+ *
+ */
+public class TestFileSharing extends TestFileBasics {
+
+}
index ea184aa..5bdf40b 100644 (file)
@@ -29,6 +29,11 @@ import org.openqa.selenium.By;
 import org.openqa.selenium.WebDriver;
 import org.openqa.selenium.firefox.FirefoxDriver;
 
+import com.google.gwt.user.client.ui.AbstractImagePrototype;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.TreeItem;
+import com.google.gwt.user.client.ui.Widget;
+
 public class TestGroup {
        
        ActionUtils action;
@@ -68,7 +73,7 @@ public class TestGroup {
                action.quit();
        }
        
-       @Test
+//     @Test
        public void createNewGroup() throws InterruptedException{
                
                action.click(By.id(userName));
@@ -104,15 +109,43 @@ public class TestGroup {
                action.click(By.id("Groups"));
        }
        
+       public void selectOneGroup(String aGroupName){
+               selectGroupsTab();
+               
+               action.click(By.id("groupsList." + aGroupName));
+       }
+       
        public void deleteGroup(String aGroupName) throws InterruptedException{         
                
-               selectGroupsTab();
+               selectOneGroup(aGroupName);
                
                //right click on the groupName          
                //TODO: Problem on displaying the context menu 
-               action.sendRightClick(By.id("groupsList." + aGroupName));
+               /**
+                * NOTES: Context menu denies to be displayed
+                * Unsuccessful scenarios:
+                * id placed in: 
+                * 
+                * 1.addImageItem() method
+                * TreeItem item = new TreeItem();
+                * Widget aWidget = imageItemHTML(imageProto, title,item);
+                * aWidget.getElement().setId("groupsList."+title);
+                * item.setWidget(aWidget);
+                * 
+                * 2.imageItemHTML either in <a id =""></a> or in <span id=""></span>
+                * 
+                * 3. changed the HTML link to
+                * final HTML link = new HTML("<span id='groupsList."+title+"'>"+AbstractImagePrototype.create(imageProto).getHTML() + "&nbsp;" + title + "</span>"){
+                * or to
+                * final HTML link = new HTML(AbstractImagePrototype.create(imageProto).getHTML() +"<span id='groupsList."+title+"'>" + "&nbsp;" + title + "</span>"){
+                * 
+                * 4. TODO: addKeyDown/keyUpHandler or catch the events the webDriver creates in the imageItemHTML
+               
+                */
+               
+               action.sendRightClick(By.id("groupsList.tree"));
                
-               Thread.sleep(1000);
+               Thread.sleep(2000);
                 
                //select 'Delete' option from right click context menu
                action.click(By.id("groupContextMenu.delete"));
@@ -122,12 +155,13 @@ public class TestGroup {
 
        }
                
-//     @Test(expected=org.openqa.selenium.NoSuchElementException.class)
+       @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)));         
+//             Assert.assertEquals(groupName, action.getText(By.id("groupsList."+groupName)));         
        
        }