< prev index next >

application/uitests/org.openjdk.jmc.test.jemmy/src/test/java/org/openjdk/jmc/test/jemmy/misc/wrappers/MCTable.java

Print this page




  32  */
  33 package org.openjdk.jmc.test.jemmy.misc.wrappers;
  34 
  35 import java.util.ArrayList;
  36 import java.util.HashMap;
  37 import java.util.List;
  38 import java.util.Map;
  39 
  40 import org.eclipse.swt.graphics.Image;
  41 import org.eclipse.swt.graphics.Rectangle;
  42 import org.eclipse.swt.widgets.Display;
  43 import org.eclipse.swt.widgets.Shell;
  44 import org.eclipse.swt.widgets.Table;
  45 import org.eclipse.swt.widgets.TableColumn;
  46 import org.eclipse.swt.widgets.TableItem;
  47 import org.jemmy.Point;
  48 import org.jemmy.control.Wrap;
  49 import org.jemmy.input.StringPopupOwner;
  50 import org.jemmy.input.StringPopupSelectableOwner;
  51 import org.jemmy.interfaces.Keyboard.KeyboardButtons;

  52 import org.jemmy.interfaces.Parent;
  53 import org.jemmy.interfaces.Selectable;
  54 import org.jemmy.lookup.Lookup;
  55 import org.jemmy.resources.StringComparePolicy;
  56 import org.jemmy.swt.ItemWrap;
  57 import org.jemmy.swt.TableWrap;
  58 import org.jemmy.swt.lookup.ByName;
  59 import org.junit.Assert;
  60 
  61 import org.openjdk.jmc.test.jemmy.misc.base.wrappers.MCJemmyBase;
  62 import org.openjdk.jmc.test.jemmy.misc.fetchers.Fetcher;
  63 
  64 /**
  65  * The Jemmy base wrapper for tables
  66  */
  67 public class MCTable extends MCJemmyBase {
  68 
  69         /**
  70          * A small representation of a row in a table, contains both the row text and a list of strings
  71          * representing all cells in the row. If no tests actually require this, we should change the


 711                                         for (int i = 0; i < columnIndex; i++) {
 712                                                 control.keyboard().pushKey(KeyboardButtons.RIGHT);
 713                                         }
 714                                 }
 715                         }
 716                         return (control.getProperty(Integer.class, Selectable.STATE_PROP_NAME) == index && index != -1);
 717                 } else {
 718                         return false;
 719                 }
 720         }
 721 
 722         /**
 723          * Selects the item at the given index (if not -1))
 724          *
 725          * @param index
 726          *            the index of the item
 727          * @return {@code true} if selected index is the same as the provided. {@code false} otherwise
 728          */
 729         public boolean select(int index) {
 730                 return select(index, 0);
















 731         }
 732 
 733         /**
 734          * Context clicks the currently selected table item and chooses the supplied option
 735          *
 736          * @param desiredState
 737          *            the selection state to which the context choice is to be to set to
 738          * @param choice
 739          *            the context menu path to the option
 740          */
 741         @SuppressWarnings("unchecked")
 742         public void contextChoose(boolean desiredState, String ... choice) {
 743                 scrollbarSafeSelection();
 744                 StringPopupSelectableOwner<Table> spo = control.as(StringPopupSelectableOwner.class);
 745                 spo.setPolicy(policy);
 746                 spo.push(desiredState, getRelativeClickPoint(getSelectedItem()), choice);
 747         }
 748 
 749         /**
 750          * Context clicks the currently selected table item and finds out the selection status of the




  32  */
  33 package org.openjdk.jmc.test.jemmy.misc.wrappers;
  34 
  35 import java.util.ArrayList;
  36 import java.util.HashMap;
  37 import java.util.List;
  38 import java.util.Map;
  39 
  40 import org.eclipse.swt.graphics.Image;
  41 import org.eclipse.swt.graphics.Rectangle;
  42 import org.eclipse.swt.widgets.Display;
  43 import org.eclipse.swt.widgets.Shell;
  44 import org.eclipse.swt.widgets.Table;
  45 import org.eclipse.swt.widgets.TableColumn;
  46 import org.eclipse.swt.widgets.TableItem;
  47 import org.jemmy.Point;
  48 import org.jemmy.control.Wrap;
  49 import org.jemmy.input.StringPopupOwner;
  50 import org.jemmy.input.StringPopupSelectableOwner;
  51 import org.jemmy.interfaces.Keyboard.KeyboardButtons;
  52 import org.jemmy.interfaces.Keyboard.KeyboardModifiers;
  53 import org.jemmy.interfaces.Parent;
  54 import org.jemmy.interfaces.Selectable;
  55 import org.jemmy.lookup.Lookup;
  56 import org.jemmy.resources.StringComparePolicy;
  57 import org.jemmy.swt.ItemWrap;
  58 import org.jemmy.swt.TableWrap;
  59 import org.jemmy.swt.lookup.ByName;
  60 import org.junit.Assert;
  61 
  62 import org.openjdk.jmc.test.jemmy.misc.base.wrappers.MCJemmyBase;
  63 import org.openjdk.jmc.test.jemmy.misc.fetchers.Fetcher;
  64 
  65 /**
  66  * The Jemmy base wrapper for tables
  67  */
  68 public class MCTable extends MCJemmyBase {
  69 
  70         /**
  71          * A small representation of a row in a table, contains both the row text and a list of strings
  72          * representing all cells in the row. If no tests actually require this, we should change the


 712                                         for (int i = 0; i < columnIndex; i++) {
 713                                                 control.keyboard().pushKey(KeyboardButtons.RIGHT);
 714                                         }
 715                                 }
 716                         }
 717                         return (control.getProperty(Integer.class, Selectable.STATE_PROP_NAME) == index && index != -1);
 718                 } else {
 719                         return false;
 720                 }
 721         }
 722 
 723         /**
 724          * Selects the item at the given index (if not -1))
 725          *
 726          * @param index
 727          *            the index of the item
 728          * @return {@code true} if selected index is the same as the provided. {@code false} otherwise
 729          */
 730         public boolean select(int index) {
 731                 return select(index, 0);
 732         }
 733 
 734         /**
 735          * Selects the table row at a specified "start" index, and uses SHIFT+DOWN to
 736          * add to the selection up until a specified "end" index
 737          *
 738          * @param from
 739          *            the row index to start from
 740          * @param to
 741          *            the row index to stop selecting
 742          */
 743         public void selectItems(int start, int end) {
 744                 select(start);
 745                 for (int i = 1; i < end; i++) {
 746                         getShell().keyboard().pushKey(KeyboardButtons.DOWN, new KeyboardModifiers[] {KeyboardModifiers.SHIFT_DOWN_MASK});
 747                 }
 748         }
 749 
 750         /**
 751          * Context clicks the currently selected table item and chooses the supplied option
 752          *
 753          * @param desiredState
 754          *            the selection state to which the context choice is to be to set to
 755          * @param choice
 756          *            the context menu path to the option
 757          */
 758         @SuppressWarnings("unchecked")
 759         public void contextChoose(boolean desiredState, String ... choice) {
 760                 scrollbarSafeSelection();
 761                 StringPopupSelectableOwner<Table> spo = control.as(StringPopupSelectableOwner.class);
 762                 spo.setPolicy(policy);
 763                 spo.push(desiredState, getRelativeClickPoint(getSelectedItem()), choice);
 764         }
 765 
 766         /**
 767          * Context clicks the currently selected table item and finds out the selection status of the


< prev index next >