001: /*
002: * To change this template, choose Tools | Templates
003: * and open the template in the editor.
004: */
005:
006: package gui.action;
007:
008: import gui.Projects;
009: import java.awt.event.KeyEvent;
010: import org.netbeans.jellytools.EditorOperator;
011: import org.netbeans.jellytools.EditorWindowOperator;
012: import org.netbeans.jellytools.ProjectsTabOperator;
013: import org.netbeans.jellytools.actions.Action.Shortcut;
014: import org.netbeans.jellytools.actions.ActionNoBlock;
015: import org.netbeans.jellytools.actions.OpenAction;
016: import org.netbeans.jellytools.nodes.Node;
017: import org.netbeans.jemmy.operators.ComponentOperator;
018: import org.netbeans.performance.test.guitracker.LoggingRepaintManager;
019:
020: /**
021: *
022: * @author Administrator
023: */
024: public class PageUpPageDownScriptingEditor extends
025: org.netbeans.performance.test.utilities.PerformanceTestCase {
026:
027: private boolean pgup;
028: private EditorOperator editorOperator;
029: protected static ProjectsTabOperator projectsTab = null;
030:
031: protected Node fileToBeOpened;
032: protected String testProject;
033: protected String fileName;
034: protected String nodePath;
035:
036: public PageUpPageDownScriptingEditor(String testName) {
037: super (testName);
038: expectedTime = UI_RESPONSE;
039: WAIT_AFTER_OPEN = 200;
040: }
041:
042: public PageUpPageDownScriptingEditor(String testName,
043: String performanceDataName) {
044: super (testName, performanceDataName);
045: expectedTime = UI_RESPONSE;
046: WAIT_AFTER_OPEN = 200;
047: }
048:
049: @Override
050: public void initialize() {
051: EditorOperator.closeDiscardAll();
052:
053: String path = nodePath + "|" + fileName;
054: fileToBeOpened = new Node(getProjectNode(testProject), path);
055: new OpenAction().performAPI(fileToBeOpened);
056: editorOperator = EditorWindowOperator.getEditor(fileName);
057: waitNoEvent(2000);
058:
059: repaintManager().addRegionFilter(
060: LoggingRepaintManager.EDITOR_FILTER);
061: setJavaEditorCaretFilteringOn(); //????
062: ///setEditorCaretFilteringOn(arg0); //Which classes I can use???
063:
064: }
065:
066: protected Node getProjectNode(String projectName) {
067: if (projectsTab == null)
068: projectsTab = new ProjectsTabOperator();
069:
070: return projectsTab.getProjectRootNode(projectName);
071: }
072:
073: @Override
074: public void prepare() {
075: // scroll to the place where we start
076: if (pgup)
077: // press CTRL+END
078: new ActionNoBlock(null, null, new Shortcut(KeyEvent.VK_END,
079: KeyEvent.CTRL_MASK)).perform(editorOperator);
080: else
081: // go to the first line
082: editorOperator.setCaretPositionToLine(1);
083: }
084:
085: @Override
086: public ComponentOperator open() {
087: if (pgup)
088: new ActionNoBlock(null, null, new Shortcut(
089: KeyEvent.VK_PAGE_UP)).perform(editorOperator);
090: else
091: new ActionNoBlock(null, null, new Shortcut(
092: KeyEvent.VK_PAGE_DOWN)).perform(editorOperator);
093: return null;
094: }
095:
096: @Override
097: public void close() {
098: log("close");
099: }
100:
101: @Override
102: public void shutdown() {
103: log("shutdown");
104: super .shutdown();
105: repaintManager().resetRegionFilters();
106: EditorOperator.closeDiscardAll();
107: }
108:
109: public void testPgUp_In_RBEditor() {
110: testProject = Projects.RUBY_PROJECT;
111: fileName = "ruby20kb.rb";
112: nodePath = "Source Files";
113: pgup = true;
114: doMeasurement();
115: }
116:
117: public void testPgDn_In_RBEditor() {
118: testProject = Projects.RUBY_PROJECT;
119: fileName = "ruby20kb.rb";
120: nodePath = "Source Files";
121: pgup = false;
122: doMeasurement();
123: }
124:
125: public void testPgUp_In_RHTMLEditor() {
126: testProject = Projects.RAILS_PROJECT;
127: fileName = "rhtml20kb.rhtml";
128: nodePath = "Views";
129: pgup = true;
130: doMeasurement();
131: }
132:
133: public void testPgDn_In_RHTMLEditor() {
134: testProject = Projects.RAILS_PROJECT;
135: fileName = "rhtml20kb.rhtml";
136: nodePath = "Views";
137: pgup = false;
138: doMeasurement();
139: }
140:
141: public void testPgUp_In_JSEditor() {
142: testProject = Projects.SCRIPTING_PROJECT;
143: nodePath = "Web Pages";
144: fileName = "javascript20kb.js";
145: pgup = true;
146: doMeasurement();
147: }
148:
149: public void testPgDn_In_JSEditor() {
150: testProject = Projects.SCRIPTING_PROJECT;
151: nodePath = "Web Pages";
152: fileName = "javascript20kb.js";
153: pgup = false;
154: doMeasurement();
155: }
156:
157: public void testPgUp_In_CSSEditor() {
158: testProject = Projects.SCRIPTING_PROJECT;
159: nodePath = "Web Pages";
160: fileName = "css20kb.css";
161: pgup = true;
162: doMeasurement();
163: }
164:
165: public void testPgDn_In_CSSEditor() {
166: testProject = Projects.SCRIPTING_PROJECT;
167: nodePath = "Web Pages";
168: fileName = "css20kb.css";
169: pgup = false;
170: doMeasurement();
171: }
172:
173: }
|