From 116cd1f29a432fe5ca64f3023a9fec1ca130f078 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Fri, 27 Jan 2012 14:17:02 +0000 Subject: [PATCH] #8311 Additional CRLF->LF fixes svn changeset:22799/svn branch:6.8 --- .../gwt/client/ui/VCalendarPanel.java | 219 +++++++++--------- .../terminal/gwt/client/ui/VSlider.java | 4 - .../AddComponentsTest.java | 8 +- .../csslayout/AddComponentsTest.java | 2 +- .../AbstractIndexedLayoutTest.java | 168 +++++++------- .../tests/application/WebBrowserSizeTest.java | 90 +++---- .../tests/application/WebBrowserTest.java | 2 +- .../PopupDateFieldExtendedRange.java | 138 +++++------ 8 files changed, 311 insertions(+), 320 deletions(-) diff --git a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java index e35bd93f67..a2f03d6176 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VCalendarPanel.java @@ -72,7 +72,7 @@ public class VCalendarPanel extends FocusableFlexTable implements /** * FocusChangeListener is notified when the panel changes its _focused_ - * value. It can be set with + * value. */ public interface FocusChangeListener { void focusChanged(Date focusedDate); @@ -103,6 +103,8 @@ public class VCalendarPanel extends FocusableFlexTable implements private static final String CN_SELECTED = "selected"; + private static final String CN_OFFMONTH = "offmonth"; + /** * Represents a click handler for when a user selects a value by using the * mouse @@ -117,7 +119,7 @@ public class VCalendarPanel extends FocusableFlexTable implements */ public void onClick(ClickEvent event) { Day day = (Day) event.getSource(); - focusDay(day.getDay()); + focusDay(day.getDate()); selectFocused(); onSubmit(); } @@ -151,6 +153,8 @@ public class VCalendarPanel extends FocusableFlexTable implements private boolean showISOWeekNumbers; + private Date displayedMonth; + private Date focusedDate; private Day selectedDay; @@ -187,21 +191,22 @@ public class VCalendarPanel extends FocusableFlexTable implements } /** - * Sets the focus to given day of current time. Used when moving in the - * calender with the keyboard. + * Sets the focus to given date in the current view. Used when moving in the + * calendar with the keyboard. * - * @param day - * The day number from by Date.getDate() + * @param date + * A Date representing the day of month to be focused. Must be + * one of the days currently visible. */ - private void focusDay(int day) { + private void focusDay(Date date) { // Only used when calender body is present if (resolution > VDateField.RESOLUTION_MONTH) { if (focusedDay != null) { focusedDay.removeStyleDependentName(CN_FOCUSED); } - if (day > 0 && focusedDate != null) { - focusedDate.setDate(day); + if (date != null && focusedDate != null) { + focusedDate.setTime(date.getTime()); int rowCount = days.getRowCount(); for (int i = 0; i < rowCount; i++) { int cellCount = days.getCellCount(i); @@ -209,7 +214,7 @@ public class VCalendarPanel extends FocusableFlexTable implements Widget widget = days.getWidget(i, j); if (widget != null && widget instanceof Day) { Day curday = (Day) widget; - if (curday.getDay() == day) { + if (curday.getDate().equals(date)) { curday.addStyleDependentName(CN_FOCUSED); focusedDay = curday; focusedRow = i; @@ -223,11 +228,14 @@ public class VCalendarPanel extends FocusableFlexTable implements } /** - * Sets the selection hightlight to a given date of current time + * Sets the selection highlight to a given day in the current view + * + * @param date + * A Date representing the day of month to be selected. Must be + * one of the days currently visible. * - * @param day */ - private void selectDate(int day) { + private void selectDate(Date date) { if (selectedDay != null) { selectedDay.removeStyleDependentName(CN_SELECTED); } @@ -239,7 +247,7 @@ public class VCalendarPanel extends FocusableFlexTable implements Widget widget = days.getWidget(i, j); if (widget != null && widget instanceof Day) { Day curday = (Day) widget; - if (curday.getDay() == day) { + if (curday.getDate().equals(date)) { curday.addStyleDependentName(CN_SELECTED); selectedDay = curday; return; @@ -278,7 +286,7 @@ public class VCalendarPanel extends FocusableFlexTable implements // it was forced to 1 above. value.setDate(focusedDate.getDate()); - selectDate(focusedDate.getDate()); + selectDate(focusedDate); } else { VConsole.log("Trying to select a the focused date which is NULL!"); } @@ -467,97 +475,62 @@ public class VCalendarPanel extends FocusableFlexTable implements } } - // The day of month that is selected, -1 if no day of this month is - // selected (i.e, showing another month/year than selected or nothing is - // selected) - int dayOfMonthSelected = -1; - // The day of month that is today, -1 if no day of this month is today - // (i.e., showing another month/year than current) - int dayOfMonthToday = -1; - - boolean initiallyNull = value == null; - - if (!initiallyNull && value.getMonth() == focusedDate.getMonth() - && value.getYear() == focusedDate.getYear()) { - dayOfMonthSelected = value.getDate(); - } - final Date today = new Date(); - if (today.getMonth() == focusedDate.getMonth() - && today.getYear() == focusedDate.getYear()) { - dayOfMonthToday = today.getDate(); - } + // today must have zeroed hours, minutes, seconds, and milliseconds + final Date tmp = new Date(); + final Date today = new Date(tmp.getYear(), tmp.getMonth(), + tmp.getDate()); final int startWeekDay = getDateTimeService().getStartWeekDay( focusedDate); - final int daysInMonth = DateTimeService - .getNumberOfDaysInMonth(focusedDate); - - int dayCount = 0; - final Date curr = new Date(focusedDate.getTime()); + final Date curr = (Date) focusedDate.clone(); + // Start from the first day of the week that at least partially belongs + // to the current month + curr.setDate(-startWeekDay); // No month has more than 6 weeks so 6 is a safe maximum for rows. for (int weekOfMonth = 1; weekOfMonth < 7; weekOfMonth++) { - boolean weekNumberProcessed[] = new boolean[] { false, false, - false, false, false, false, false }; - for (int dayOfWeek = 0; dayOfWeek < 7; dayOfWeek++) { - if (!(weekOfMonth == 1 && dayOfWeek < startWeekDay)) { - - if (dayCount >= daysInMonth) { - // All days printed and we are done - break; - } - - final int dayOfMonth = ++dayCount; - - curr.setDate(dayCount); - // Actually write the day of month - Day day = new Day(dayOfMonth); + // Actually write the day of month + Day day = new Day((Date) curr.clone()); - if (dayOfMonthSelected == dayOfMonth) { - day.addStyleDependentName(CN_SELECTED); - selectedDay = day; + if (curr.equals(value)) { + day.addStyleDependentName(CN_SELECTED); + selectedDay = day; + } + if (curr.equals(today)) { + day.addStyleDependentName(CN_TODAY); + } + if (curr.equals(focusedDate)) { + focusedDay = day; + focusedRow = weekOfMonth; + if (hasFocus) { + day.addStyleDependentName(CN_FOCUSED); } + } + if (curr.getMonth() != focusedDate.getMonth()) { + day.addStyleDependentName(CN_OFFMONTH); + } - if (dayOfMonthToday == dayOfMonth) { - day.addStyleDependentName(CN_TODAY); - } + days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek, day); - if (dayOfMonth == focusedDate.getDate()) { - focusedDay = day; - focusedRow = weekOfMonth; - if (hasFocus) { - day.addStyleDependentName(CN_FOCUSED); - } - } + // ISO week numbers if requested + days.getCellFormatter().setVisible(weekOfMonth, weekColumn, + isShowISOWeekNumbers()); + if (isShowISOWeekNumbers()) { + final String baseCssClass = VDateField.CLASSNAME + + "-calendarpanel-weeknumber"; + String weekCssClass = baseCssClass; - days.setWidget(weekOfMonth, firstWeekdayColumn + dayOfWeek, - day); - - // ISO week numbers if requested - if (!weekNumberProcessed[weekOfMonth]) { - days.getCellFormatter().setVisible(weekOfMonth, - weekColumn, isShowISOWeekNumbers()); - if (isShowISOWeekNumbers()) { - final String baseCssClass = VDateField.CLASSNAME - + "-calendarpanel-weeknumber"; - String weekCssClass = baseCssClass; - - int weekNumber = DateTimeService - .getISOWeekNumber(curr); - - days.setHTML(weekOfMonth, 0, "" + weekNumber - + ""); - weekNumberProcessed[weekOfMonth] = true; - } + int weekNumber = DateTimeService.getISOWeekNumber(curr); - } + days.setHTML(weekOfMonth, 0, "" + weekNumber + + ""); } + curr.setDate(curr.getDate() + 1); } } - } /** @@ -621,6 +594,7 @@ public class VCalendarPanel extends FocusableFlexTable implements while (focusedDate.getMonth() != requestedMonth) { focusedDate.setDate(focusedDate.getDate() - 1); } + displayedMonth.setMonth(displayedMonth.getMonth() + 1); renderCalendar(); } @@ -640,6 +614,7 @@ public class VCalendarPanel extends FocusableFlexTable implements while (focusedDate.getMonth() == currentMonth) { focusedDate.setDate(focusedDate.getDate() - 1); } + displayedMonth.setMonth(displayedMonth.getMonth() - 1); renderCalendar(); } @@ -649,6 +624,7 @@ public class VCalendarPanel extends FocusableFlexTable implements */ private void focusPreviousYear(int years) { focusedDate.setYear(focusedDate.getYear() - years); + displayedMonth.setYear(displayedMonth.getYear() - years); renderCalendar(); } @@ -657,6 +633,7 @@ public class VCalendarPanel extends FocusableFlexTable implements */ private void focusNextYear(int years) { focusedDate.setYear(focusedDate.getYear() + years); + displayedMonth.setYear(displayedMonth.getYear() + years); renderCalendar(); } @@ -905,7 +882,7 @@ public class VCalendarPanel extends FocusableFlexTable implements if (newCurrentDate.getMonth() == focusedDate.getMonth()) { // Month did not change, only move the selection - focusDay(focusedDate.getDate() + 1); + focusDay(newCurrentDate); } else { // If the month changed we need to re-render the calendar focusedDate.setDate(focusedDate.getDate() + 1); @@ -924,7 +901,7 @@ public class VCalendarPanel extends FocusableFlexTable implements if (newCurrentDate.getMonth() == focusedDate.getMonth()) { // Month did not change, only move the selection - focusDay(focusedDate.getDate() - 1); + focusDay(newCurrentDate); } else { // If the month changed we need to re-render the calendar focusedDate.setDate(focusedDate.getDate() - 1); @@ -944,10 +921,10 @@ public class VCalendarPanel extends FocusableFlexTable implements if (newCurrentDate.getMonth() == focusedDate.getMonth() && focusedRow > 1) { // Month did not change, only move the selection - focusDay(focusedDate.getDate() - 7); + focusDay(newCurrentDate); } else { // If the month changed we need to re-render the calendar - focusedDate.setDate(focusedDate.getDate() - 7); + focusedDate = newCurrentDate; renderCalendar(); } @@ -963,10 +940,10 @@ public class VCalendarPanel extends FocusableFlexTable implements if (newCurrentDate.getMonth() == focusedDate.getMonth()) { // Month did not change, only move the selection - focusDay(focusedDate.getDate() + 7); + focusDay(newCurrentDate); } else { // If the month changed we need to re-render the calendar - focusedDate.setDate(focusedDate.getDate() + 7); + focusedDate = newCurrentDate; renderCalendar(); } @@ -1210,27 +1187,28 @@ public class VCalendarPanel extends FocusableFlexTable implements return; } - Date oldFocusedValue = focusedDate; + Date oldDisplayedMonth = displayedMonth; value = currentDate; if (value == null) { - focusedDate = null; + focusedDate = displayedMonth = null; } else { focusedDate = (Date) value.clone(); + displayedMonth = (Date) value.clone(); } // Re-render calendar if month or year of focused date has changed - if (oldFocusedValue == null || value == null - || oldFocusedValue.getYear() != value.getYear() - || oldFocusedValue.getMonth() != value.getMonth()) { + if (oldDisplayedMonth == null || value == null + || oldDisplayedMonth.getYear() != value.getYear() + || oldDisplayedMonth.getMonth() != value.getMonth()) { renderCalendar(); } else { - focusDay(currentDate.getDate()); + focusDay(currentDate); selectFocused(); } if (!hasFocus) { - focusDay(-1); + focusDay((Date) null); } } @@ -1552,20 +1530,23 @@ public class VCalendarPanel extends FocusableFlexTable implements } + /** + * A widget representing a single day in the calendar panel. + */ private class Day extends InlineHTML { private static final String BASECLASS = VDateField.CLASSNAME + "-calendarpanel-day"; - private final int day; + private final Date date; - Day(int dayOfMonth) { - super("" + dayOfMonth); + Day(Date date) { + super("" + date.getDate()); setStyleName(BASECLASS); - day = dayOfMonth; + this.date = date; addClickHandler(dayClickHandler); } - public int getDay() { - return day; + public Date getDate() { + return date; } } @@ -1648,7 +1629,7 @@ public class VCalendarPanel extends FocusableFlexTable implements public void onBlur(final BlurEvent event) { if (event.getSource() instanceof VCalendarPanel) { hasFocus = false; - focusDay(-1); + focusDay(null); } } @@ -1665,7 +1646,7 @@ public class VCalendarPanel extends FocusableFlexTable implements // Focuses the current day if the calendar shows the days if (focusedDay != null) { - focusDay(focusedDay.getDay()); + focusDay(focusedDate); } } } @@ -1696,7 +1677,17 @@ public class VCalendarPanel extends FocusableFlexTable implements // Day, find out which dayOfMonth and use that as the identifier Day day = Util.findWidget(subElement, Day.class); if (day != null) { - return SUBPART_DAY + day.getDay(); + Date date = day.getDate(); + int id = date.getDate(); + // Zero or negative ids map to days of the preceding month, + // past-the-end-of-month ids to days of the following month + if (date.getMonth() < displayedMonth.getMonth()) { + id -= DateTimeService.getNumberOfDaysInMonth(date); + } else if (date.getMonth() > displayedMonth.getMonth()) { + id += DateTimeService + .getNumberOfDaysInMonth(displayedMonth); + } + return SUBPART_DAY + id; } } else if (time != null) { if (contains(time.hours, subElement)) { @@ -1762,14 +1753,18 @@ public class VCalendarPanel extends FocusableFlexTable implements return time.ampm.getElement(); } if (subPart.startsWith(SUBPART_DAY)) { + // Zero or negative ids map to days in the preceding month, + // past-the-end-of-month ids to days in the following month int dayOfMonth = Integer.parseInt(subPart.substring(SUBPART_DAY .length())); + Date date = new Date(displayedMonth.getYear(), + displayedMonth.getMonth(), dayOfMonth); Iterator iter = days.iterator(); while (iter.hasNext()) { Widget w = iter.next(); if (w instanceof Day) { Day day = (Day) w; - if (day.getDay() == dayOfMonth) { + if (day.getDate().equals(date)) { return day.getElement(); } } diff --git a/src/com/vaadin/terminal/gwt/client/ui/VSlider.java b/src/com/vaadin/terminal/gwt/client/ui/VSlider.java index a001ca7f13..4a46346613 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VSlider.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VSlider.java @@ -425,10 +425,6 @@ public class VSlider extends SimpleFocusablePanel implements Paintable, Field, setValueByEvent(event, true); DOM.eventCancelBubble(event, true); } - } else if (DOM.eventGetType(event) == Event.ONMOUSEDOWN && dragging) { - dragging = false; - DOM.releaseCapture(getElement()); - setValueByEvent(event, true); } } diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java index bd67841f33..1971fb6d0e 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractorderedlayout/AddComponentsTest.java @@ -1,14 +1,14 @@ package com.vaadin.tests.server.component.abstractorderedlayout; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.fail; - import java.util.Iterator; import java.util.NoSuchElementException; import org.junit.Test; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + import com.vaadin.ui.AbstractOrderedLayout; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; diff --git a/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java b/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java index d4a0592768..c0d739b597 100644 --- a/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java +++ b/tests/server-side/com/vaadin/tests/server/component/csslayout/AddComponentsTest.java @@ -5,8 +5,8 @@ import java.util.NoSuchElementException; import org.junit.Test; -import static org.junit.Assert.assertSame; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import com.vaadin.ui.Component; diff --git a/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java b/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java index 9271e9f1b3..e3e743d02a 100644 --- a/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java +++ b/tests/server-side/com/vaadin/tests/server/componentcontainer/AbstractIndexedLayoutTest.java @@ -1,84 +1,84 @@ -package com.vaadin.tests.server.componentcontainer; - -import junit.framework.TestCase; - -import com.vaadin.ui.Component; -import com.vaadin.ui.Label; -import com.vaadin.ui.Layout; - -public abstract class AbstractIndexedLayoutTest extends TestCase { - - private Layout layout; - - protected abstract Layout createLayout(); - - @Override - protected void setUp() throws Exception { - layout = createLayout(); - } - - public Layout getLayout() { - return layout; - } - - public void testAddRemoveComponent() { - Label c1 = new Label(); - Label c2 = new Label(); - - layout.addComponent(c1); - - assertEquals(c1, getComponent(0)); - assertEquals(1, getComponentCount()); - layout.addComponent(c2); - assertEquals(c1, getComponent(0)); - assertEquals(c2, getComponent(1)); - assertEquals(2, getComponentCount()); - layout.removeComponent(c1); - assertEquals(c2, getComponent(0)); - assertEquals(1, getComponentCount()); - layout.removeComponent(c2); - assertEquals(0, getComponentCount()); - } - - protected abstract int getComponentCount(); - - protected abstract Component getComponent(int index); - - protected abstract int getComponentIndex(Component c); - - public void testGetComponentIndex() { - Label c1 = new Label(); - Label c2 = new Label(); - - layout.addComponent(c1); - assertEquals(0, getComponentIndex(c1)); - layout.addComponent(c2); - assertEquals(0, getComponentIndex(c1)); - assertEquals(1, getComponentIndex(c2)); - layout.removeComponent(c1); - assertEquals(0, getComponentIndex(c2)); - layout.removeComponent(c2); - assertEquals(-1, getComponentIndex(c2)); - assertEquals(-1, getComponentIndex(c1)); - } - - public void testGetComponent() { - Label c1 = new Label(); - Label c2 = new Label(); - - layout.addComponent(c1); - assertEquals(c1, getComponent(0)); - layout.addComponent(c2); - assertEquals(c1, getComponent(0)); - assertEquals(c2, getComponent(1)); - layout.removeComponent(c1); - assertEquals(c2, getComponent(0)); - layout.removeComponent(c2); - try { - getComponent(0); - fail(); - } catch (IndexOutOfBoundsException e) { - // Expected - } - } -} +package com.vaadin.tests.server.componentcontainer; + +import junit.framework.TestCase; + +import com.vaadin.ui.Component; +import com.vaadin.ui.Label; +import com.vaadin.ui.Layout; + +public abstract class AbstractIndexedLayoutTest extends TestCase { + + private Layout layout; + + protected abstract Layout createLayout(); + + @Override + protected void setUp() throws Exception { + layout = createLayout(); + } + + public Layout getLayout() { + return layout; + } + + public void testAddRemoveComponent() { + Label c1 = new Label(); + Label c2 = new Label(); + + layout.addComponent(c1); + + assertEquals(c1, getComponent(0)); + assertEquals(1, getComponentCount()); + layout.addComponent(c2); + assertEquals(c1, getComponent(0)); + assertEquals(c2, getComponent(1)); + assertEquals(2, getComponentCount()); + layout.removeComponent(c1); + assertEquals(c2, getComponent(0)); + assertEquals(1, getComponentCount()); + layout.removeComponent(c2); + assertEquals(0, getComponentCount()); + } + + protected abstract int getComponentCount(); + + protected abstract Component getComponent(int index); + + protected abstract int getComponentIndex(Component c); + + public void testGetComponentIndex() { + Label c1 = new Label(); + Label c2 = new Label(); + + layout.addComponent(c1); + assertEquals(0, getComponentIndex(c1)); + layout.addComponent(c2); + assertEquals(0, getComponentIndex(c1)); + assertEquals(1, getComponentIndex(c2)); + layout.removeComponent(c1); + assertEquals(0, getComponentIndex(c2)); + layout.removeComponent(c2); + assertEquals(-1, getComponentIndex(c2)); + assertEquals(-1, getComponentIndex(c1)); + } + + public void testGetComponent() { + Label c1 = new Label(); + Label c2 = new Label(); + + layout.addComponent(c1); + assertEquals(c1, getComponent(0)); + layout.addComponent(c2); + assertEquals(c1, getComponent(0)); + assertEquals(c2, getComponent(1)); + layout.removeComponent(c1); + assertEquals(c2, getComponent(0)); + layout.removeComponent(c2); + try { + getComponent(0); + fail(); + } catch (IndexOutOfBoundsException e) { + // Expected + } + } +} diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java index f2726118d4..eacf2a0e53 100644 --- a/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java +++ b/tests/testbench/com/vaadin/tests/application/WebBrowserSizeTest.java @@ -1,45 +1,45 @@ -package com.vaadin.tests.application; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Label; - -public class WebBrowserSizeTest extends TestBase { - - @Override - protected void setup() { - - final Label screenSizeLabel = new Label("n/a"); - screenSizeLabel.setCaption("Screen size"); - - final Label browserSizeLabel = new Label("n/a"); - browserSizeLabel.setCaption("Client (browser window) size"); - - final Button update = new Button("Refresh", new Button.ClickListener() { - - public void buttonClick(ClickEvent event) { - screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x " - + getBrowser().getScreenHeight()); - browserSizeLabel.setValue(getBrowser().getClientWidth() + " x " - + getBrowser().getClientHeight()); - } - }); - - addComponent(update); - addComponent(screenSizeLabel); - addComponent(browserSizeLabel); - - } - - @Override - protected String getDescription() { - return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations."; - } - - @Override - protected Integer getTicketNumber() { - return 5655; - } - -} +package com.vaadin.tests.application; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Label; + +public class WebBrowserSizeTest extends TestBase { + + @Override + protected void setup() { + + final Label screenSizeLabel = new Label("n/a"); + screenSizeLabel.setCaption("Screen size"); + + final Label browserSizeLabel = new Label("n/a"); + browserSizeLabel.setCaption("Client (browser window) size"); + + final Button update = new Button("Refresh", new Button.ClickListener() { + + public void buttonClick(ClickEvent event) { + screenSizeLabel.setValue(getBrowser().getScreenWidth() + " x " + + getBrowser().getScreenHeight()); + browserSizeLabel.setValue(getBrowser().getClientWidth() + " x " + + getBrowser().getClientHeight()); + } + }); + + addComponent(update); + addComponent(screenSizeLabel); + addComponent(browserSizeLabel); + + } + + @Override + protected String getDescription() { + return "Verifies that browser sizes are reported correctly. Note that client width differs depending on browser decorations."; + } + + @Override + protected Integer getTicketNumber() { + return 5655; + } + +} diff --git a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java index 4508e4ef90..35235bbe1f 100644 --- a/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java +++ b/tests/testbench/com/vaadin/tests/application/WebBrowserTest.java @@ -71,6 +71,7 @@ public class WebBrowserTest extends TestBase { curDateLabel.setValue(getBrowser().getCurrentDate() .toString()); + } }); @@ -82,7 +83,6 @@ public class WebBrowserTest extends TestBase { addComponent(curDateLabel); addComponent(diffLabel); addComponent(containsLabel); - } @Override diff --git a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java index 4fc8f87398..357c61f4f6 100644 --- a/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java +++ b/tests/testbench/com/vaadin/tests/components/datefield/PopupDateFieldExtendedRange.java @@ -1,69 +1,69 @@ -package com.vaadin.tests.components.datefield; - -import java.util.Calendar; -import java.util.Locale; - -import com.vaadin.tests.components.TestBase; -import com.vaadin.ui.Button; -import com.vaadin.ui.Button.ClickEvent; -import com.vaadin.ui.Button.ClickListener; -import com.vaadin.ui.DateField; -import com.vaadin.ui.PopupDateField; - -@SuppressWarnings("serial") -public class PopupDateFieldExtendedRange extends TestBase { - - private Calendar date = Calendar.getInstance(); - - @Override - protected void setup() { - date.set(2011, 0, 1); - - getLayout().setSpacing(true); - - final PopupDateField[] fields = new PopupDateField[3]; - - fields[0] = makeDateField(); - fields[0].setLocale(new Locale("fi", "FI")); - fields[0].setCaption("Finnish locale"); - - fields[1] = makeDateField(); - fields[1].setLocale(new Locale("en", "US")); - fields[1].setCaption("US English locale"); - - fields[2] = makeDateField(); - fields[2].setLocale(new Locale("fi", "FI")); - fields[2].setShowISOWeekNumbers(true); - fields[2].setCaption("Finnish locale with week numbers"); - - for (PopupDateField f : fields) { - addComponent(f); - } - - addComponent(new Button("Change date", new ClickListener() { - public void buttonClick(ClickEvent event) { - date.set(2010, 1, 16); - for (PopupDateField f : fields) { - f.setValue(date.getTime()); - } - } - })); - } - - @Override - protected String getDescription() { - return "Show a few days of the preceding and following months in the datefield popup"; - } - - @Override - protected Integer getTicketNumber() { - return 6718; - } - - private PopupDateField makeDateField() { - PopupDateField pdf = new PopupDateField(); - pdf.setResolution(DateField.RESOLUTION_DAY); - pdf.setValue(date.getTime()); - return pdf; - } -} +package com.vaadin.tests.components.datefield; + +import java.util.Calendar; +import java.util.Locale; + +import com.vaadin.tests.components.TestBase; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; +import com.vaadin.ui.Button.ClickListener; +import com.vaadin.ui.DateField; +import com.vaadin.ui.PopupDateField; + +@SuppressWarnings("serial") +public class PopupDateFieldExtendedRange extends TestBase { + + private Calendar date = Calendar.getInstance(); + + @Override + protected void setup() { + date.set(2011, 0, 1); + + getLayout().setSpacing(true); + + final PopupDateField[] fields = new PopupDateField[3]; + + fields[0] = makeDateField(); + fields[0].setLocale(new Locale("fi", "FI")); + fields[0].setCaption("Finnish locale"); + + fields[1] = makeDateField(); + fields[1].setLocale(new Locale("en", "US")); + fields[1].setCaption("US English locale"); + + fields[2] = makeDateField(); + fields[2].setLocale(new Locale("fi", "FI")); + fields[2].setShowISOWeekNumbers(true); + fields[2].setCaption("Finnish locale with week numbers"); + + for (PopupDateField f : fields) { + addComponent(f); + } + + addComponent(new Button("Change date", new ClickListener() { + public void buttonClick(ClickEvent event) { + date.set(2010, 1, 16); + for (PopupDateField f : fields) { + f.setValue(date.getTime()); + } + } + })); + } + + @Override + protected String getDescription() { + return "Show a few days of the preceding and following months in the datefield popup"; + } + + @Override + protected Integer getTicketNumber() { + return 6718; + } + + private PopupDateField makeDateField() { + PopupDateField pdf = new PopupDateField(); + pdf.setResolution(DateField.RESOLUTION_DAY); + pdf.setValue(date.getTime()); + return pdf; + } +} -- 2.39.5