| 1 | /* |
|---|
| 2 | * To change this license header, choose License Headers in Project Properties. |
|---|
| 3 | * To change this template file, choose Tools | Templates |
|---|
| 4 | * and open the template in the editor. |
|---|
| 5 | */ |
|---|
| 6 | package pizzaorderintl; |
|---|
| 7 | |
|---|
| 8 | import java.util.Arrays; |
|---|
| 9 | import java.util.List; |
|---|
| 10 | import org.uispec4j.*; |
|---|
| 11 | import org.uispec4j.interception.*; |
|---|
| 12 | import pizzaorder.GUI; |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | * |
|---|
| 16 | * @author Bryan McGuffin |
|---|
| 17 | */ |
|---|
| 18 | public class PizzaOrderIntlGUITest extends UISpecTestCase |
|---|
| 19 | { |
|---|
| 20 | |
|---|
| 21 | public PizzaOrderIntlGUITest(String testName) |
|---|
| 22 | { |
|---|
| 23 | super(testName); |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | public void testPizzaGUI() |
|---|
| 27 | { |
|---|
| 28 | GUI view = new GUI(); |
|---|
| 29 | |
|---|
| 30 | Window win = new Window(view); |
|---|
| 31 | |
|---|
| 32 | ComboBox langBox = win.getComboBox(); |
|---|
| 33 | |
|---|
| 34 | assertTrue(langBox.contains("en / English")); |
|---|
| 35 | |
|---|
| 36 | langBox.select("en / English"); |
|---|
| 37 | |
|---|
| 38 | final List<String> tops = Arrays.asList("Onions", "Olives", "Peppers", "Tomatoes"); |
|---|
| 39 | |
|---|
| 40 | for (String top : tops) |
|---|
| 41 | { |
|---|
| 42 | assertFalse(win.getCheckBox(top).isSelected()); |
|---|
| 43 | win.getCheckBox(top).select(); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | for (String top : tops) |
|---|
| 47 | { |
|---|
| 48 | assertTrue(win.getCheckBox(top).isSelected()); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | final List<String> nonTops = Arrays.asList("Mushrooms", "Pepperoni"); |
|---|
| 52 | |
|---|
| 53 | for (String n : nonTops) |
|---|
| 54 | { |
|---|
| 55 | assertFalse(win.getCheckBox(n).isSelected()); |
|---|
| 56 | } |
|---|
| 57 | |
|---|
| 58 | Button submitButton = win.getButton("Submit"); |
|---|
| 59 | |
|---|
| 60 | WindowInterceptor inter = WindowInterceptor.init(submitButton.triggerClick()); |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | inter.process(new WindowHandler() |
|---|
| 64 | { |
|---|
| 65 | |
|---|
| 66 | @Override |
|---|
| 67 | public Trigger process(Window window) throws Exception |
|---|
| 68 | { |
|---|
| 69 | String message1 = "You ordered a pizza with these toppings:"; |
|---|
| 70 | |
|---|
| 71 | assertTrue(window.containsLabel(message1)); |
|---|
| 72 | |
|---|
| 73 | for(String t: tops) |
|---|
| 74 | { |
|---|
| 75 | assertTrue(window.containsLabel(t)); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | return window.getButton("OK").triggerClick(); |
|---|
| 79 | } |
|---|
| 80 | }).run(); |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | } |
|---|
| 84 | // TODO add test methods here. The name must begin with 'test'. For example: |
|---|
| 85 | // public void testHello() {} |
|---|
| 86 | } |
|---|