package net.airpost.relan.quirky;

import static junit.framework.Assert.*;
import android.test.AndroidTestCase;
import android.widget.TextView;

public class QrContentTest extends AndroidTestCase {

	public void testGooglePlayMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "market://details?id=com.example");
		assertTrue(content instanceof QrContent.GooglePlayContent);
		tv = (TextView) content.render();
		assertEquals(tv.getText(), "com.example");

		//
		// Other possible urls:
		//
		// market://search?pub=Trikita
		// market://search?q=SomeQuery&c=apps
		// market://apps/collection/editors_choice
	}

	public void testUrlMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "http://example.com");
		assertTrue(content instanceof QrContent.WebUrlContent);
		content = QrContent.from(getContext(), "https://example.com");
		assertTrue(content instanceof QrContent.WebUrlContent);
		content = QrContent.from(getContext(), "example.com");
		assertTrue(content instanceof QrContent.WebUrlContent);
	}

	public void testEmailMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "mailto:johndoe@example.com");
		assertTrue(content instanceof QrContent.EmailContent);
	}

	public void testSmsMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "smsto:+123456789");
		assertTrue(content instanceof QrContent.SmsContent);
	}

	public void testPhoneNumberMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "tel:+123456789");
		assertTrue(content instanceof QrContent.PhoneNumberContent);
	}

	public void testWifiMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "WIFI:S:Example;T:WPA;P:example123;;");
		assertTrue(content instanceof QrContent.WifiContent);
	}

	public void testContactMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "MECARD:N:John Doe;EMAIL:john@example.com;;");
		assertTrue(content instanceof QrContent.ContactContent);
	}

	public void testGeolocationMatcher() {
		QrContent content;
		TextView tv;

		content = QrContent.from(getContext(), "geo:0,0");
		assertTrue(content instanceof QrContent.GeoLocationContent);
	}
}

@@ -108,40 +108,8 @@
 ase;
-%0Aimport android.widget.TextView;
 %0A%0Apu
@@ -215,39 +215,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -364,44 +364,8 @@
 t);%0A
-%09%09tv = (TextView) content.render();%0A
 %09%09as
@@ -375,18 +375,23 @@
 tEquals(
+conten
 t
-v
 .getText
@@ -617,39 +617,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -1037,39 +1037,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -1224,39 +1224,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -1407,39 +1407,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -1589,39 +1589,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -1788,39 +1788,24 @@
 ent content;
-%0A%09%09TextView tv;
 %0A%0A%09%09content 
@@ -1977,32 +1977,32 @@
 tionMatcher() %7B%0A
+
 %09%09QrContent cont
@@ -2009,23 +2009,8 @@
 ent;
-%0A%09%09TextView tv;
 %0A%0A%09%09

Fix use of unexisting method in the tests