01: // Copyright © 2004-2007 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.extension.dialogs;
03:
04: import com.canoo.webtest.engine.Context;
05: import com.canoo.webtest.self.ContextStub;
06: import junit.framework.TestCase;
07:
08: /**
09: * Tests for {@link DialogHelper}.
10: * @author Paul King
11: */
12: public class DialogHelperTest extends TestCase {
13: private final Context fContext = new ContextStub();
14:
15: public void testAddDialogTest() {
16: assertEquals(0, DialogHelper.getExpectedDialogsCount(fContext));
17: DialogHelper.addExpectedDialog(fContext, new AlertDialogStep(
18: null, null, null, null));
19: assertEquals(1, DialogHelper.getExpectedDialogsCount(fContext));
20: }
21:
22: public void testGetDialogsTest() {
23: assertNull("should be no dialogs initially", DialogHelper
24: .getNextExpectedDialog(fContext));
25: DialogHelper.addExpectedDialog(fContext, new AlertDialogStep(
26: null, null, null, null));
27: assertEquals("adding a dialog response should increase count",
28: 1, DialogHelper.getExpectedDialogsCount(fContext));
29: DialogHelper.getNextExpectedDialog(fContext);
30: assertEquals("using a dialog response should decrease count",
31: 0, DialogHelper.getExpectedDialogsCount(fContext));
32: }
33:
34: }
|