summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAhmed Ashour <asashour@yahoo.com>2017-10-02 11:43:19 +0200
committerHenri Sara <henri.sara@gmail.com>2017-10-02 12:43:19 +0300
commit7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce (patch)
tree9351fb5d91124db9935f684da60bdb74ef01881d /uitest
parent43f4a17f0d17e584e83ea3faaa40ac1def1dd4b1 (diff)
downloadvaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.tar.gz
vaadin-framework-7e4b4ff5a9e9eca6810d473a4d7681a61c9a89ce.zip
Use enhanced for loop for arrays. (#10121)
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java10
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestBench.java5
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java8
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java7
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java12
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java12
-rw-r--r--uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java3
-rw-r--r--uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java6
-rw-r--r--uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java11
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java12
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java13
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java8
15 files changed, 58 insertions, 66 deletions
diff --git a/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java
index 93ddea656f..7599522c38 100644
--- a/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java
+++ b/uitest/src/main/java/com/vaadin/launcher/DevelopmentServerLauncher.java
@@ -371,11 +371,11 @@ public class DevelopmentServerLauncher {
*/
protected static Map<String, String> parseArguments(String[] args) {
final Map<String, String> map = new HashMap<>();
- for (int i = 0; i < args.length; i++) {
- final int d = args[i].indexOf("=");
- if (d > 0 && d < args[i].length() && args[i].startsWith("--")) {
- final String name = args[i].substring(2, d);
- final String value = args[i].substring(d + 1);
+ for (String arg : args) {
+ final int d = arg.indexOf("=");
+ if (d > 0 && d < arg.length() && arg.startsWith("--")) {
+ final String name = arg.substring(2, d);
+ final String value = arg.substring(d + 1);
map.put(name, value);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/TestBench.java b/uitest/src/main/java/com/vaadin/tests/TestBench.java
index 2c5634ab32..56c5dc986a 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestBench.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestBench.java
@@ -307,9 +307,8 @@ public class TestBench extends com.vaadin.server.LegacyApplication
}
}
- // for (int i = 0; i < c.getInterfaces().length; i++) {
- // Class cc = c.getInterfaces()[i];
- // if (c.getInterfaces()[i].equals(Testable.class)) {
+ // for (Class cc : c.getInterfaces()) {
+ // if (cc.equals(Testable.class)) {
// // Class is testable
// classes.add(c);
// }
diff --git a/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java b/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java
index 74dcd40ba1..971d0d9bfd 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestForMultipleStyleNames.java
@@ -82,11 +82,10 @@ public class TestForMultipleStyleNames extends CustomComponent
public void valueChange(ValueChangeEvent event) {
final String currentStyle = l.getStyleName();
- final String[] tmp = currentStyle.split(" ");
final List<String> curStyles = new ArrayList<>();
- for (int i = 0; i < tmp.length; i++) {
- if (tmp[i] != "") {
- curStyles.add(tmp[i]);
+ for (String tmp : currentStyle.split(" ")) {
+ if (tmp != "") {
+ curStyles.add(tmp);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
index 45de6b34a4..95602fb78b 100644
--- a/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
+++ b/uitest/src/main/java/com/vaadin/tests/TestSizeableIncomponents.java
@@ -144,8 +144,7 @@ public class TestSizeableIncomponents extends LegacyApplication {
URL dir = cl.getResource("com/vaadin/ui");
String[] list2 = (new File(dir.getFile())).list();
- for (int i = 0; i < list2.length; i++) {
- String f = list2[i];
+ for (String f : list2) {
if (f.endsWith(".class") && (f.indexOf("CustomComponent") == -1)
&& (f.indexOf("Window") == -1)) {
f = f.replaceAll(".class", "");
diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
index c665537250..bbc067ec39 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxCombinedWithEnterShortcut.java
@@ -9,16 +9,16 @@ import com.vaadin.v7.shared.ui.combobox.FilteringMode;
import com.vaadin.v7.ui.ComboBox;
public class ComboBoxCombinedWithEnterShortcut extends TestBase {
- final String[] cities = { "Berlin", "Brussels", "Helsinki",
- "Madrid", "Oslo", "Paris", "Stockholm" };
+ final String[] cities = { "Berlin", "Brussels", "Helsinki", "Madrid",
+ "Oslo", "Paris", "Stockholm" };
private Log log = new Log(5);
@Override
protected void setup() {
final ComboBox l = new ComboBox("Please select a city");
- for (int i = 0; i < cities.length; i++) {
- l.addItem(cities[i]);
+ for (String city : cities) {
+ l.addItem(city);
}
l.setFilteringMode(FilteringMode.OFF);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java
index af894cf61e..d88e2ce286 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java
@@ -85,8 +85,8 @@ public class HeaderPositionWhenSorting extends AbstractReindeerTestUI
// Calculate the average of the numeric column
double avgAge = 0;
- for (int i = 0; i < people.length; i++) {
- avgAge += (Integer) people[i][1];
+ for (Object[] person : people) {
+ avgAge += (Integer) person[1];
}
avgAge /= people.length;
@@ -98,8 +98,7 @@ public class HeaderPositionWhenSorting extends AbstractReindeerTestUI
// Adjust the table height a bit
table.setPageLength(table.size() + 2);
- for (int i = 0; i < people.length; i++) {
- Object[] person = people[i];
+ for (Object[] person : people) {
String name = (String) person[0];
addComponent(new Link("Google for " + name, new ExternalResource(
"http://www.google.co.uk/search?q=" + name)));
diff --git a/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java b/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
index 89b4b46da4..64bf1c908c 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
@@ -83,8 +83,8 @@ public class TableAndBrowserContextMenu extends TestBase
// Calculate the average of the numeric column
double avgAge = 0;
- for (int i = 0; i < people.length; i++) {
- avgAge += (Integer) people[i][1];
+ for (Object[] person : people) {
+ avgAge += (Integer) person[1];
}
avgAge /= people.length;
@@ -96,8 +96,7 @@ public class TableAndBrowserContextMenu extends TestBase
// Adjust the table height a bit
table.setPageLength(table.size() + 2);
- for (int i = 0; i < people.length; i++) {
- Object[] person = people[i];
+ for (Object[] person : people) {
String name = (String) person[0];
addComponent(new Link("Google for " + name, new ExternalResource(
"http://www.google.co.uk/search?q=" + name)));
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java
index 815ebc5197..441d2a4302 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java
@@ -69,9 +69,9 @@ public class TextChangeEvents extends AbstractTestUIWithLog {
*/
private class VaadinDeveloperNameField extends TextField
implements HasValue.ValueChangeListener<String> {
- private String[] names = { "Matti Tahvonen",
- "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita",
- "Marko Grönroos", "Artur Signell" };
+ private String[] names = { "Matti Tahvonen", "Marc Englund",
+ "Joonas Lehtinen", "Jouni Koivuviita", "Marko Grönroos",
+ "Artur Signell" };
public VaadinDeveloperNameField() {
setCaption("Start typing 'old' Vaadin developers.");
@@ -111,9 +111,9 @@ public class TextChangeEvents extends AbstractTestUIWithLog {
private String findMatch(String currentTextContent) {
if (!currentTextContent.isEmpty()) {
- for (int i = 0; i < names.length; i++) {
- if (names[i].startsWith(currentTextContent)) {
- return names[i];
+ for (String name : names) {
+ if (name.startsWith(currentTextContent)) {
+ return name;
}
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java
index 5c98476630..71b0a801b6 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java
+++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java
@@ -100,9 +100,9 @@ public class TextFieldsValueChangeMode extends AbstractTestUIWithLog {
*
*/
private class VaadinDeveloperNameField extends TextField {
- private String[] names = { "Matti Tahvonen",
- "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita",
- "Marko Grönroos", "Artur Signell" };
+ private String[] names = { "Matti Tahvonen", "Marc Englund",
+ "Joonas Lehtinen", "Jouni Koivuviita", "Marko Grönroos",
+ "Artur Signell" };
public VaadinDeveloperNameField() {
setCaption("Start typing 'old' Vaadin developers.");
@@ -139,9 +139,9 @@ public class TextFieldsValueChangeMode extends AbstractTestUIWithLog {
private String findMatch(String currentTextContent) {
if (!currentTextContent.isEmpty()) {
- for (int i = 0; i < names.length; i++) {
- if (names[i].startsWith(currentTextContent)) {
- return names[i];
+ for (String name : names) {
+ if (name.startsWith(currentTextContent)) {
+ return name;
}
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java b/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java
index 384a02b87b..d525c4f9e8 100644
--- a/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java
+++ b/uitest/src/main/java/com/vaadin/tests/dd/DragAndDropFiles.java
@@ -47,8 +47,7 @@ public class DragAndDropFiles extends TestBase {
Html5File[] files = transferable.getFiles();
if (files != null) {
- for (int i = 0; i < files.length; i++) {
- Html5File file = files[i];
+ for (Html5File file : files) {
// Max 1 MB files are uploaded
if (file.getFileSize() > 1024 * 1024) {
getMainWindow().showNotification("File "
diff --git a/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java b/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java
index 768177683a..6a415f4268 100644
--- a/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java
+++ b/uitest/src/main/java/com/vaadin/tests/elements/abstracttextfield/CompatibilityAbstractFieldElementSetValueReadOnly.java
@@ -31,9 +31,9 @@ public class CompatibilityAbstractFieldElementSetValueReadOnly
@Override
protected void setup(VaadinRequest request) {
- for (int i = 0; i < elems.length; i++) {
- elems[i].setReadOnly(true);
- addComponent(elems[i]);
+ for (AbstractField<?> c : elems) {
+ c.setReadOnly(true);
+ addComponent(c);
}
}
diff --git a/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java b/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java
index 1e7b310c53..76bdb6cd13 100644
--- a/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java
@@ -112,21 +112,20 @@ public class ButtonsTest extends com.vaadin.server.LegacyApplication {
private Layout buildButtons(boolean disabled, boolean icon, boolean error,
boolean sized) {
- String[] buttonStyles = { "Normal", "Primary", "Small",
- "Link" };
+ String[] buttonStyles = { "Normal", "Primary", "Small", "Link" };
HorizontalLayout hl = new HorizontalLayout();
hl.setSpacing(true);
hl.setMargin(true);
- for (int i = 0; i < buttonStyles.length; i++) {
+ for (String style : buttonStyles) {
Button b;
if (nativeButtons) {
- b = new NativeButton(buttonStyles[i] + " style");
+ b = new NativeButton(style + " style");
} else {
- b = new Button(buttonStyles[i] + " style");
+ b = new Button(style + " style");
}
- b.setStyleName(buttonStyles[i].toLowerCase());
+ b.setStyleName(style.toLowerCase());
if (icon) {
b.setIcon(new ThemeResource("../runo/icons/"
+ (largeIcons ? "64" : "16") + "/document.png"));
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java b/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java
index 207d62d157..cc8ee57dd0 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java
+++ b/uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java
@@ -81,9 +81,9 @@ public class TextChangeEvents extends TestBase {
*/
private class VaadinDeveloperNameField extends TextField
implements TextChangeListener {
- private String[] names = { "Matti Tahvonen",
- "Marc Englund", "Joonas Lehtinen", "Jouni Koivuviita",
- "Marko Grönroos", "Artur Signell" };
+ private String[] names = { "Matti Tahvonen", "Marc Englund",
+ "Joonas Lehtinen", "Jouni Koivuviita", "Marko Grönroos",
+ "Artur Signell" };
public VaadinDeveloperNameField() {
setCaption("Start typing 'old' Vaadin developers.");
@@ -123,9 +123,9 @@ public class TextChangeEvents extends TestBase {
private String findMatch(String currentTextContent) {
if (!currentTextContent.isEmpty()) {
- for (int i = 0; i < names.length; i++) {
- if (names[i].startsWith(currentTextContent)) {
- return names[i];
+ for (String name : names) {
+ if (name.startsWith(currentTextContent)) {
+ return name;
}
}
}
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java
index 934c25f330..c2c4e7d262 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java
+++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/SimpleTree.java
@@ -13,7 +13,7 @@ import com.vaadin.v7.ui.AbstractSelect.ItemDescriptionGenerator;
import com.vaadin.v7.ui.Tree;
public class SimpleTree extends TestBase implements Action.Handler {
- private static final String[][] hardware = { //
+ private static final String[][] hardware = {
{ "Desktops", "Dell OptiPlex GX240", "Dell OptiPlex GX260",
"Dell OptiPlex GX280" },
{ "Monitors", "Benq T190HD", "Benq T220HD", "Benq T240HD" },
@@ -28,8 +28,7 @@ public class SimpleTree extends TestBase implements Action.Handler {
// Actions for the context menu
private static final Action ACTION_ADD = new Action("Add child item");
private static final Action ACTION_DELETE = new Action("Delete");
- private static final Action[] ACTIONS = { ACTION_ADD,
- ACTION_DELETE };
+ private static final Action[] ACTIONS = { ACTION_ADD, ACTION_DELETE };
private Tree tree;
@@ -83,15 +82,15 @@ public class SimpleTree extends TestBase implements Action.Handler {
// Create containerproperty for icon
hwContainer.addContainerProperty("icon", ThemeResource.class,
new ThemeResource("../runo/icons/16/document.png"));
- for (int i = 0; i < hardware.length; i++) {
+ for (String[] type : hardware) {
// Add new item
item = hwContainer.addItem(itemId);
// Add name property for item
- item.getItemProperty("name").setValue(hardware[i][0]);
+ item.getItemProperty("name").setValue(type[0]);
// Allow children
hwContainer.setChildrenAllowed(itemId, true);
itemId++;
- for (int j = 1; j < hardware[i].length; j++) {
+ for (int j = 1; j < type.length; j++) {
if (j == 1) {
item.getItemProperty("icon").setValue(
new ThemeResource("../runo/icons/16/folder.png"));
@@ -99,7 +98,7 @@ public class SimpleTree extends TestBase implements Action.Handler {
// Add child items
item = hwContainer.addItem(itemId);
- item.getItemProperty("name").setValue(hardware[i][j]);
+ item.getItemProperty("name").setValue(type[j]);
hwContainer.setParent(itemId, itemId - j);
hwContainer.setChildrenAllowed(itemId, false);
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java
index b38e4d9bf3..a2d4aa1c80 100644
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java
+++ b/uitest/src/main/java/com/vaadin/v7/tests/components/tree/TreeHorizontalResize.java
@@ -60,22 +60,22 @@ public class TreeHorizontalResize extends TestBase {
// Create containerproperty for icon
hwContainer.addContainerProperty(hw_PROPERTY_ICON, ThemeResource.class,
new ThemeResource("../runo/icons/16/document.png"));
- for (int i = 0; i < hardware.length; i++) {
+ for (String[] type : hardware) {
// Add new item
item = hwContainer.addItem(itemId);
// Add name property for item
- item.getItemProperty(hw_PROPERTY_NAME).setValue(hardware[i][0]);
+ item.getItemProperty(hw_PROPERTY_NAME).setValue(type[0]);
// Allow children
hwContainer.setChildrenAllowed(itemId, true);
itemId++;
- for (int j = 1; j < hardware[i].length; j++) {
+ for (int j = 1; j < type.length; j++) {
if (j == 1) {
item.getItemProperty(hw_PROPERTY_ICON).setValue(
new ThemeResource("../runo/icons/16/folder.png"));
}
// Add child items
item = hwContainer.addItem(itemId);
- item.getItemProperty(hw_PROPERTY_NAME).setValue(hardware[i][j]);
+ item.getItemProperty(hw_PROPERTY_NAME).setValue(type[j]);
hwContainer.setParent(itemId, itemId - j);
hwContainer.setChildrenAllowed(itemId, false);