< prev index next >

test/java/awt/event/InputEvent/ButtonArraysEquality/ButtonArraysEquality.java

Print this page




  55                                                 public Object run() {
  56                                                     try {
  57                                                         Class clazz = Class.forName("java.awt.event.InputEvent");
  58                                                         Method method  = clazz.getDeclaredMethod("getButtonDownMasks",new Class [] {});
  59                                                         if (method != null) {
  60                                                             method.setAccessible(true);
  61                                                             return method.invoke(null, (Object[])null);
  62                                                         }
  63                                                     }catch (Exception e){
  64                                                         throw new RuntimeException("Test failed. Exception occured:", e);
  65                                                     }
  66                                                     return null;
  67                                                 }
  68                                             });
  69 
  70         int [] buttonDownMasks = new int [Array.getLength(obj)];
  71         checkNullAndPutValuesToArray(buttonDownMasks, obj);
  72 
  73         //check lengths: array shouldn't contain less elements then the number of buttons on a mouse
  74         if (buttonDownMasks.length < buttonDownMasksAPI.length){
  75             throw new RuntimeException("Test failed. The lengths array is less then the number of buttons");
  76         }
  77 
  78         // verify values for first three buttons
  79         for (int i = 0; i < 3; i++) {
  80             if (eventDownMask[i] != buttonDownMasks[i])
  81             {
  82                 System.out.println("Test : "+ i + " | " + " | " +eventDownMask[i] + " | "+ buttonDownMasks[i]);
  83                 throw new RuntimeException("Failure: masks are not correct for standard buttons");
  84             }
  85         }
  86 
  87         // verify values for extra buttons if any
  88         for (int i = 3; i < MouseInfo.getNumberOfButtons(); i++) {
  89             if (buttonDownMasksAPI[i] != buttonDownMasks[i]) {
  90                 throw new RuntimeException("Failure: masks are not the same for extra buttons");
  91             }
  92         }
  93         System.out.println("Test passed.");
  94     }
  95 


  55                                                 public Object run() {
  56                                                     try {
  57                                                         Class clazz = Class.forName("java.awt.event.InputEvent");
  58                                                         Method method  = clazz.getDeclaredMethod("getButtonDownMasks",new Class [] {});
  59                                                         if (method != null) {
  60                                                             method.setAccessible(true);
  61                                                             return method.invoke(null, (Object[])null);
  62                                                         }
  63                                                     }catch (Exception e){
  64                                                         throw new RuntimeException("Test failed. Exception occured:", e);
  65                                                     }
  66                                                     return null;
  67                                                 }
  68                                             });
  69 
  70         int [] buttonDownMasks = new int [Array.getLength(obj)];
  71         checkNullAndPutValuesToArray(buttonDownMasks, obj);
  72 
  73         //check lengths: array shouldn't contain less elements then the number of buttons on a mouse
  74         if (buttonDownMasks.length < buttonDownMasksAPI.length){
  75             throw new RuntimeException("Test failed. The lengths array is less than the number of buttons");
  76         }
  77 
  78         // verify values for first three buttons
  79         for (int i = 0; i < 3; i++) {
  80             if (eventDownMask[i] != buttonDownMasks[i])
  81             {
  82                 System.out.println("Test : "+ i + " | " + " | " +eventDownMask[i] + " | "+ buttonDownMasks[i]);
  83                 throw new RuntimeException("Failure: masks are not correct for standard buttons");
  84             }
  85         }
  86 
  87         // verify values for extra buttons if any
  88         for (int i = 3; i < MouseInfo.getNumberOfButtons(); i++) {
  89             if (buttonDownMasksAPI[i] != buttonDownMasks[i]) {
  90                 throw new RuntimeException("Failure: masks are not the same for extra buttons");
  91             }
  92         }
  93         System.out.println("Test passed.");
  94     }
  95 
< prev index next >