package ca.ualberta.cs.lonelytwitter.test;

//import android.annotation.SuppressLint;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.test.ViewAsserts;
import android.widget.TextView;
import ca.ualberta.cs.lonelytwitter.IntentReaderActivity;

//@SuppressLint("NewApi") 
public class IntentReaderActivityTest extends
        ActivityInstrumentationTestCase2<IntentReaderActivity> {

    public IntentReaderActivityTest() {
        super(IntentReaderActivity.class);
    }

    public void testSendText() {
        Intent intent = new Intent();
        String text = "hello";
        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, text);
        
        setActivityIntent(intent);
        IntentReaderActivity activity = getActivity();
        
        assertEquals("IntentReaderActivity should get text from intent!", text, activity.getText());
    }    
    
    public void testDisplayText() {
        Intent intent = new Intent();
        String str = "hello";
        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, str);
        
        setActivityIntent(intent);
        IntentReaderActivity activity = getActivity();

        TextView textView = (TextView) activity.findViewById(ca.ualberta.cs.lonelytwitter.R.id.intentText);
        assertEquals("Tex should be displayed.", str, textView.getText().toString());
    }
    
    public void testDoubleText() {
        Intent intent = new Intent();
        String text = "hello";
        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, text);
        intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.DOUBLE);
        
        setActivityIntent(intent);
        IntentReaderActivity activity = getActivity();
        
        assertEquals("The text should be repeated.", "hellohello", activity.getText());
    }
    
//---------------------------------------------------------------------------
    public void testReverseText() {
        Intent intent = new Intent();
        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, "Hello");
        intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.REVERSE);
        
        setActivityIntent(intent);
        IntentReaderActivity activity = getActivity();
        
        assertEquals("IntentReaderActivity should reverse the text", "olleH", activity.getText());
    }
    
    public void testDefaultMessage() {
        Intent intent = new Intent();
        //if there is no extras, then the mode will be DEFAULT and the text will be "default text". So there is no need to the next line:
        //intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.NORMAL);
        setActivityIntent(intent);
        IntentReaderActivity activity = getActivity();
        
        TextView textView = (TextView) activity.findViewById(ca.ualberta.cs.lonelytwitter.R.id.intentText);
        assertEquals("Text should be displayed", textView.getText().toString(), "default text");
    }
    
    public void testTextViewIsVisible() {
    	Intent intent = new Intent();
        String text = "hello";
        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, text);
        intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.REVERSE);
        
        setActivityIntent(intent);
        IntentReaderActivity activity = getActivity();
        //To assert that the first parameter contains the second parameter 
        //(getDecorView() gives a view that contains anything on screen)   (the textView: "intentText")
        ViewAsserts.assertOnScreen(activity.getWindow().getDecorView(), 
        		activity.findViewById(ca.ualberta.cs.lonelytwitter.R.id.intentText));
    }
       
}
@@ -521,3278 +521,42 @@
  %7D%0A%0A
-    public void testSendText() %7B%0A        Intent intent = new Intent();%0A        String text = %22hello%22;%0A        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, text);%0A        %0A        setActivityIntent(intent);%0A        IntentReaderActivity activity = getActivity();%0A        %0A        assertEquals(%22IntentReaderActivity should get text from intent!%22, text, activity.getText());%0A    %7D    %0A    %0A    public void testDisplayText() %7B%0A        Intent intent = new Intent();%0A        String str = %22hello%22;%0A        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, str);%0A        %0A        setActivityIntent(intent);%0A        IntentReaderActivity activity = getActivity();%0A%0A        TextView textView = (TextView) activity.findViewById(ca.ualberta.cs.lonelytwitter.R.id.intentText);%0A        assertEquals(%22Tex should be displayed.%22, str, textView.getText().toString());%0A    %7D%0A    %0A    public void testDoubleText() %7B%0A        Intent intent = new Intent();%0A        String text = %22hello%22;%0A        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, text);%0A        intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.DOUBLE);%0A        %0A        setActivityIntent(intent);%0A        IntentReaderActivity activity = getActivity();%0A        %0A        assertEquals(%22The text should be repeated.%22, %22hellohello%22, activity.getText());%0A    %7D%0A    %0A//---------------------------------------------------------------------------%0A    public void testReverseText() %7B%0A        Intent intent = new Intent();%0A        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, %22Hello%22);%0A        intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.REVERSE);%0A        %0A        setActivityIntent(intent);%0A        IntentReaderActivity activity = getActivity();%0A        %0A        assertEquals(%22IntentReaderActivity should reverse the text%22, %22olleH%22, activity.getText());%0A    %7D%0A    %0A    public void testDefaultMessage() %7B%0A        Intent intent = new Intent();%0A        //if there is no extras, then the mode will be DEFAULT and the text will be %22default text%22. So there is no need to the next line:%0A        //intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.NORMAL);%0A        setActivityIntent(intent);%0A        IntentReaderActivity activity = getActivity();%0A        %0A        TextView textView = (TextView) activity.findViewById(ca.ualberta.cs.lonelytwitter.R.id.intentText);%0A        assertEquals(%22Text should be displayed%22, textView.getText().toString(), %22default text%22);%0A    %7D%0A    %0A    public void testTextViewIsVisible() %7B%0A    %09Intent intent = new Intent();%0A        String text = %22hello%22;%0A        intent.putExtra(IntentReaderActivity.TEXT_TO_TRANSFORM_KEY, text);%0A        intent.putExtra(IntentReaderActivity.MODE_OF_TRANSFORM_KEY, IntentReaderActivity.REVERSE);%0A        %0A        setActivityIntent(intent);%0A        IntentReaderActivity activity = getActivity();%0A        //To assert that the first parameter contains the second parameter %0A        //(getDecorView() gives a view that contains anything on screen)   (the textView: %22intentText%22)%0A        ViewAsserts.assertOnScreen(activity.getWindow().getDecorView(), %0A        %09%09activity.findViewById(ca.ualberta.cs.lonelytwitter.R.id.intentText));%0A    %7D%0A       %0A%7D
+//TODO: Add your code here:%0A       %0A%7D%0A

Update IntentReaderActivityTest.java