2012-11-12 30 views
0

看從我SetupActivity下面的代碼片段活動解僱線程/任務 - 我怎麼能測試任務我解僱這裏其實正確執行?如何測試從Android的

例如這條線:從我的活動

new AttachChildGcmTask(app).execute(app.getChildInfo().getId()); 

代碼片段:

.... 
@Override 
public void onClick(View v) { 
    if (v.getId() == R.id.btn_proceed) { 
     finishSetup(); 
    } 
} 


private void finishSetup() { 
    UIUtilities.showToast(this, R.string.setup_completed, true); 
    final AppBipper app = (AppBipper) getApplication(); 
    app.setSetupCompleted(true); 

    Log.i(TAG, "finishSetup childId: "+app.getChildInfo().getId()); 
    new AttachChildGcmTask(app).execute(app.getChildInfo().getId()); 
    Log.i(TAG, "download settings"); 
    new FetchClientSettings(app).execute(); 

    Log.i(TAG, "cancel all scheduled alarms"); 
    ScheduledLocationsHelper helper = 
      ScheduledLocationsHelper.getInstance(app.getDBManager(), app); 
    helper.cancelAlarms(); 

    startActivity(new Intent(this, StartupActivity.class)); 
    finish(); 
} 
+0

你是詢問如何編寫功能/單元測試? –

+0

只是做了一個小代碼格式化修復,所以沒有水平滾動(很煩人的事情)。 –

回答

0

我猜你的意思是活動在任務完成之前就已經死亡了。

因此包括那些測試AsyncTask類,讓他們向你的UI莫名其妙報告(廣播的意圖,利用處理器等等...)