aboutsummaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorDenis <denis@vaadin.com>2016-12-27 16:37:43 +0200
committerIlia Motornyi <elmot@vaadin.com>2016-12-27 16:37:43 +0200
commitc66e5959745b13a95239873059ccd92acc14144a (patch)
tree0f329ed1e4c9b66c5ca1b84c4ac29ab04df9ce6f /uitest
parent95626bc699d61e48669a7bc333907e64be883e5a (diff)
downloadvaadin-framework-c66e5959745b13a95239873059ccd92acc14144a.tar.gz
vaadin-framework-c66e5959745b13a95239873059ccd92acc14144a.zip
Clean up calendar tests. (#8094)
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java193
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionEventSource.java115
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsMenuTest.java142
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsUI.java111
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarBackwardForward.java135
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java123
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarHtmlInEvents.java98
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java114
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarNotifications.java116
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java105
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java103
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfView.java109
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java1265
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarVisibleHours.java134
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarWeekSelection.java39
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetails.java46
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java61
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/NotificationTestUI.java104
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/NullEventMoveHandler.java62
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDay.java80
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCase.java81
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java113
-rw-r--r--uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerTest.java75
-rw-r--r--uitest/src/main/java/com/vaadin/tests/smoke/CalendarSmoke.java (renamed from uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarReadOnly.java)17
-rw-r--r--uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java1
-rw-r--r--uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTestEvent.java (renamed from uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTestEvent.java)2
-rw-r--r--uitest/src/main/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSort.java223
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java60
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java83
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java99
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java52
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java100
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java119
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java82
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java87
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java82
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java139
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java68
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java68
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java42
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java36
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java71
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java113
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java100
-rw-r--r--uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java (renamed from uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarReadOnlyTest.java)78
-rw-r--r--uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java183
46 files changed, 27 insertions, 5402 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java
deleted file mode 100644
index 0f468ae979..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/BeanItemContainerTestUI.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/**
- * Copyright 2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.GregorianCalendar;
-
-import com.vaadin.event.Action;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalSplitPanel;
-import com.vaadin.ui.Window;
-import com.vaadin.ui.Window.CloseEvent;
-import com.vaadin.v7.data.fieldgroup.FieldGroup;
-import com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException;
-import com.vaadin.v7.data.util.BeanItem;
-import com.vaadin.v7.data.util.BeanItemContainer;
-import com.vaadin.v7.shared.ui.datefield.Resolution;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.DateField;
-import com.vaadin.v7.ui.Table;
-import com.vaadin.v7.ui.TextField;
-import com.vaadin.v7.ui.components.calendar.ContainerEventProvider;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-public class BeanItemContainerTestUI extends UI {
-
- private Calendar calendar;
-
- private Table table;
-
- private BeanItemContainer<BasicEvent> events = new BeanItemContainer<>(
- BasicEvent.class);
-
- @SuppressWarnings("deprecation")
- @Override
- protected void init(VaadinRequest request) {
- VerticalSplitPanel content = new VerticalSplitPanel();
- content.setSizeFull();
- setContent(content);
-
- // Create Calendar
- calendar = new Calendar();
- calendar.setImmediate(true);
- calendar.setSizeFull();
- calendar.setContainerDataSource(events);
- calendar.setStartDate(new Date(100, 1, 1));
- calendar.setEndDate(new Date(100, 2, 1));
-
- content.addComponent(calendar);
-
- // Add event table connected to same data source
- table = createTable();
- table.setContainerDataSource(events);
- table.setVisibleColumns(
- new Object[] { "caption", "description", "start", "end" });
- content.addComponent(table);
-
- BasicEvent longEvent = new BasicEvent();
- longEvent.setCaption("Long event");
- longEvent.setAllDay(true);
- longEvent.setStart(new GregorianCalendar(2000, 1, 3).getTime());
- longEvent.setEnd(new GregorianCalendar(2000, 2, 5).getTime());
- events.addBean(longEvent);
- }
-
- /**
- * Creates a table with some actions
- *
- * @return
- */
- private Table createTable() {
- Table table = new Table();
- table.setSizeFull();
- table.addActionHandler(new Action.Handler() {
-
- private final Action ADD = new Action("Add event");
- private final Action EDIT = new Action("Edit event");
- private final Action REMOVE = new Action("Remove event");
-
- @Override
- public void handleAction(Action action, Object sender,
- Object target) {
- if (action == ADD) {
- BasicEvent event = new BasicEvent();
- event.setStart(new Date(100, 1, 1));
- event.setEnd(new Date(100, 1, 1));
- editEvent(event);
- } else if (action == EDIT) {
- editEvent((BasicEvent) target);
- } else if (action == REMOVE) {
- events.removeItem(target);
- }
- }
-
- @Override
- public Action[] getActions(Object target, Object sender) {
- if (target == null) {
- return new Action[] { ADD };
- } else {
- return new Action[] { EDIT, REMOVE };
- }
- }
- });
- return table;
- }
-
- /**
- * Opens up a modal dialog window where an event can be modified
- *
- * @param event
- * The event to modify
- */
- private void editEvent(final BasicEvent event) {
- Window modal = new Window("Add event");
- modal.setModal(true);
- modal.setResizable(false);
- modal.setDraggable(false);
- modal.setWidth("300px");
- final FieldGroup fieldGroup = new FieldGroup();
-
- FormLayout formLayout = new FormLayout();
- TextField captionField = new TextField("Caption");
- captionField.setImmediate(true);
- TextField descriptionField = new TextField("Description");
- descriptionField.setImmediate(true);
- DateField startField = new DateField("Start");
- startField.setResolution(Resolution.MINUTE);
- startField.setImmediate(true);
- DateField endField = new DateField("End");
- endField.setImmediate(true);
- endField.setResolution(Resolution.MINUTE);
-
- formLayout.addComponent(captionField);
- formLayout.addComponent(descriptionField);
- formLayout.addComponent(startField);
- formLayout.addComponent(endField);
-
- fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY);
- fieldGroup.bind(descriptionField,
- ContainerEventProvider.DESCRIPTION_PROPERTY);
- fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY);
- fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY);
-
- fieldGroup.setItemDataSource(new BeanItem<>(event,
- Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY,
- ContainerEventProvider.DESCRIPTION_PROPERTY,
- ContainerEventProvider.STARTDATE_PROPERTY,
- ContainerEventProvider.ENDDATE_PROPERTY)));
- modal.setContent(formLayout);
- modal.addCloseListener(new Window.CloseListener() {
- @Override
- public void windowClose(CloseEvent e) {
- // Commit changes to bean
- try {
- fieldGroup.commit();
- } catch (CommitException e1) {
- e1.printStackTrace();
- }
-
- if (events.containsId(event)) {
- /*
- * BeanItemContainer does not notify container listeners
- * when the bean changes so we need to trigger a
- * ItemSetChange event
- */
- BasicEvent dummy = new BasicEvent();
- events.addBean(dummy);
- events.removeItem(dummy);
-
- } else {
- events.addBean(event);
- }
- }
- });
- getUI().addWindow(modal);
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionEventSource.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionEventSource.java
deleted file mode 100644
index dbd9dc7056..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionEventSource.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.Label;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-public class CalendarActionEventSource extends AbstractReindeerTestUI {
-
- private Calendar calendar;
-
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar(new CalendarEventProvider() {
-
- @Override
- public List<com.vaadin.v7.ui.components.calendar.event.CalendarEvent> getEvents(
- Date startDate, Date endDate) {
-
- List<CalendarEvent> events = new ArrayList<>();
-
- CalendarEvent event = null;
- try {
- event = new BasicEvent("NAME", null,
- new SimpleDateFormat("yyyy-MM-dd hh:mm")
- .parse("2013-01-01 07:00"),
- new SimpleDateFormat("yyyy-MM-dd hh:mm")
- .parse("2013-01-01 11:00"));
- } catch (ParseException e) {
- // Nothing to do
- }
- events.add(event);
-
- return events;
- }
-
- });
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-31"));
- } catch (ParseException e) {
- // Nothing to do
- }
- calendar.setImmediate(true);
- calendar.setFirstVisibleHourOfDay(6);
- calendar.setLastVisibleHourOfDay(22);
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setHandler((EventResizeHandler) null);
-
- setEnabled(true);
- calendar.addActionHandler(new Handler() {
- @Override
- public void handleAction(Action action, Object sender,
- Object target) {
- Label label1 = new Label(calendar.toString());
- label1.setId("calendarlabel");
- addComponent(label1);
-
- Label label2 = new Label(sender.toString());
- label2.setId("senderlabel");
- addComponent(label2);
- }
-
- @Override
- public Action[] getActions(Object target, Object sender) {
- return new Action[] { new Action("ACTION") };
- }
- });
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
-
- }
-
- @Override
- protected String getTestDescription() {
- return "Calendar action event source should be the calendar itself";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 13191;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsMenuTest.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsMenuTest.java
deleted file mode 100644
index b1e5677de1..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsMenuTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.Notification;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClick;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClickHandler;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventMoveHandler;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.MoveEvent;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-public class CalendarActionsMenuTest extends AbstractReindeerTestUI {
-
- private Calendar calendar;
-
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar(new CalendarEventProvider() {
-
- @Override
- public List<com.vaadin.v7.ui.components.calendar.event.CalendarEvent> getEvents(
- Date startDate, Date endDate) {
-
- List<CalendarEvent> events = new ArrayList<>();
-
- CalendarEvent event = null;
- try {
- event = new BasicEvent("NAME", "TOOLTIP",
- new SimpleDateFormat("yyyy-MM-dd hh:mm")
- .parse("2013-01-01 07:00"),
- new SimpleDateFormat("yyyy-MM-dd hh:mm")
- .parse("2013-01-01 11:00"));
- } catch (ParseException e) {
- // Nothing to do
- }
- events.add(event);
-
- try {
- event = new BasicEvent("NAME 2", "TOOLTIP2",
- new SimpleDateFormat("yyyy-MM-dd hh:mm")
- .parse("2013-01-03 07:00"),
- new SimpleDateFormat("yyyy-MM-dd hh:mm")
- .parse("2013-01-04 11:00"));
- } catch (ParseException e) {
- // Nothing to do
- }
- events.add(event);
-
- return events;
- }
-
- });
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-01-31"));
- } catch (ParseException e) {
- // Nothing to do
- }
- calendar.setImmediate(true);
- calendar.setFirstVisibleHourOfDay(6);
- calendar.setLastVisibleHourOfDay(22);
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setHandler((EventResizeHandler) null);
-
- setEnabled(true);
- calendar.addActionHandler(new Handler() {
- @Override
- public void handleAction(Action action, Object sender,
- Object target) {
- Notification.show("ACTION CLICKED");
-
- }
-
- @Override
- public Action[] getActions(Object target, Object sender) {
- return new Action[] { new Action("ACTION") };
- }
- });
- calendar.setHandler(new EventClickHandler() {
- private static final long serialVersionUID = -177173530105538438L;
-
- @Override
- public void eventClick(EventClick event) {
- Notification.show("EVENT CLICKED");
- }
- });
-
- calendar.setHandler(new EventMoveHandler() {
- @Override
- public void eventMove(MoveEvent event) {
- Notification.show("EVENT MOVED");
- }
- });
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
-
- }
-
- @Override
- protected String getTestDescription() {
- // TODO Auto-generated method stub
- return "The context should appear if you right click on a calendar event regardless of view mode";
- }
-
- @Override
- protected Integer getTicketNumber() {
- // TODO Auto-generated method stub
- return 12181;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsUI.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsUI.java
deleted file mode 100644
index 82c110c21e..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarActionsUI.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/**
- * Copyright 2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.event.Action;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.UI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.CalendarDateRange;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-public class CalendarActionsUI extends UI {
-
- @SuppressWarnings("deprecation")
- @Override
- protected void init(VaadinRequest request) {
- GridLayout content = new GridLayout(1, 2);
- content.setSizeFull();
- setContent(content);
-
- final Calendar calendar = new Calendar();
- calendar.setLocale(new Locale("fi", "FI"));
-
- calendar.setSizeFull();
- calendar.setStartDate(new Date(100, 1, 1));
- calendar.setEndDate(new Date(100, 2, 1));
-
- calendar.addActionHandler(new Action.Handler() {
-
- public final Action NEW_EVENT = new Action("Add event");
- public final Action EDIT_EVENT = new Action("Edit event");
- public final Action REMOVE_EVENT = new Action("Remove event");
-
- /*
- * (non-Javadoc)
- *
- * @see
- * com.vaadin.event.Action.Handler#handleAction(com.vaadin.event
- * .Action, java.lang.Object, java.lang.Object)
- */
- @Override
- public void handleAction(Action action, Object sender,
- Object target) {
- Date date = (Date) target;
- if (action == NEW_EVENT) {
- BasicEvent event = new BasicEvent("New event",
- "Hello world", date, date);
- calendar.addEvent(event);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.event.Action.Handler#getActions(java.lang.Object,
- * java.lang.Object)
- */
- @Override
- public Action[] getActions(Object target, Object sender) {
- CalendarDateRange date = (CalendarDateRange) target;
-
- java.util.Calendar cal = java.util.Calendar.getInstance();
- cal.set(2000, 1, 1, 12, 0, 0);
-
- if (date.inRange(cal.getTime())) {
- return new Action[] { NEW_EVENT, };
- }
-
- cal.add(java.util.Calendar.DAY_OF_WEEK, 1);
-
- if (date.inRange(cal.getTime())) {
- return new Action[] { REMOVE_EVENT };
- }
-
- return null;
- }
- });
-
- content.addComponent(calendar);
-
- content.addComponent(
- new Button("Set week view", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- calendar.setEndDate(new Date(100, 1, 7));
- }
- }));
-
- content.setRowExpandRatio(0, 1);
-
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarBackwardForward.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarBackwardForward.java
deleted file mode 100644
index 3b407413f6..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarBackwardForward.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-/**
- * Test: Vaadin Calendar: Navigation to invisible days of week (#12243)
- *
- * @author Vaadin Ltd
- */
-@Theme("tests-calendar")
-public class CalendarBackwardForward extends AbstractReindeerTestUI {
-
- private static final long serialVersionUID = 1L;
- private Calendar calendar;
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
- * VaadinRequest)
- */
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar();
-
- try {
-
- BasicEvent event = new BasicEvent("EVENT NAME 1", "EVENT TOOLTIP 1",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 15:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-07 22:20"));
- event.setStyleName("color1");
- calendar.addEvent(event);
-
- event = new BasicEvent("EVENT NAME 2", "EVENT TOOLTIP 2",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 12:10"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 13:20"));
- event.setStyleName("color2");
- calendar.addEvent(event);
-
- event = new BasicEvent("EVENT NAME 3", "EVENT TOOLTIP 3",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-01 11:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-29 15:20"));
- event.setStyleName("color3");
- calendar.addEvent(event);
-
- event = new BasicEvent("EVENT NAME 4", "EVENT TOOLTIP 4",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-01 11:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-01 15:20"));
- event.setStyleName("color4");
- event.setAllDay(true);
- calendar.addEvent(event);
- } catch (ParseException e1) { // Nothing to do
- e1.printStackTrace();
- }
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-30"));
- } catch (ParseException e) { // Nothing to do
-
- }
-
- calendar.setImmediate(true);
-
- // in english locale first day of week - sunday
- calendar.setLocale(Locale.ENGLISH);
- // show only working days: 2 - monday, 6 - friday
- calendar.setFirstVisibleDayOfWeek(2);
- calendar.setLastVisibleDayOfWeek(6);
-
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setHandler((EventResizeHandler) null);
- setEnabled(true);
-
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
- */
- @Override
- protected String getTestDescription() {
- return "If one uses the feature setVisibleDaysOfWeek of Calendar, the invisible days should be skipped in single-day-mode.";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
- */
- @Override
- protected Integer getTicketNumber() {
- return 12243;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java
deleted file mode 100644
index 215c929af5..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarDragAndDrop.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-/**
- *
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.GregorianCalendar;
-import java.util.Locale;
-
-import com.vaadin.event.dd.DragAndDropEvent;
-import com.vaadin.event.dd.DropHandler;
-import com.vaadin.event.dd.acceptcriteria.AcceptAll;
-import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Table;
-import com.vaadin.v7.ui.Table.TableDragMode;
-import com.vaadin.v7.ui.Table.TableTransferable;
-import com.vaadin.v7.ui.components.calendar.CalendarTargetDetails;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-public class CalendarDragAndDrop extends AbstractReindeerTestUI {
-
- private Calendar calendar;
-
- private Table table;
-
- private class TestDropHandler implements DropHandler {
-
- @Override
- public void drop(DragAndDropEvent event) {
- CalendarTargetDetails details = (CalendarTargetDetails) event
- .getTargetDetails();
-
- TableTransferable transferable = (TableTransferable) event
- .getTransferable();
-
- calendar.addEvent(new BasicEvent(
- transferable.getItemId().toString(),
- "This event was dragged here", details.getDropTime()));
-
- table.removeItem(transferable.getItemId());
- }
-
- @Override
- public AcceptCriterion getAcceptCriterion() {
- return AcceptAll.get();
- }
- }
-
- @Override
- protected void setup(VaadinRequest request) {
- setSizeFull();
- getContent().setSizeFull();
- getLayout().setSizeFull();
-
- HorizontalLayout root = new HorizontalLayout();
- root.setSizeFull();
- addComponent(root);
-
- Locale locale = new Locale("en", "US");
- GregorianCalendar cal = new GregorianCalendar(locale);
- cal.set(2013, 0, 1);
-
- calendar = new Calendar();
- calendar.setId("Calendar");
- calendar.setLocale(locale);
- calendar.setDropHandler(new TestDropHandler());
- calendar.setSizeFull();
- root.addComponent(calendar);
-
- calendar.setStartDate(cal.getTime());
- cal.add(java.util.Calendar.MONTH, 1);
- calendar.setEndDate(cal.getTime());
-
- table = new Table();
- table.setSizeFull();
- table.setDragMode(TableDragMode.ROW);
- table.addGeneratedColumn("COLUMN", new Table.ColumnGenerator() {
-
- @Override
- public Object generateCell(Table source, Object itemId,
- Object columnId) {
- return itemId;
- }
- });
-
- for (int eventNum = 1; eventNum < 50; eventNum++) {
- table.addItem("Event " + eventNum);
- }
-
- root.addComponent(table);
- }
-
- @Override
- protected String getTestDescription() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 11048;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarHtmlInEvents.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarHtmlInEvents.java
deleted file mode 100644
index 03048fd88a..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarHtmlInEvents.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUIWithLog;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.v7.data.Property.ValueChangeEvent;
-import com.vaadin.v7.data.Property.ValueChangeListener;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.NativeSelect;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-public class CalendarHtmlInEvents extends AbstractReindeerTestUIWithLog {
-
- private Calendar calendar = new Calendar();
-
- @Override
- protected void setup(VaadinRequest request) {
- final NativeSelect ns = new NativeSelect("Period");
- ns.addItems("Day", "Week", "Month");
- ns.addValueChangeListener(new ValueChangeListener() {
- @Override
- public void valueChange(ValueChangeEvent event) {
- if ("Day".equals(ns.getValue())) {
- calendar.setStartDate(new Date(2014 - 1900, 1 - 1, 1));
- calendar.setEndDate(new Date(2014 - 1900, 1 - 1, 1));
- } else if ("Week".equals(ns.getValue())) {
- calendar.setStartDate(new Date(2014 - 1900, 1 - 1, 1));
- calendar.setEndDate(new Date(2014 - 1900, 1 - 1, 7));
- } else if ("Month".equals(ns.getValue())) {
- calendar.setStartDate(new Date(2014 - 1900, 1 - 1, 1));
- calendar.setEndDate(new Date(2014 - 1900, 2 - 1, 1));
- }
- }
- });
- ns.setValue("Month");
- final CheckBox allowHtml = new CheckBox("Allow HTML in event caption");
- allowHtml.setValue(calendar.isEventCaptionAsHtml());
- allowHtml.addValueChangeListener(event -> {
- calendar.setEventCaptionAsHtml(event.getValue());
- log("HTML in event caption: " + event.getValue());
- });
- HorizontalLayout hl = new HorizontalLayout();
- hl.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
- hl.addComponents(ns, allowHtml);
- hl.setSpacing(true);
- hl.setMargin(true);
- calendar.setEventProvider(new CalendarEventProvider() {
-
- @Override
- public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
- Date d = startDate;
- ArrayList<CalendarEvent> events = new ArrayList<>();
- while (d.before(endDate)) {
- BasicEvent ce = new BasicEvent();
- ce.setAllDay(false);
- ce.setCaption("<b>Hello</b> <u>world</u>!");
- ce.setDescription("Nothing really important");
- Date start = new Date(d.getTime());
- start.setHours(d.getDay());
- Date end = new Date(d.getTime());
- end.setHours(d.getDay() + 3);
- ce.setStart(start);
- ce.setEnd(end);
- events.add(ce);
- d.setTime(d.getTime() + 1000 * 60 * 60 * 24);
- }
-
- return events;
- }
-
- });
- addComponent(hl);
- addComponent(calendar);
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java
deleted file mode 100644
index 2300268f1a..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEvent.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.BasicEventProvider;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider.EventSetChangeEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider.EventSetChangeListener;
-
-/**
- * Test UI for DnD regular (not all day event) in month view.
- *
- * @author Vaadin Ltd
- */
-public class CalendarMonthViewDndEvent extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- final Calendar calendar = new Calendar("Test calendar");
- final java.util.Calendar cal = getAdjustedCalendar();
- if (cal.get(
- java.util.Calendar.DAY_OF_WEEK) == java.util.Calendar.SUNDAY) {
- // don't use Sunday: no space to move event on the left
- cal.add(java.util.Calendar.DAY_OF_MONTH, 1);
- }
-
- Date from = cal.getTime();
-
- Date start = new Date(from.getTime() - 24 * 3600000);
- calendar.setStartDate(start);
-
- cal.add(java.util.Calendar.HOUR, 1);
- Date to = cal.getTime();
-
- cal.add(java.util.Calendar.MONTH, 1);
- calendar.setEndDate(cal.getTime());
-
- final BasicEvent basicEvent = new BasicEvent("event", "description",
- from, to);
-
- HorizontalLayout info = new HorizontalLayout();
- info.setSpacing(true);
- info.setMargin(true);
- addComponent(info);
- final Label startLbl = new Label(String.valueOf(from.getTime()));
- startLbl.addStyleName("start");
- info.addComponent(startLbl);
-
- final Label endLbl = new Label(String.valueOf(to.getTime()));
- endLbl.addStyleName("end");
- info.addComponent(endLbl);
-
- BasicEventProvider provider = new BasicEventProvider();
- provider.addEvent(basicEvent);
- calendar.setEventProvider(provider);
- provider.addEventSetChangeListener(new EventSetChangeListener() {
-
- @Override
- public void eventSetChange(EventSetChangeEvent event) {
- List<CalendarEvent> events = event.getProvider()
- .getEvents(new Date(0), new Date(Long.MAX_VALUE));
- CalendarEvent calEvent = events.get(0);
- Date startEvent = calEvent.getStart();
- Date endEvent = calEvent.getEnd();
-
- startLbl.setValue(String.valueOf(startEvent.getTime()));
- endLbl.setValue(String.valueOf(endEvent.getTime()));
- }
- });
-
- addComponent(calendar);
- }
-
- @Override
- protected String getTestDescription() {
- return "Allow DnD any events in Calendar Month view";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 12413;
- }
-
- private java.util.Calendar getAdjustedCalendar() {
- final java.util.Calendar cal = java.util.Calendar.getInstance();
-
- cal.set(java.util.Calendar.SECOND, 0);
- cal.set(java.util.Calendar.MILLISECOND, 0);
- return cal;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarNotifications.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarNotifications.java
deleted file mode 100644
index 7bd0bf1f88..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarNotifications.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Notification;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickEvent;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-public class CalendarNotifications extends AbstractTestUIWithLog {
-
- private DummyEventProvider provider;
-
- private static class DummyEventProvider implements CalendarEventProvider {
-
- private int index;
- private List<CalendarEvent> events = new ArrayList<>();
-
- public void addEvent(Date date) {
- BasicEvent e = new BasicEvent();
- e.setAllDay(true);
- e.setStart(date);
- e.setEnd(date);
- e.setCaption("Some event " + ++index);
- events.add(e);
- }
-
- @Override
- public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
- return events;
- }
-
- }
-
- @Override
- protected void setup(VaadinRequest request) {
- GridLayout content = new GridLayout(1, 2);
- content.setSizeFull();
- content.setRowExpandRatio(1, 1.0f);
- addComponent(content);
- final Button btn = new Button("Show working notification",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Notification.show(
- "This will disappear when you move your mouse!");
- }
- });
- content.addComponent(btn);
-
- provider = new DummyEventProvider();
- final Calendar cal = new Calendar(provider);
- cal.setLocale(Locale.US);
- cal.setSizeFull();
- cal.setHandler(new DateClickHandler() {
- @Override
- public void dateClick(DateClickEvent event) {
- provider.addEvent(event.getDate());
- log("Opening a notification");
- Notification
- .show("This should disappear when the mouse is moved.");
-
- // this requestRepaint call interferes with the notification
- cal.markAsDirty();
- }
- });
- content.addComponent(cal);
-
- java.util.Calendar javaCal = java.util.Calendar.getInstance();
- javaCal.set(java.util.Calendar.YEAR, 2000);
- javaCal.set(java.util.Calendar.MONTH, 0);
- javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
- Date start = javaCal.getTime();
- javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31);
- Date end = javaCal.getTime();
-
- cal.setStartDate(start);
- cal.setEndDate(end);
- }
-
- @Override
- protected String getTestDescription() {
- return "Notifications should be opened and then closed after the user has moved the mouse.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 6769;
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java
deleted file mode 100644
index 873d9df233..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarRescheduleEvent.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.BasicEventProvider;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider.EventSetChangeEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider.EventSetChangeListener;
-
-/**
- * Test UI to check ability to reschedule events unlimited times.
- *
- * @author Vaadin Ltd
- */
-public class CalendarRescheduleEvent extends AbstractReindeerTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- final Calendar calendar = new Calendar("Test calendar");
- final java.util.Calendar cal = getAdjustedCalendar(1);
-
- Date from = cal.getTime();
-
- cal.add(java.util.Calendar.HOUR, 1);
- Date to = cal.getTime();
-
- final BasicEvent basicEvent = new BasicEvent("event", "description",
- from, to);
-
- HorizontalLayout info = new HorizontalLayout();
- info.setSpacing(true);
- info.setMargin(true);
- addComponent(info);
- final Label startLbl = new Label();
- startLbl.addStyleName("start");
- info.addComponent(startLbl);
-
- final Label endLbl = new Label();
- endLbl.addStyleName("end");
- info.addComponent(endLbl);
-
- BasicEventProvider provider = new BasicEventProvider();
- provider.addEvent(basicEvent);
- calendar.setEventProvider(provider);
- provider.addEventSetChangeListener(new EventSetChangeListener() {
-
- @Override
- public void eventSetChange(EventSetChangeEvent event) {
- List<CalendarEvent> events = event.getProvider()
- .getEvents(new Date(0), new Date(Long.MAX_VALUE));
- CalendarEvent calEvent = events.get(0);
- Date startEvent = calEvent.getStart();
- Date endEvent = calEvent.getEnd();
-
- startLbl.setValue(String.valueOf(startEvent.getTime()));
- endLbl.setValue(String.valueOf(endEvent.getTime()));
- }
- });
-
- addComponent(calendar);
- }
-
- @Override
- protected String getTestDescription() {
- return "It should be possible to reschedule events unlimited times.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 13233;
- }
-
- private java.util.Calendar getAdjustedCalendar(int hour) {
- final java.util.Calendar cal = java.util.Calendar.getInstance();
-
- cal.set(java.util.Calendar.HOUR_OF_DAY, hour);
- cal.set(java.util.Calendar.MINUTE, 0);
- cal.set(java.util.Calendar.SECOND, 0);
- cal.set(java.util.Calendar.MILLISECOND, 0);
- return cal;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java
deleted file mode 100644
index 0fd9396c59..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEvents.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-/**
- *
- * @author Vaadin Ltd
- */
-public class CalendarResizeOverlappingEvents extends AbstractReindeerTestUI {
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
- * VaadinRequest)
- */
- @Override
- protected void setup(VaadinRequest request) {
- Calendar calendar = new Calendar(new CalendarEventProvider() {
-
- @Override
- public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
- DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- DateFormat dayFormat = new SimpleDateFormat("yyyy-MM-dd");
- List<CalendarEvent> events = new ArrayList<>();
- try {
- java.util.Calendar today = java.util.Calendar.getInstance();
-
- String todayString = dayFormat.format(today.getTime());
-
- Date date1 = format.parse(todayString + " 09:00:00");
- Date date2 = format.parse(todayString + " 11:00:00");
- Date date3 = format.parse(todayString + " 12:00:00");
- Date date4 = format.parse(todayString + " 14:00:00");
- Date date5 = format.parse(todayString + " 15:00:00");
- Date date6 = format.parse(todayString + " 17:00:00");
-
- CalendarEvent event1 = new BasicEvent("First", "", date1,
- date2);
- CalendarEvent event2 = new BasicEvent("Second", "", date3,
- date4);
- CalendarEvent event3 = new BasicEvent("Third", "", date5,
- date6);
-
- events.add(event1);
- events.add(event2);
- events.add(event3);
- } catch (ParseException e) {
- }
- return events;
- }
- });
- calendar.setSizeFull();
- setContent(calendar);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
- */
- @Override
- protected String getTestDescription() {
- return "Verify the widths of the events are correctly recalculated when these are resized and overlapped";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
- */
- @Override
- protected Integer getTicketNumber() {
- return 13961;
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfView.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfView.java
deleted file mode 100644
index 7b68174666..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfView.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-/**
- *
- * @since
- * @author Vaadin Ltd
- *
- * test for defect: Calendar event not shown correctly when partially
- * out of view (#7261)
- */
-@Theme("tests-calendar")
-public class CalendarShownNotCorrectlyWhenPartiallyOutOfView
- extends AbstractReindeerTestUI {
-
- private static final long serialVersionUID = 1L;
- private Calendar calendar;
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
- * VaadinRequest)
- */
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar();
-
- try {
- BasicEvent event = new BasicEvent("EVENT NAME 1", "EVENT TOOLTIP 1",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 09:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 14:00"));
- event.setStyleName("color1");
- calendar.addEvent(event);
- } catch (ParseException e1) { // Nothing to do
- e1.printStackTrace();
- }
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-30"));
- } catch (ParseException e) { // Nothing to do
-
- }
-
- calendar.setImmediate(true);
-
- calendar.setFirstVisibleHourOfDay(11);
- calendar.setLastVisibleHourOfDay(23);
-
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setHandler((EventResizeHandler) null);
- setEnabled(true);
-
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
- */
- @Override
- protected String getTestDescription() {
- return "Validate fix of defect 'Calendar event not shown correctly when partially out of view'";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
- */
- @Override
- protected Integer getTicketNumber() {
- return 7261;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java
deleted file mode 100644
index 86510f5879..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java
+++ /dev/null
@@ -1,1265 +0,0 @@
-/**
- * Copyright 2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.DateFormatSymbols;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.data.Binder;
-import com.vaadin.data.ValidationException;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.shared.ui.MarginInfo;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.UI;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-import com.vaadin.v7.data.Item;
-import com.vaadin.v7.data.Property.ValueChangeEvent;
-import com.vaadin.v7.data.Property.ValueChangeListener;
-import com.vaadin.v7.data.fieldgroup.FieldGroup;
-import com.vaadin.v7.data.fieldgroup.FieldGroup.CommitException;
-import com.vaadin.v7.data.util.BeanItem;
-import com.vaadin.v7.shared.ui.combobox.FilteringMode;
-import com.vaadin.v7.shared.ui.datefield.Resolution;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.ComboBox;
-import com.vaadin.v7.ui.DateField;
-import com.vaadin.v7.ui.TextArea;
-import com.vaadin.v7.ui.TextField;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickEvent;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClick;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClickHandler;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.RangeSelectEvent;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.RangeSelectHandler;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.WeekClick;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.WeekClickHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.BasicEventProvider;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.handler.BasicDateClickHandler;
-import com.vaadin.v7.ui.components.calendar.handler.BasicWeekClickHandler;
-
-/** Calendar component test application */
-@Theme("tests-calendar")
-public class CalendarTest extends UI {
-
- private static final long serialVersionUID = -5436777475398410597L;
-
- private static final String DEFAULT_ITEMID = "DEFAULT";
-
- private enum Mode {
- MONTH, WEEK, DAY;
- }
-
- /**
- * This Gregorian calendar is used to control dates and time inside of this
- * test application.
- */
- private GregorianCalendar calendar;
-
- /** Target calendar component that this test application is made for. */
- private Calendar calendarComponent;
-
- private Date currentMonthsFirstDate;
-
- private final Label captionLabel = new Label("");
-
- private Button monthButton;
-
- private Button weekButton;
-
- private Button nextButton;
-
- private Button prevButton;
-
- private ComboBox timeZoneSelect;
-
- private ComboBox formatSelect;
-
- private ComboBox localeSelect;
-
- private CheckBox hideWeekendsButton;
-
- private CheckBox readOnlyButton;
- private ComboBox customFirstDayOfWeekSelect;
-
- private TextField captionField;
-
- private Window scheduleEventPopup;
-
- private final FormLayout scheduleEventFieldLayout = new FormLayout();
- private FieldGroup scheduleEventFieldGroup = new FieldGroup();
- private Binder<CalendarEvent> scheduledEventBinder = new Binder<>();
-
- private Button deleteEventButton;
-
- private Button applyEventButton;
-
- private Mode viewMode = Mode.MONTH;
-
- private BasicEventProvider dataSource;
-
- private Button addNewEvent;
-
- /*
- * When testBench is set to true, CalendarTest will have static content that
- * is more suitable for Vaadin TestBench testing. Calendar will use a static
- * date Mon 10 Jan 2000. Enable by starting the application with a
- * "testBench" parameter in the URL.
- */
- private boolean testBench = false;
-
- private String calendarHeight = null;
-
- private String calendarWidth = null;
-
- private CheckBox disabledButton;
-
- private Integer firstHour;
-
- private Integer lastHour;
-
- private Integer firstDay;
-
- private Integer lastDay;
-
- private Locale defaultLocale = Locale.US;
-
- private boolean showWeeklyView;
-
- private boolean useSecondResolution;
-
- private DateField startDateField;
- private DateField endDateField;
-
- @SuppressWarnings("serial")
- @Override
- public void init(VaadinRequest request) {
- GridLayout layout = new GridLayout();
- layout.setSizeFull();
- layout.setMargin(true);
- setContent(layout);
-
- handleURLParams(request.getParameterMap());
-
- initContent();
- }
-
- private void handleURLParams(Map<String, String[]> parameters) {
- testBench = parameters.containsKey("testBench")
- || parameters.containsKey("?testBench");
-
- if (parameters.containsKey("width")) {
- calendarWidth = parameters.get("width")[0];
- }
-
- if (parameters.containsKey("height")) {
- calendarHeight = parameters.get("height")[0];
- }
-
- if (parameters.containsKey("firstDay")) {
- firstDay = Integer.parseInt(parameters.get("firstDay")[0]);
- }
-
- if (parameters.containsKey("lastDay")) {
- lastDay = Integer.parseInt(parameters.get("lastDay")[0]);
- }
-
- if (parameters.containsKey("firstHour")) {
- firstHour = Integer.parseInt(parameters.get("firstHour")[0]);
- }
-
- if (parameters.containsKey("lastHour")) {
- lastHour = Integer.parseInt(parameters.get("lastHour")[0]);
- }
-
- if (parameters.containsKey("locale")) {
- String localeArray[] = parameters.get("locale")[0].split("_");
- defaultLocale = new Locale(localeArray[0], localeArray[1]);
- setLocale(defaultLocale);
- }
-
- if (parameters.containsKey("secondsResolution")) {
- useSecondResolution = true;
- }
-
- showWeeklyView = parameters.containsKey("weekly");
-
- }
-
- public void initContent() {
- // Set default Locale for this application
- if (testBench) {
- setLocale(defaultLocale);
-
- } else {
- setLocale(Locale.getDefault());
- }
-
- // Initialize locale, timezone, timeformat and custom first day of week
- // selects.
- localeSelect = createLocaleSelect();
- timeZoneSelect = createTimeZoneSelect();
- formatSelect = createCalendarFormatSelect();
- customFirstDayOfWeekSelect = createCustomFirstDayOfWeekSelect();
-
- initCalendar();
- initLayoutContent();
- addInitialEvents();
- }
-
- private Date resolveFirstDateOfWeek(Date today,
- java.util.Calendar currentCalendar) {
- int firstDayOfWeek = currentCalendar.getFirstDayOfWeek();
- currentCalendar.setTime(today);
- while (firstDayOfWeek != currentCalendar
- .get(java.util.Calendar.DAY_OF_WEEK)) {
- currentCalendar.add(java.util.Calendar.DATE, -1);
- }
- return currentCalendar.getTime();
- }
-
- private Date resolveLastDateOfWeek(Date today,
- java.util.Calendar currentCalendar) {
- currentCalendar.setTime(today);
- currentCalendar.add(java.util.Calendar.DATE, 1);
- int firstDayOfWeek = currentCalendar.getFirstDayOfWeek();
- // Roll to weeks last day using firstdayofweek. Roll until FDofW is
- // found and then roll back one day.
- while (firstDayOfWeek != currentCalendar
- .get(java.util.Calendar.DAY_OF_WEEK)) {
- currentCalendar.add(java.util.Calendar.DATE, 1);
- }
- currentCalendar.add(java.util.Calendar.DATE, -1);
- return currentCalendar.getTime();
- }
-
- private void addInitialEvents() {
- Date originalDate = calendar.getTime();
- Date today = getToday();
-
- // Add a event that last a whole week
-
- Date start = resolveFirstDateOfWeek(today, calendar);
- Date end = resolveLastDateOfWeek(today, calendar);
- CalendarTestEvent event = getNewEvent("Whole week event", start, end);
- event.setAllDay(true);
- event.setStyleName("color4");
- event.setDescription("Description for the whole week event.");
- dataSource.addEvent(event);
-
- // Add a allday event
- calendar.setTime(start);
- calendar.add(GregorianCalendar.DATE, 3);
- start = calendar.getTime();
- end = start;
- event = getNewEvent("Allday event", start, end);
- event.setAllDay(true);
- event.setDescription("Some description.");
- event.setStyleName("color3");
- dataSource.addEvent(event);
-
- // Add a second allday event
- calendar.add(GregorianCalendar.DATE, 1);
- start = calendar.getTime();
- end = start;
- event = getNewEvent("Second allday event", start, end);
- event.setAllDay(true);
- event.setDescription("Some description.");
- event.setStyleName("color2");
- dataSource.addEvent(event);
-
- calendar.add(GregorianCalendar.DATE, -3);
- calendar.set(GregorianCalendar.HOUR_OF_DAY, 9);
- calendar.set(GregorianCalendar.MINUTE, 30);
- start = calendar.getTime();
- calendar.add(GregorianCalendar.HOUR_OF_DAY, 5);
- calendar.set(GregorianCalendar.MINUTE, 0);
- end = calendar.getTime();
- event = getNewEvent("Appointment", start, end);
- event.setWhere("Office");
- event.setStyleName("color1");
- event.setDescription(
- "A longer description, which should display correctly.");
- dataSource.addEvent(event);
-
- calendar.add(GregorianCalendar.DATE, 1);
- calendar.set(GregorianCalendar.HOUR_OF_DAY, 11);
- calendar.set(GregorianCalendar.MINUTE, 0);
- start = calendar.getTime();
- calendar.add(GregorianCalendar.HOUR_OF_DAY, 8);
- end = calendar.getTime();
- event = getNewEvent("Training", start, end);
- event.setStyleName("color2");
- dataSource.addEvent(event);
-
- calendar.add(GregorianCalendar.DATE, 4);
- calendar.set(GregorianCalendar.HOUR_OF_DAY, 9);
- calendar.set(GregorianCalendar.MINUTE, 0);
- start = calendar.getTime();
- calendar.add(GregorianCalendar.HOUR_OF_DAY, 9);
- end = calendar.getTime();
- event = getNewEvent("Free time", start, end);
- dataSource.addEvent(event);
-
- calendar.setTime(originalDate);
- }
-
- private void initLayoutContent() {
- initNavigationButtons();
- initHideWeekEndButton();
- initReadOnlyButton();
- initDisabledButton();
- initAddNewEventButton();
-
- HorizontalLayout hl = new HorizontalLayout();
- hl.setWidth("100%");
- hl.setSpacing(true);
- hl.setMargin(new MarginInfo(false, false, true, false));
- hl.addComponent(prevButton);
- hl.addComponent(captionLabel);
- hl.addComponent(monthButton);
- hl.addComponent(weekButton);
- hl.addComponent(nextButton);
- hl.setComponentAlignment(prevButton, Alignment.MIDDLE_LEFT);
- hl.setComponentAlignment(captionLabel, Alignment.MIDDLE_CENTER);
- hl.setComponentAlignment(monthButton, Alignment.MIDDLE_CENTER);
- hl.setComponentAlignment(weekButton, Alignment.MIDDLE_CENTER);
- hl.setComponentAlignment(nextButton, Alignment.MIDDLE_RIGHT);
-
- monthButton.setVisible(viewMode == Mode.WEEK);
- weekButton.setVisible(viewMode == Mode.DAY);
-
- HorizontalLayout controlPanel = new HorizontalLayout();
- controlPanel.setSpacing(true);
- controlPanel.setMargin(new MarginInfo(false, false, true, false));
- controlPanel.setWidth("100%");
- controlPanel.addComponent(localeSelect);
- controlPanel.addComponent(timeZoneSelect);
- controlPanel.addComponent(formatSelect);
- controlPanel.addComponent(customFirstDayOfWeekSelect);
- controlPanel.addComponent(hideWeekendsButton);
- controlPanel.addComponent(readOnlyButton);
- controlPanel.addComponent(disabledButton);
- controlPanel.addComponent(addNewEvent);
-
- controlPanel.setComponentAlignment(timeZoneSelect,
- Alignment.MIDDLE_LEFT);
- controlPanel.setComponentAlignment(formatSelect, Alignment.MIDDLE_LEFT);
- controlPanel.setComponentAlignment(localeSelect, Alignment.MIDDLE_LEFT);
- controlPanel.setComponentAlignment(hideWeekendsButton,
- Alignment.MIDDLE_LEFT);
- controlPanel.setComponentAlignment(readOnlyButton,
- Alignment.MIDDLE_LEFT);
- controlPanel.setComponentAlignment(disabledButton,
- Alignment.MIDDLE_LEFT);
- controlPanel.setComponentAlignment(addNewEvent, Alignment.MIDDLE_LEFT);
-
- GridLayout layout = (GridLayout) getContent();
- layout.addComponent(controlPanel);
- layout.addComponent(hl);
- layout.addComponent(calendarComponent);
- layout.setRowExpandRatio(layout.getRows() - 1, 1.0f);
- }
-
- private void initNavigationButtons() {
- monthButton = new Button("Month view", new ClickListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- switchToMonthView();
- }
- });
-
- weekButton = new Button("Week view", new ClickListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- // simulate week click
- WeekClickHandler handler = (WeekClickHandler) calendarComponent
- .getHandler(WeekClick.EVENT_ID);
- handler.weekClick(new WeekClick(calendarComponent,
- calendar.get(GregorianCalendar.WEEK_OF_YEAR),
- calendar.get(GregorianCalendar.YEAR)));
- }
- });
-
- nextButton = new Button("Next", new Button.ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- handleNextButtonClick();
- }
- });
-
- prevButton = new Button("Prev", new Button.ClickListener() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- handlePreviousButtonClick();
- }
- });
- }
-
- private void initHideWeekEndButton() {
- hideWeekendsButton = new CheckBox("Hide weekends");
- hideWeekendsButton.addValueChangeListener(
- event -> setWeekendsHidden(hideWeekendsButton.getValue()));
- }
-
- private void setWeekendsHidden(boolean weekendsHidden) {
- if (weekendsHidden) {
- int firstToShow = (GregorianCalendar.MONDAY
- - calendar.getFirstDayOfWeek()) % 7;
- calendarComponent.setFirstVisibleDayOfWeek(firstToShow + 1);
- calendarComponent.setLastVisibleDayOfWeek(firstToShow + 5);
- } else {
- calendarComponent.setFirstVisibleDayOfWeek(1);
- calendarComponent.setLastVisibleDayOfWeek(7);
- }
-
- }
-
- private void initReadOnlyButton() {
- readOnlyButton = new CheckBox("Read-only mode");
- readOnlyButton.addValueChangeListener(event -> calendarComponent
- .setReadOnly(readOnlyButton.getValue()));
- }
-
- private void initDisabledButton() {
- disabledButton = new CheckBox("Disabled");
- disabledButton.addValueChangeListener(event -> calendarComponent
- .setEnabled(!disabledButton.getValue()));
- }
-
- public void initAddNewEventButton() {
- addNewEvent = new Button("Add new event");
- addNewEvent.addClickListener(new Button.ClickListener() {
-
- private static final long serialVersionUID = -8307244759142541067L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- Date start = getToday();
- start.setHours(0);
- start.setMinutes(0);
- start.setSeconds(0);
-
- Date end = getEndOfDay(calendar, start);
-
- showEventPopup(createNewEvent(start, end), true);
- }
- });
- }
-
- private void initFormFields(Layout formLayout,
- Class<? extends CalendarEvent> eventClass) {
-
- startDateField = createDateField("Start date");
- endDateField = createDateField("End date");
-
- final CheckBox allDayField = createCheckBox("All-day");
- allDayField.addValueChangeListener(event -> {
- if (event.getValue()) {
- setFormDateResolution(Resolution.DAY);
- } else {
- setFormDateResolution(Resolution.MINUTE);
- }
- });
-
- captionField = createTextField("Caption");
- final TextField whereField = createTextField("Where");
- final TextArea descriptionField = createTextArea("Description");
- descriptionField.setRows(3);
-
- final ComboBox styleNameField = createStyleNameComboBox();
-
- formLayout.addComponent(startDateField);
- formLayout.addComponent(endDateField);
- formLayout.addComponent(allDayField);
- formLayout.addComponent(captionField);
- if (eventClass == CalendarTestEvent.class) {
- formLayout.addComponent(whereField);
- }
- formLayout.addComponent(descriptionField);
- formLayout.addComponent(styleNameField);
-
- scheduleEventFieldGroup.bind(startDateField, "start");
- scheduleEventFieldGroup.bind(endDateField, "end");
- scheduleEventFieldGroup.bind(captionField, "caption");
- scheduleEventFieldGroup.bind(descriptionField, "description");
- if (eventClass == CalendarTestEvent.class) {
- scheduleEventFieldGroup.bind(whereField, "where");
- }
- scheduleEventFieldGroup.bind(styleNameField, "styleName");
- scheduledEventBinder.bind(allDayField, CalendarEvent::isAllDay, null);
- }
-
- private CheckBox createCheckBox(String caption) {
- CheckBox cb = new CheckBox(caption);
- return cb;
- }
-
- private TextField createTextField(String caption) {
- TextField f = new TextField(caption);
- f.setNullRepresentation("");
- return f;
- }
-
- private TextArea createTextArea(String caption) {
- TextArea f = new TextArea(caption);
- f.setNullRepresentation("");
- return f;
- }
-
- private DateField createDateField(String caption) {
- DateField f = new DateField(caption);
- if (useSecondResolution) {
- f.setResolution(Resolution.SECOND);
- } else {
- f.setResolution(Resolution.MINUTE);
- }
- return f;
- }
-
- private ComboBox createStyleNameComboBox() {
- ComboBox s = new ComboBox("Color");
- s.addContainerProperty("c", String.class, "");
- s.setItemCaptionPropertyId("c");
- Item i = s.addItem("color1");
- i.getItemProperty("c").setValue("Green");
- i = s.addItem("color2");
- i.getItemProperty("c").setValue("Blue");
- i = s.addItem("color3");
- i.getItemProperty("c").setValue("Red");
- i = s.addItem("color4");
- i.getItemProperty("c").setValue("Orange");
- return s;
- }
-
- private void initCalendar() {
- dataSource = new BasicEventProvider();
-
- calendarComponent = new Calendar(dataSource);
- calendarComponent.setLocale(getLocale());
- calendarComponent.setImmediate(true);
-
- if (calendarWidth != null || calendarHeight != null) {
- if (calendarHeight != null) {
- calendarComponent.setHeight(calendarHeight);
- }
- if (calendarWidth != null) {
- calendarComponent.setWidth(calendarWidth);
- }
- } else {
- calendarComponent.setSizeFull();
- }
-
- if (firstHour != null && lastHour != null) {
- calendarComponent.setFirstVisibleHourOfDay(firstHour);
- calendarComponent.setLastVisibleHourOfDay(lastHour);
- }
-
- if (firstDay != null && lastDay != null) {
- calendarComponent.setFirstVisibleDayOfWeek(firstDay);
- calendarComponent.setLastVisibleDayOfWeek(lastDay);
- }
-
- Date today = getToday();
- calendar = new GregorianCalendar(getLocale());
- calendar.setTime(today);
-
- updateCaptionLabel();
-
- if (!showWeeklyView) {
- int rollAmount = calendar.get(GregorianCalendar.DAY_OF_MONTH) - 1;
- calendar.add(GregorianCalendar.DAY_OF_MONTH, -rollAmount);
- resetTime(false);
- currentMonthsFirstDate = calendar.getTime();
- calendarComponent.setStartDate(currentMonthsFirstDate);
- calendar.add(GregorianCalendar.MONTH, 1);
- calendar.add(GregorianCalendar.DATE, -1);
- calendarComponent.setEndDate(calendar.getTime());
- }
-
- addCalendarEventListeners();
- }
-
- private Date getToday() {
- if (testBench) {
- GregorianCalendar testDate = new GregorianCalendar();
- testDate.set(GregorianCalendar.YEAR, 2000);
- testDate.set(GregorianCalendar.MONTH, 0);
- testDate.set(GregorianCalendar.DATE, 10);
- testDate.set(GregorianCalendar.HOUR_OF_DAY, 0);
- testDate.set(GregorianCalendar.MINUTE, 0);
- testDate.set(GregorianCalendar.SECOND, 0);
- testDate.set(GregorianCalendar.MILLISECOND, 0);
- return testDate.getTime();
- }
- return new Date();
- }
-
- @SuppressWarnings("serial")
- private void addCalendarEventListeners() {
- // Register week clicks by changing the schedules start and end dates.
- calendarComponent.setHandler(new BasicWeekClickHandler() {
-
- @Override
- public void weekClick(WeekClick event) {
- // let BasicWeekClickHandler handle calendar dates, and update
- // only the other parts of UI here
- super.weekClick(event);
- updateCaptionLabel();
- switchToWeekView();
- }
- });
-
- calendarComponent.setHandler(new EventClickHandler() {
-
- @Override
- public void eventClick(EventClick event) {
- showEventPopup(event.getCalendarEvent(), false);
- }
- });
-
- calendarComponent.setHandler(new BasicDateClickHandler() {
-
- @Override
- public void dateClick(DateClickEvent event) {
- // let BasicDateClickHandler handle calendar dates, and update
- // only the other parts of UI here
- super.dateClick(event);
- switchToDayView();
- }
- });
-
- calendarComponent.setHandler(new RangeSelectHandler() {
-
- @Override
- public void rangeSelect(RangeSelectEvent event) {
- handleRangeSelect(event);
- }
- });
- }
-
- private ComboBox createTimeZoneSelect() {
- ComboBox s = new ComboBox("Timezone");
- s.addContainerProperty("caption", String.class, "");
- s.setItemCaptionPropertyId("caption");
- s.setFilteringMode(FilteringMode.CONTAINS);
-
- Item i = s.addItem(DEFAULT_ITEMID);
- i.getItemProperty("caption")
- .setValue("Default (" + TimeZone.getDefault().getID() + ")");
- for (String id : TimeZone.getAvailableIDs()) {
- if (!s.containsId(id)) {
- i = s.addItem(id);
- i.getItemProperty("caption").setValue(id);
- }
- }
-
- if (testBench) {
- s.select("America/New_York");
- } else {
- s.select(DEFAULT_ITEMID);
- }
- s.setImmediate(true);
- s.addValueChangeListener(new ValueChangeListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
-
- updateCalendarTimeZone(event.getProperty().getValue());
- }
- });
-
- return s;
- }
-
- private ComboBox createCalendarFormatSelect() {
- ComboBox s = new ComboBox("Calendar format");
- s.addContainerProperty("caption", String.class, "");
- s.setItemCaptionPropertyId("caption");
-
- Item i = s.addItem(DEFAULT_ITEMID);
- i.getItemProperty("caption").setValue("Default by locale");
- i = s.addItem(TimeFormat.Format12H);
- i.getItemProperty("caption").setValue("12H");
- i = s.addItem(TimeFormat.Format24H);
- i.getItemProperty("caption").setValue("24H");
-
- s.select(DEFAULT_ITEMID);
- s.setImmediate(true);
- s.addValueChangeListener(new ValueChangeListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- updateCalendarFormat(event.getProperty().getValue());
- }
- });
-
- return s;
- }
-
- private ComboBox createCustomFirstDayOfWeekSelect() {
- ComboBox comboBox = new ComboBox("First day of week");
-
- comboBox.addContainerProperty("caption", String.class, "");
- comboBox.setItemCaptionPropertyId("caption");
-
- comboBox.setImmediate(true);
-
- Item defaultItem = comboBox.addItem(DEFAULT_ITEMID);
- defaultItem.getItemProperty("caption").setValue("Default by locale");
-
- Item sunday = comboBox.addItem(java.util.Calendar.SUNDAY);
- sunday.getItemProperty("caption").setValue("Sunday");
-
- Item monday = comboBox.addItem(java.util.Calendar.MONDAY);
- monday.getItemProperty("caption").setValue("Monday");
-
- comboBox.select(DEFAULT_ITEMID);
- comboBox.setNullSelectionAllowed(false);
-
- comboBox.addValueChangeListener(new ValueChangeListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- updateCalendarFirstDayOfWeek(event.getProperty().getValue());
- }
- });
-
- return comboBox;
- }
-
- private ComboBox createLocaleSelect() {
- ComboBox s = new ComboBox("Locale");
- s.addContainerProperty("caption", String.class, "");
- s.setItemCaptionPropertyId("caption");
- s.setFilteringMode(FilteringMode.CONTAINS);
-
- for (Locale l : Locale.getAvailableLocales()) {
- if (!s.containsId(l)) {
- Item i = s.addItem(l);
- i.getItemProperty("caption").setValue(getLocaleItemCaption(l));
- }
- }
-
- s.select(getLocale());
- s.setImmediate(true);
- s.addValueChangeListener(new ValueChangeListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- updateCalendarLocale((Locale) event.getProperty().getValue());
- }
- });
-
- return s;
- }
-
- private void updateCalendarTimeZone(Object timezoneId) {
- TimeZone tz = null;
- if (!DEFAULT_ITEMID.equals(timezoneId)) {
- tz = TimeZone.getTimeZone((String) timezoneId);
- }
-
- // remember the week that was showing, so we can re-set it later
- Date startDate = calendarComponent.getStartDate();
- calendar.setTime(startDate);
- int weekNumber = calendar.get(java.util.Calendar.WEEK_OF_YEAR);
- calendarComponent.setTimeZone(tz);
- calendar.setTimeZone(calendarComponent.getTimeZone());
-
- if (viewMode == Mode.WEEK) {
- calendar.set(java.util.Calendar.WEEK_OF_YEAR, weekNumber);
- calendar.set(java.util.Calendar.DAY_OF_WEEK,
- calendar.getFirstDayOfWeek());
-
- calendarComponent.setStartDate(calendar.getTime());
- calendar.add(java.util.Calendar.DATE, 6);
- calendarComponent.setEndDate(calendar.getTime());
- }
- }
-
- private void updateCalendarFormat(Object format) {
- TimeFormat calFormat = null;
- if (format instanceof TimeFormat) {
- calFormat = (TimeFormat) format;
- }
-
- calendarComponent.setTimeFormat(calFormat);
- }
-
- private void updateCalendarFirstDayOfWeek(Object firstDayOfWeek) {
- Integer firstDayOfWeekValue = null;
- if (firstDayOfWeek instanceof Integer) {
- firstDayOfWeekValue = (Integer) firstDayOfWeek;
- calendarComponent.setFirstDayOfWeek(firstDayOfWeekValue);
- } else {
- // it means 'Default by locale has been selected'
- calendarComponent.setFirstDayOfWeek(null);
- }
-
- // if we need we may update also field of this test 'calendar' which
- // also keeps first day of week
- }
-
- private String getLocaleItemCaption(Locale l) {
- String country = l.getDisplayCountry(getLocale());
- String language = l.getDisplayLanguage(getLocale());
- StringBuilder caption = new StringBuilder(country);
- if (caption.length() != 0) {
- caption.append(", ");
- }
- caption.append(language);
- return caption.toString();
- }
-
- private void updateCalendarLocale(Locale l) {
- int oldFirstDayOfWeek = calendar.getFirstDayOfWeek();
- setLocale(l);
- calendarComponent.setLocale(l);
- calendar = new GregorianCalendar(l);
- int newFirstDayOfWeek = calendar.getFirstDayOfWeek();
-
- // we are showing 1 week, and the first day of the week has changed
- // update start and end dates so that the same week is showing
- if (viewMode == Mode.WEEK && oldFirstDayOfWeek != newFirstDayOfWeek) {
- calendar.setTime(calendarComponent.getStartDate());
- calendar.add(java.util.Calendar.DAY_OF_WEEK, 2);
- // starting at the beginning of the week
- calendar.set(GregorianCalendar.DAY_OF_WEEK, newFirstDayOfWeek);
- Date start = calendar.getTime();
-
- // ending at the end of the week
- calendar.add(GregorianCalendar.DATE, 6);
- Date end = calendar.getTime();
-
- calendarComponent.setStartDate(start);
- calendarComponent.setEndDate(end);
-
- // Week days depend on locale so this must be refreshed
- setWeekendsHidden(hideWeekendsButton.getValue());
- }
-
- }
-
- private void handleNextButtonClick() {
- switch (viewMode) {
- case MONTH:
- nextMonth();
- break;
- case WEEK:
- nextWeek();
- break;
- case DAY:
- nextDay();
- break;
- }
- }
-
- private void handlePreviousButtonClick() {
- switch (viewMode) {
- case MONTH:
- previousMonth();
- break;
- case WEEK:
- previousWeek();
- break;
- case DAY:
- previousDay();
- break;
- }
- }
-
- private void handleRangeSelect(RangeSelectEvent event) {
- Date start = event.getStart();
- Date end = event.getEnd();
-
- /*
- * If a range of dates is selected in monthly mode, we want it to end at
- * the end of the last day.
- */
- if (event.isMonthlyMode()) {
- end = getEndOfDay(calendar, end);
- }
-
- showEventPopup(createNewEvent(start, end), true);
- }
-
- private void showEventPopup(CalendarEvent event, boolean newEvent) {
- if (event == null) {
- return;
- }
-
- updateCalendarEventPopup(newEvent);
- updateCalendarEventForm(event);
-
- if (!getWindows().contains(scheduleEventPopup)) {
- addWindow(scheduleEventPopup);
- }
- }
-
- /* Initializes a modal window to edit schedule event. */
- private void createCalendarEventPopup() {
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- layout.setSpacing(true);
-
- scheduleEventPopup = new Window(null, layout);
- scheduleEventPopup.setWidth("400px");
- scheduleEventPopup.setModal(true);
- scheduleEventPopup.center();
-
- layout.addComponent(scheduleEventFieldLayout);
-
- applyEventButton = new Button("Apply", new ClickListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- commitCalendarEvent();
- } catch (CommitException | ValidationException e) {
- e.printStackTrace();
- }
- }
- });
- Button cancel = new Button("Cancel", new ClickListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- discardCalendarEvent();
- }
- });
- deleteEventButton = new Button("Delete", new ClickListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void buttonClick(ClickEvent event) {
- deleteCalendarEvent();
- }
- });
- scheduleEventPopup.addCloseListener(new Window.CloseListener() {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void windowClose(Window.CloseEvent e) {
- discardCalendarEvent();
- }
- });
-
- HorizontalLayout buttons = new HorizontalLayout();
- buttons.setSpacing(true);
- buttons.addComponent(deleteEventButton);
- buttons.addComponent(applyEventButton);
- buttons.addComponent(cancel);
- layout.addComponent(buttons);
- layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);
- }
-
- private void updateCalendarEventPopup(boolean newEvent) {
- if (scheduleEventPopup == null) {
- createCalendarEventPopup();
- }
-
- if (newEvent) {
- scheduleEventPopup.setCaption("New event");
- } else {
- scheduleEventPopup.setCaption("Edit event");
- }
-
- deleteEventButton.setVisible(!newEvent);
- deleteEventButton.setEnabled(!calendarComponent.isReadOnly());
- applyEventButton.setEnabled(!calendarComponent.isReadOnly());
- }
-
- private void updateCalendarEventForm(CalendarEvent event) {
- BeanItem<CalendarEvent> item = new BeanItem<>(event);
- scheduleEventFieldLayout.removeAllComponents();
- scheduleEventFieldGroup = new FieldGroup();
- initFormFields(scheduleEventFieldLayout, event.getClass());
- scheduleEventFieldGroup.setBuffered(true);
- scheduleEventFieldGroup.setItemDataSource(item);
- scheduledEventBinder.readBean(event);
- }
-
- private void setFormDateResolution(Resolution resolution) {
- if (startDateField != null && endDateField != null) {
- startDateField.setResolution(resolution);
- endDateField.setResolution(resolution);
- }
- }
-
- private CalendarEvent createNewEvent(Date startDate, Date endDate) {
-
- BasicEvent event = new BasicEvent();
- event.setCaption("");
- event.setStart(startDate);
- event.setEnd(endDate);
- event.setStyleName("color1");
- return event;
- }
-
- /* Removes the event from the data source and fires change event. */
- private void deleteCalendarEvent() {
- BasicEvent event = getFormCalendarEvent();
- if (dataSource.containsEvent(event)) {
- dataSource.removeEvent(event);
- }
- removeWindow(scheduleEventPopup);
- }
-
- /* Adds/updates the event in the data source and fires change event. */
- private void commitCalendarEvent()
- throws CommitException, ValidationException {
- scheduleEventFieldGroup.commit();
- BasicEvent event = getFormCalendarEvent();
- scheduledEventBinder.writeBean(event);
- if (event.getEnd() == null) {
- event.setEnd(event.getStart());
- }
- if (!dataSource.containsEvent(event)) {
- dataSource.addEvent(event);
- }
-
- removeWindow(scheduleEventPopup);
- }
-
- private void discardCalendarEvent() {
- scheduleEventFieldGroup.discard();
- scheduledEventBinder.readBean(getFormCalendarEvent());
- removeWindow(scheduleEventPopup);
- }
-
- @SuppressWarnings("unchecked")
- private BasicEvent getFormCalendarEvent() {
- BeanItem<CalendarEvent> item = (BeanItem<CalendarEvent>) scheduleEventFieldGroup
- .getItemDataSource();
- CalendarEvent event = item.getBean();
- return (BasicEvent) event;
- }
-
- private void nextMonth() {
- rollMonth(1);
- }
-
- private void previousMonth() {
- rollMonth(-1);
- }
-
- private void nextWeek() {
- rollWeek(1);
- }
-
- private void previousWeek() {
- rollWeek(-1);
- }
-
- private void nextDay() {
- rollDate(1);
- }
-
- private void previousDay() {
- rollDate(-1);
- }
-
- private void rollMonth(int direction) {
- calendar.setTime(currentMonthsFirstDate);
- calendar.add(GregorianCalendar.MONTH, direction);
- resetTime(false);
- currentMonthsFirstDate = calendar.getTime();
- calendarComponent.setStartDate(currentMonthsFirstDate);
-
- updateCaptionLabel();
-
- calendar.add(GregorianCalendar.MONTH, 1);
- calendar.add(GregorianCalendar.DATE, -1);
- resetCalendarTime(true);
- }
-
- private void rollWeek(int direction) {
- calendar.add(GregorianCalendar.WEEK_OF_YEAR, direction);
- calendar.set(GregorianCalendar.DAY_OF_WEEK,
- calendar.getFirstDayOfWeek());
- resetCalendarTime(false);
- resetTime(true);
- calendar.add(GregorianCalendar.DATE, 6);
- calendarComponent.setEndDate(calendar.getTime());
- }
-
- private void rollDate(int direction) {
- calendar.add(GregorianCalendar.DATE, direction);
- resetCalendarTime(false);
- resetCalendarTime(true);
- }
-
- private void updateCaptionLabel() {
- DateFormatSymbols s = new DateFormatSymbols(getLocale());
- String month = s.getShortMonths()[calendar
- .get(GregorianCalendar.MONTH)];
- captionLabel
- .setValue(month + " " + calendar.get(GregorianCalendar.YEAR));
- }
-
- private CalendarTestEvent getNewEvent(String caption, Date start,
- Date end) {
- CalendarTestEvent event = new CalendarTestEvent();
- event.setCaption(caption);
- event.setStart(start);
- event.setEnd(end);
-
- return event;
- }
-
- /*
- * Switch the view to week view.
- */
- public void switchToWeekView() {
- viewMode = Mode.WEEK;
- weekButton.setVisible(false);
- monthButton.setVisible(true);
- }
-
- /*
- * Switch the Calendar component's start and end date range to the target
- * month only. (sample range: 01.01.2010 00:00.000 - 31.01.2010 23:59.999)
- */
- public void switchToMonthView() {
- viewMode = Mode.MONTH;
- monthButton.setVisible(false);
- weekButton.setVisible(false);
-
- calendar.setTime(currentMonthsFirstDate);
- calendarComponent.setStartDate(currentMonthsFirstDate);
-
- updateCaptionLabel();
-
- calendar.add(GregorianCalendar.MONTH, 1);
- calendar.add(GregorianCalendar.DATE, -1);
- resetCalendarTime(true);
- }
-
- /*
- * Switch to day view (week view with a single day visible).
- */
- public void switchToDayView() {
- viewMode = Mode.DAY;
- monthButton.setVisible(true);
- weekButton.setVisible(true);
- }
-
- private void resetCalendarTime(boolean resetEndTime) {
- resetTime(resetEndTime);
- if (resetEndTime) {
- calendarComponent.setEndDate(calendar.getTime());
- } else {
- calendarComponent.setStartDate(calendar.getTime());
- updateCaptionLabel();
- }
- }
-
- /*
- * Resets the calendar time (hour, minute second and millisecond) either to
- * zero or maximum value.
- */
- private void resetTime(boolean max) {
- if (max) {
- calendar.set(GregorianCalendar.HOUR_OF_DAY,
- calendar.getMaximum(GregorianCalendar.HOUR_OF_DAY));
- calendar.set(GregorianCalendar.MINUTE,
- calendar.getMaximum(GregorianCalendar.MINUTE));
- calendar.set(GregorianCalendar.SECOND,
- calendar.getMaximum(GregorianCalendar.SECOND));
- calendar.set(GregorianCalendar.MILLISECOND,
- calendar.getMaximum(GregorianCalendar.MILLISECOND));
- } else {
- calendar.set(GregorianCalendar.HOUR_OF_DAY, 0);
- calendar.set(GregorianCalendar.MINUTE, 0);
- calendar.set(GregorianCalendar.SECOND, 0);
- calendar.set(GregorianCalendar.MILLISECOND, 0);
- }
- }
-
- private static Date getEndOfDay(java.util.Calendar calendar, Date date) {
- java.util.Calendar calendarClone = (java.util.Calendar) calendar
- .clone();
-
- calendarClone.setTime(date);
- calendarClone.set(java.util.Calendar.MILLISECOND,
- calendarClone.getActualMaximum(java.util.Calendar.MILLISECOND));
- calendarClone.set(java.util.Calendar.SECOND,
- calendarClone.getActualMaximum(java.util.Calendar.SECOND));
- calendarClone.set(java.util.Calendar.MINUTE,
- calendarClone.getActualMaximum(java.util.Calendar.MINUTE));
- calendarClone.set(java.util.Calendar.HOUR,
- calendarClone.getActualMaximum(java.util.Calendar.HOUR));
- calendarClone.set(java.util.Calendar.HOUR_OF_DAY,
- calendarClone.getActualMaximum(java.util.Calendar.HOUR_OF_DAY));
-
- return calendarClone.getTime();
- }
-
- private static Date getStartOfDay(java.util.Calendar calendar, Date date) {
- java.util.Calendar calendarClone = (java.util.Calendar) calendar
- .clone();
-
- calendarClone.setTime(date);
- calendarClone.set(java.util.Calendar.MILLISECOND, 0);
- calendarClone.set(java.util.Calendar.SECOND, 0);
- calendarClone.set(java.util.Calendar.MINUTE, 0);
- calendarClone.set(java.util.Calendar.HOUR, 0);
- calendarClone.set(java.util.Calendar.HOUR_OF_DAY, 0);
-
- return calendarClone.getTime();
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarVisibleHours.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarVisibleHours.java
deleted file mode 100644
index e2bc61afeb..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarVisibleHours.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventResizeHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-/**
- *
- * @since
- * @author Vaadin Ltd
- *
- * test for defect: calendar visible hours of day invalid shows invalid
- * dates(week/day view) (#12521)
- */
-@Theme("tests-calendar")
-public class CalendarVisibleHours extends AbstractReindeerTestUI {
-
- private static final long serialVersionUID = 1L;
- private Calendar calendar;
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
- * VaadinRequest)
- */
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar();
-
- try {
-
- BasicEvent event = new BasicEvent("EVENT NAME 1", "EVENT TOOLTIP 1",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 15:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-07 22:20"));
- event.setStyleName("color1");
- calendar.addEvent(event);
-
- event = new BasicEvent("EVENT NAME 2", "EVENT TOOLTIP 2",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 12:10"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 13:20"));
- event.setStyleName("color2");
- calendar.addEvent(event);
-
- event = new BasicEvent("EVENT NAME 3", "EVENT TOOLTIP 3",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-01 11:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-29 15:20"));
- event.setStyleName("color3");
- calendar.addEvent(event);
-
- event = new BasicEvent("EVENT NAME 4", "EVENT TOOLTIP 4",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-01 11:30"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-01 15:20"));
- event.setStyleName("color4");
- event.setAllDay(true);
- calendar.addEvent(event);
- } catch (ParseException e1) { // Nothing to do
- e1.printStackTrace();
- }
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-30"));
- } catch (ParseException e) { // Nothing to do
-
- }
-
- calendar.setImmediate(true);
-
- calendar.setFirstVisibleHourOfDay(8);
- calendar.setLastVisibleHourOfDay(16);
-
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setHandler((EventResizeHandler) null);
- setEnabled(true);
-
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
- */
- @Override
- protected String getTestDescription() {
- return "Validate fix of defect 'Calendar visible hours of day invalid shows invalid dates(week/day view)'";
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
- */
- @Override
- protected Integer getTicketNumber() {
- return 12521;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarWeekSelection.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarWeekSelection.java
deleted file mode 100644
index c5b1469679..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarWeekSelection.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-
-public class CalendarWeekSelection extends AbstractReindeerTestUI {
- @Override
- protected void setup(VaadinRequest request) {
- Calendar calendar = new Calendar();
- calendar.setLocale(Locale.US);
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-12-15"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2014-01-15"));
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
- addComponent(calendar);
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 14783;
- }
-
- @Override
- protected String getTestDescription() {
- return "December 2013 - January 2014. Clicking the week 1 "
- + "should open the week view for the first week of 2014.";
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetails.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetails.java
deleted file mode 100644
index 93d2374951..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetails.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.table.DndTableTargetDetails;
-import com.vaadin.v7.ui.Calendar;
-
-/**
- * Test UI for calendar as a drop target: CalendarTargetDetails should provide
- * getMouseEvent() method.
- *
- * @author Vaadin Ltd
- */
-public class DndCalendarTargetDetails extends DndTableTargetDetails {
-
- @Override
- protected void setup(VaadinRequest request) {
- createSourceTable();
-
- Calendar calendar = new Calendar();
- calendar.addStyleName("target");
- calendar.setDropHandler(new TestDropHandler());
- calendar.setWidth(100, Unit.PERCENTAGE);
- addComponent(calendar);
- }
-
- @Override
- protected String getTestDescription() {
- return "Mouse details should be available for CalendarTargetDetails DnD when calendar is a target";
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java
deleted file mode 100644
index 37df80ef0f..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/HiddenFwdBackButtons.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.UI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.BackwardHandler;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.ForwardHandler;
-
-public class HiddenFwdBackButtons extends UI {
-
- @SuppressWarnings("deprecation")
- @Override
- protected void init(VaadinRequest request) {
- GridLayout content = new GridLayout(1, 2);
- content.setSizeFull();
- setContent(content);
-
- final Calendar calendar = new Calendar();
- calendar.setLocale(new Locale("fi", "FI"));
-
- calendar.setSizeFull();
- calendar.setStartDate(new Date(100, 1, 1));
- calendar.setEndDate(new Date(100, 1, 7));
- content.addComponent(calendar);
- Button button = new Button("Hide forward and back buttons");
- button.addClickListener(new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- // This should hide the forward and back navigation buttons
- calendar.setHandler((BackwardHandler) null);
- calendar.setHandler((ForwardHandler) null);
- }
- });
- content.addComponent(button);
-
- content.setRowExpandRatio(0, 1);
-
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/NotificationTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/NotificationTestUI.java
deleted file mode 100644
index a5648abf19..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/NotificationTestUI.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Locale;
-
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.UI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickEvent;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.DateClickHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-public class NotificationTestUI extends UI {
-
- private DummyEventProvider provider;
-
- private static class DummyEventProvider implements CalendarEventProvider {
-
- private int index;
- private List<CalendarEvent> events = new ArrayList<>();
-
- public void addEvent(Date date) {
- BasicEvent e = new BasicEvent();
- e.setAllDay(true);
- e.setStart(date);
- e.setEnd(date);
- e.setCaption("Some event " + ++index);
- events.add(e);
- }
-
- @Override
- public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
- return events;
- }
-
- }
-
- @Override
- protected void init(com.vaadin.server.VaadinRequest request) {
- GridLayout content = new GridLayout(1, 2);
- content.setSizeFull();
- content.setRowExpandRatio(1, 1.0f);
- setContent(content);
- final Button btn = new Button("Show working notification",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- Notification.show(
- "This will disappear when you move your mouse!");
- }
- });
- content.addComponent(btn);
-
- provider = new DummyEventProvider();
- final Calendar cal = new Calendar(provider);
- cal.setLocale(Locale.US);
- cal.setSizeFull();
- cal.setHandler(new DateClickHandler() {
- @Override
- public void dateClick(DateClickEvent event) {
- provider.addEvent(event.getDate());
- Notification.show(
- "This should disappear, but if wont unless clicked.");
-
- // this requestRepaint call interferes with the notification
- cal.markAsDirty();
- }
- });
- content.addComponent(cal);
-
- java.util.Calendar javaCal = java.util.Calendar.getInstance();
- javaCal.set(java.util.Calendar.YEAR, 2000);
- javaCal.set(java.util.Calendar.MONTH, 0);
- javaCal.set(java.util.Calendar.DAY_OF_MONTH, 1);
- Date start = javaCal.getTime();
- javaCal.set(java.util.Calendar.DAY_OF_MONTH, 31);
- Date end = javaCal.getTime();
-
- cal.setStartDate(start);
- cal.setEndDate(end);
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/NullEventMoveHandler.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/NullEventMoveHandler.java
deleted file mode 100644
index 059b50ede8..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/NullEventMoveHandler.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUIWithLog;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClick;
-import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents.EventClickHandler;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-public class NullEventMoveHandler extends AbstractTestUIWithLog {
- @Override
- protected void setup(VaadinRequest request) {
- Calendar calendar = getCalendar();
-
- calendar.setHandler((CalendarComponentEvents.EventMoveHandler) null);
- calendar.setHandler(new EventClickHandler() {
-
- @Override
- public void eventClick(EventClick event) {
- log("Clicked on " + event.getCalendarEvent().getCaption());
-
- }
- });
-
- addComponent(calendar);
- }
-
- private Calendar getCalendar() {
- Calendar calendar = new Calendar();
- calendar.setLocale(Locale.US);
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2014-06-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2014-06-30"));
-
- BasicEvent event = new BasicEvent("foo", "bar",
- new SimpleDateFormat("yyyy-MM-dd").parse("2014-06-01"));
-
- calendar.addEvent(event);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- return calendar;
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 15174;
- }
-
- @Override
- protected String getTestDescription() {
- return "Events should not be movable when EventMoveHandler is null.";
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDay.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDay.java
deleted file mode 100644
index a430e434ce..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDay.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-@Theme("tests-calendar")
-public class SetFirstVisibleHourOfDay extends AbstractReindeerTestUI {
-
- private Calendar calendar;
-
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar();
-
- try {
- BasicEvent event = new BasicEvent("EVENT NAME 1", "EVENT TOOLTIP 1",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 00:00"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 13:00"));
- event.setStyleName("color1");
- calendar.addEvent(event);
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-30"));
- } catch (ParseException e) {
- e.printStackTrace();
- }
-
- calendar.setImmediate(true);
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setLocale(new Locale("en", "US"));
-
- calendar.setFirstVisibleHourOfDay(7);
-
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
- }
-
- @Override
- protected String getTestDescription() {
- return "Calendar week and day views should work correctly when using setFirstVisibleHourOfDay()";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 13431;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCase.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCase.java
deleted file mode 100644
index 92c2f1f59c..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCase.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.Calendar.TimeFormat;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-
-@Theme("tests-calendar")
-public class SetFirstVisibleHourOfDaySpecialCase extends AbstractTestUI {
-
- private Calendar calendar;
-
- @Override
- protected void setup(VaadinRequest request) {
- calendar = new Calendar();
-
- try {
- BasicEvent event = new BasicEvent("EVENT NAME 1", "EVENT TOOLTIP 1",
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-05 16:00"),
- new SimpleDateFormat("yyyy-MM-dd HH:mm")
- .parse("2013-09-06 00:00"));
- event.setStyleName("color1");
- calendar.addEvent(event);
- } catch (ParseException e1) { // Nothing to do
- e1.printStackTrace();
- }
-
- try {
- calendar.setStartDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-01"));
- calendar.setEndDate(
- new SimpleDateFormat("yyyy-MM-dd").parse("2013-09-30"));
- } catch (ParseException e) { // Nothing to do
-
- }
-
- calendar.setImmediate(true);
- calendar.setTimeFormat(TimeFormat.Format24H);
- calendar.setLocale(new Locale("en", "US"));
-
- calendar.setFirstVisibleHourOfDay(15);
-
- addComponent(calendar);
- calendar.setSizeFull();
- setSizeFull();
- }
-
- @Override
- protected String getTestDescription() {
- return "Calendar week and day views should work correctly when using setFirstVisibleHourOfDay() and "
- + "setting the end time of event to 00:00 of the following day";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 14737;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java b/uitest/src/main/java/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java
deleted file mode 100644
index 895a873e50..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/TestHideTimeAndSeparator.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.vaadin.tests.components.calendar;
-
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.annotations.Theme;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractReindeerTestUI;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-
-@Theme("tests-calendar")
-public class TestHideTimeAndSeparator extends AbstractReindeerTestUI {
-
- class GenericEvent implements CalendarEvent {
- private final Date start;
- private final Date end;
- private final String caption;
- private final boolean hideTime;
-
- public GenericEvent(Date start, Date end, String caption,
- boolean hideTime) {
- this.start = start;
- this.end = end;
- this.caption = caption;
- this.hideTime = hideTime;
- }
-
- @Override
- public Date getStart() {
- return start;
- }
-
- @Override
- public Date getEnd() {
- return end;
- }
-
- @Override
- public String getCaption() {
- return caption;
- }
-
- @Override
- public String getDescription() {
- return "This is a " + caption;
- }
-
- @Override
- public String getStyleName() {
- return hideTime ? "hide-time" : null;
- }
-
- @Override
- public boolean isAllDay() {
- return false;
- }
-
- }
-
- CalendarEvent shortEventHidden = new GenericEvent(
- makeDate(2013, 1, 2, 8, 0), makeDate(2013, 1, 2, 8, 30),
- "Short event", true);
- CalendarEvent longEventHidden = new GenericEvent(
- makeDate(2013, 1, 2, 10, 0), makeDate(2013, 1, 2, 12, 0),
- "Long event", true);
- CalendarEvent shortEvent = new GenericEvent(makeDate(2013, 1, 3, 8, 0),
- makeDate(2013, 1, 3, 8, 30), "Short event", false);
- CalendarEvent longEvent = new GenericEvent(makeDate(2013, 1, 3, 10, 0),
- makeDate(2013, 1, 3, 12, 0), "Long event", false);
-
- @Override
- protected void setup(VaadinRequest request) {
- Calendar cal = new Calendar();
- cal.setWidth("100%");
- cal.setHeight("500px");
-
- cal.setLocale(Locale.US);
-
- cal.addEvent(shortEventHidden);
- cal.addEvent(longEventHidden);
- cal.addEvent(shortEvent);
- cal.addEvent(longEvent);
-
- cal.setStartDate(makeDate(2013, 1, 1));
- cal.setEndDate(makeDate(2013, 1, 7));
- cal.setFirstVisibleHourOfDay(7);
-
- addComponent(cal);
- }
-
- @Override
- protected String getTestDescription() {
- return "The time should be hideable by CSS";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 12460;
- }
-
- private Date makeDate(int year, int month, int day, int hour, int minute) {
- java.util.Calendar juc = java.util.Calendar.getInstance();
- juc.set(year, month, day, hour, minute);
- return juc.getTime();
- }
-
- private Date makeDate(int year, int month, int day) {
- java.util.Calendar juc = java.util.Calendar.getInstance();
- juc.set(year, month, day);
- return juc.getTime();
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerTest.java b/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerTest.java
deleted file mode 100644
index 3946ec12be..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.vaadin.tests.containers;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-import com.vaadin.v7.data.util.BeanItemContainer;
-
-public class BeanItemContainerTest {
-
- /**
- * Test class for BeanItemContainer
- *
- * @throws IllegalAccessException
- * @throws InstantiationException
- */
- public static void main(String[] args)
- throws InstantiationException, IllegalAccessException {
- BeanItemContainer<Hello> c = new BeanItemContainer<>(Hello.class);
- c.addItem(new Hello());
-
- Collection<Hello> col = new LinkedList<>();
- for (int i = 0; i < 100; i++) {
- col.add(new Hello());
- }
- col.add(new Hello2());
-
- c = new BeanItemContainer<>(col);
-
- System.out.println(c + " contains " + c.size() + " objects");
-
- // test that subclass properties are handled correctly
- System.out.println(c + " item 0 second = "
- + c.getContainerProperty(c.getIdByIndex(0), "second"));
- System.out.println(c + " item 100 second = "
- + c.getContainerProperty(c.getIdByIndex(100), "second"));
-
- }
-
- public static class Hello {
-
- public String first;
- public String second;
-
- public Hello() {
- first = "f";
- second = "l";
- }
-
- public String getFirst() {
- return first;
- }
-
- public void setFirst(String first) {
- this.first = first;
- }
-
- public String getSecond() {
- return second;
- }
-
- public void setSecond(String second) {
- this.second = second;
- }
-
- }
-
- public static class Hello2 extends Hello {
-
- @Override
- public String getSecond() {
- return "second";
- }
-
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarReadOnly.java b/uitest/src/main/java/com/vaadin/tests/smoke/CalendarSmoke.java
index a0cadd24b2..fdd98a90b9 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarReadOnly.java
+++ b/uitest/src/main/java/com/vaadin/tests/smoke/CalendarSmoke.java
@@ -1,4 +1,4 @@
-package com.vaadin.tests.components.calendar;
+package com.vaadin.tests.smoke;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -9,7 +9,7 @@ import com.vaadin.v7.ui.Calendar;
import com.vaadin.v7.ui.components.calendar.CalendarComponentEvents;
import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-public class CalendarReadOnly extends AbstractTestUI {
+public class CalendarSmoke extends AbstractTestUI {
@Override
protected void setup(VaadinRequest request) {
@@ -19,10 +19,6 @@ public class CalendarReadOnly extends AbstractTestUI {
calendar.setReadOnly(true);
}
- if (request.getParameter("disabled") != null) {
- calendar.setEnabled(false);
- }
-
calendar.setFirstVisibleHourOfDay(8);
calendar.setLastVisibleHourOfDay(16);
@@ -56,13 +52,4 @@ public class CalendarReadOnly extends AbstractTestUI {
addComponent(calendar);
}
- @Override
- protected Integer getTicketNumber() {
- return 16523;
- }
-
- @Override
- protected String getTestDescription() {
- return "When set to readonly, you should still be able to navigate through the calendar.";
- }
}
diff --git a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
index 92c5323b86..59f71cbbca 100644
--- a/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
+++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
@@ -11,7 +11,6 @@ import com.vaadin.data.Binder;
import com.vaadin.data.ValidationException;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
-import com.vaadin.tests.components.calendar.CalendarTestEvent;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
diff --git a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTestEvent.java b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTestEvent.java
index e0416a14a6..8b5cc38743 100644
--- a/uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTestEvent.java
+++ b/uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTestEvent.java
@@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package com.vaadin.tests.components.calendar;
+package com.vaadin.tests.themes.valo;
import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
diff --git a/uitest/src/main/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSort.java b/uitest/src/main/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSort.java
deleted file mode 100644
index e0d97e7558..0000000000
--- a/uitest/src/main/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSort.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.v7.tests.components.calendar;
-
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.v7.shared.ui.calendar.CalendarState.EventSortOrder;
-import com.vaadin.v7.ui.Calendar;
-import com.vaadin.v7.ui.components.calendar.event.BasicEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEvent;
-import com.vaadin.v7.ui.components.calendar.event.CalendarEventProvider;
-
-/**
- *
- * Test UI for event sorting in calendar month and week views.
- *
- * @author Vaadin Ltd
- */
-public class CalendarEventsSort extends AbstractTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- getContent().setSizeFull();
- final Calendar calendar = new Calendar("Test calendar");
-
- toMonthView(calendar);
- calendar.setEventSortOrder(EventSortOrder.UNSORTED);
-
- calendar.setEventProvider(createEventProvider());
- addComponent(calendar);
-
- createSortByDateButton(calendar);
- createSortByDurationButton(calendar);
- createSortByProviderButton(calendar);
- createViewSwitchButton(calendar);
- }
-
- private void createViewSwitchButton(final Calendar calendar) {
- Button toWeek = new Button("Switch to week view", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- Button button = event.getButton();
- Boolean month = (Boolean) button.getData();
- button.setData(!month);
- if (month) {
- button.setCaption("Switch to month view");
- toWeekView(calendar);
- } else {
- button.setCaption("Switch to week view");
- toMonthView(calendar);
- }
- }
-
- });
- toWeek.addStyleName("view");
- toWeek.setData(true);
- addComponent(toWeek);
- }
-
- private Button createSortByProviderButton(final Calendar calendar) {
- Button byProvider = new Button("Sort by provider", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- calendar.setEventSortOrder(EventSortOrder.UNSORTED);
- }
- });
- byProvider.addStyleName("by-provider");
- addComponent(byProvider);
- return byProvider;
- }
-
- private void createSortByDurationButton(final Calendar calendar) {
- Button byDuration = new Button("Sort by duration DESC",
- new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- Button button = event.getButton();
- EventSortOrder order = (EventSortOrder) button
- .getData();
- if (EventSortOrder.DURATION_DESC.equals(order)) {
- order = EventSortOrder.DURATION_ASC;
- button.setCaption("Sort by duration DESC");
- addSortOrder(true, button);
- } else {
- order = EventSortOrder.DURATION_DESC;
- button.setCaption("Sort by duration ASC");
- addSortOrder(false, button);
- }
- button.setData(order);
- calendar.setEventSortOrder(order);
- }
- });
- byDuration.addStyleName("by-duration");
- byDuration.setData(EventSortOrder.DURATION_ASC);
- addComponent(byDuration);
- }
-
- private void createSortByDateButton(final Calendar calendar) {
- Button byStartDate = new Button("Sort by start date DESC",
- new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- Button button = event.getButton();
- EventSortOrder order = (EventSortOrder) button
- .getData();
- if (EventSortOrder.START_DATE_DESC.equals(order)) {
- order = EventSortOrder.START_DATE_ASC;
- button.setCaption("Sort by start date DESC");
- addSortOrder(true, button);
- } else {
- order = EventSortOrder.START_DATE_DESC;
- button.setCaption("Sort by start date ASC");
- addSortOrder(false, button);
- }
- button.setData(order);
- calendar.setEventSortOrder(order);
- }
- });
- byStartDate.setData(EventSortOrder.START_DATE_ASC);
- byStartDate.addStyleName("by-start-date");
- addComponent(byStartDate);
- }
-
- private CalendarEventProvider createEventProvider() {
- CalendarEventProvider provider = new CalendarEventProvider() {
-
- @Override
- public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
- java.util.Calendar cal = java.util.Calendar.getInstance();
- cal.set(java.util.Calendar.HOUR_OF_DAY, 5);
- cal.set(java.util.Calendar.MINUTE, 0);
- cal.set(java.util.Calendar.SECOND, 0);
- cal.set(java.util.Calendar.MILLISECOND, 0);
-
- Date start = cal.getTime();
- cal.add(java.util.Calendar.HOUR_OF_DAY, 2);
- Date end = cal.getTime();
-
- CalendarEvent event1 = new BasicEvent("first", "descr1", start,
- end);
-
- cal.set(java.util.Calendar.HOUR_OF_DAY, 2);
- start = cal.getTime();
- cal.add(java.util.Calendar.HOUR_OF_DAY, 4);
- end = cal.getTime();
-
- CalendarEvent event2 = new BasicEvent("second", "descr2", start,
- end);
-
- cal.set(java.util.Calendar.HOUR_OF_DAY, 1);
- start = cal.getTime();
- cal.add(java.util.Calendar.HOUR_OF_DAY, 2);
- end = cal.getTime();
-
- CalendarEvent event3 = new BasicEvent("third", "descr2", start,
- end);
-
- return Arrays.asList(event1, event2, event3);
- }
-
- };
- return provider;
- }
-
- private void addSortOrder(boolean ascending, Button button) {
- if (ascending) {
- button.addStyleName("asc");
- button.removeStyleName("desc");
- } else {
- button.removeStyleName("asc");
- button.addStyleName("desc");
- }
- }
-
- private void toMonthView(final Calendar calendar) {
- final java.util.Calendar cal = java.util.Calendar.getInstance();
-
- cal.add(java.util.Calendar.DAY_OF_YEAR, -2);
- calendar.setStartDate(cal.getTime());
- cal.add(java.util.Calendar.DAY_OF_YEAR, 14);
- calendar.setEndDate(cal.getTime());
- }
-
- private void toWeekView(final Calendar calendar) {
- java.util.Calendar cal = java.util.Calendar.getInstance();
- cal.add(java.util.Calendar.DAY_OF_YEAR, 2);
- calendar.setEndDate(cal.getTime());
- }
-
- @Override
- public String getDescription() {
- return "Make event sorting strategy customizable.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 14849;
- }
-} \ No newline at end of file
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
deleted file mode 100644
index 5cd234336c..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/BeanItemContainerLongEventTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests if long event which began before the view period is shown (#15242)
- */
-public class BeanItemContainerLongEventTest extends MultiBrowserTest {
-
- @Override
- protected String getDeploymentPath() {
- return "/run/BeanItemContainerTestUI?restartApplication";
- }
-
- @Override
- protected void openTestURL(String... parameters) {
- driver.get(getTestUrl());
- }
-
- @Test
- public void testEventDisplayedInWeekView() {
- openTestURL();
- WebElement target = driver
- .findElements(By.className("v-calendar-week-number")).get(1);
- target.click();
- target = driver.findElement(By.className("v-calendar-event"));
- Assert.assertEquals("Wrong event name", "Long event", target.getText());
- }
-
- @Test
- public void testEventDisplayedInDayView() {
- openTestURL();
- WebElement target = driver
- .findElements(By.className("v-calendar-day-number")).get(5);
- target.click();
- target = driver.findElement(By.className("v-calendar-event"));
- Assert.assertEquals("Wrong event name", "Long event", target.getText());
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java
deleted file mode 100644
index 809bd316af..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarActionEventSourceTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-
-import com.vaadin.tests.tb3.PrivateTB3Configuration;
-
-/**
- * Test that calendar action event source is the calendar, not a private nested
- * class in it.
- *
- * The related code is not browser dependent so only running on a single
- * browser.
- *
- * @author Vaadin Ltd
- */
-public class CalendarActionEventSourceTest extends PrivateTB3Configuration {
- @Test
- public void testActionEventSourceIsCalendarForEmptyCell() throws Exception {
- openTestURL();
-
- // perform action on empty cell
- WebElement element = getDriver()
- .findElement(By.className("v-calendar-spacer"));
- performAction(element);
-
- checkEventSourceIsCalendar();
- }
-
- @Test
- public void testActionEventSourceIsCalendarForEvent() throws Exception {
- openTestURL();
-
- // perform action on calendar event
- WebElement element = getDriver()
- .findElement(By.className("v-calendar-event"));
- performAction(element);
-
- checkEventSourceIsCalendar();
- }
-
- private void performAction(WebElement element) {
- // right click
- new Actions(getDriver()).contextClick(element).perform();
- WebElement menuItem = getDriver()
- .findElement(By.className("gwt-MenuItem"));
- menuItem.click();
- }
-
- private void checkEventSourceIsCalendar() {
- String calendarObject = getDriver().findElement(By.id("calendarlabel"))
- .getText();
- String actionSourceObject = getDriver()
- .findElement(By.id("senderlabel")).getText();
- Assert.assertEquals(
- "Calendar action event source must be the calendar itself",
- calendarObject, actionSourceObject);
- }
-
- @Override
- protected Class<?> getUIClass() {
- return CalendarActionEventSource.class;
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java
deleted file mode 100644
index e901d531b3..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarBackwardForwardTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests: Vaadin Calendar: Navigation to invisible days of week (#12243)
- *
- * @author Vaadin Ltd
- */
-public class CalendarBackwardForwardTest extends MultiBrowserTest {
-
- @Test
- public void testCalendar() throws InterruptedException, IOException {
- openTestURL();
-
- openWeekView();
- openDayView();
- clickCalendarNext();
-
- WebElement headerDayElement = getDriver()
- .findElement(By.className("v-calendar-header-day"));
-
- assertThat("This day should be Monday 9/9/13",
- headerDayElement.getText().equals("Monday 9/9/13"));
-
- for (int i = 0; i < 6; i++) {
- clickCalendarBack();
- }
-
- headerDayElement = getDriver()
- .findElement(By.className("v-calendar-header-day"));
-
- assertThat("This day should be Friday 8/30/13",
- headerDayElement.getText().equals("Friday 8/30/13"));
- }
-
- private void openWeekView() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-week-number"));
-
- for (WebElement webElement : elements) {
- if (webElement.getText().equals("36")) {
- webElement.click();
- break;
- }
- }
- }
-
- private void openDayView() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-header-day"));
-
- for (WebElement webElement : elements) {
- if (webElement.getText().contains("Friday 9/6/13")) {
- webElement.click();
- break;
- }
- }
- }
-
- private void clickCalendarNext() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-next"));
-
- elements.get(0).click();
- }
-
- private void clickCalendarBack() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-back"));
-
- elements.get(0).click();
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java
deleted file mode 100644
index dc1be07676..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarDisabledTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.vaadin.tests.components.calendar;
-
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Test;
-
-import com.vaadin.testbench.customelements.CalendarElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class CalendarDisabledTest extends MultiBrowserTest {
-
- @Override
- protected Class<?> getUIClass() {
- return CalendarReadOnly.class;
- }
-
- @Override
- public void setup() throws Exception {
- super.setup();
-
- openTestURL("restartApplication&disabled");
- }
-
- private CalendarElement getCalendar() {
- return $(CalendarElement.class).first();
- }
-
- @Test
- public void weekViewCannotBeOpenedFromMonthView() {
- tryOpenWeekView();
- assertCalendarInMonthView();
- }
-
- @Test
- public void dayViewCannotBeOpenedFromMonthView() {
- tryOpenDayView();
- assertCalendarInMonthView();
- }
-
- private void tryOpenDayView() {
- getCalendar().getDayNumbers().get(0).click();
- }
-
- private void tryOpenWeekView() {
- getCalendar().getWeekNumbers().get(0).click();
- }
-
- private void assertCalendarInMonthView() {
- assertTrue("Calendar wasn't in month view.",
- getCalendar().hasMonthView());
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java
deleted file mode 100644
index b51a75c027..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarHtmlInEventsTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.customelements.CalendarElement;
-import com.vaadin.testbench.elements.CheckBoxElement;
-import com.vaadin.testbench.elements.NativeSelectElement;
-import com.vaadin.tests.tb3.SingleBrowserTest;
-
-public class CalendarHtmlInEventsTest extends SingleBrowserTest {
-
- private NativeSelectElement periodSelect;
- private CheckBoxElement htmlAllowed;
- private CalendarElement calendar;
-
- @Override
- public void setup() throws Exception {
- super.setup();
- openTestURL();
- periodSelect = $(NativeSelectElement.class).first();
- htmlAllowed = $(CheckBoxElement.class).first();
- calendar = $(CalendarElement.class).first();
- }
-
- @Test
- public void monthViewEventCaptions() {
- Assert.assertEquals(getMonthEvent(0).getText(),
- "12:00 AM <b>Hello</b> <u>world</u>!");
-
- // Switch to HTML mode
- click(htmlAllowed);
- Assert.assertEquals("1. HTML in event caption: true", getLogRow(0));
-
- Assert.assertEquals(getMonthEvent(0).getText(),
- "12:00 AM Hello world!");
- }
-
- @Test
- public void weekViewEventCaptions() {
- periodSelect.selectByText("Week");
- Assert.assertEquals("4:00 AM\n<b>Hello</b> <u>world</u>!",
- getWeekEvent(1).getText());
-
- // Switch to HTML mode
- click(htmlAllowed);
- Assert.assertEquals("1. HTML in event caption: true", getLogRow(0));
-
- Assert.assertEquals("4:00 AM\nHello world!", getWeekEvent(1).getText());
- }
-
- @Test
- public void dayViewEventCaptions() {
- periodSelect.selectByText("Day");
- Assert.assertEquals("3:00 AM\n<b>Hello</b> <u>world</u>!",
- getWeekEvent(0).getText());
-
- // Switch to HTML mode
- click(htmlAllowed);
- Assert.assertEquals("1. HTML in event caption: true", getLogRow(0));
- Assert.assertEquals("3:00 AM\nHello world!", getWeekEvent(0).getText());
- }
-
- private WebElement getMonthEvent(int dayInCalendar) {
- return getMonthDay(dayInCalendar)
- .findElement(By.className("v-calendar-event"));
- }
-
- private WebElement getWeekEvent(int dayInCalendar) {
- return getWeekDay(dayInCalendar)
- .findElement(By.className("v-calendar-event"));
- }
-
- private WebElement getMonthDay(int i) {
- return calendar.findElements(By.className("v-calendar-month-day"))
- .get(i);
- }
-
- private WebElement getWeekDay(int i) {
- return calendar.findElements(By.className("v-calendar-day-times"))
- .get(i);
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
deleted file mode 100644
index ee0cd0dce7..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarMonthViewDndEventTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.DndActionsTest;
-
-/**
- * Test to check how DnD works for regular (not all day event) in calendar month
- * view.
- *
- * @author Vaadin Ltd
- */
-public class CalendarMonthViewDndEventTest extends DndActionsTest {
-
- @Test
- public void dragAndDropEventToNextDay() {
- openTestURL();
-
- WebElement calendar = findElement(By.className("v-calendar"));
- int calendarRight = calendar.getLocation().getX()
- + calendar.getSize().getWidth();
-
- WebElement event = findElement(By.className("v-calendar-event"));
- int x = event.getLocation().getX();
- int width = event.getSize().getWidth();
-
- // does calendar have space on the right for one more event (i.e. day
- // cell on the right).
- boolean moveRight = event.getLocation().getX()
- + 2 * event.getSize().getWidth() <= calendarRight;
-
- WebElement cell = getParentCell(event, "v-calendar-month-day");
-
- int cellY = cell.getLocation().getY();
- int cellHeight = cell.getSize().getHeight();
-
- long origStart = getTime("start");
- long origEnd = getTime("end");
-
- if (moveRight) {
- dragAndDrop(event, event.getSize().getWidth() + 5, 0);
- } else {
- dragAndDrop(event, -width / 2, 0);
- }
-
- event = findElement(By.className("v-calendar-event"));
- int newX = event.getLocation().getX();
- int newY = event.getLocation().getY();
-
- Assert.assertTrue(
- "Moved event has wrong Y position (not the same row), new Y position="
- + newY + ", cell Y position=" + cellY + ", cell height="
- + cellHeight,
- newY >= cellY && newY < cellY + cellHeight);
- if (moveRight) {
- Assert.assertTrue(
- "Moved event has wrong X position (not after original event)",
- newX >= x + width - 1);
- } else {
- width = event.getSize().getWidth();
- Assert.assertTrue(
- "Moved event has wrong X position (not after original event)",
- x >= newX + width - 1);
- }
-
- long start = getTime("start");
- long end = getTime("end");
-
- int day = 24 * 3600000;
- if (moveRight) {
- Assert.assertEquals(
- "Start date of moved event is not next day, same time",
- origStart + day, start);
- Assert.assertEquals(
- "End date of moved event is not next day, same time",
- origEnd + day, end);
- } else {
- Assert.assertEquals(
- "Start date of moved event is not previous day, same time",
- origStart - day, start);
- Assert.assertEquals(
- "End date of moved event is not previous day, same time",
- origEnd - day, end);
-
- }
- }
-
- private WebElement getParentCell(WebElement element, String style) {
- WebElement parent = element;
- do {
- // ".." xpath expression chooses the parent of the element
- parent = parent.findElement(By.xpath(".."));
- } while (!parent.getAttribute("class").contains(style));
- return parent;
- }
-
- private long getTime(String style) {
- WebElement start = findElement(By.className(style));
- return Long.parseLong(start.getText());
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java
deleted file mode 100644
index 8c0e83084f..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.NotificationElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests opening and closing of calendar notifications.
- *
- * @since
- * @author Vaadin Ltd
- */
-public class CalendarNotificationsTest extends MultiBrowserTest {
-
- @Override
- protected Class<?> getUIClass() {
- return NotificationTestUI.class;
- }
-
- @Override
- protected DesiredCapabilities getDesiredCapabilities() {
- DesiredCapabilities desiredCapabilities = new DesiredCapabilities(
- super.getDesiredCapabilities());
- desiredCapabilities.setCapability("enablePersistentHover", false);
- desiredCapabilities.setCapability("requireWindowFocus", true);
-
- return desiredCapabilities;
- }
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- // TODO: IE testing is pending on #14312. For now, IE testing is handled
- // with a logger.
- return getBrowsersExcludingIE();
- }
-
- @Test
- public void notificationTest() throws Exception {
- openTestURL();
-
- WebElement day = findElements(By.className("v-calendar-day-number"))
- .get(2);
- // IE8 requires you to click on the text part to fire the event
- new Actions(getDriver()).moveToElement(day, 83, 11).click().perform();
-
- Assert.assertTrue("There should be a notification",
- $(NotificationElement.class).exists());
-
- // move the mouse around a bit
- new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100)
- .perform();
-
- // wait until the notification has animated out
- sleep(1000);
-
- Assert.assertFalse("There should be no notification on the page",
- $(NotificationElement.class).exists());
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java
deleted file mode 100644
index 0640f19b0d..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarNotificationsTestIE.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-import org.openqa.selenium.interactions.Actions;
-import org.openqa.selenium.remote.DesiredCapabilities;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.NotificationElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests opening and closing of calendar notifications.
- *
- * @since
- * @author Vaadin Ltd
- */
-public class CalendarNotificationsTestIE extends MultiBrowserTest {
-
- @Override
- protected Class<?> getUIClass() {
- return CalendarNotifications.class;
- }
-
- @Override
- protected boolean requireWindowFocusForIE() {
- return true;
- }
-
- @Override
- protected boolean usePersistentHoverForIE() {
- return false;
- }
-
- @Override
- public List<DesiredCapabilities> getBrowsersToTest() {
- return getIEBrowsersOnly();
- }
-
- @Test
- public void notificationTest() throws Exception {
- openTestURL();
-
- WebElement day = findElements(By.className("v-calendar-day-number"))
- .get(2);
- // IE8 requires you to click on the text part to fire the event
- new Actions(getDriver()).moveToElement(day,
- day.getSize().getWidth() - 3, day.getSize().getHeight() / 2)
- .click().perform();
-
- // check that a notification was opened, this is done with a log instead
- // of a screenshot or element presence check due to problems with IE
- // webdriver
- String text = findElement(By.id("Log"))
- .findElement(By.className("v-label")).getText();
- Assert.assertTrue("Notification should've opened",
- "1. Opening a notification".equals(text));
-
- // move the mouse around a bit
- new Actions(getDriver()).moveByOffset(5, 5).moveByOffset(100, 100)
- .perform();
-
- // wait until the notification has animated out
- sleep(1000);
-
- Assert.assertFalse("There should be no notification on the page",
- $(NotificationElement.class).exists());
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java
deleted file mode 100644
index af49d39a00..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarRescheduleEventTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.DndActionsTest;
-
-/**
- * Test to check ability to reschedule events unlimited times.
- *
- * @author Vaadin Ltd
- */
-public class CalendarRescheduleEventTest extends DndActionsTest {
-
- @Test
- public void rescheduleEventSeveralTimes() {
- openTestURL();
-
- // Reschedule event for the first time
- int y = rescheduleEvent(20);
-
- WebElement startElement = getDriver()
- .findElement(By.className("start"));
- WebElement endElement = getDriver().findElement(By.className("end"));
-
- long start = Long.parseLong(startElement.getText());
- long end = Long.parseLong(endElement.getText());
-
- long duration = end - start;
-
- // Reschedule event for the second time
- int yNew = rescheduleEvent(20);
-
- startElement = getDriver().findElement(By.className("start"));
- endElement = getDriver().findElement(By.className("end"));
-
- long newStart = Long.parseLong(startElement.getText());
- long newEnd = Long.parseLong(endElement.getText());
-
- Assert.assertTrue(
- "Second rescheduling did not change the event start time",
- newStart > start);
- Assert.assertEquals(
- "Duration of the event after second rescheduling has been changed",
- duration, newEnd - newStart);
- Assert.assertTrue(
- "Second rescheduling did not change the event Y coordinate",
- yNew > y);
- }
-
- /*
- * DnD event by Y axis
- */
- private int rescheduleEvent(int yOffset) {
- WebElement eventCaption = getDriver()
- .findElement(By.className("v-calendar-event-caption"));
-
- dragAndDrop(eventCaption, 0, yOffset);
-
- eventCaption = getDriver()
- .findElement(By.className("v-calendar-event-caption"));
- return eventCaption.getLocation().getY();
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java
deleted file mode 100644
index 00e4039318..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarResizeOverlappingEventsTest.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.DndActionsTest;
-
-/**
- *
- * @author Vaadin Ltd
- */
-public class CalendarResizeOverlappingEventsTest extends DndActionsTest {
-
- private int noOverlapWidth;
- private int oneOverlapWidth;
- private int twoOverlapsWidth;
-
- private WebElement firstEvent;
- private WebElement secondEvent;
- private WebElement thirdEvent;
-
- private WebElement firstEventBottomResize;
- private WebElement secondEventBottomResize;
- private WebElement thirdEventBottomResize;
-
- @Test
- public void testCalendarResizeOverlappingEvents()
- throws InterruptedException, IOException {
-
- openTestURL();
- initParams();
- doTest();
- }
-
- private void doTest() {
- assertWidths(noOverlapWidth, noOverlapWidth, noOverlapWidth);
-
- dragAndDrop(firstEventBottomResize, 240);
- assertWidths(oneOverlapWidth, oneOverlapWidth, oneOverlapWidth);
-
- dragAndDrop(secondEventBottomResize, 240);
- assertWidths(twoOverlapsWidth, twoOverlapsWidth, twoOverlapsWidth);
-
- dragAndDrop(secondEventBottomResize, -240);
- dragAndDrop(firstEventBottomResize, -240);
- assertWidths(noOverlapWidth, noOverlapWidth, noOverlapWidth);
-
- }
-
- private void assertWidths(int firstEventExpectedWidth,
- int secondEventExpectedWidth, int thirdEventExpectedWidth) {
- int widthTolerance = 5;
- String errorMessage = "Wrong event width after resizing, expected [%d] (+/-%d), obtained [%d]";
-
- int actualWidth = firstEvent.getSize().getWidth();
- int expectedWidth = firstEventExpectedWidth;
- Assert.assertTrue(
- String.format(errorMessage, expectedWidth, widthTolerance,
- actualWidth),
- isAproximateWidth(actualWidth, expectedWidth, widthTolerance));
-
- actualWidth = secondEvent.getSize().getWidth();
- expectedWidth = secondEventExpectedWidth;
- Assert.assertTrue(
- String.format(errorMessage, expectedWidth, widthTolerance,
- actualWidth),
- isAproximateWidth(actualWidth, expectedWidth, widthTolerance));
-
- actualWidth = thirdEvent.getSize().getWidth();
- expectedWidth = thirdEventExpectedWidth;
- Assert.assertTrue(
- String.format(errorMessage, expectedWidth, widthTolerance,
- actualWidth),
- isAproximateWidth(actualWidth, expectedWidth, widthTolerance));
- }
-
- private boolean isAproximateWidth(int actualWidth, int expectedWidth,
- int tolerance) {
- return Math.abs(expectedWidth - actualWidth) <= tolerance;
- }
-
- private void dragAndDrop(WebElement element, int yOffset) {
- dragAndDrop(element, 0, yOffset);
- }
-
- private void initParams() {
- WebElement dateSlot = getDriver()
- .findElement(By.className("v-datecellslot"));
- int dateSlotWidth = dateSlot.getSize().getWidth();
- noOverlapWidth = dateSlotWidth;
- oneOverlapWidth = dateSlotWidth / 2;
- twoOverlapsWidth = dateSlotWidth / 3;
-
- Comparator<WebElement> startTimeComparator = new Comparator<WebElement>() {
- @Override
- public int compare(WebElement e1, WebElement e2) {
- int e1Top = e1.getLocation().getY();
- int e2Top = e2.getLocation().getY();
- return e1Top - e2Top;
- }
- };
-
- List<WebElement> eventElements = getDriver()
- .findElements(By.className("v-calendar-event-content"));
- Collections.sort(eventElements, startTimeComparator);
- firstEvent = eventElements.get(0);
- secondEvent = eventElements.get(1);
- thirdEvent = eventElements.get(2);
-
- List<WebElement> resizeBottomElements = getDriver()
- .findElements(By.className("v-calendar-event-resizebottom"));
- Collections.sort(resizeBottomElements, startTimeComparator);
- firstEventBottomResize = resizeBottomElements.get(0);
- secondEventBottomResize = resizeBottomElements.get(1);
- thirdEventBottomResize = resizeBottomElements.get(2);
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java
deleted file mode 100644
index b6f8be7368..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests calendar via prepared screenshots 'Calendar event not shown correctly
- * when partially out of view' (#7261)
- */
-public class CalendarShownNotCorrectlyWhenPartiallyOutOfViewTest
- extends MultiBrowserTest {
-
- @Test
- public void testCalendar() throws InterruptedException, IOException {
- openTestURL();
-
- openWeekView();
- compareScreen("weekview");
-
- openDayView();
- compareScreen("dayview");
- }
-
- private void openWeekView() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-week-number"));
-
- for (WebElement webElement : elements) {
- if (webElement.getText().equals("36")) {
- webElement.click();
- break;
- }
- }
- }
-
- private void openDayView() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-header-day"));
-
- for (WebElement webElement : elements) {
- if (webElement.getText().contains("Thursday 9/5/13")) {
- webElement.click();
- break;
- }
- }
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java
deleted file mode 100644
index 5033047bd0..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarVisibleHoursTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.io.IOException;
-import java.util.List;
-
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests calendar via prepared screenshots calendar visible hours of day invalid
- * shows invalid dates(week/day view) (#12521)
- */
-public class CalendarVisibleHoursTest extends MultiBrowserTest {
-
- @Test
- public void testCalendar() throws InterruptedException, IOException {
- openTestURL();
-
- openWeekView();
- compareScreen("weekview");
-
- openDayView();
-
- compareScreen("dayview");
- }
-
- private void openWeekView() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-week-number"));
-
- for (WebElement webElement : elements) {
- if (webElement.getText().equals("36")) {
- webElement.click();
- break;
- }
- }
- }
-
- private void openDayView() {
- List<WebElement> elements = getDriver()
- .findElements(By.className("v-calendar-header-day"));
-
- for (WebElement webElement : elements) {
- if (webElement.getText().contains("Thursday 9/5/13")) {
- webElement.click();
- break;
- }
- }
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java
deleted file mode 100644
index facf44775b..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.vaadin.tests.components.calendar;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.List;
-
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class CalendarWeekSelectionTest extends MultiBrowserTest {
-
- @Test
- public void correctYearIsSelected() {
- openTestURL();
-
- clickOnWeek("1");
-
- assertThat(getFirstDayOfTheYear().getText(), is("Wednesday 1/1/14"));
- }
-
- private WebElement getFirstDayOfTheYear() {
- WebElement header = findElement(By.className("v-calendar-header-week"));
- List<WebElement> headerElements = header.findElements(By.tagName("td"));
-
- // Wednesday is the first day of 2014.
- return headerElements.get(4);
- }
-
- private void clickOnWeek(String week) {
- for (WebElement e : findElements(
- By.className("v-calendar-week-number"))) {
- if (e.getText().equals(week)) {
- e.click();
- break;
- }
- }
- }
-} \ No newline at end of file
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java
deleted file mode 100644
index 3ac6a2b0c3..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/DndCalendarTargetDetailsTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2000-2013 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.tests.components.table.DndTableTargetDetailsTest;
-
-/**
- * Test for mouse details in CalendarTargetDetails class when DnD target is a
- * calendar.
- *
- * @author Vaadin Ltd
- */
-public class DndCalendarTargetDetailsTest extends DndTableTargetDetailsTest {
-
- @Override
- protected WebElement getTarget() {
- return findElement(By.className("v-datecellslot-even"));
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java
deleted file mode 100644
index 156100310c..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/NullEventMoveHandlerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.vaadin.tests.components.calendar;
-
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.DndActionsTest;
-
-public class NullEventMoveHandlerTest extends DndActionsTest {
-
- @Override
- public void setup() throws Exception {
- super.setup();
- openTestURL();
- }
-
- @Test
- public void eventIsNotMovableInMonthView() {
- assertEventCannotBeMoved();
- }
-
- @Test
- public void eventIsClickableWhenNotMovableInMonthView() {
- getEvent().click();
- Assert.assertEquals("1. Clicked on foo", getLogRow(0));
- }
-
- @Test
- public void eventIsNotMovableInWeekView() {
- openWeekView();
- assertEventCannotBeMoved();
- }
-
- @Test
- public void eventIsClickableWhenNotMovableInWeekView() {
- openWeekView();
- getEvent().findElement(By.className("v-calendar-event-caption"))
- .click();
- Assert.assertEquals("1. Clicked on foo", getLogRow(0));
- }
-
- private void assertEventCannotBeMoved() {
- int originalPosition = getEventXPosition();
-
- moveEventToNextDay();
-
- assertThat("Event position changed.", getEventXPosition(),
- is(originalPosition));
- }
-
- private void openWeekView() {
- getDriver().findElement(By.className("v-calendar-week-number")).click();
- }
-
- private void moveEventToNextDay() {
- WebElement event = getEvent();
- dragAndDrop(event, event.getSize().getWidth() + 5, 0);
- }
-
- private int getEventXPosition() {
- return getEvent().getLocation().getX();
- }
-
- private WebElement getEvent() {
- return getDriver().findElement(By.className("v-calendar-event"));
- }
-} \ No newline at end of file
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java
deleted file mode 100644
index 84e5f452e4..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDaySpecialCaseTest.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.StaleElementReferenceException;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.parallel.BrowserUtil;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests that calendar week and day views are correct when using
- * setFirstVisibleHourOfDay() and the end event time is 00:00 of the following
- * day
- */
-public class SetFirstVisibleHourOfDaySpecialCaseTest extends MultiBrowserTest {
-
- @Override
- protected boolean requireWindowFocusForIE() {
- return true;
- }
-
- @Test
- public void testDayView() {
- openTestURL();
-
- // open day view
- clickElement("v-calendar-day-number", "5");
-
- // first of all check if event is present in calendar view
- waitForElementPresent(By.className("v-calendar-event-content"));
-
- // check that event has correct height
- WebElement event = getDriver()
- .findElement(By.className("v-calendar-event-content"));
- WebElement dateSlot = getDriver()
- .findElement(By.className("v-datecellslot"));
-
- Assert.assertEquals(
- "The height of shown part of calendar event should be equal to 16 datecell slots",
- dateSlot.getSize().getHeight() * 16,
- event.getSize().getHeight());
- }
-
- @Test
- public void testWeekView() {
- openTestURL();
-
- // open week view
- clickElement("v-calendar-week-number", "36");
-
- // first of all check if event is present in calendar view
- waitForElementPresent(By.className("v-calendar-event-content"));
-
- // check that event has correct height
- WebElement event = getDriver()
- .findElement(By.className("v-calendar-event-content"));
- WebElement dateSlot = getDriver()
- .findElement(By.className("v-datecellslot"));
-
- Assert.assertEquals(
- "The height of shown part of calendar event should be equal to 16 datecell slots",
- dateSlot.getSize().getHeight() * 16,
- event.getSize().getHeight());
- }
-
- private void clickElement(String className, String text) {
- List<WebElement> elements = findElements(By.className(className));
-
- boolean found = false;
- for (WebElement webElement : elements) {
- if (webElement.getText().equals(text)) {
- webElement.click();
- if (BrowserUtil.isIE8(getDesiredCapabilities())) {
- try {
- // sometimes the element only gets focus from click and
- // we need to click the text, which is in the right edge
- // of the element
- testBenchElement(webElement)
- .click(webElement.getSize().getWidth() - 5, 9);
- } catch (StaleElementReferenceException e) {
- // the first click succeeded after all
- }
- }
- found = true;
- break;
- }
- }
-
- if (!found) {
- Assert.fail("Element " + className + " with text " + text
- + " not found.");
- }
- }
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java b/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java
deleted file mode 100644
index 11464ac7bb..0000000000
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/SetFirstVisibleHourOfDayTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.tests.components.calendar;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Tests that calendar week and day views are correct when using
- * setFirstVisibleHourOfDay()
- */
-public class SetFirstVisibleHourOfDayTest extends MultiBrowserTest {
-
- @Override
- protected boolean requireWindowFocusForIE() {
- return true;
- }
-
- @Test
- public void testDayView() {
- openTestURL();
- waitForElementPresent(By.className("v-calendar"));
-
- // open day view
- clickElement("v-calendar-day-number", "5");
-
- // first of all check if event is present in calendar view
- waitForElementPresent(By.className("v-calendar-event-content"));
-
- WebElement event = getDriver()
- .findElement(By.className("v-calendar-event-content"));
- WebElement dateSlot = getDriver()
- .findElement(By.className("v-datecellslot"));
-
- Assert.assertEquals(
- "The height of shown part of calendar event should be equal to 12 datecell slots",
- dateSlot.getSize().getHeight() * 12,
- event.getSize().getHeight());
- }
-
- @Test
- public void testWeekView() {
- openTestURL();
- waitForElementPresent(By.className("v-calendar"));
-
- // open week view
- clickElement("v-calendar-week-number", "36");
-
- // first of all check if event is present in calendar view
- waitForElementPresent(By.className("v-calendar-event-content"));
-
- WebElement event = getDriver()
- .findElement(By.className("v-calendar-event-content"));
- WebElement dateSlot = getDriver()
- .findElement(By.className("v-datecellslot"));
-
- Assert.assertEquals(
- "The height of shown part of calendar event should be equal to 12 datecell slots",
- dateSlot.getSize().getHeight() * 12,
- event.getSize().getHeight());
- }
-
- private void clickElement(String className, String text) {
- List<WebElement> elements = findElements(By.className(className));
-
- boolean found = false;
- for (WebElement webElement : elements) {
- if (webElement.getText().equals(text)) {
- webElement.click();
- found = true;
- break;
- }
- }
-
- if (!found) {
- Assert.fail("Element " + className + " with text " + text
- + " not found.");
- }
- }
-
-}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarReadOnlyTest.java b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java
index da8dec927b..8228419db1 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/calendar/CalendarReadOnlyTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/smoke/CalendarSmokeTest.java
@@ -1,4 +1,4 @@
-package com.vaadin.tests.components.calendar;
+package com.vaadin.tests.smoke;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
@@ -14,100 +14,66 @@ import com.vaadin.testbench.By;
import com.vaadin.testbench.customelements.CalendarElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
-public class CalendarReadOnlyTest extends MultiBrowserTest {
+public class CalendarSmokeTest extends MultiBrowserTest {
- @Override
- public void setup() throws Exception {
- super.setup();
+ @Test
+ public void calendarSmokeTest() {
+ openTestURL();
- openTestURL("restartApplication&readonly");
+ smokeTest();
}
@Test
- public void weekViewCanBeOpenedFromMonthView() {
+ public void readOnlyCalendarSmokeTest() {
+ openTestURL("restartApplication&readonly");
+
+ smokeTest();
+ }
+
+ private void smokeTest() {
openWeekView();
assertTrue("Calendar wasn't in week view.",
getCalendar().hasWeekView());
- }
+ reload();
- @Test
- public void dayViewCanBeOpenedFromMonthView() {
openDayView();
-
assertTrue("Calendar wasn't in day view.", getCalendar().hasDayView());
- }
+ reload();
- @Test
- public void dayViewCanBeOpenedFromWeekView() {
openWeekView();
-
getCalendar().getDayHeaders().get(0).click();
-
assertTrue("Calendar wasn't in day view.", getCalendar().hasDayView());
- }
+ reload();
- @Test
- public void weekViewCanBeBrowsedForwards() {
openWeekView();
-
String firstDayOfCurrentWeek = getVisibleFirstDay();
getCalendar().next();
-
String firstDayOfNextWeek = getVisibleFirstDay();
-
assertThat("Week didn't change.", firstDayOfCurrentWeek,
is(not(firstDayOfNextWeek)));
- }
-
- @Test
- public void weekViewCanBeBrowsedBackwards() {
- openWeekView();
-
- String firstDayOfCurrentWeek = getVisibleFirstDay();
- getCalendar().back();
-
- String firstDayOfPreviousWeek = getVisibleFirstDay();
-
- assertThat("Week didn't change.", firstDayOfCurrentWeek,
- is(not(firstDayOfPreviousWeek)));
- }
+ reload();
- @Test
- public void dayViewCanBeBrowsedForwards() {
openDayView();
-
String currentDay = getVisibleFirstDay();
getCalendar().next();
-
String nextDay = getVisibleFirstDay();
-
assertThat("Day didn't change.", currentDay, is(not(nextDay)));
- }
+ reload();
- @Test
- public void dayViewCanBeBrowsedBackwards() {
openDayView();
-
- String currentDay = getVisibleFirstDay();
+ currentDay = getVisibleFirstDay();
getCalendar().back();
-
String previousDay = getVisibleFirstDay();
-
assertThat("Day didn't change.", currentDay, is(not(previousDay)));
- }
+ reload();
- @Test
- public void hiddenEventsCanBeExpanded() {
WebElement dayWithEvents = getFirstDayWithEvents();
-
assertThat("Incorrect event count.",
getVisibleEvents(dayWithEvents).size(), is(2));
-
toggleExpandEvents(dayWithEvents).click();
assertThat("Incorrect event count.",
getVisibleEvents(dayWithEvents).size(), is(4));
-
toggleExpandEvents(dayWithEvents).click();
assertThat("Incorrect event count.",
getVisibleEvents(dayWithEvents).size(), is(2));
@@ -139,6 +105,10 @@ public class CalendarReadOnlyTest extends MultiBrowserTest {
return null;
}
+ private void reload() {
+ getDriver().navigate().refresh();
+ }
+
private WebElement toggleExpandEvents(WebElement dayWithEvents) {
return dayWithEvents
.findElement(By.className("v-calendar-bottom-spacer"));
diff --git a/uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java b/uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java
deleted file mode 100644
index 9519a68317..0000000000
--- a/uitest/src/test/java/com/vaadin/v7/tests/components/calendar/CalendarEventsSortTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2000-2014 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.v7.tests.components.calendar;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-/**
- * Check how event sorting works in calendar month and week views.
- *
- * @author Vaadin Ltd
- */
-public class CalendarEventsSortTest extends MultiBrowserTest {
-
- @Test
- public void testByDuration() {
- openTestURL();
-
- checkSortByDuration(true);
- }
-
- @Test
- public void testByStartDate() {
- openTestURL();
-
- checkSortByStartDate(true);
- }
-
- @Test
- public void testByProvider() {
- openTestURL();
-
- List<WebElement> events = findElements(
- By.className("v-calendar-event-month"));
- checkProviderOrder(events);
- }
-
- @Test
- public void testWeekByDuration() {
- openTestURL();
-
- findElement(By.className("view")).click();
-
- checkSortByDuration(false);
- }
-
- @Test
- public void testWeekByStartDate() {
- openTestURL();
-
- findElement(By.className("view")).click();
-
- checkSortByStartDate(false);
- }
-
- @Test
- public void testWeekByProvider() {
- openTestURL();
-
- findElement(By.className("view")).click();
-
- List<WebElement> events = findElements(
- By.className("v-calendar-event-caption"));
- checkProviderOrder(events);
- }
-
- private void checkSortByStartDate(boolean month) {
- sort("by-start-date", false);
-
- String style = month ? "v-calendar-event-month"
- : "v-calendar-event-caption";
- List<WebElement> events = findElements(By.className(style));
- checkStartDateOrderDesc(events);
-
- sort("by-start-date", true);
-
- events = findElements(By.className(style));
- checkStartDateOrderAsc(events);
- }
-
- private void sort(String style, boolean ascending) {
- findElement(By.className(style)).click();
-
- if (!isElementPresent(
- By.cssSelector('.' + style + (ascending ? ".asc" : ".desc")))) {
- findElement(By.className(style)).click();
- }
- }
-
- private void checkSortByDuration(boolean month) {
- sort("by-duration", false);
-
- String style = month ? "v-calendar-event-month"
- : "v-calendar-event-caption";
-
- List<WebElement> events = findElements(By.className(style));
- checkDurationOrderDesc(events);
-
- sort("by-duration", true);
- events = findElements(By.className(style));
- checkDurationOrderAsc(events);
- }
-
- private void checkDurationOrderDesc(List<WebElement> events) {
- Assert.assertTrue(
- "'Second' event should be the first when sorted by duration",
- events.get(0).getText().endsWith("second"));
- Assert.assertTrue(
- "'Third' event should be the second when sorted by duration",
- events.get(1).getText().endsWith("third"));
- Assert.assertTrue(
- "'First' event should be the third when sorted by duration",
- events.get(2).getText().endsWith("first"));
- }
-
- private void checkDurationOrderAsc(List<WebElement> events) {
- Assert.assertTrue(
- "'First' event should be the first when sorted by duration",
- events.get(0).getText().endsWith("first"));
- Assert.assertTrue(
- "'Third' event should be the second when sorted by duration",
- events.get(1).getText().endsWith("third"));
- Assert.assertTrue(
- "'Second' event should be the third when sorted by duration",
- events.get(2).getText().endsWith("second"));
- }
-
- private void checkStartDateOrderDesc(List<WebElement> events) {
- Assert.assertTrue(
- "'Third' event should be the first when sorted by start date",
- events.get(0).getText().endsWith("third"));
- Assert.assertTrue(
- "'Second' event should be the second when sorted by start date",
- events.get(1).getText().endsWith("second"));
- Assert.assertTrue(
- "'First' event should be the third when sorted by start date",
- events.get(2).getText().endsWith("first"));
- }
-
- private void checkStartDateOrderAsc(List<WebElement> events) {
- Assert.assertTrue(
- "'First' event should be the first when sorted by start date",
- events.get(0).getText().endsWith("first"));
- Assert.assertTrue(
- "'Second' event should be the second when sorted by start date",
- events.get(1).getText().endsWith("second"));
- Assert.assertTrue(
- "'Third' event should be the third when sorted by start date",
- events.get(2).getText().endsWith("third"));
- }
-
- private void checkProviderOrder(List<WebElement> events) {
- Assert.assertTrue(
- "'First' event should be the first when sorted by provider",
- events.get(0).getText().endsWith("first"));
- Assert.assertTrue(
- "'Second' event should be the second when sorted by provider",
- events.get(1).getText().endsWith("second"));
- Assert.assertTrue(
- "'Third' event should be the third when sorted by provider",
- events.get(2).getText().endsWith("third"));
- }
-
-}