Added some id's regarding tests on files. Experiments on upload/download files -...
authorNatasa Kapravelou <akapravelou@gmail.com>
Fri, 25 Feb 2011 16:24:28 +0000 (18:24 +0200)
committerNatasa Kapravelou <akapravelou@gmail.com>
Fri, 25 Feb 2011 16:24:28 +0000 (18:24 +0200)
src/gr/ebs/gss/client/FileMenu.java
src/gr/ebs/gss/client/FilePropertiesDialog.java
src/gr/ebs/gss/client/FileUploadDialog.java
test/gr/ebs/gss/client/selenium/tests/FileUtils.java
test/gr/ebs/gss/client/selenium/tests/FolderUtils.java
test/gr/ebs/gss/client/selenium/tests/GeneralPurposeUtils.java
test/gr/ebs/gss/client/selenium/tests/TestFileBasics.java
test/gr/ebs/gss/client/selenium/tests/TestFileProperties.java

index 85a6748..6bf820b 100644 (file)
@@ -137,7 +137,7 @@ public class FileMenu extends PopupPanel implements ClickHandler {
        void createDownloadLink(String[] link, boolean forceDownload) {
                String downloadURL = getDownloadURL();
                if (!downloadURL.isEmpty()) {
-                       link[0] = "<a class='hidden-link' href='" + downloadURL
+                       link[0] = "<a id ='topMenu.file.download' class='hidden-link' href='" + downloadURL
                                        + (forceDownload ? "&dl=1" : "") + "' target='_blank'>";
                        link[1] = "</a>";
                }
@@ -189,8 +189,7 @@ public class FileMenu extends PopupPanel implements ClickHandler {
                        contextMenu.addItem(newFolderItem);                     
                }
                if(uploadVisible){
-                       MenuItem uploadItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));
-                       uploadItem.getElement().setId("topMenu.file.upload");
+                       MenuItem uploadItem = new MenuItem("<span id='topMenu.file.upload'>" + AbstractImagePrototype.create(images.fileUpdate()).getHTML() + "&nbsp;Upload</span>", true, new UploadFileCommand(this));                        
                        contextMenu.addItem(uploadItem);
                }
                if (downloadVisible) {
@@ -199,12 +198,10 @@ public class FileMenu extends PopupPanel implements ClickHandler {
                        
                        MenuItem downloadItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(images.download()).getHTML() + "&nbsp;Download" + link[1] + "</span>", true, downloadCmd);
                        contextMenu.addItem(downloadItem);
-                       downloadItem.getElement().setId("topMenu.file.download");
                        
                        createDownloadLink(link, true);
                        
-                       MenuItem saveAsItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(images.download()).getHTML() + "&nbsp;Save As" + link[1] + "</span>", true, downloadCmd);
-                       saveAsItem.getElement().setId("topMenu.file.saveAs");
+                       MenuItem saveAsItem = new MenuItem("<span>" + link[0] + AbstractImagePrototype.create(images.download()).getHTML() + "&nbsp;Save As" + link[1] + "</span>", true, downloadCmd);                 
                        contextMenu.addItem(saveAsItem);
                }
                MenuItem emptyTrashItem = new MenuItem("<span>" + AbstractImagePrototype.create(images.emptyTrash()).getHTML() + "&nbsp;Empty Trash</span>", true, new EmptyTrashCommand(this));
index 512815b..1a47930 100644 (file)
@@ -136,7 +136,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                final HorizontalPanel vPanel2 = new HorizontalPanel();\r
 \r
                versioned.setValue(file.isVersioned());\r
-               versioned.getElement().setId("filePropertiesDialog.versioned");\r
+               versioned.getElement().setId("filePropertiesDialog.chechBox.versioned");\r
                inner.add(generalPanel, "General");\r
                inner.add(permPanel, "Sharing");\r
                inner.add(verPanel, "Versions");\r
@@ -154,6 +154,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                generalTable.setText(4, 0, "Tags");\r
                name.setWidth("100%");\r
                name.setText(file.getName());\r
+               name.getElement().setId("filePropertiesDialog.textBox.name");\r
                generalTable.setWidget(0, 1, name);\r
                name.addChangeHandler(new ChangeHandler() {\r
 \r
@@ -187,6 +188,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                        tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1);\r
                initialTagText = tagsBuffer.toString();\r
                tags.setWidth("100%");\r
+               tags.getElement().setId("filePropertiesDialog.textBox.tags");\r
                tags.setText(initialTagText);\r
                generalTable.setWidget(4, 1, tags);\r
                generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels");\r
@@ -215,6 +217,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                }               \r
                        }\r
                });\r
+               ok.getElement().setId("filePropertiesDialog.button.ok");                \r
                buttons.add(ok);\r
                buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);\r
                // Create the 'Cancel' button, along with a listener that hides the\r
@@ -225,6 +228,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                closeDialog();\r
                        }\r
                });\r
+               cancel.getElement().setId("filePropertiesDialog.button.cancel");\r
                buttons.add(cancel);\r
                buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);\r
                buttons.setSpacing(8);\r
@@ -255,6 +259,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                dlg.center();\r
                        }\r
                });\r
+               add.getElement().setId("filePropertiesDialog.button.addGroup");\r
                permButtons.add(add);\r
                permButtons.setCellHorizontalAlignment(add, HasHorizontalAlignment.ALIGN_CENTER);\r
 \r
@@ -265,6 +270,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                                dlg.center();\r
                        }\r
                });\r
+               add.getElement().setId("filePropertiesDialog.button.addUser");\r
                permButtons.add(addUser);\r
                permButtons.setCellHorizontalAlignment(addUser, HasHorizontalAlignment.ALIGN_CENTER);\r
 \r
@@ -279,6 +285,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
                readForAllNote.setStylePrimaryName("gss-readForAllNote");\r
 \r
                readForAll = new CheckBox();\r
+               readForAll.getElement().setId("filePropertiesDialog.checkBox.public");\r
                readForAll.setValue(file.isReadForAll());\r
                readForAll.addClickHandler(new ClickHandler() {\r
                        @Override\r
@@ -312,6 +319,7 @@ public class FilePropertiesDialog extends AbstractPropertiesDialog {
 \r
                });\r
                path.setText(file.getUri());\r
+               path.getElement().setId("filePropertiesDialog.textBox.link");\r
                path.setTitle("Use this link for sharing the file via e-mail, IM, etc. (crtl-C/cmd-C to copy to system clipboard)");\r
                path.setWidth("100%");\r
                path.setReadOnly(true);\r
index 0165141..f1c2cfe 100644 (file)
@@ -121,6 +121,7 @@ public class FileUploadDialog extends DialogBox implements Updateable {
                HorizontalPanel fileUloadPanel = new HorizontalPanel();
                fileUloadPanel.add(filenameLabel);
                fileUloadPanel.add(upload);
+               upload.getElement().setId("fileUploadDiallog.uploadPanel");
                Grid generalTable = new Grid(2, 2);
                generalTable.setText(0, 0, "Folder");
                generalTable.setText(1, 0, "File");
@@ -145,6 +146,7 @@ public class FileUploadDialog extends DialogBox implements Updateable {
                                prepareAndSubmit();
                        }
                });
+               submit.getElement().setId("fileUploadDialog.button.upload");
                buttons.add(submit);
                buttons.setCellHorizontalAlignment(submit, HasHorizontalAlignment.ALIGN_CENTER);
                // Create the 'Cancel' button, along with a listener that hides the
@@ -156,6 +158,7 @@ public class FileUploadDialog extends DialogBox implements Updateable {
                                hide();
                        }
                });
+               cancel.getElement().setId("fileUploadDialog.button.cancel");
                buttons.add(cancel);
                buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
                buttons.setSpacing(8);
index 96f98e4..8790d81 100644 (file)
 package gr.ebs.gss.client.selenium.tests;
 
 
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+
 import org.openqa.selenium.By;
 
 
 public class FileUtils extends GeneralPurposeUtils{
 
-       public void clickAFile(String aFileName){               
-               action.click(By.id("fileList."+ aFileName));
-       }
-
        public void rightClickOnFile(String aFileName){
                action.sendRightClick(By.id("fileList." + aFileName));
                
@@ -37,26 +37,43 @@ public class FileUtils extends GeneralPurposeUtils{
                action.click(By.id("fileContextMenu." + anOption));
        }
        
-       /**
-        * TODO: Download a file below in a folder
-        * > select a file
-        * > select File > 'Download'
-        * > save file from the popup window to your hdd
-        *      
-        */
-       
-       public void downloadFile() throws InterruptedException{
+
+       public void downloadFile() throws InterruptedException, AWTException{
                selectTopMenu("file");
                
                Thread.sleep(1000);
                
                selectAnOptionInTopMenu("file","download");
                
-               selectConfirmation("ok");
+               /**
+                * TODO: Solve the problem of not opening the dialog boxes
+                */
+               Thread.sleep(3000);
+               Robot robot = new Robot();
+               //Alt + S to select save 
+               robot.keyPress(KeyEvent.VK_ALT);
+               robot.keyPress(KeyEvent.VK_S);
+               robot.keyRelease(KeyEvent.VK_ALT);
+               System.out.println("window = " + driver.getWindowHandle());
+               Thread.sleep(3000);
+               //Then press enter
+               robot.keyPress(KeyEvent.VK_ENTER);
+                       
+               // and save the file in the indicated location 
+               // using Alt + S
+               robot.keyPress(KeyEvent.VK_ALT);
+               robot.keyPress(KeyEvent.VK_S);
+               robot.keyPress(KeyEvent.VK_S);
+               robot.keyRelease(KeyEvent.VK_ALT); 
+               
+               
+               
+               Thread.sleep(3000);
+               //TODO: confirm download - how??
        }
 
        
-       /** TODO: Save As Assert
+       /**
         * This action performs the same results to the above 'Download' option
         */
        
@@ -67,17 +84,14 @@ public class FileUtils extends GeneralPurposeUtils{
                
                selectAnOptionInTopMenu("file","saveAs");
                
+               //TODO: confirm save As - how??
+               
        }
-       /**
-        * TODO: assert somehow
-        * @param aUserName
-        * @param aFolderName
-        * @param aFileName
-        */
+
        public void refreshFile(String aUserName, String aFolderName, String aFileName){                
                selectFolderBelowHome(aUserName, aFolderName);
                
-               clickAFile(aFileName);
+               selectFile(aFileName);
                
                //Click top edit menu
                selectTopMenu("file");
@@ -85,19 +99,14 @@ public class FileUtils extends GeneralPurposeUtils{
                //Click move to trash option
                selectAnOptionInTopMenu("file","refresh");
                
+               //TODO: confirm refresh
+               
        }
 
-       /**
-        * TODO: . Cut file
-        * > select a file
-        * > select Edit > 'Cut'
-        * > select a destination folder
-        * > click Edit > Paste on the destination folder 
-        */
        public void cutFile(String aFileName){
                
                //Click a file
-               clickAFile(aFileName);
+               selectFile(aFileName);
                                
                //Click the top file menu
                selectTopMenu("edit");          
@@ -107,17 +116,10 @@ public class FileUtils extends GeneralPurposeUtils{
                                
        }
        
-       /** TODO: . Copy file
-        * > select a file
-        * > select Edit > 'Copy'
-        * > select a destination folder
-        * > click Edit > 'Paste' on the destination folder
-        * 
-        */
        public void copyFile(String aFileName){
                
                //Click a file
-               clickAFile(aFileName);
+               selectFile(aFileName);
                                
                //Click the top file menu
                selectTopMenu("edit");          
@@ -134,7 +136,7 @@ public class FileUtils extends GeneralPurposeUtils{
         */
        public void pasteFile(String aUserName, String aFolderDestination, String aFileName){
                //Click a file
-               clickAFile(aFileName);
+               selectFile(aFileName);
                
                //Click on the folder destination which is below home folder
                selectFolderBelowHome(aUserName, aFolderDestination);
@@ -145,35 +147,33 @@ public class FileUtils extends GeneralPurposeUtils{
                //Click the New Folder option from the file menu
                selectAnOptionInTopMenu("edit","paste");
                
+               /**
+                * TODO: expand the folder that paste option was performed
+                * and confirm the existence of the file
+                */
+               
        }
-          
-       /** TODO: . Move to Trash
-        * > select a file
-        * > select Edit > 'Move to Trash'
-        * > select Trash folder and your file is in the Trash
-        */
-       
+               
        public void moveToTrashFile(String aFileName){
                
                //Click a file
-               clickAFile(aFileName);
+               selectFile(aFileName);
                                
                //Click the top file menu
                selectTopMenu("edit");          
                
                //Click the New Folder option from the file menu
                selectAnOptionInTopMenu("edit","moveToTrash");
+               
+               /**
+                * TODO: expand Trash and confirm the existence of the file
+                */
                                
        }
-       /**. Delete
-        * > select a file
-        * > select Edit > 'Move to Trash'
-        * > click Delete to confirm
-        * */
        
        public void deleteFile(String aFileName) throws InterruptedException{
                
-               clickAFile(aFileName);
+               selectFile(aFileName);
                
                selectTopMenu("edit");          
                                        
@@ -183,16 +183,16 @@ public class FileUtils extends GeneralPurposeUtils{
                
                //Click ok button in the confirmation dialog box
                selectConfirmation("ok");
+               
+               /**
+                * TODO: assert deletion
+                */     
        
        }
-
-       /** TODO:. Select All
-        * > select a file
-        * > select Edit > 'Select All' this action results to select all files that are inside home folder
-        */
+       
        public void selectAllFile(String aFileName) throws InterruptedException{
                
-               clickAFile(aFileName);
+               selectFile(aFileName);
                
                selectTopMenu("edit");          
                                        
@@ -200,15 +200,15 @@ public class FileUtils extends GeneralPurposeUtils{
                selectAnOptionInTopMenu("edit","selectAll");
                Thread.sleep(1000);
                
+               /**
+                * TODO: assert 
+                */     
+               
        }
           
-       /** TODO:. Unselect All
-        * > select a file
-        * > select Edit > 'Unselect All'     this action results to unselect all files that are inside home folder
-        */
        public void unSelectAllFile(String aFileName) throws InterruptedException{
                
-               clickAFile(aFileName);
+               selectFile(aFileName);
                
                selectTopMenu("edit");          
                                        
@@ -216,6 +216,9 @@ public class FileUtils extends GeneralPurposeUtils{
                selectAnOptionInTopMenu("edit","unSelectAll");
                Thread.sleep(1000);
                
+               /**
+                * TODO: assert 
+                */                     
        }
 
 }
index 02bbcf8..5c2b65c 100644 (file)
  */
 package gr.ebs.gss.client.selenium.tests;
 
+import java.awt.AWTException;
+import java.awt.Robot;
+import java.awt.event.KeyEvent;
+
+import org.junit.Test;
 import org.openqa.selenium.By;
 import org.openqa.selenium.Keys;
 import org.openqa.selenium.WebElement;
@@ -133,7 +138,29 @@ public class FolderUtils extends GeneralPurposeUtils{
        }
        
        //TODO: upload file to a folder
-       public void upload(){
+       public void upload() throws AWTException{
+               action.click(By.id("fileUploadDiallog.uploadPanel"));
+               
+               Robot robot = new Robot(); 
+               robot.keyPress(KeyEvent.VK_ALT);
+               robot.keyPress(KeyEvent.VK_S);
+               robot.keyRelease(KeyEvent.VK_ALT); 
+               
+               //<button type="button" class="gwt-Button">Browse...</button>
+               
+               /**
+                * /home/Desktop/links.txt
+                */ 
+               
+       }
+       @Test
+       public void testUpload() throws InterruptedException{
+               selectFolderBelowHome(userName, folderName);
+               selectTopMenu("file");
+               Thread.sleep(1000);
+               selectAnOptionInTopMenu("file","upload");
+               action.click(By.id("fileUploadDiallog.uploadPanel"));
+               Thread.sleep(5000);
                
        }
        
index c814122..7cb2339 100644 (file)
@@ -36,7 +36,11 @@ public class GeneralPurposeUtils {
        
        public String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/";
        
-       public String fileName = "darth_vader.jpg";
+       public String fileName = "anakin.jpg";
+       
+       public String newFileName = "darth_vader.jpg";
+       
+       public String fileToDownload = "David Bowie - All the Young Dudes.mp3";
        
        public String groupName = "Wookiees";
        
@@ -103,8 +107,7 @@ public class GeneralPurposeUtils {
                
        }
        
-       public void selectConfirmation(String anOption){
-               
+       public void selectConfirmation(String anOption){                
                action.click(By.id("confirmation."+ anOption));
                
        }
@@ -177,8 +180,11 @@ public class GeneralPurposeUtils {
                Thread.sleep(1000);
                
                selectAnOptionInTopMenu("file","emptyTrash");
-               
 
        }
-
+       
+       public void selectFile(String aFileName){               
+               action.click(By.id("fileList."+ aFileName));
+       }
+       
 }
index 7033664..1e18a1c 100644 (file)
@@ -19,6 +19,8 @@
 package gr.ebs.gss.client.selenium.tests;
 
 
+import java.awt.AWTException;
+
 import org.junit.Test;
 import org.openqa.selenium.By;
 import org.openqa.selenium.Keys;
@@ -29,17 +31,17 @@ import org.openqa.selenium.WebElement;
 
 public class TestFileBasics extends FileUtils{
        
-       @Test
+//     @Test
        public void testClickAFile(){
                selectFolderBelowHome(userName, folderName);
-               clickAFile(fileName);
+               selectFile(fileName);
                
                rightClickOnFile(fileName);
                
                selectFileContextMenuOption("refresh");
        }
        
-       @Test
+//     @Test
        public void testRightClickOnFile() throws InterruptedException{
                /**
                 * Q: The "onchange" event doesn't fire after a call "sendKeys"
@@ -68,4 +70,24 @@ public class TestFileBasics extends FileUtils{
                
        }
        
+       @Test
+       public void testDownloadFile() throws InterruptedException, AWTException{
+               selectFolderBelowHome(userName, folderName);
+               Thread.sleep(1000);
+               selectFile(fileToDownload);
+               Thread.sleep(1000);
+               downloadFile();
+               Thread.sleep(3000);
+       }
+
+       public void testFileProperties() throws InterruptedException{
+               selectFolderBelowHome(userName, folderName);
+               Thread.sleep(1000);
+               selectFile(fileToDownload);
+               Thread.sleep(1000);
+               
+               selectTopMenu("file");
+               Thread.sleep(1000);
+               selectAnOptionInTopMenu("file","properties");
+       }
 }
index d249b9f..ded79a1 100644 (file)
  */
 package gr.ebs.gss.client.selenium.tests;
 
+import org.openqa.selenium.By;
+import org.junit.Test;
 
-
-
-/**
- * @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'
-        */
+       public void renameFile() throws InterruptedException{
+               action.click(By.id("filePropertiesDialog.textBox.name"));
+               Thread.sleep(1000);
+               action.type(By.id("filePropertiesDialog.textBox.name"), fileToDownload);
+               Thread.sleep(2000);
+               action.click(By.id("filePropertiesDialog.button.ok"));
+               
+       }
+       
+       
+//     @Test
+       public void testRenameFile() throws InterruptedException{
+               
+               selectFolderBelowHome(userName, folderName);
+               Thread.sleep(1000);
+               selectFile(fileName);
+               Thread.sleep(1000);
+               selectTopMenu("file");
+               Thread.sleep(1000);
+               selectAnOptionInTopMenu("file", "properties");
+               Thread.sleep(1000);
+               renameFile();
+               
+               //TODO:assert new name
+       }
           
        /** TODO:. Add a Tag to a file
         * > select a file