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: * The Original Software is NetBeans.
026: * The Initial Developer of the Original Software is Sun Microsystems, Inc.
027: * Portions created by Sun Microsystems, Inc. are Copyright (C) 2003
028: * 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: * Contributor(s): Sun Microsystems, Inc.
042: */
043:
044: package gui.debuggercore;
045:
046: import java.io.File;
047: import junit.textui.TestRunner;
048: import org.netbeans.jellytools.*;
049: import org.netbeans.jellytools.actions.ActionNoBlock;
050: import org.netbeans.jellytools.actions.OpenAction;
051: import org.netbeans.jellytools.modules.debugger.actions.RunToCursorAction;
052: import org.netbeans.jellytools.nodes.SourcePackagesNode;
053: import org.netbeans.jemmy.EventTool;
054: import org.netbeans.jemmy.JemmyProperties;
055: import org.netbeans.jemmy.Waitable;
056: import org.netbeans.jemmy.Waiter;
057: import org.netbeans.jemmy.operators.JTextFieldOperator;
058: import org.netbeans.jemmy.util.PNGEncoder;
059: import org.netbeans.junit.NbTestSuite;
060: import org.openide.nodes.Node;
061:
062: /**
063: *
064: * @author ehucka
065: */
066: public class Watches extends JellyTestCase {
067:
068: /**
069: *
070: * @param name
071: */
072: public Watches(String name) {
073: super (name);
074: }
075:
076: /**
077: *
078: * @param args
079: */
080: public static void main(String[] args) {
081: TestRunner.run(suite());
082: }
083:
084: /**
085: *
086: * @return
087: */
088: public static NbTestSuite suite() {
089: NbTestSuite suite = new NbTestSuite();
090: suite.addTest(new Watches("testWatchesPublicVariables"));
091: suite.addTest(new Watches("testWatchesProtectedVariables"));
092: suite.addTest(new Watches("testWatchesPrivateVariables"));
093: suite
094: .addTest(new Watches(
095: "testWatchesPackagePrivateVariables"));
096: suite.addTest(new Watches("testWatchesFiltersBasic"));
097: suite.addTest(new Watches("testWatchesFiltersLinkedList"));
098: suite.addTest(new Watches("testWatchesFiltersArrayList"));
099: suite.addTest(new Watches("testWatchesFiltersVector"));
100: suite.addTest(new Watches("testWatchesFiltersHashMap"));
101: suite.addTest(new Watches("testWatchesFiltersHashtable"));
102: suite.addTest(new Watches("testWatchesFiltersTreeMap"));
103: suite.addTest(new Watches("testWatchesFiltersTreeSet"));
104: suite.addTest(new Watches("testWatchesFilters1DArray"));
105: suite.addTest(new Watches("testWatchesFilters2DArray"));
106: suite.addTest(new Watches("testWatchesValues"));
107: return suite;
108: }
109:
110: /**
111: *
112: */
113: public void setUp() {
114: System.out.println("######## " + getName() + " #######");
115: if ("testWatchesPublicVariables".equals(getName())) {
116: //open source
117: org.netbeans.jellytools.nodes.Node beanNode = new org.netbeans.jellytools.nodes.Node(
118: new SourcePackagesNode(Utilities.testProjectName),
119: "examples.advanced|MemoryView.java"); //NOI18N
120: new OpenAction().performAPI(beanNode); // NOI18N
121: EditorOperator op = new EditorOperator("MemoryView.java");
122: Utilities.setCaret(op, 76);
123: new RunToCursorAction().perform();
124: Utilities.getDebugToolbar().waitComponentVisible(true);
125: Utilities.waitDebuggerConsole(
126: "Thread main stopped at MemoryView.java:76", 0);
127: }
128: }
129:
130: /**
131: *
132: */
133: public void tearDown() {
134: JemmyProperties.getCurrentOutput().printTrace("\nteardown\n");
135: if ("testWatchesValues".equals(getName())) {
136: Utilities.endAllSessions();
137: }
138: Utilities.deleteAllWatches();
139: }
140:
141: /**
142: *
143: */
144: public void testWatchesPublicVariables() throws Throwable {
145: try {
146: createWatch("Vpublic");
147: createWatch("Spublic");
148: createWatch("inheritedVpublic");
149: createWatch("inheritedSpublic");
150: Utilities.showDebuggerView(Utilities.watchesViewTitle);
151: TreeTableOperator jTableOperator = new TreeTableOperator(
152: new TopComponentOperator(Utilities.watchesViewTitle));
153: checkTTVLine(jTableOperator, 0, "Vpublic", "String",
154: "\"Public Variable\"");
155: checkTTVLine(jTableOperator, 1, "Spublic", "String",
156: "\"Public Variable\"");
157: checkTTVLine(jTableOperator, 2, "inheritedVpublic",
158: "String", "\"Inherited Public Variable\"");
159: checkTTVLine(jTableOperator, 3, "inheritedSpublic",
160: "String", "\"Inherited Public Variable\"");
161: } catch (Throwable th) {
162: Utilities.captureScreen(this );
163: throw th;
164: }
165: }
166:
167: /**
168: *
169: */
170: public void testWatchesProtectedVariables() throws Throwable {
171: try {
172: createWatch("Vprotected");
173: createWatch("Sprotected");
174: createWatch("inheritedVprotected");
175: createWatch("inheritedSprotected");
176: Utilities.showDebuggerView(Utilities.watchesViewTitle);
177: TreeTableOperator jTableOperator = new TreeTableOperator(
178: new TopComponentOperator(Utilities.watchesViewTitle));
179: checkTTVLine(jTableOperator, 0, "Vprotected", "String",
180: "\"Protected Variable\"");
181: checkTTVLine(jTableOperator, 1, "Sprotected", "String",
182: "\"Protected Variable\"");
183: checkTTVLine(jTableOperator, 2, "inheritedVprotected",
184: "String", "\"Inherited Protected Variable\"");
185: checkTTVLine(jTableOperator, 3, "inheritedSprotected",
186: "String", "\"Inherited Protected Variable\"");
187: } catch (Throwable th) {
188: Utilities.captureScreen(this );
189: throw th;
190: }
191: }
192:
193: /**
194: *
195: */
196: public void testWatchesPrivateVariables() throws Throwable {
197: try {
198: createWatch("Vprivate");
199: createWatch("Sprivate");
200: createWatch("inheritedVprivate");
201: createWatch("inheritedSprivate");
202: Utilities.showDebuggerView(Utilities.watchesViewTitle);
203: TreeTableOperator jTableOperator = new TreeTableOperator(
204: new TopComponentOperator(Utilities.watchesViewTitle));
205: checkTTVLine(jTableOperator, 0, "Vprivate", "String",
206: "\"Private Variable\"");
207: checkTTVLine(jTableOperator, 1, "Sprivate", "String",
208: "\"Private Variable\"");
209: checkTTVLine(jTableOperator, 2, "inheritedVprivate",
210: "String", "\"Inherited Private Variable\"");
211: checkTTVLine(jTableOperator, 3, "inheritedSprivate",
212: "String", "\"Inherited Private Variable\"");
213: } catch (Throwable th) {
214: Utilities.captureScreen(this );
215: throw th;
216: }
217: }
218:
219: /**
220: *
221: */
222: public void testWatchesPackagePrivateVariables() throws Throwable {
223: try {
224: createWatch("VpackagePrivate");
225: createWatch("SpackagePrivate");
226: createWatch("inheritedVpackagePrivate");
227: createWatch("inheritedSpackagePrivate");
228: Utilities.showDebuggerView(Utilities.watchesViewTitle);
229: TreeTableOperator jTableOperator = new TreeTableOperator(
230: new TopComponentOperator(Utilities.watchesViewTitle));
231: checkTTVLine(jTableOperator, 0, "VpackagePrivate",
232: "String", "\"Package-private Variable\"");
233: checkTTVLine(jTableOperator, 1, "SpackagePrivate",
234: "String", "\"Package-private Variable\"");
235: checkTTVLine(jTableOperator, 2, "inheritedVpackagePrivate",
236: "String", "\"Inherited Package-private Variable\"");
237: checkTTVLine(jTableOperator, 3, "inheritedSpackagePrivate",
238: "String", "\"Inherited Package-private Variable\"");
239: } catch (Throwable th) {
240: Utilities.captureScreen(this );
241: throw th;
242: }
243: }
244:
245: /**
246: *
247: */
248: public void testWatchesFiltersBasic() throws Throwable {
249: try {
250: createWatch("1==1");
251: createWatch("1==0");
252: createWatch("Integer.toString(10)");
253: createWatch("clazz");
254: createWatch("n");
255: Utilities.showDebuggerView(Utilities.watchesViewTitle);
256: TreeTableOperator jTableOperator = new TreeTableOperator(
257: new TopComponentOperator(Utilities.watchesViewTitle));
258: checkTTVLine(jTableOperator, 0, "1==1", "boolean", "true");
259: checkTTVLine(jTableOperator, 1, "1==0", "boolean", "false");
260: checkTTVLine(jTableOperator, 2, "Integer.toString(10)",
261: "String", "\"10\"");
262: checkTTVLine(jTableOperator, 3, "clazz", "Class",
263: "class java.lang.Runtime");
264: assertTrue("Node \'clazz\' has no child nodes",
265: hasChildNodes("clazz", jTableOperator));
266: checkTTVLine(jTableOperator, 4, "n", "int", "50");
267: } catch (Throwable th) {
268: Utilities.captureScreen(this );
269: throw th;
270: }
271: }
272:
273: /**
274: *
275: */
276: public void testWatchesFiltersLinkedList() throws Throwable {
277: try {
278: createWatch("llist");
279: createWatch("llist.toString()");
280: createWatch("llist.getFirst()");
281: createWatch("llist.getLast()");
282: createWatch("llist.get(1)");
283: Utilities.showDebuggerView(Utilities.watchesViewTitle);
284: TreeTableOperator jTableOperator = new TreeTableOperator(
285: new TopComponentOperator(Utilities.watchesViewTitle));
286: checkTTVLine(jTableOperator, 0, "llist", "LinkedList", null);
287: assertTrue("Node \'llist\' has no child nodes",
288: hasChildNodes("llist", jTableOperator));
289: checkTTVLine(
290: jTableOperator,
291: 1,
292: "llist.toString()",
293: "String",
294: "\"[0. item, 1. item, 2. item, 3. item, 4. item, 5. item, 6. item, 7. item, 8. item, 9. item, 10. item, 11. item, 12. item, 13. item, 14. item, 15. item, 16. item, 17. item, 18. item, 19. item, 20. item, 21. item, 22. item, 23. item, 24. item, 25. item, 26. item, 27. item, 28. item, 29. item, 30. item, 31. item, 32. item, 33. item, 34. item, 35. item, 36. item, 37. item, 38. item, 39. item, 40. item, 41. item, 42. item, 43. item, 44. item, 45. item, 46. item, 47. item, 48. item, 49. item]\"");
295: checkTTVLine(jTableOperator, 2, "llist.getFirst()",
296: "String", "\"0. item\"");
297: checkTTVLine(jTableOperator, 3, "llist.getLast()",
298: "String", "\"49. item\"");
299: checkTTVLine(jTableOperator, 4, "llist.get(1)", "String",
300: "\"1. item\"");
301: } catch (Throwable th) {
302: Utilities.captureScreen(this );
303: throw th;
304: }
305: }
306:
307: /**
308: *
309: */
310: public void testWatchesFiltersArrayList() throws Throwable {
311: try {
312: createWatch("alist");
313: createWatch("alist.toString()");
314: createWatch("alist.get(2)");
315: Utilities.showDebuggerView(Utilities.watchesViewTitle);
316: TreeTableOperator jTableOperator = new TreeTableOperator(
317: new TopComponentOperator(Utilities.watchesViewTitle));
318: checkTTVLine(jTableOperator, 0, "alist", "ArrayList", null);
319: assertTrue("Node \'alist\' has no child nodes",
320: hasChildNodes("alist", jTableOperator));
321: checkTTVLine(
322: jTableOperator,
323: 1,
324: "alist.toString()",
325: "String",
326: "\"[0. item, 1. item, 2. item, 3. item, 4. item, 5. item, 6. item, 7. item, 8. item, 9. item, 10. item, 11. item, 12. item, 13. item, 14. item, 15. item, 16. item, 17. item, 18. item, 19. item, 20. item, 21. item, 22. item, 23. item, 24. item, 25. item, 26. item, 27. item, 28. item, 29. item, 30. item, 31. item, 32. item, 33. item, 34. item, 35. item, 36. item, 37. item, 38. item, 39. item, 40. item, 41. item, 42. item, 43. item, 44. item, 45. item, 46. item, 47. item, 48. item, 49. item]\"");
327: checkTTVLine(jTableOperator, 2, "alist.get(2)", "String",
328: "\"2. item\"");
329: } catch (Throwable th) {
330: Utilities.captureScreen(this );
331: throw th;
332: }
333: }
334:
335: /**
336: *
337: */
338: public void testWatchesFiltersVector() throws Throwable {
339: try {
340: createWatch("vec");
341: createWatch("vec.toString()");
342: createWatch("vec.get(3)");
343: Utilities.showDebuggerView(Utilities.watchesViewTitle);
344: TreeTableOperator jTableOperator = new TreeTableOperator(
345: new TopComponentOperator(Utilities.watchesViewTitle));
346: checkTTVLine(jTableOperator, 0, "vec", "Vector", null);
347: assertTrue("Node \'vec\' has no child nodes",
348: hasChildNodes("vec", jTableOperator));
349: checkTTVLine(
350: jTableOperator,
351: 1,
352: "vec.toString()",
353: "String",
354: "\"[0. item, 1. item, 2. item, 3. item, 4. item, 5. item, 6. item, 7. item, 8. item, 9. item, 10. item, 11. item, 12. item, 13. item, 14. item, 15. item, 16. item, 17. item, 18. item, 19. item, 20. item, 21. item, 22. item, 23. item, 24. item, 25. item, 26. item, 27. item, 28. item, 29. item, 30. item, 31. item, 32. item, 33. item, 34. item, 35. item, 36. item, 37. item, 38. item, 39. item, 40. item, 41. item, 42. item, 43. item, 44. item, 45. item, 46. item, 47. item, 48. item, 49. item]\"");
355: checkTTVLine(jTableOperator, 2, "vec.get(3)", "String",
356: "\"3. item\"");
357: } catch (Throwable th) {
358: Utilities.captureScreen(this );
359: throw th;
360: }
361: }
362:
363: /**
364: *
365: */
366: public void testWatchesFiltersHashMap() throws Throwable {
367: try {
368: createWatch("hmap");
369: createWatch("hmap.containsKey(\"4\")");
370: createWatch("hmap.get(\"5\")");
371: createWatch("hmap.put(\"6\",\"test\")");
372: Utilities.showDebuggerView(Utilities.watchesViewTitle);
373: TreeTableOperator jTableOperator = new TreeTableOperator(
374: new TopComponentOperator(Utilities.watchesViewTitle));
375: checkTTVLine(jTableOperator, 0, "hmap", "HashMap", null);
376: assertTrue("Node \'hmap\' has no child nodes",
377: hasChildNodes("hmap", jTableOperator));
378: checkTTVLine(jTableOperator, 1, "hmap.containsKey(\"4\")",
379: "boolean", "true");
380: checkTTVLine(jTableOperator, 2, "hmap.get(\"5\")",
381: "String", "\"5. item\"");
382: checkTTVLine(jTableOperator, 3, "hmap.put(\"6\",\"test\")",
383: "String", "\"6. item\"");
384: } catch (Throwable th) {
385: Utilities.captureScreen(this );
386: throw th;
387: }
388: }
389:
390: /**
391: *
392: */
393: public void testWatchesFiltersHashtable() throws Throwable {
394: try {
395: createWatch("htab");
396: createWatch("htab.containsKey(\"7\")");
397: createWatch("htab.get(\"9\")");
398: createWatch("htab.put(\"10\", \"test\")");
399: Utilities.showDebuggerView(Utilities.watchesViewTitle);
400: TreeTableOperator jTableOperator = new TreeTableOperator(
401: new TopComponentOperator(Utilities.watchesViewTitle));
402: checkTTVLine(jTableOperator, 0, "htab", "Hashtable", null);
403: assertTrue("Node \'htab\' has no child nodes",
404: hasChildNodes("htab", jTableOperator));
405: checkTTVLine(jTableOperator, 1, "htab.containsKey(\"7\")",
406: "boolean", "true");
407: checkTTVLine(jTableOperator, 2, "htab.get(\"9\")",
408: "String", "\"9. item\"");
409: checkTTVLine(jTableOperator, 3,
410: "htab.put(\"10\", \"test\")", "String",
411: "\"10. item\"");
412: } catch (Throwable th) {
413: Utilities.captureScreen(this );
414: throw th;
415: }
416: }
417:
418: /**
419: *
420: */
421: public void testWatchesFiltersTreeMap() throws Throwable {
422: try {
423: createWatch("tmap");
424: createWatch("tmap.containsKey(\"11\")");
425: createWatch("tmap.get(\"12\")");
426: createWatch("tmap.put(\"13\",\"test\")");
427: Utilities.showDebuggerView(Utilities.watchesViewTitle);
428: TreeTableOperator jTableOperator = new TreeTableOperator(
429: new TopComponentOperator(Utilities.watchesViewTitle));
430: checkTTVLine(jTableOperator, 0, "tmap", "TreeMap", null);
431: assertTrue("Node \'tmap\' has no child nodes",
432: hasChildNodes("tmap", jTableOperator));
433: checkTTVLine(jTableOperator, 1, "tmap.containsKey(\"11\")",
434: "boolean", "true");
435: checkTTVLine(jTableOperator, 2, "tmap.get(\"12\")",
436: "String", "\"12. item\"");
437: checkTTVLine(jTableOperator, 3,
438: "tmap.put(\"13\",\"test\")", "String",
439: "\"13. item\"");
440: } catch (Throwable th) {
441: Utilities.captureScreen(this );
442: throw th;
443: }
444: }
445:
446: /**
447: *
448: */
449: public void testWatchesFiltersTreeSet() throws Throwable {
450: try {
451: createWatch("tset");
452: createWatch("tset.contains(\"14. item\")");
453: createWatch("tset.iterator()");
454: Utilities.showDebuggerView(Utilities.watchesViewTitle);
455: TreeTableOperator jTableOperator = new TreeTableOperator(
456: new TopComponentOperator(Utilities.watchesViewTitle));
457: checkTTVLine(jTableOperator, 0, "tset", "TreeSet", null);
458: assertTrue("Node \'tset\' has no child nodes",
459: hasChildNodes("tset", jTableOperator));
460: checkTTVLine(jTableOperator, 1,
461: "tset.contains(\"14. item\")", "boolean", "true");
462: checkTTVLine(jTableOperator, 2, "tset.iterator()",
463: "TreeMap$KeyIterator", null);
464: } catch (Throwable th) {
465: Utilities.captureScreen(this );
466: throw th;
467: }
468: }
469:
470: /**
471: *
472: */
473: public void testWatchesFilters1DArray() throws Throwable {
474: try {
475: createWatch("policko");
476: createWatch("policko.length");
477: createWatch("policko[1]");
478: createWatch("policko[10]");
479: createWatch("pole");
480: createWatch("pole.length");
481: createWatch("pole[1]");
482: Utilities.showDebuggerView(Utilities.watchesViewTitle);
483: TreeTableOperator jTableOperator = new TreeTableOperator(
484: new TopComponentOperator(Utilities.watchesViewTitle));
485: checkTTVLine(jTableOperator, 0, "policko", "int[]", null);
486: assertTrue("Node \'policko\' has no child nodes",
487: hasChildNodes("policko", jTableOperator));
488: checkTTVLine(jTableOperator, 1, "policko.length", "int",
489: "5");
490: checkTTVLine(jTableOperator, 2, "policko[1]", "int", "2");
491: checkTTVLine(jTableOperator, 3, "policko[10]", null,
492: ">Array index \"10\" is out of range <0,4><");
493: checkTTVLine(jTableOperator, 4, "pole", "int[]", null);
494: assertTrue("Node \'pole\' has no child nodes",
495: hasChildNodes("pole", jTableOperator));
496: checkTTVLine(jTableOperator, 5, "pole.length", "int", "50");
497: checkTTVLine(jTableOperator, 6, "pole[1]", "int", "0");
498: } catch (Throwable th) {
499: Utilities.captureScreen(this );
500: throw th;
501: }
502: }
503:
504: /**
505: *
506: */
507: public void testWatchesFilters2DArray() throws Throwable {
508: try {
509: createWatch("d2");
510: createWatch("d2.length");
511: createWatch("d2[1]");
512: createWatch("d2[1].length");
513: createWatch("d2[1][1]");
514: createWatch("d2[15].length");
515: Utilities.showDebuggerView(Utilities.watchesViewTitle);
516: TreeTableOperator jTableOperator = new TreeTableOperator(
517: new TopComponentOperator(Utilities.watchesViewTitle));
518: checkTTVLine(jTableOperator, 0, "d2", "int[][]", null);
519: assertTrue("Node \'d2\' has no child nodes", hasChildNodes(
520: "d2", jTableOperator));
521: checkTTVLine(jTableOperator, 1, "d2.length", "int", "10");
522: checkTTVLine(jTableOperator, 2, "d2[1]", "int[]", null);
523: assertTrue("Node \'d2[1]\' has no child nodes",
524: hasChildNodes("d2[1]", jTableOperator));
525: checkTTVLine(jTableOperator, 3, "d2[1].length", "int", "20");
526: checkTTVLine(jTableOperator, 4, "d2[1][1]", "int", "0");
527: checkTTVLine(jTableOperator, 5, "d2[15].length", null,
528: ">Array index \"15\" is out of range <0,9><");
529: } catch (Throwable th) {
530: Utilities.captureScreen(this );
531: throw th;
532: }
533: }
534:
535: /**
536: *
537: */
538: public void testWatchesValues() throws Throwable {
539: try {
540: EditorOperator op = new EditorOperator("MemoryView.java");
541: Utilities.setCaret(op, 104);
542: new RunToCursorAction().perform();
543: MainWindowOperator.getDefault().waitStatusText(
544: "Thread main stopped at MemoryView.java:104.");
545:
546: createWatch("free");
547: createWatch("taken");
548: createWatch("total");
549: createWatch("this");
550:
551: Utilities.showDebuggerView(Utilities.watchesViewTitle);
552: TreeTableOperator jTableOperator = new TreeTableOperator(
553: new TopComponentOperator(Utilities.watchesViewTitle));
554: Node.Property property;
555: int count = 0;
556:
557: try {
558: if (!("free".equals(jTableOperator.getValueAt(count, 0)
559: .toString())))
560: assertTrue(
561: "Watch for expression \'free\' was not created",
562: false);
563: property = (Node.Property) jTableOperator.getValueAt(
564: count, 1);
565: if (!("long".equals(property.getValue())))
566: assertTrue("Watch type for expression \'free\' is "
567: + property.getValue() + ", should be long",
568: false);
569: property = (Node.Property) jTableOperator.getValueAt(
570: count++, 2);
571: long free = Long.parseLong(property.getValue()
572: .toString());
573:
574: if (!("taken".equals(jTableOperator
575: .getValueAt(count, 0).toString())))
576: assertTrue(
577: "Watch for expression \'taken\' was not created",
578: false);
579: property = (Node.Property) jTableOperator.getValueAt(
580: count, 1);
581: if (!("int".equals(property.getValue())))
582: assertTrue(
583: "Watch type for expression \'taken\' is "
584: + property.getValue()
585: + ", should be long", false);
586: property = (Node.Property) jTableOperator.getValueAt(
587: count++, 2);
588: long taken = Long.parseLong(property.getValue()
589: .toString());
590:
591: if (!("total".equals(jTableOperator
592: .getValueAt(count, 0).toString())))
593: assertTrue(
594: "Watch for expression \'total\' was not created",
595: false);
596: property = (Node.Property) jTableOperator.getValueAt(
597: count, 1);
598: if (!("long".equals(property.getValue())))
599: assertTrue(
600: "Watch type for expression \'total\' is "
601: + property.getValue()
602: + ", should be long", false);
603: property = (Node.Property) jTableOperator.getValueAt(
604: count++, 2);
605: long total = Long.parseLong(property.getValue()
606: .toString());
607:
608: assertTrue(
609: "Watches values does not seem to be correct (total != free + taken)",
610: total == free + taken);
611:
612: if (!("this".equals(jTableOperator.getValueAt(count, 0)
613: .toString())))
614: assertTrue(
615: "Watch for expression \'this\' was not created",
616: false);
617: property = (Node.Property) jTableOperator.getValueAt(
618: count, 1);
619: if (!("MemoryView".equals(property.getValue())))
620: assertTrue("Watch type for expression \'this\' is "
621: + property.getValue()
622: + ", should be MemoryView", false);
623: assertTrue("Watch this has no child nodes",
624: hasChildNodes("this", jTableOperator));
625: } catch (java.lang.IllegalAccessException e1) {
626: assertTrue(e1.getMessage(), false);
627: } catch (java.lang.reflect.InvocationTargetException e2) {
628: assertTrue(e2.getMessage(), false);
629: }
630: } catch (Throwable th) {
631: Utilities.captureScreen(this );
632: throw th;
633: }
634: }
635:
636: /**
637: *
638: * @param exp
639: */
640: protected void createWatch(String exp) {
641: new ActionNoBlock(Utilities.runMenu + "|"
642: + Utilities.newWatchItem, null).perform();
643: //new ActionNoBlock(null, null, Utilities.newWatchShortcut).performShortcut();
644: NbDialogOperator dialog = new NbDialogOperator(
645: Utilities.newWatchTitle);
646: new JTextFieldOperator(dialog, 0).setText(exp);
647: dialog.ok();
648: try {
649: new Waiter(new Waitable() {
650: public Object actionProduced(Object dialog) {
651: NbDialogOperator op = (NbDialogOperator) dialog;
652: if (!op.isVisible()) {
653: return Boolean.TRUE;
654: }
655: return null;
656: }
657:
658: public String getDescription() {
659: return "Wait new watch dialog is closed";
660: }
661: }).waitAction(dialog);
662: } catch (InterruptedException ex) {
663: ex.printStackTrace();
664: }
665: }
666:
667: /**
668: *
669: * @param table
670: * @param lineNumber
671: * @param name
672: * @param type
673: * @param value
674: */
675: protected void checkTTVLine(TreeTableOperator table,
676: int lineNumber, String name, String type, String value) {
677: try {
678: table.scrollToCell(lineNumber, 0);
679: org.openide.nodes.Node.Property property;
680: String string = null;
681: assertTrue("Node " + name
682: + " not displayed in Watches view", name
683: .equals(table.getValueAt(lineNumber, 0).toString()));
684: property = (org.openide.nodes.Node.Property) table
685: .getValueAt(lineNumber, 1);
686: string = property.getValue().toString();
687: int maxWait = 100;
688: while (string.equals(Utilities.evaluatingPropertyText)
689: && maxWait > 0) {
690: new EventTool().waitNoEvent(300);
691: maxWait--;
692: }
693: assertTrue("Node " + name
694: + " has wrong type in Watches view (displayed: "
695: + string + ", expected: " + type + ")",
696: (type == null) || type.length() == 0
697: || type.equals(string));
698: property = (org.openide.nodes.Node.Property) table
699: .getValueAt(lineNumber, 2);
700: string = property.getValue().toString();
701: maxWait = 100;
702: while (string.equals(Utilities.evaluatingPropertyText)
703: && maxWait > 0) {
704: new EventTool().waitNoEvent(300);
705: maxWait--;
706: }
707: assertTrue("Node " + name
708: + " has wrong value in Watches view (displayed: "
709: + string + ", expected: " + value + ")",
710: (type == null) || !type.equals(string));
711: } catch (java.lang.IllegalAccessException e1) {
712: assertTrue(e1.getMessage(), false);
713: } catch (java.lang.reflect.InvocationTargetException e2) {
714: assertTrue(e2.getMessage(), false);
715: }
716: }
717:
718: protected boolean hasChildNodes(String nodePath,
719: TreeTableOperator jTableOperator) {
720: org.netbeans.jellytools.nodes.Node node = new org.netbeans.jellytools.nodes.Node(
721: jTableOperator.tree(), nodePath);
722: node.select();
723: return !node.isLeaf();
724: }
725: }
|