1 19 20 package gui.action; 21 22 import java.awt.event.KeyEvent ; 23 import javax.swing.JComponent ; 24 import org.netbeans.jellytools.EditorOperator; 25 import org.netbeans.jellytools.EditorWindowOperator; 26 import org.netbeans.jellytools.ProjectsTabOperator; 27 import org.netbeans.jellytools.nodes.Node; 28 import org.netbeans.jellytools.actions.ActionNoBlock; 29 import org.netbeans.jellytools.actions.Action.Shortcut; 30 import org.netbeans.jellytools.actions.OpenAction; 31 import org.netbeans.jemmy.operators.ComponentOperator; 32 import org.netbeans.performance.test.guitracker.LoggingRepaintManager; 33 import org.netbeans.test.web.performance.WebPerformanceTestCase; 34 35 40 public class JavaCompletionInJspEditor extends WebPerformanceTestCase { 41 42 43 public JavaCompletionInJspEditor(String testName) { 44 super(testName); 45 expectedTime = WINDOW_OPEN; 46 init(); 47 } 48 49 50 public JavaCompletionInJspEditor(String testName, String performanceDataName) { 51 super(testName, performanceDataName); 52 expectedTime = WINDOW_OPEN; 53 init(); 54 } 55 56 protected void init() { 57 super.init(); 58 WAIT_AFTER_OPEN = 6000; 59 shcut = new Shortcut(KeyEvent.VK_SPACE, KeyEvent.CTRL_MASK); 60 } 61 62 public String text; 63 public Shortcut shcut; 64 protected LoggingRepaintManager.RegionFilter COMPLETION_DIALOG_FILTER = 65 new LoggingRepaintManager.RegionFilter() { 66 public boolean accept(JComponent comp) { 67 return comp.getClass().getName().startsWith("org.netbeans.editor.ext."); 68 } 69 70 public String getFilterName() { 71 return "Completion Dialog Filter (accepts only componenets from" + 72 "'org.netbeans.editor.ext.**' packages"; 73 } 74 }; 75 76 public void testScriptletCC() { 77 text = "<% "; 78 measureTime(); 79 } 80 81 public void testExpressionCC() { 82 text = "<%= request."; 83 measureTime(); 84 } 85 86 public void testDeclarationCC() { 87 text = "<%! java."; 88 measureTime(); 89 } 90 91 public void testAllTags() { 92 text = "<"; 93 measureTime(); 94 } 95 96 public void testTagAttribute1() { 97 text = "<%@page "; 98 measureTime(); 99 } 100 101 public void testTagAttribute2() { 102 text = "<jsp:useBean "; 103 measureTime(); 104 } 105 106 public void testAttributeValue1() { 107 text = "<%@page import=\""; 108 measureTime(); 109 } 110 111 public void testAttributeValue2() { 112 text = "<%@include file=\""; 113 measureTime(); 114 } 115 116 public void testAttributeValue3() { 117 text = "<jsp:useBean id=\"bean\" scope=\""; 118 measureTime(); 119 } 120 121 public void testAttributeValue4() { 122 text = "<jsp:useBean id=\"beanInstanceName\" scope=\"session\" class=\""; 123 measureTime(); 124 } 125 126 public void testAttributeValue5() { 127 text = "<jsp:getProperty name=\"bean\" property=\""; 128 measureTime(); 129 } 130 131 public void testAttributeValue6() { 132 text = "<%@taglib prefix=\"d\" tagdir=\""; 133 measureTime(); 134 } 135 136 private EditorOperator editorOperator; 137 138 protected void initialize() { 139 jspOptions().setCaretBlinkRate(0); 140 jspOptions().setStatusBarCaretDelay(0); 142 jspOptions().setCodeFoldingEnable(false); 143 jspOptions().setCompletionAutoPopupDelay(0); 144 jspOptions().setJavaDocAutoPopup(false); 145 javaOptions().setCompletionAutoPopupDelay(0); 146 javaOptions().setJavaDocAutoPopup(false); 147 151 152 new OpenAction().performAPI(new Node(new ProjectsTabOperator(). 153 getProjectRootNode("TestWebProject"),"Web Pages|index.jsp")); 154 editorOperator = new EditorWindowOperator().getEditor("index.jsp"); 155 eventTool().waitNoEvent(1000); 156 waitNoEvent(2000); 157 } 158 159 public void prepare() { 160 editorOperator.activateWindow(); 162 clearTestLine(); 163 editorOperator.setCaretPositionToLine(8); 164 editorOperator.insert(text); 166 eventTool().waitNoEvent(500); 168 } 169 170 public ComponentOperator open(){ 171 repaintManager().setRegionFilter(COMPLETION_DIALOG_FILTER); 172 new ActionNoBlock(null, null, shcut).perform(editorOperator); 174 return null; 175 } 176 177 public void close() { 178 repaintManager().setRegionFilter(null); 179 new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_ESCAPE)). 180 perform(editorOperator); 181 clearTestLine(); 182 } 183 184 protected void shutdown() { 185 super.shutdown(); 186 editorOperator.closeDiscard(); 187 } 188 189 private void clearTestLine() { 190 int linelength = editorOperator.getText(8).length(); 191 if (linelength > 1) 192 editorOperator.delete(8,1,linelength-1); 193 } 194 }
| Popular Tags
|