@@ -28,7 +28,7 @@ import com.vaadin.event.ShortcutAction.KeyCode; | |||
import com.vaadin.event.ShortcutAction.ModifierKey; | |||
/** | |||
* Converter for {@link ShortcutActions}. | |||
* Converter for {@link ShortcutAction ShortcutActions}. | |||
* | |||
* @since 7.4 | |||
* @author Vaadin Ltd |
@@ -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); | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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."; | |||
} | |||
} |
@@ -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"; | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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."; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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"; | |||
} | |||
} | |||
} |
@@ -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."; | |||
} | |||
} |
@@ -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; |
@@ -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; | |||
@@ -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; | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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()); | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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); | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
} | |||
} |
@@ -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")); | |||
} | |||
} |
@@ -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")); | |||
} | |||
} |
@@ -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."); | |||
} | |||
} | |||
} |
@@ -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."); | |||
} | |||
} | |||
} |
@@ -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")); |
@@ -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")); | |||
} | |||
} |