/*
 * =================================================================================================
 *                             Copyright (C) 2015 Martin Albedinsky
 * =================================================================================================
 *         Licensed under the Apache License, Version 2.0 or later (further "License" only).
 * -------------------------------------------------------------------------------------------------
 * You may use this file only in compliance with the License. More details and copy of this License 
 * you may obtain at
 * 
 * 		http://www.apache.org/licenses/LICENSE-2.0
 * 
 * You can redistribute, modify or publish any part of the code written within this file but as it 
 * is described in the License, the software distributed under the License is distributed on an 
 * "AS IS" BASIS, WITHOUT WARRANTIES or CONDITIONS OF ANY KIND.
 * 
 * See the License for the specific language governing permissions and limitations under the License.
 * =================================================================================================
 */
package com.albedinsky.android.intent;

import android.content.Intent;
import android.net.Uri;

/**
 * @author Martin Albedinsky
 */
public final class PlayIntentTest extends IntentBaseTest<PlayIntent> {

	@SuppressWarnings("unused")
	private static final String TAG = "PlayIntentTest";

	public PlayIntentTest() {
		super(PlayIntent.class);
	}

	public void testDefaultPackageName() {
		final String packageName = mIntent.packageName();
		assertNotNull(packageName);
		assertEquals(getActivity().getPackageName(), packageName);
	}

	public void testPackageName() {
		mIntent.packageName("com.google.android.inbox");
		assertEquals("com.google.android.inbox", mIntent.packageName());
	}

	public void testBuild() {
		mIntent.packageName("com.google.android.inbox");

		final Intent intent = mIntent.build();
		assertNotNull(intent);
		assertEquals(Intent.ACTION_VIEW, intent.getAction());
		assertEquals(Uri.parse(PlayIntent.VIEW_URL_BASE + "com.google.android.inbox"), intent.getData());
	}

	public void testBuildWithInvalidPackageName() {
		mIntent.packageName("");
		assertBuildThrowsExceptionWithCause(
				mIntent,
				"No package name specified."
		);
	}
}