package com.kyleduo.rabbits.demo;

import android.content.Context;
import android.net.Uri;
import android.support.test.InstrumentationRegistry;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import com.kyleduo.rabbits.Rabbit;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.junit.Assert.assertEquals;

/**
 * Instrumentation test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
@LargeTest
public class ExampleInstrumentedTest {
	@Test
	public void useAppContext() throws Exception {
		// Context of the app under test.
		Context appContext = InstrumentationRegistry.getTargetContext();

		assertEquals("com.kyleduo.rabbits.demo", appContext.getPackageName());
	}

	@Rule
	public ActivityTestRule<MainActivity> mMainActivityRule = new ActivityTestRule<>(MainActivity.class, true);

	@Test
	public void testRabbitsParams() {
		String[] urls = new String[]{
				"demo://rabbits.kyleduo.com/test/testing",
				"/test/testing",
				"test/testing",
				"test?Testing=testing"
		};

		for (String url : urls) {
			Rabbit.from(mMainActivityRule.getActivity())
					.to(url)
					.start();
			onView(withId(R.id.params_tv)).check(matches(withText("testing")));
			onView(withId(R.id.back_home_bt)).perform(click());
//			onView(withId(R.id.start_test_bt)).check(matches(isDisplayed()));
		}
	}

	@Test
	public void testUriParse() {
		String url = "test/test2";
		Uri uri = Uri.parse(url);
		Log.d("uri", "scheme: " + uri.getScheme());
		Log.d("uri", "host: " + uri.getHost());
		Log.d("uri", "path: " + uri.getPath());

		Uri.Builder builder = uri.buildUpon();
		if (uri.getScheme() == null) {
			builder.scheme("demo");
		}
		if (uri.getHost() == null) {
			builder.authority("kyleduo.com");
		}

		uri = builder.build();
		Log.i("uri", "uri: " + uri.toString());
		Log.i("uri", "scheme: " + uri.getScheme());
		Log.i("uri", "host: " + uri.getHost());
		Log.i("uri", "path: " + uri.getPath());
	}
}

@@ -47,870 +47,38 @@
 oid.
-content.Context;%0Aimport android.net.Uri;%0Aimport android.support.test.InstrumentationRegistry;%0Aimport android.support.test.filters.LargeTest;%0Aimport android.support.test.rule.ActivityTestRule;%0Aimport android.support.test.runner.AndroidJUnit4;%0Aimport android.util.Log;%0A%0Aimport com.kyleduo.rabbits.Rabbit;%0A%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0A%0Aimport static android.support.test.espresso.Espresso.onView;%0Aimport static android.support.test.espresso.action.ViewActions.click;%0Aimport static android.support.test.espresso.assertion.ViewAssertions.matches;%0Aimport static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;%0Aimport static android.support.test.espresso.matcher.ViewMatchers.withId;%0Aimport static android.support.test.espresso.matcher.ViewMatchers.withText;%0Aimport static org.junit.Assert.assertEquals
+support.test.filters.LargeTest
 ;%0A%0A/
@@ -236,38 +236,8 @@
  */%0A
-@RunWith(AndroidJUnit4.class)%0A
 @Lar
@@ -286,1467 +286,7 @@
 t %7B%0A
-%09@Test%0A%09public void useAppContext() throws Exception %7B%0A%09%09// Context of the app under test.%0A%09%09Context appContext = InstrumentationRegistry.getTargetContext();%0A%0A%09%09assertEquals(%22com.kyleduo.rabbits.demo%22, appContext.getPackageName());%0A%09%7D%0A%0A%09@Rule%0A%09public ActivityTestRule%3CMainActivity%3E mMainActivityRule = new ActivityTestRule%3C%3E(MainActivity.class, true);%0A%0A%09@Test%0A%09public void testRabbitsParams() %7B%0A%09%09String%5B%5D urls = new String%5B%5D%7B%0A%09%09%09%09%22demo://rabbits.kyleduo.com/test/testing%22,%0A%09%09%09%09%22/test/testing%22,%0A%09%09%09%09%22test/testing%22,%0A%09%09%09%09%22test?Testing=testing%22%0A%09%09%7D;%0A%0A%09%09for (String url : urls) %7B%0A%09%09%09Rabbit.from(mMainActivityRule.getActivity())%0A%09%09%09%09%09.to(url)%0A%09%09%09%09%09.start();%0A%09%09%09onView(withId(R.id.params_tv)).check(matches(withText(%22testing%22)));%0A%09%09%09onView(withId(R.id.back_home_bt)).perform(click());%0A//%09%09%09onView(withId(R.id.start_test_bt)).check(matches(isDisplayed()));%0A%09%09%7D%0A%09%7D%0A%0A%09@Test%0A%09public void testUriParse() %7B%0A%09%09String url = %22test/test2%22;%0A%09%09Uri uri = Uri.parse(url);%0A%09%09Log.d(%22uri%22, %22scheme: %22 + uri.getScheme());%0A%09%09Log.d(%22uri%22, %22host: %22 + uri.getHost());%0A%09%09Log.d(%22uri%22, %22path: %22 + uri.getPath());%0A%0A%09%09Uri.Builder builder = uri.buildUpon();%0A%09%09if (uri.getScheme() == null) %7B%0A%09%09%09builder.scheme(%22demo%22);%0A%09%09%7D%0A%09%09if (uri.getHost() == null) %7B%0A%09%09%09builder.authority(%22kyleduo.com%22);%0A%09%09%7D%0A%0A%09%09uri = builder.build();%0A%09%09Log.i(%22uri%22, %22uri: %22 + uri.toString());%0A%09%09Log.i(%22uri%22, %22scheme: %22 + uri.getScheme());%0A%09%09Log.i(%22uri%22, %22host: %22 + uri.getHost());%0A%09%09Log.i(%22uri%22, %22path: %22 + uri.getPath());%0A%09%7D
 %0A%7D%0A

remove deprecated test