author | Jaroslav Tulach <jtulach@netbeans.org> |
Sun, 06 Oct 2013 22:05:14 +0200 | |
changeset 407 | e1439046d96e |
parent 128 | 8ef997796d0a |
permissions | -rw-r--r-- |
jtulach@0 | 1 |
/* |
jtulach@0 | 2 |
* Sun Public License Notice |
jtulach@0 | 3 |
* |
jtulach@0 | 4 |
* The contents of this file are subject to the Sun Public License |
jtulach@0 | 5 |
* Version 1.0 (the "License"). You may not use this file except in |
jtulach@0 | 6 |
* compliance with the License. A copy of the License is available at |
jtulach@0 | 7 |
* http://www.sun.com/ |
jtulach@0 | 8 |
* |
jtulach@0 | 9 |
* The Original Code is NetBeans. The Initial Developer of the Original |
jtulach@36 | 10 |
* Code is Jaroslav Tulach. Portions Copyright 2007 Jaroslav Tulach. |
jtulach@36 | 11 |
* All Rights Reserved. |
jtulach@0 | 12 |
*/ |
jtulach@0 | 13 |
|
jtulach@287 | 14 |
package org.apidesign.friendpackage.impl; |
jtulach@0 | 15 |
|
jtulach@0 | 16 |
import javax.swing.event.ChangeEvent; |
jtulach@287 | 17 |
import javax.swing.event.ChangeListener; |
jtulach@0 | 18 |
import junit.framework.TestCase; |
jtulach@287 | 19 |
import org.apidesign.friendpackage.api.Item; |
jtulach@0 | 20 |
|
jtulach@0 | 21 |
/** |
jtulach@0 | 22 |
* |
jtulach@0 | 23 |
* @author Jaroslav Tulach |
jtulach@0 | 24 |
*/ |
jtulach@0 | 25 |
public class AccessorTest extends TestCase |
jtulach@0 | 26 |
implements ChangeListener { |
jtulach@0 | 27 |
|
jtulach@0 | 28 |
private int cnt; |
jtulach@0 | 29 |
|
jtulach@0 | 30 |
public AccessorTest(String testName) { |
jtulach@0 | 31 |
super(testName); |
jtulach@0 | 32 |
} |
jtulach@0 | 33 |
|
jtulach@0 | 34 |
public void testGetTheItemAttachListenerChangeValue() { |
jtulach@3 | 35 |
// BEGIN: design.less.friend.use |
jtulach@128 | 36 |
Item item = Accessor.getDefault().newItem(); |
jtulach@0 | 37 |
assertNotNull("Some item is really created", item); |
jtulach@0 | 38 |
|
jtulach@128 | 39 |
Accessor.getDefault().addChangeListener(item, this); |
jtulach@3 | 40 |
// END: design.less.friend.use |
jtulach@0 | 41 |
|
jtulach@0 | 42 |
item.setValue(10); |
jtulach@0 | 43 |
assertEquals("Value is 10", 10, item.getValue()); |
jtulach@0 | 44 |
cnt = 0; |
jtulach@0 | 45 |
item.setValue(7); |
jtulach@0 | 46 |
assertEquals("Now it is 7", 7, item.getValue()); |
jtulach@0 | 47 |
|
jtulach@0 | 48 |
assertEquals("There was one change", 1, cnt); |
jtulach@0 | 49 |
} |
jtulach@0 | 50 |
|
jtulach@0 | 51 |
public void stateChanged(ChangeEvent e) { |
jtulach@0 | 52 |
cnt++; |
jtulach@0 | 53 |
} |
jtulach@0 | 54 |
} |