1 /**
2 * Copyright 2008 WebPhotos
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.sf.webphotos.gui.util.uispec4j;
17
18 import static org.junit.Assert.assertTrue;
19 import org.uispec4j.Trigger;
20 import org.uispec4j.Window;
21 import org.uispec4j.interception.WindowHandler;
22
23 /**
24 *
25 * @author Guilherme
26 */
27 public class ModalWindowHandler extends WindowHandler {
28
29 private String titleName;
30 private String modalText;
31
32 /**
33 *
34 * @param titleName
35 * @param modalText
36 */
37 public ModalWindowHandler(String titleName, String modalText) {
38 this.modalText = modalText;
39 this.titleName = titleName;
40 }
41
42 /**
43 *
44 * @param window
45 * @return
46 * @throws Exception
47 */
48 @Override
49 public Trigger process(Window window) throws Exception {
50 assertTrue("Tittle: " + window.getTitle(), window.titleContains(titleName).isTrue());
51 assertTrue("Modal: " + window.getTitle(), window.isModal().isTrue());
52 window.getInputTextBox().setText(modalText);
53 return window.getButton("OK").triggerClick();
54 }
55
56 }