javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/S60Utils.java
changeset 35 85266cc22c7f
parent 26 dc7c549001d5
child 40 c6043ea9b06a
child 44 0105bdca6f9c
child 47 f40128debb5d
child 49 35baca0e7a2e
equal deleted inserted replaced
26:dc7c549001d5 35:85266cc22c7f
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 package com.nokia.mj.impl.uitestutils;
       
    18 
       
    19 
       
    20 final class S60Utils {
       
    21 
       
    22 	static {
       
    23 		// Should use vmport, this is CDC/J2SE API
       
    24 		//System.loadLibrary("s60uitestutils");
       
    25 		org.eclipse.swt.internal.Library.loadLibrary("s60uitestutils");
       
    26 	}
       
    27 
       
    28     /**
       
    29      * Constant for key press event. 
       
    30      */
       
    31     static final int PRESS = 0;
       
    32     
       
    33     /**
       
    34      * Constant for key release event. 
       
    35      */
       
    36     static final int RELEASE = 1;
       
    37     
       
    38     /**
       
    39      * Button constants. 
       
    40      */
       
    41     static final int BUTTON1 = 1;
       
    42     static final int BUTTON2 = 2;
       
    43     static final int BUTTON3 = 3;
       
    44 
       
    45 
       
    46 	/**
       
    47 	 * Sends a key event to the window which has the keyboard focus. Get the keycode of 
       
    48 	 * the desired symbol using XKeysymToKeycode and pass that here. Or if the desired 
       
    49 	 * keycode is known it can be passed directly. 
       
    50 	 * @param keycode The keycode of the key to send. 
       
    51 	 * @param modifiers The modifiers to send. 
       
    52      * @param pressOrRelease Either PRESS or RELEASE must be passed here.  
       
    53 	 * @return 0 if successful, otherwise a non-zero error code
       
    54      * @see XlibKeys
       
    55 	 */
       
    56     static final native int S60SendKeyToFocusWindow(int keycode, int modifiers, int pressOrRelease);
       
    57 	
       
    58 	/**
       
    59 	 * Returns the keycode of the given symbol (keysym) in the currently active
       
    60 	 * keyboard layout. Keysym constants are defined in XlibKeys. 
       
    61 	 * @param keysym
       
    62 	 * @return The keycode or zero in case of an error
       
    63 	 * @see XlibKeys
       
    64 	 */
       
    65 	static final native int S60KeysymToKeycode(int keysym);
       
    66 
       
    67     /**
       
    68      * Sends a pointer press or release event. 
       
    69      * @param x X-coordinate to send, relative to X root window (i.e. screen). 
       
    70      * @param y Y-coordinate to send, relative to X root window (i.e. screen). 
       
    71      * @param modifiers The modifiers to send. 
       
    72      * @param button The button that's pressed or released. 
       
    73      * @param pressOrRelease Either PRESS or RELEASE must be passed here.  
       
    74      * @return 0 if successful, otherwise a non-zero error code
       
    75      */
       
    76     static final native int S60SendPointerEvent(int x, int y, int button, int pressOrRelease);
       
    77 
       
    78     /**
       
    79      * Sends a pointer move event. 
       
    80      * @param x X-coordinate to send, relative to X root window (i.e. screen). 
       
    81      * @param y Y-coordinate to send, relative to X root window (i.e. screen).
       
    82      * @param button The button that's held pressed during the move. 
       
    83      * @return 0 if successful, otherwise a non-zero error code
       
    84      */
       
    85     static final native int S60SendPointerMoveEvent(int x, int y, int button);
       
    86 
       
    87     /**
       
    88      * Disables the screensaver. 
       
    89      */
       
    90     static final native void S60DisableScreensaver();
       
    91 
       
    92     /**
       
    93      * Sets the doubleclick interval. Set to 0 to disable doubleclicks. 
       
    94      * @param interval New doubleclick interval
       
    95      */
       
    96     static final native void S60SetDoubleclickInterval(int interval);
       
    97 
       
    98 	/*static final native int _create(int toolkitHandle, UITestUtils testUtils); 
       
    99 	static final native void _dispose(int toolkitHandle, UITestUtils testUtils, int testUtilsHandle);
       
   100 
       
   101 	static final native void _startTest(int toolkitHandle, int handle, String screenShotDir); 	
       
   102 	static final native void _endTest(int toolkitHandle, int handle, boolean passed, String msg);
       
   103 
       
   104 	static final native void _log(int toolkitHandle, int handle, String msg); 	
       
   105 	static final native void _logResult(int toolkitHandle, int handle, boolean passed, String msgPassed, String msgFailed);
       
   106 
       
   107 	static final native void _triggerKeyPressEvent(int toolkitHandle, int handle, int keyCode, int scanCode); 	
       
   108 	static final native int _triggerKeyRepeatEvents(int toolkitHandle, int handle, int keyCode, int scanCode, int count); 	
       
   109 	static final native int _triggerMediaKeyRepeatEvents(int toolkitHandle, int handle, int keyCode, int scanCode, int pressedTimeInMillis); 	
       
   110 	
       
   111 	static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName);
       
   112 	static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName, 
       
   113 	                                      int areaToCompare, int displayableType);
       
   114 	static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName, 
       
   115 	                                      int topLeftX, int topLeftY, int bottomRightX, int bottomRightY);
       
   116 	
       
   117 	static final native void _triggerPointerDownEvent(int toolkitHandle, int handle, int x, int y); 	
       
   118 	static final native void _triggerPointerUpEvent(int toolkitHandle, int handle, int x, int y); 	
       
   119 	static final native void _triggerPointerDragEvent(int toolkitHandle, int handle, int x, int y); 	
       
   120 
       
   121 	static final native void _changeQwertyInput(int toolkitHandle, int handle, boolean aOn); 	
       
   122 	static final native int _switchResolution(int toolkitHandle, int handle, int numTimes, int delayMillis); 
       
   123 
       
   124     static final native void _getBoundsOf(int toolkitHandle, int handle, int type, int[] coordinates);	
       
   125     
       
   126     static final native void _allowScreenSaver(int toolkitHandle, int handle, int allow);*/
       
   127 
       
   128 }