package com.example.stockprophit.test;

import com.example.stockprophit.DisplayMessageActivity;
import com.example.stockprophit.FriendProfile_Activity;
import com.example.stockprophit.LoginActivity;
import com.example.stockprophit.MainActivity;
import com.example.stockprophit.SocialActivity;
import com.example.stockprophit.SocialSearch;
import com.jayway.android.robotium.solo.Solo;

import android.test.ActivityInstrumentationTestCase2;

/**
 * @author Frank Bohn
 *
 */
public class Test3 extends ActivityInstrumentationTestCase2<LoginActivity> {

	private Solo solo; 
	
	public Test3() {
		super("com.example.stockprophit", LoginActivity.class);
	}

	/* (non-Javadoc)
	 * @see android.test.ActivityInstrumentationTestCase2#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
		solo = new Solo(getInstrumentation(), getActivity());
	}
	public void testSearchStock()
	{
		//Series of button clicks and entering text to test the interface
		solo.assertCurrentActivity("check on first activity", LoginActivity.class);
		solo.clickOnText("Username");
		solo.enterText(0, "EricLee");
		solo.enterText(1, "aaaaa");
		solo.clickOnButton("Sign in or register");
		//solo.clickOnText("Enter a Ticker Symbol.");
		solo.sleep(5000);
		solo.enterText(0,"BAC Bank of America");
		//solo.clickOnText("BAC Bank of America");
		solo.sleep(5000);
		solo.clickOnButton("Send"); 
		//for some reason robotium does not accept the text in the box, this is not an error on our part.
		//This is the same problem as in Test2.java
		
		solo.sleep(5000);
		
		boolean x=solo.isCheckBoxChecked("Favorite");
		
		if(!x){
			solo.clickOnText("Favorite");
		}
		solo.goBack();
		solo.clickOnButton("Faves");
		assertTrue(solo.searchText("BAC Bank of America",1));
		solo.clickOnText("BAC Bank of America");
		solo.sleep(5000);
		solo.clickOnText("Favorite");
		solo.goBack();
		solo.clickOnButton("Faves");
		assertFalse(solo.searchText("BAC Bank of America",1));
	}
	
	
	
}
	


