01: // Copyright © 2004-2005 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.extension.dialogs;
03:
04: import com.canoo.webtest.engine.StepFailedException;
05: import com.canoo.webtest.self.TestBlock;
06: import com.canoo.webtest.self.ThrowAssert;
07: import com.canoo.webtest.steps.BaseStepTestCase;
08: import com.canoo.webtest.steps.Step;
09:
10: /**
11: * Test class for {@link com.canoo.webtest.extension.dialogs.VerifyNoDialogs}.<p>
12: *
13: * @author Paul King, ASERT
14: */
15: public class VerifyNoDialogsTest extends BaseStepTestCase {
16: protected Step createStep() {
17: return new VerifyNoDialogs();
18: }
19:
20: public void testSucceedsWhenNoDialogsPresent() throws Exception {
21: executeStep(getStep());
22: }
23:
24: public void testFailsWhenDialogsPresent() {
25: final AbstractDialogStep dialogStep = new AlertDialogStep(null,
26: null, null, null);
27: DialogHelper.addExpectedDialog(getContext(), dialogStep);
28: final String msg = ThrowAssert.assertThrows(
29: StepFailedException.class, new TestBlock() {
30: public void call() throws Exception {
31: executeStep(getStep());
32: }
33: });
34: assertEquals("Dialogs found but none expected!", msg);
35: }
36:
37: }
|