-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use collect in ListenersTrait instead of filter and map
- Loading branch information
Henri Kerola
committed
Jan 2, 2015
1 parent
0c4c9eb
commit e3297cf
Showing
2 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
addon/src/test/scala/vaadin/scala/tests/ListenersTraitTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package vaadin.scala.tests | ||
|
||
import com.vaadin.ui.Button.{ClickEvent, ClickListener} | ||
import vaadin.scala._ | ||
|
||
/** | ||
* | ||
* @author Henri Kerola / Vaadin | ||
*/ | ||
class ListenersTraitTests extends ScaladinTestSuite { | ||
|
||
test("iterator") { | ||
val button = new Button | ||
|
||
button.clickListeners += { e => } | ||
|
||
button.p.addClickListener(new ClickListener { | ||
override def buttonClick(clickEvent: ClickEvent): Unit = {} | ||
}) | ||
|
||
assert(1 == button.clickListeners.size) | ||
assert(2 == button.p.getListeners(classOf[com.vaadin.ui.Button.ClickEvent]).size) | ||
} | ||
|
||
test("-=") { | ||
val button = new Button | ||
|
||
val clickListener = { e: Button.ClickEvent => } | ||
button.clickListeners += clickListener | ||
assert(1 == button.clickListeners.size) | ||
|
||
button.clickListeners -= clickListener | ||
assert(0 == button.clickListeners.size) | ||
} | ||
|
||
} |