package com.eni.android.hello.test;

import com.eni.android.helloandroid.HelloAndroidActivity;

import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;

/**
 * Cf Projet Ch4_HelloAndroid
 */
public class HelloAndroidActivityTest extends
		ActivityInstrumentationTestCase2<HelloAndroidActivity> {

	private HelloAndroidActivity myActivity = null;
	private TextView myView = null;
	private String expectedStr = null;

	public HelloAndroidActivityTest() {
		super(HelloAndroidActivity.class);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		myActivity = this.getActivity();
		myView = (TextView) myActivity
				.findViewById(com.eni.android.helloandroid.R.id.helloTxt);
		expectedStr = myActivity.getResources().getString(
				com.eni.android.helloandroid.R.string.hello_world);
	}

	public void testPreconditions() {
		assertNotNull(myActivity);
		assertNotNull(myView);
		assertNotNull(expectedStr);
	}

	public void testText() {
		assertEquals(expectedStr, (String) myView.getText());
	}
}
