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 Test2 extends ActivityInstrumentationTestCase2<LoginActivity> {

	private Solo solo; 
	
	public Test2() {
		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 testSocialSearch()
	{
		//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("Social");
		solo.clickOnButton("Search");
		solo.sleep(5000);
		solo.enterText(0, "FrankBohn");
		solo.clickOnButton("Search"); 
		//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
		
		
		assertTrue(solo.searchText("FrankBohn: Robotium Test",1));
		boolean x=solo.isCheckBoxChecked("Follow");
		
		if(!x){
			solo.clickOnText("Follow");
		}
		solo.goBack();
		solo.sleep(5000);
		solo.clickOnButton("Following");
		assertTrue(solo.searchText("FrankBohn",1));	
		solo.clickOnText("FrankBohn");
		solo.sleep(5000);
		solo.clickOnText("Follow");
		solo.goBack();
		solo.clickOnButton("Following");
		assertFalse(solo.searchText("FrankBohn",1));
	}
}
