001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.test.web.performance;
043:
044: import org.netbeans.jemmy.EventTool;
045: import org.netbeans.modules.editor.html.HTMLKit;
046: import org.netbeans.modules.editor.java.JavaKit;
047: import org.netbeans.modules.editor.options.BaseOptions;
048: import org.netbeans.modules.html.editor.options.HTMLOptions;
049: import org.netbeans.modules.java.editor.options.JavaOptions;
050: import org.netbeans.modules.web.core.syntax.JSPKit;
051: import org.netbeans.modules.web.core.syntax.settings.JSPOptions;
052: import org.netbeans.modules.xml.text.syntax.XMLKit;
053: import org.netbeans.modules.xml.text.syntax.XMLOptions;
054: import org.netbeans.performance.test.utilities.PerformanceTestCase;
055:
056: /**
057: *
058: * @author ms113234
059: */
060: public abstract class WebPerformanceTestCase extends
061: PerformanceTestCase {
062: // Options
063: private JSPOptions jspOptions = null;
064: private JavaOptions javaOptions = null;
065: private HTMLOptions htmlOptions = null;
066: private XMLOptions xmlOptions = null;
067: /* TODO doesn't work after retouche integration
068: private JavaSettings javaSettings = null;
069: */
070: // jsp options
071: private int defCaretBlinkingRate;
072: private boolean defCodeFoldindEnabled;
073: private int defCompletionAutoPopupDelayJsp;
074: private int defFontSize;
075: private boolean defJavaDocAutoPopupJsp;
076: private int defStatusBarCaretDelay;
077: // java options
078: private int defCompletionAutoPopupDelayJava;
079: private boolean defJavaDocAutoPopupJava;
080: // java settings
081: private int defParsingErrors;
082: private EventTool eventTool = null;
083:
084: /**
085: * Creates a new instance of WebPerformanceTestCase
086: * @param testName name of the test
087: */
088: public WebPerformanceTestCase(String testName) {
089: super (testName);
090: init();
091: }
092:
093: /**
094: * Creates a new instance of WebPerformanceTestCase
095: * @param testName name of the test
096: * @param performanceDataName name for measured performance data, measured values are stored to results under this name
097: */
098: public WebPerformanceTestCase(String testName,
099: String performanceDataName) {
100: super (testName, performanceDataName);
101: init();
102: }
103:
104: protected void init() {
105: // timeouts
106: WAIT_AFTER_PREPARE = 1500;
107: WAIT_AFTER_OPEN = 2000;
108: HEURISTIC_FACTOR = -1;
109: // init options
110: jspOptions = (JSPOptions) BaseOptions.getOptions(JSPKit.class);
111: javaOptions = (JavaOptions) BaseOptions
112: .getOptions(JavaKit.class);
113: htmlOptions = (HTMLOptions) BaseOptions
114: .getOptions(HTMLKit.class);
115: xmlOptions = (XMLOptions) BaseOptions.getOptions(XMLKit.class);
116: /* TODO doesn't work after retouche integration
117: javaSettings = JavaSettings.getDefault();
118: */
119: // TODO replace by store/reload whole settings impl
120: // jsp options
121: defCaretBlinkingRate = jspOptions.getCaretBlinkRate();
122: // defCodeFoldindEnabled = jspOptions.getCodeFoldingEnable();
123: defCompletionAutoPopupDelayJsp = jspOptions
124: .getCompletionAutoPopupDelay();
125: defFontSize = jspOptions.getFontSize();
126: defJavaDocAutoPopupJsp = jspOptions.getJavaDocAutoPopup();
127: defStatusBarCaretDelay = jspOptions.getStatusBarCaretDelay();
128: // java options
129: defCompletionAutoPopupDelayJava = javaOptions
130: .getCompletionAutoPopupDelay();
131: defJavaDocAutoPopupJava = javaOptions.getJavaDocAutoPopup();
132: // java settings
133: /* TODO doesn't work after retouche integration
134: defParsingErrors = javaSettings.getParsingErrors();
135: */
136: // turn off caret blinking
137: jspOptions.setCaretBlinkRate(0);
138: javaOptions.setCaretBlinkRate(0);
139: htmlOptions.setCaretBlinkRate(0);
140: xmlOptions.setCaretBlinkRate(0);
141: // try {
142: // ByteArrayOutputStream baos = new ByteArrayOutputStream();
143: // // save default JSP Options
144: // ObjectOutputStream out = new ObjectOutputStream(baos);
145: // jspOptions.writeExternal(out);
146: // defJspOptions = baos.toByteArray();
147: // out.reset();
148: // // save default Java Options
149: // javaOptions.writeExternal(out);
150: // defJavaOptions = baos.toByteArray();
151: // out.reset();
152: // // save default Java Settings
153: // javaSettings.writeExternal(out);
154: // defJavaSettings = baos.toByteArray();
155: // out.reset();
156: // } catch (IOException ioe) {
157: // fail(ioe);
158: // }
159:
160: }
161:
162: protected void resetOptions() {
163: // TODO replace by store/reload whole settings impl
164: // jspOptions.setCodeFoldingEnable(defCodeFoldindEnabled);
165: jspOptions
166: .setCompletionAutoPopupDelay(defCompletionAutoPopupDelayJsp);
167: jspOptions.setFontSize(defFontSize);
168: jspOptions.setJavaDocAutoPopup(defJavaDocAutoPopupJsp);
169: jspOptions.setStatusBarCaretDelay(defStatusBarCaretDelay);
170: // java options
171: javaOptions
172: .setCompletionAutoPopupDelay(defCompletionAutoPopupDelayJava);
173: javaOptions.setJavaDocAutoPopup(defJavaDocAutoPopupJava);
174: // java settings
175: /* TODO doesn't work after retouche integration
176: javaSettings.setParsingErrors(defParsingErrors);
177: */
178: // try {
179: // System.out.println("defJavaSettings= " + defJavaSettings.length);
180: // System.out.println("defJavaOptions= " + defJavaOptions.length);
181: // System.out.println("defJspOptions= " + defJspOptions.length);
182: //
183: // // java settings
184: // ByteArrayInputStream bais = new ByteArrayInputStream(defJavaSettings);
185: // ObjectInputStream in = new ObjectInputStream(bais);
186: // javaSettings.readExternal(in);
187: // // java options
188: // bais = new ByteArrayInputStream(defJavaOptions);
189: // in = new ObjectInputStream(bais);
190: // javaOptions.readExternal(in);
191: // // jsp options
192: // bais = new ByteArrayInputStream(defJspOptions);
193: // in = new ObjectInputStream(bais);
194: // jspOptions.readExternal(in);
195: // } catch (Exception e) {
196: // fail(e);
197: // }
198: }
199:
200: protected JSPOptions jspOptions() {
201: return jspOptions;
202: }
203:
204: protected JavaOptions javaOptions() {
205: return javaOptions;
206: }
207:
208: /* TODO doesn't work after retouche integration
209: protected JavaSettings javaSettings() {
210: return javaSettings;
211: }
212: */
213:
214: protected void shutdown() {
215: resetOptions();
216: repaintManager().resetRegionFilters();
217: }
218:
219: protected EventTool eventTool() {
220: if (eventTool == null) {
221: eventTool = new EventTool();
222: }
223: return eventTool;
224: }
225:
226: public String toString() {
227: return renamedTestCaseName.toString();
228: }
229: }
|