|
What this is
Other links
The source code
/*
* Sun Public License Notice
*
* The contents of this file are subject to the Sun Public License
* Version 1.0 (the "License"). You may not use this file except in
* compliance with the License. A copy of the License is available at
* http://www.sun.com/
*
* The Original Code is NetBeans. The Initial Developer of the Original
* Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.openide.util.actions;
import org.netbeans.junit.*;
import junit.textui.TestRunner;
import org.openide.nodes.CookieSet;
import org.openide.nodes.Node;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import org.openide.util.lookup.AbstractLookup;
import org.openide.cookies.OpenCookie;
/** Simulation for bug 40734.
*
* @author Jaroslav Tulach
*/
public class CookieActionIsTooSlowTest extends NbTestCase implements java.beans.PropertyChangeListener {
static {
// Get Lookup right to begin with.
ActionsInfraHid.class.getName();
}
public CookieActionIsTooSlowTest (String name) {
super(name);
}
public static void main(String[] args) {
TestRunner.run(new NbTestSuite(CookieActionIsTooSlowTest.class));
}
private SimpleCookieAction a1;
private Node[] arr;
private int propertyChange;
protected void setUp() throws Exception {
a1 = (SimpleCookieAction)SystemAction.get(SimpleCookieAction.class);
a1.addPropertyChangeListener (this);
int count = 10;
arr = new Node[count];
for (int i = 0; i < count; i++) {
arr[i] = new org.openide.nodes.FilterNode (new CookieNode ("n" + i));
}
}
protected void tearDown () throws Exception {
a1.removePropertyChangeListener (this);
}
/**
* in order to run in awt event queue
* fix for #39789
*/
protected boolean runInEQ() {
return true;
}
public void propertyChange (java.beans.PropertyChangeEvent ev) {
propertyChange++;
}
public void testSelectionOfMoreNodesMakesToManyCallsToActionEnableMethodIssue40734 () throws Exception {
assertFalse ("No nodes are enabled", a1.isEnabled ());
assertEquals ("One call to enabled method", 1, a1.queried);
a1.queried = 0;
ActionsInfraHid.UT.setCurrentNodes (arr);
assertTrue ("All nodes have open cookie", a1.isEnabled ());
assertEquals ("The enable method has been called once", 1, a1.queried);
assertEquals ("Listener changed once", 1, propertyChange);
}
public static class SimpleCookieAction extends CookieAction {
private int queried;
protected int mode() {
return MODE_ALL;
}
protected Class[] cookieClasses() {
return new Class[] {OpenCookie.class};
}
public static final java.util.List runOn = new java.util.ArrayList(); // List
|
| ... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.