austgl / robotium

Automatically exported from code.google.com/p/robotium
0 stars 0 forks source link

Solo.sendkey() function Home Hardware Button #43

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I would like to press the Home Key Button on the device.

Using the function mySolo.sendkey(KeyEvent.KEYCODE_HOME) does not work because 
the value of KeyEvent.KEYCODE_HOME is 3, which is already used by Solo.LEFT.

Could you please fix the function?

Original issue reported on code.google.com by JoaRe...@gmail.com on 7 Dec 2010 at 9:31

GoogleCodeExporter commented 9 years ago
Thanks for this. This will be fixed in the next release.

Original comment by renasr...@gmail.com on 7 Dec 2010 at 10:20

GoogleCodeExporter commented 9 years ago
This issue has been resolved in Robotium 2.0

Original comment by renasr...@gmail.com on 7 Dec 2010 at 7:37

GoogleCodeExporter commented 9 years ago
While the KeyCode of Solo.LEFT has been changed, the function does not provide 
the possibility to perform mySolo.sendkey(KeyEvent.KEYCODE_HOME).

Maybe changing the following procedure in Solo like that:

    public void sendKey(int key)
    {
        switch (key) {
            case RIGHT:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_DPAD_RIGHT);
                break;
            case LEFT:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_DPAD_LEFT);
                break;
            case UP:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_DPAD_UP);
                break;
            case DOWN:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_DPAD_DOWN);
                break;
            case ENTER:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_ENTER);
                break;
            case MENU:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_MENU);
                break;
            case DELETE:
                robotiumUtils.sendKeyCode(KeyEvent.KEYCODE_DEL);
                break;
            default:
                try {
                    robotiumUtils.sendKeyCode(key);
                } catch (Exception e) {
                    // TODO: handle exception
                }
                break;
        }
    }

Original comment by JoaRe...@gmail.com on 17 Dec 2010 at 9:32

GoogleCodeExporter commented 9 years ago
Thanks for this, I have updated sendKey now.

Original comment by renasr...@gmail.com on 28 Dec 2010 at 8:52

GoogleCodeExporter commented 9 years ago
Unless I am wrong this issue has reappeared in version 2.1 

A manual click in the emulator works fine.
Using robotium with 
    solo.sendKey(KeyEvent.KEYCODE_HOME); 
does not take the application to Home screen 

Original comment by arngrimu...@gmail.com on 16 Feb 2011 at 9:52

GoogleCodeExporter commented 9 years ago
Setup for Comment 5:
Using Android 2.2
OS: Ubuntu Linux 10.04 in a VirtualBox 3.2.12 hosted on Windows 7

Original comment by arngrimu...@gmail.com on 16 Feb 2011 at 9:56

GoogleCodeExporter commented 9 years ago
No, it has not reapeared. Its not for sure that KEYCODE_HOME does take one to 
the homescreen. If you e.g. try solo.sendKey(KeyEvent.KEYCODE_VOLUME_UP) or any 
other KeyEvent that is working fron an application point of view you will see 
that it works.

Original comment by renasr...@gmail.com on 16 Feb 2011 at 10:01

GoogleCodeExporter commented 9 years ago
Sorry for bothering but why is not guaranteed that KEYCODE_HOME takes you to 
the Home screen ?

From the API documentation  one can read that KEYCODE_HOME is never delivered 
to the application, is this the problem?

-------------------snip---------------------------------
public static final int KEYCODE_HOME
Since: API Level 1

Key code constant: Home key. This key is handled by the framework and is never 
delivered to applications.
Constant Value: 3 (0x00000003
-------------------/snip----------------------------------

Original comment by arngrimu...@gmail.com on 16 Feb 2011 at 10:24

GoogleCodeExporter commented 9 years ago
I asked about this here:
http://stackoverflow.com/questions/25184160/android-instrumentation-home-button

Original comment by martin.k...@gmail.com on 7 Aug 2014 at 1:47