diff options
author | caalador <mikael.grankvist@gmail.com> | 2017-01-30 08:16:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-30 08:16:44 +0200 |
commit | 07814a2b556eff6bd14959cee81a9b3dcd105bb7 (patch) | |
tree | 1d7a49df4f32c301a0d41fc8598abf4a17ede846 /server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java | |
parent | e7b49b4893607904bac69ca79e5ef583abfbe679 (diff) | |
download | vaadin-framework-07814a2b556eff6bd14959cee81a9b3dcd105bb7.tar.gz vaadin-framework-07814a2b556eff6bd14959cee81a9b3dcd105bb7.zip |
Add convenience constructors to new components (#598) (#8351)
Add convenience constructors (#598)
Added convenience constructors to ui components that have
been reimplemented for Vaadin 8
Diffstat (limited to 'server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java')
-rw-r--r-- | server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java b/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java new file mode 100644 index 0000000000..c090d86efe --- /dev/null +++ b/server/src/test/java/com/vaadin/ui/TextAreaConstructorTest.java @@ -0,0 +1,72 @@ +/* + * 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.ui; + +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +import com.vaadin.data.HasValue; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; + +public class TextAreaConstructorTest { + + @Test + public void initiallyEmpty() { + TextArea textArea = new TextArea(); + Assert.assertTrue(textArea.isEmpty()); + } + + @Test + public void testValueConstructor_emptyAfterClear() { + TextArea textArea = new TextArea(null, "foobar"); + Assert.assertFalse(textArea.isEmpty()); + + textArea.clear(); + Assert.assertTrue(textArea.isEmpty()); + } + + @Test + public void testValueChangeListener_eventOnValueChange() { + HasValue.ValueChangeListener valueChangeListener = Mockito + .mock(HasValue.ValueChangeListener.class); + TextArea textArea = new TextArea(valueChangeListener); + + textArea.setValue("value change"); + + verify(valueChangeListener) + .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); + + } + + @Test + public void testCaptionValueListener() { + HasValue.ValueChangeListener valueChangeListener = Mockito + .mock(HasValue.ValueChangeListener.class); + TextArea textArea = new TextArea("Caption", "Initial value", + valueChangeListener); + + verify(valueChangeListener, never()) + .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); + + textArea.setValue("value change"); + + verify(valueChangeListener) + .valueChange(Mockito.any(HasValue.ValueChangeEvent.class)); + + } +} |