public void testcase04_DownloadingCancel() {

    mPreference.edit().putInt(OTA_PRE_STATUS, STATE_DOWNLOADING).commit();
    mPreference.edit().putInt(OTA_PRE_DELTA_ID, PKG_ID_TEST).commit();

    mActivity = getActivity();

    ProgressBar dlRatioProgressBar = (ProgressBar) mActivity.findViewById(R.id.downloaingProBar);

    assertTrue(dlRatioProgressBar != null);
    assertTrue(dlRatioProgressBar.isShown());

    if (Util.isSdcardAvailable(mActivity) && Util.isNetWorkAvailable(mActivity, "WIFI")) {
      if (mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_PAUSEDOWNLOAD) {
        return;
      }
      mInst.invokeMenuActionSync(mActivity, MENU_ID_CANCEL, 0);
      mInst.waitForIdleSync();

      assertTrue(mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_PAUSEDOWNLOAD);
      sendKeys(KeyEvent.KEYCODE_DPAD_DOWN);
      sendKeys(KeyEvent.KEYCODE_DPAD_RIGHT);

      sendKeys(KeyEvent.KEYCODE_DPAD_CENTER);

      mInst.waitForIdleSync();
      assertTrue(mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_QUERYNEWVERSION);
    }
  }
  protected void tearDown() throws Exception {

    if (mActivity != null) {
      mActivity.finish();
      Xlog.i(TAG, "activity finish");
    }
    super.tearDown();
  }
  /*
   * Test the download function when new version detected
   */
  public void testcase01_NewVersionLayout() {
    Xlog.i(TAG, "start1 ");
    mPreference.edit().putInt(OTA_PRE_STATUS, STATE_NEWVERSION_READY).commit();
    mPreference.edit().putString(OTA_ANDR_VER, ANDROID_VER_TEST).commit();
    mPreference.edit().putString(OTA_PRE_VER, LOAD_VER_TEST).commit();
    mActivity = getActivity();

    TextView textAndroidVer = (TextView) mActivity.findViewById(R.id.textAndroidNum);

    assertTrue(textAndroidVer != null);

    Xlog.i(TAG, textAndroidVer.getText().toString());

    assertTrue(ANDROID_VER_TEST.equals(textAndroidVer.getText()));

    TextView textLoadVer = (TextView) mActivity.findViewById(R.id.textVerNum);

    assertTrue(textLoadVer != null);
  }
  public void testcase03_DownloadingPaused() {

    mPreference.edit().putInt(OTA_PRE_STATUS, STATE_PAUSEDOWNLOAD).commit();
    mPreference.edit().putInt(OTA_PRE_DELTA_ID, PKG_ID_TEST).commit();
    mActivity = getActivity();

    ProgressBar dlRatioProgressBar = (ProgressBar) mActivity.findViewById(R.id.downloaingProBar);

    assertTrue(dlRatioProgressBar != null);
    assertTrue(dlRatioProgressBar.isShown());

    Xlog.i(TAG, "OTA_PRE_STATUS = " + mPreference.getInt(OTA_PRE_STATUS, -1));
    if (Util.isSdcardAvailable(mActivity) && Util.isNetWorkAvailable(mActivity, "WIFI")) {
      assertTrue(mPreference.getInt(OTA_PRE_STATUS, -1) == STATE_PAUSEDOWNLOAD);
    }
  }