-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...-tests/src/main/java/com/vaadin/flow/component/datetimepicker/DateTimePickerI18nPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright 2000-2024 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.flow.component.datetimepicker; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.NativeButton; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("vaadin-date-time-picker/i18n") | ||
public class DateTimePickerI18nPage extends Div { | ||
|
||
public DateTimePickerI18nPage() { | ||
DateTimePicker dateTimePicker = new DateTimePicker(); | ||
|
||
DateTimePicker.DateTimePickerI18n i18n = new DateTimePicker.DateTimePickerI18n(); | ||
i18n.setDateLabel("date"); | ||
i18n.setTimeLabel("time"); | ||
|
||
NativeButton setI18n = new NativeButton("Set i18n", | ||
event -> dateTimePicker.setI18n(i18n)); | ||
setI18n.setId("set-i18n"); | ||
|
||
NativeButton setDateAriaLabel = new NativeButton("Set date aria label", | ||
event -> dateTimePicker.setDateAriaLabel("Custom date")); | ||
setDateAriaLabel.setId("set-date-aria-label"); | ||
|
||
NativeButton removeDateAriaLabel = new NativeButton( | ||
"Remove date aria label", | ||
event -> dateTimePicker.setDateAriaLabel(null)); | ||
removeDateAriaLabel.setId("remove-date-aria-label"); | ||
|
||
NativeButton setTimeAriaLabel = new NativeButton("Set time aria label", | ||
event -> dateTimePicker.setTimeAriaLabel("Custom time")); | ||
setTimeAriaLabel.setId("set-time-aria-label"); | ||
|
||
NativeButton removeTimeAriaLabel = new NativeButton( | ||
"Remove time aria label", | ||
event -> dateTimePicker.setTimeAriaLabel(null)); | ||
removeTimeAriaLabel.setId("remove-time-aria-label"); | ||
|
||
add(dateTimePicker, setI18n, setDateAriaLabel, removeDateAriaLabel, | ||
setTimeAriaLabel, removeTimeAriaLabel); | ||
} | ||
|
||
} |
93 changes: 93 additions & 0 deletions
93
...on-tests/src/test/java/com/vaadin/flow/component/datetimepicker/DateTimePickerI18nIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/* | ||
* Copyright 2000-2024 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.flow.component.datetimepicker; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.vaadin.flow.component.datetimepicker.testbench.DateTimePickerElement; | ||
import com.vaadin.tests.AbstractComponentIT; | ||
import com.vaadin.flow.testutil.TestPath; | ||
|
||
@TestPath("vaadin-date-time-picker/i18n") | ||
public class DateTimePickerI18nIT extends AbstractComponentIT { | ||
|
||
private DateTimePickerElement dateTimePicker; | ||
|
||
@Before | ||
public void init() { | ||
open(); | ||
dateTimePicker = $(DateTimePickerElement.class).first(); | ||
} | ||
|
||
@Test | ||
public void setAndRemoveDateAriaLabel_assertI18nProperty() { | ||
$("button").id("set-date-aria-label").click(); | ||
Assert.assertEquals("Custom date", | ||
dateTimePicker.getPropertyString("i18n", "dateLabel")); | ||
|
||
$("button").id("remove-date-aria-label").click(); | ||
Assert.assertNull( | ||
dateTimePicker.getPropertyString("i18n", "dateLabel")); | ||
} | ||
|
||
@Test | ||
public void setAndRemoveTimeAriaLabel_assertI18nProperty() { | ||
$("button").id("set-time-aria-label").click(); | ||
Assert.assertEquals("Custom time", | ||
dateTimePicker.getPropertyString("i18n", "timeLabel")); | ||
|
||
$("button").id("remove-time-aria-label").click(); | ||
Assert.assertNull( | ||
dateTimePicker.getPropertyString("i18n", "timeLabel")); | ||
} | ||
|
||
@Test | ||
public void setI18n_assertI18nProperty() { | ||
$("button").id("set-i18n").click(); | ||
Assert.assertEquals("date", | ||
dateTimePicker.getPropertyString("i18n", "dateLabel")); | ||
Assert.assertEquals("time", | ||
dateTimePicker.getPropertyString("i18n", "timeLabel")); | ||
} | ||
|
||
@Test | ||
public void setI18n_setAndRemoveDateAriaLabel_assertI18nProperty() { | ||
$("button").id("set-i18n").click(); | ||
|
||
$("button").id("set-date-aria-label").click(); | ||
Assert.assertEquals("Custom date", | ||
dateTimePicker.getPropertyString("i18n", "dateLabel")); | ||
|
||
$("button").id("remove-date-aria-label").click(); | ||
Assert.assertEquals("date", | ||
dateTimePicker.getPropertyString("i18n", "dateLabel")); | ||
} | ||
|
||
@Test | ||
public void setI18n_setAndRemoveTimeAriaLabel_assertI18nProperty() { | ||
$("button").id("set-i18n").click(); | ||
|
||
$("button").id("set-time-aria-label").click(); | ||
Assert.assertEquals("Custom time", | ||
dateTimePicker.getPropertyString("i18n", "timeLabel")); | ||
|
||
$("button").id("remove-time-aria-label").click(); | ||
Assert.assertEquals("time", | ||
dateTimePicker.getPropertyString("i18n", "timeLabel")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters