Code example for ImageButton

Methods: getVisibility

0
        } 
    }*/ 
 
    public void testCase07_EnterRecordingMode() { 
        enterRecordingMode(); 
        assertTrue(mButtonRecord.getVisibility() == View.VISIBLE);
        assertTrue(mButtonStop.getVisibility() == View.VISIBLE);
        assertTrue(mButtonPlayback.getVisibility() == View.VISIBLE);
    } 
 
    /*public void testCase08_RecordingAndPlayback() { 
        enterRecordingMode(); 
        assertTrue(mButtonRecord.getVisibility() == View.VISIBLE); 
        // judge whether enter recording mode 
        assertTrue(mButtonRecord.isEnabled()); 
        // test recording 
        clickView(mButtonRecord); 
        mInstrumentation.waitForIdleSync(); 
        try { 
            Thread.sleep(1000); 
        } catch (InterruptedException e) { 
            e.printStackTrace(); 
        } 
        assertTrue(mButtonStop.isEnabled()); 
        assertFalse(mButtonPlayback.isEnabled()); 
        // make recording time have 3 seconds 
        try { 
            Thread.sleep(RECORDING_TIME); 
        } catch (InterruptedException e) { 
            e.printStackTrace(); 
        } 
        // test stop reocording and save recording file 
        clickView(mButtonStop); 
        mInstrumentation.waitForIdleSync(); 
        // because the edit text of save recording dialog request focus, just sendkey 
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_F); 
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_M); 
        mInstrumentation.waitForIdleSync(); 
        // make focus at OK button of save recording dialog 
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_DOWN); 
        // click OK button of save recording dialog 
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_CENTER); 
        mInstrumentation.waitForIdleSync(); 
        assertTrue(mButtonPlayback.isEnabled()); 
        assertTrue(mButtonRecord.isEnabled()); 
 
        // test playback recording file clickView(mButtonPlayback); 
        mInstrumentation.waitForIdleSync(); 
        assertTrue(mButtonStop.isEnabled()); 
        assertFalse(mButtonRecord.isEnabled()); 
 
        // test stop playback recording file 
 
        clickView(mButtonStop); 
        mInstrumentation.waitForIdleSync(); 
        assertTrue(mButtonRecord.isEnabled()); 
        assertTrue(mButtonPlayback.isEnabled()); 
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_BACK); 
 
    } 
 
    public void testCase09_EnterChannelList() { 
        clickView(mButtonFavorite); 
        mActivityMonitor = new ActivityMonitor("com.mediatek.FMRadio.FMRadioFavorite", null, false); 
        mInstrumentation.addMonitor(mActivityMonitor); 
        mFMRadioFavorite = (FMRadioFavorite) mActivityMonitor.waitForActivityWithTimeout(TIMEOUT); 
        assertNotNull(mFMRadioFavorite); 
        Uri uri = Uri.parse(CONTENTURI); 
        Cursor c = mFMRadioFavorite.getContentResolver().query( 
                uri, 
                new String[] { FMRadioStation.Station._ID, 
                        FMRadioStation.Station.COLUMN_STATION_FREQ }, null, null, null); 
        assertTrue(c != null && c.getCount() > 0); 
        if (c != null) { 
            c.moveToFirst(); 
            while (!c.isAfterLast()) { 
                int stationFreq = c.getInt(1); 
                assertTrue(isExistInChannelList(stationFreq)); 
                c.moveToNext(); 
            } 
        } 
        if (c != null) { 
            c.close(); 
        } 
    }*/ 
 
    private void enterRecordingMode() { 
        if (View.INVISIBLE == mButtonRecord.getVisibility()) {
            makeFMPowerUp(); 
        } 
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_MENU);
        mInstrumentation.waitForIdleSync();
        mInstrumentation.sendKeyDownUpSync(KeyEvent.KEYCODE_DPAD_UP);