package camp.androidboot.tipcalculator;

import android.test.ActivityInstrumentationTestCase2;

public class TipCalculatorActivityInstrumentationTest
    extends ActivityInstrumentationTestCase2<TipCalculatorActivity> {

  private TipCalculatorActivity activity;

  public TipCalculatorActivityInstrumentationTest() {
    super(TipCalculatorActivity.class);
  }

  @Override
  public void setUp() throws Exception {
    super.setUp();

    activity = getActivity();
  }
}

@@ -87,16 +87,142 @@
 stCase2;
+%0Aimport android.test.TouchUtils;%0Aimport android.widget.Button;%0Aimport android.widget.EditText;%0Aimport android.widget.TextView;
 %0A%0Apublic
@@ -354,242 +354,2522 @@
 ate 
-TipCalculatorActivity activity;%0A%0A  public TipCalculatorActivityInstrumentationTest() %7B%0A    super(TipCalculatorActivity.class);%0A  %7D%0A%0A  @Override%0A  public void setUp() throws Exception %7B%0A    super.setUp();%0A%0A    activity = getActivity();
+static final double TIP1 = 0.15;%0A  private static final double TIP2 = 0.20;%0A  private static final double TIP3 = 0.25;%0A%0A  private TipCalculatorActivity activity;%0A%0A  private EditText billAmountField;%0A  private Button tip1Button;%0A  private Button tip2Button;%0A  private Button tip3Button;%0A  private TextView tipAmountUi;%0A  private TextView totalAmountUi;%0A%0A  public TipCalculatorActivityInstrumentationTest() %7B%0A    super(TipCalculatorActivity.class);%0A  %7D%0A%0A  @Override%0A  public void setUp() throws Exception %7B%0A    super.setUp();%0A%0A    activity = getActivity();%0A    billAmountField = (EditText) activity.findViewById(R.id.bill_amount);%0A    tip1Button = (Button) activity.findViewById(R.id.tip1_button);%0A    tip2Button = (Button) activity.findViewById(R.id.tip2_button);%0A    tip3Button = (Button) activity.findViewById(R.id.tip3_button);%0A    tipAmountUi = (TextView) activity.findViewById(R.id.tip_amount);%0A    totalAmountUi = (TextView) activity.findViewById(R.id.total_amount);%0A  %7D%0A%0A  public void testTipAndTotalCalculation() throws Exception %7B%0A    double%5B%5D billAmounts = new double%5B%5D %7B 0, 0.99, 5.33, 10.75, 50, 98.99, 125, 1059.33 %7D;%0A%0A    for (final double billAmount : billAmounts) %7B%0A      String expectedTip1 = activity.getString(R.string.amount_format, billAmount * TIP1);%0A      String expectedTip2 = activity.getString(R.string.amount_format, billAmount * TIP2);%0A      String expectedTip3 = activity.getString(R.string.amount_format, billAmount * TIP3);%0A      String expectedTotal1 = activity.getString(R.string.amount_format, billAmount * TIP1 + billAmount);%0A      String expectedTotal2 = activity.getString(R.string.amount_format, billAmount * TIP2 + billAmount);%0A      String expectedTotal3 = activity.getString(R.string.amount_format, billAmount * TIP3 + billAmount);%0A%0A      activity.runOnUiThread(new Runnable() %7B%0A        @Override%0A        public void run() %7B%0A          billAmountField.setText(String.valueOf(billAmount));%0A        %7D%0A      %7D);%0A%0A      TouchUtils.clickView(this, tip1Button);%0A      assertEquals(expectedTip1, tipAmountUi.getText().toString());%0A      assertEquals(expectedTotal1, totalAmountUi.getText().toString());%0A%0A      TouchUtils.clickView(this, tip2Button);%0A      assertEquals(expectedTip2, tipAmountUi.getText().toString());%0A      assertEquals(expectedTotal2, totalAmountUi.getText().toString());%0A%0A      TouchUtils.clickView(this, tip3Button);%0A      assertEquals(expectedTip3, tipAmountUi.getText().toString());%0A      assertEquals(expectedTotal3, totalAmountUi.getText().toString());%0A    %7D
 %0A  %7D

Add cursory acceptance test