1 | /** |
2 | * Copyright (C) 2006 Carrier Access, Corp. |
3 | */ |
4 | package biz.xsoftware.mock.client.example1; |
5 | |
6 | import biz.xsoftware.mock.client.JsCalledMethod; |
7 | |
8 | import com.google.gwt.junit.client.GWTTestCase; |
9 | import com.google.gwt.user.client.ui.ClickListener; |
10 | import com.google.gwt.user.client.ui.Widget; |
11 | |
12 | /** |
13 | */ |
14 | public class TestExample extends GWTTestCase |
15 | { |
16 | |
17 | /** |
18 | * @see com.google.gwt.junit.client.GWTTestCase#getModuleName() |
19 | */ |
20 | public String getModuleName() |
21 | { |
22 | return "biz.xsoftware.mock.MockLib"; |
23 | } |
24 | |
25 | public void testClickingButton() { |
26 | MockListenerManager mock = new MockListenerManager(); |
27 | |
28 | MyApplication app = new MyApplication(mock); |
29 | |
30 | JsCalledMethod method = mock.expect("addClickListener"); |
31 | Widget widget = (Widget)method.getAllParams()[0]; |
32 | ClickListener l = (ClickListener)method.getAllParams()[1]; |
33 | |
34 | //click the button..... |
35 | l.onClick(widget); |
36 | |
37 | assertEquals(true, app.getWasClicked()); |
38 | } |
39 | } |