1

Robotium を使用して Eclipse で自動テストを実行しています (Android jUnit テストとして実行しています)。エミュレーターを最初に起動すると、アプリはフォアグラウンドで実行されず、テストは失敗します。エミュレータを開いたままにしておくと、「メインメニュー」ボタンを押してからテストを実行すると、正常に動作します。テストは、メモ帳であるテスト プロジェクトでいくつかのイベントを実行しています。

エミュレーターを最初に開いたときにアプリをフォアグラウンドにプッシュする解決策はありますか?

テスト プロジェクトのマニフェストは次のとおりです。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.jayway.test"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-library android:name="android.test.runner" />

これが実際のプロジェクトのマニフェストです

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.notepad" >

    <application android:icon="@drawable/app_notes"
        android:label="@string/app_name" >
        <provider android:name="NotePadProvider"
            android:authorities="com.example.notepad.provider.NotePad" />

        <activity android:name="NotesList"
            android:label="@string/title_notes_list">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <action android:name="android.intent.action.PICK" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>
        </activity>

        <activity android:name="NoteEditor"
            android:theme="@android:style/Theme.Light"
            android:configChanges="keyboardHidden|orientation">
            <!-- This filter says that we can view or edit the data of
                 a single note -->
            <intent-filter android:label="@string/resolve_edit">
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <action android:name="com.android.notes.action.EDIT_NOTE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>
        </activity>

        <activity android:name="NotesLiveFolder" android:label="@string/live_folder_name"
            android:icon="@drawable/live_folder_notes">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

    <uses-sdk android:minSdkVersion="10"/>
</manifest>
    </application>
    <uses-sdk android:minSdkVersion="10" />
    <instrumentation android:targetPackage="com.example.android.notepad"   android:name="android.test.InstrumentationTestRunner" />
</manifest> 
4

1 に答える 1

1

このコマンドを使用してこれを解決しました。

adbシェル入力キーイベント82

これにより、エミュレーター/デバイスがスリープ解除されます。

于 2012-08-23T14:57:47.623 に答える