1 // https://bugs.openjdk.java.net/browse/INTJDK-7624138 2 /* 3 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 */ 26 package test.fxmltests.functional; 27 28 import client.test.AddExports; 29 import junit.framework.Assert; 30 import org.jemmy.env.Timeout; 31 import org.jemmy.timing.State; 32 import org.jemmy.timing.Waiter; 33 import org.junit.BeforeClass; 34 import org.junit.Test; 35 import test.fxmltests.app.LineNumberApp; 36 import test.javaclient.shared.TestBase; 37 import test.javaclient.shared.Utils; 38 39 @AddExports(value = "javafx.fxml/com.sun.javafx.fxml=ALL-UNNAMED") 40 public class LineNumberTest extends TestBase { 41 42 private static final long WAITER_TIMEOUT = 5000; 43 44 @BeforeClass 45 public static void runUI() { 46 Utils.launch(LineNumberApp.class, null); 47 } 48 49 /** 50 * testing LoadListener#readImportProcessingInstruction 51 */ 52 @Test 53 public void testImportProcessingInstruction() { 54 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 55 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 56 @Override 57 public Boolean reached() { 58 return LineNumberApp.importProcessingInstructionMatrix.length == LineNumberApp.importProcessingInstruction.size(); 59 } 60 }); 61 for (int i = 0; i < LineNumberApp.importProcessingInstructionMatrix.length; i++) { 62 Assert.assertEquals(LineNumberApp.importProcessingInstructionMatrix[i], LineNumberApp.importProcessingInstruction.get(i)); 63 } 64 } 65 66 /** 67 * testing LoadListener#readLanguageProcessingInstruction 68 */ 69 @Test 70 public void testLanguageProcessingInstruction() { 71 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 72 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 73 @Override 74 public Boolean reached() { 75 return LineNumberApp.languageProcessingInstructionMatrix.length == LineNumberApp.languageProcessingInstruction.size(); 76 } 77 }); 78 for (int i = 0; i < LineNumberApp.languageProcessingInstructionMatrix.length; i++) { 79 Assert.assertEquals(LineNumberApp.languageProcessingInstructionMatrix[i], LineNumberApp.languageProcessingInstruction.get(i)); 80 } 81 } 82 83 /** 84 * testing LoadListener#readComment 85 */ 86 @Test 87 public void testComment() { 88 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 89 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 90 @Override 91 public Boolean reached() { 92 return LineNumberApp.commentMatrix.length == LineNumberApp.comment.size(); 93 } 94 }); 95 for (int i = 0; i < LineNumberApp.commentMatrix.length; i++) { 96 Assert.assertEquals(LineNumberApp.commentMatrix[i], LineNumberApp.comment.get(i)); 97 } 98 } 99 100 /** 101 * testing LoadListener#beginInstanceDeclarationElement 102 */ 103 @Test 104 public void testBeginInstanceDeclarationElement() { 105 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 106 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 107 @Override 108 public Boolean reached() { 109 return LineNumberApp.instanceDeclarationElementMatrix.length == LineNumberApp.instanceDeclarationElement.size(); 110 } 111 }); 112 for (int i = 0; i < LineNumberApp.instanceDeclarationElementMatrix.length; i++) { 113 Assert.assertEquals(LineNumberApp.instanceDeclarationElementMatrix[i], LineNumberApp.instanceDeclarationElement.get(i)); 114 } 115 } 116 117 /** 118 * testing LoadListener#beginIncludeElement 119 */ 120 @Test 121 public void testIncludeElement() { 122 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 123 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 124 @Override 125 public Boolean reached() { 126 return LineNumberApp.includeElementMatrix.length == LineNumberApp.includeElement.size(); 127 } 128 }); 129 for (int i = 0; i < LineNumberApp.includeElementMatrix.length; i++) { 130 Assert.assertEquals(LineNumberApp.includeElementMatrix[i], LineNumberApp.includeElement.get(i)); 131 } 132 } 133 134 /** 135 * testing LoadListener#beginReferenceElement 136 */ 137 @Test 138 public void testReferenceElement() { 139 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 140 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 141 @Override 142 public Boolean reached() { 143 return LineNumberApp.referenceElementMatrix.length == LineNumberApp.referenceElement.size(); 144 } 145 }); 146 for (int i = 0; i < LineNumberApp.referenceElementMatrix.length; i++) { 147 Assert.assertEquals(LineNumberApp.referenceElementMatrix[i], LineNumberApp.referenceElement.get(i)); 148 } 149 } 150 151 /** 152 * testing LoadListener#beginCopyElement 153 */ 154 @Test 155 public void testCopyElement() { 156 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 157 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 158 @Override 159 public Boolean reached() { 160 return LineNumberApp.copyElementMatrix.length == LineNumberApp.copyElement.size(); 161 } 162 }); 163 for (int i = 0; i < LineNumberApp.copyElementMatrix.length; i++) { 164 Assert.assertEquals(LineNumberApp.copyElementMatrix[i], LineNumberApp.copyElement.get(i)); 165 } 166 } 167 168 /** 169 * testing LoadListener#beginRootElement 170 */ 171 @Test 172 public void testRootElement() { 173 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 174 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 175 @Override 176 public Boolean reached() { 177 return LineNumberApp.rootElement > 0; 178 } 179 }); 180 Assert.assertEquals(LineNumberApp.rootElementLine, LineNumberApp.rootElement); 181 } 182 183 /** 184 * testing LoadListener#beginPropertyElement 185 */ 186 @Test 187 public void testPropertyElement() { 188 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 189 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 190 @Override 191 public Boolean reached() { 192 return LineNumberApp.propertyElementMatrix.length == LineNumberApp.propertyElement.size(); 193 } 194 }); 195 for (int i = 0; i < LineNumberApp.propertyElementMatrix.length; i++) { 196 Assert.assertEquals(LineNumberApp.propertyElementMatrix[i], LineNumberApp.propertyElement.get(i)); 197 } 198 } 199 200 /** 201 * testing LoadListener#beginScriptElement 202 */ 203 @Test 204 public void testScriptElement() { 205 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 206 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 207 @Override 208 public Boolean reached() { 209 return LineNumberApp.propertyElementMatrix.length == LineNumberApp.propertyElement.size(); 210 } 211 }); 212 for (int i = 0; i < LineNumberApp.propertyElementMatrix.length; i++) { 213 Assert.assertEquals(LineNumberApp.propertyElementMatrix[i], LineNumberApp.propertyElement.get(i)); 214 } 215 } 216 217 /** 218 * testing LoadListener#beginDefineElement 219 */ 220 @Test 221 public void testDefineElement() { 222 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 223 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 224 @Override 225 public Boolean reached() { 226 return LineNumberApp.defineElementMatrix.length == LineNumberApp.defineElement.size(); 227 } 228 }); 229 for (int i = 0; i < LineNumberApp.defineElementMatrix.length; i++) { 230 Assert.assertEquals(LineNumberApp.defineElementMatrix[i], LineNumberApp.defineElement.get(i)); 231 } 232 } 233 234 /** 235 * testing LoadListener#readInternalAttribute 236 */ 237 @Test 238 public void testReadInternalProperty() { 239 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 240 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 241 @Override 242 public Boolean reached() { 243 return LineNumberApp.readInternalAttributeMatrix.length == LineNumberApp.readInternalAttribute.size(); 244 } 245 }); 246 for (int i = 0; i < LineNumberApp.readInternalAttributeMatrix.length; i++) { 247 Assert.assertEquals(LineNumberApp.readInternalAttributeMatrix[i], LineNumberApp.readInternalAttribute.get(i)); 248 } 249 } 250 251 /** 252 * testing LoadListener#readPropertyAttribute 253 */ 254 @Test 255 public void testReadPropertyAttribute() { 256 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 257 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 258 @Override 259 public Boolean reached() { 260 return LineNumberApp.readPropertyAttributeMatrix.length == LineNumberApp.readPropertyAttribute.size(); 261 } 262 }); 263 for (int i = 0; i < LineNumberApp.readPropertyAttributeMatrix.length; i++) { 264 Assert.assertEquals(LineNumberApp.readPropertyAttributeMatrix[i], LineNumberApp.readPropertyAttribute.get(i)); 265 } 266 } 267 268 /** 269 * testing LoadListener#readEventHandlerAttribute 270 */ 271 @Test 272 public void testReadEventHandlerAttribute() { 273 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 274 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 275 @Override 276 public Boolean reached() { 277 return LineNumberApp.readEventHandlerAttributeMatrix.length == LineNumberApp.readEventHandlerAttribute.size(); 278 } 279 }); 280 for (int i = 0; i < LineNumberApp.readEventHandlerAttributeMatrix.length; i++) { 281 Assert.assertEquals(LineNumberApp.readEventHandlerAttributeMatrix[i], LineNumberApp.readEventHandlerAttribute.get(i)); 282 } 283 } 284 285 /** 286 * testing LoadListener#endElement 287 */ 288 @Test 289 public void testEndElement() { 290 testCommon(LineNumberApp.Pages.mainPage.name(), null, false, false); 291 new Waiter(new Timeout("", WAITER_TIMEOUT)).ensureValue(true, new State<Boolean>() { 292 @Override 293 public Boolean reached() { 294 return LineNumberApp.endElementMatrix.length == LineNumberApp.endElement.size(); 295 } 296 }); 297 for (int i = 0; i < LineNumberApp.endElementMatrix.length; i++) { 298 Assert.assertEquals(LineNumberApp.endElementMatrix[i], LineNumberApp.endElement.get(i)); 299 } 300 } 301 }