You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ButtonClick.java 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2000-2016 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tests.components.button;
  17. import com.vaadin.server.VaadinRequest;
  18. import com.vaadin.tests.components.AbstractReindeerTestUI;
  19. import com.vaadin.ui.Alignment;
  20. import com.vaadin.ui.Button;
  21. import com.vaadin.ui.Button.ClickEvent;
  22. import com.vaadin.ui.Button.ClickListener;
  23. import com.vaadin.ui.Label;
  24. import com.vaadin.ui.VerticalLayout;
  25. public class ButtonClick extends AbstractReindeerTestUI {
  26. public static final String SUCCESS_TEXT = "Click received succesfully!";
  27. public static final String WRONG_BUTTON_TEXT = "Wrong button clicked.";
  28. @Override
  29. protected void setup(VaadinRequest request) {
  30. final VerticalLayout rootLayout = new VerticalLayout();
  31. final Label statusLabel = new Label("Test initialized");
  32. rootLayout.addComponent(new Button("Click here", new ClickListener() {
  33. @Override
  34. public void buttonClick(ClickEvent event) {
  35. statusLabel.setValue(SUCCESS_TEXT);
  36. }
  37. }));
  38. Button visitLocation = new Button("Drag here", new ClickListener() {
  39. @Override
  40. public void buttonClick(ClickEvent event) {
  41. statusLabel.setValue(WRONG_BUTTON_TEXT);
  42. }
  43. });
  44. rootLayout.addComponent(statusLabel);
  45. rootLayout.addComponent(visitLocation);
  46. rootLayout.setComponentAlignment(visitLocation, Alignment.BOTTOM_RIGHT);
  47. rootLayout.setSizeFull();
  48. rootLayout.setMargin(true);
  49. setContent(rootLayout);
  50. }
  51. @Override
  52. protected String getTestDescription() {
  53. return "Verify button click logic";
  54. }
  55. @Override
  56. protected Integer getTicketNumber() {
  57. return 13550;
  58. }
  59. }