/*
 * ***********************************************************************
 *
 *  ADOBE CONFIDENTIAL
 *  ___________________
 *
 *  Copyright 2013 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 *  NOTICE:  All information contained herein is, and remains
 *  the property of Adobe Systems Incorporated and its suppliers,
 *  if any.  The intellectual and technical concepts contained
 *  herein are proprietary to Adobe Systems Incorporated and its
 *  suppliers and are protected by trade secret or copyright law.
 *  Dissemination of this information or reproduction of this material
 *  is strictly forbidden unless prior written permission is obtained
 *  from Adobe Systems Incorporated.
 *
 * ***********************************************************************
 */

package com.adobe.primetime.reference.feature.drm;

import junit.framework.Assert;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;

import com.adobe.primetime.reference.feeds.ContentRenditionInfo.ContentFormat;
import com.adobe.primetime.reference.ui.catalog.VideoItem;
import com.adobe.primetime.reference.ui.player.PlayerActivity;
import com.robotium.solo.Solo;

/**
 * Base class for DRM end to end tests which use the PlayerActivity to load DRM
 * protected media. Loads a media URL with specified in the contentUrl, which
 * must be set in the constructor of derived classes. Uses the Robotium
 * framework to enable test interaction with the UI.
 */
public abstract class DRMEndToEndTestBase extends
		ActivityInstrumentationTestCase2<PlayerActivity> {

	public DRMEndToEndTestBase() {
		super(PlayerActivity.class);
	}

	protected String contentUrl;
	protected ContentFormat contentFormat = ContentFormat.hls;

	public Solo solo = null;
	private VideoItem content = null;

	@Override
	protected void setUp() throws Exception {
		super.setUp();

		Intent intent = new Intent(getInstrumentation().getTargetContext(),
				PlayerActivity.class);

		Assert.assertNotNull(contentUrl);
		content = new VideoItem(new SimpleFeedItem(contentFormat, contentUrl));

		intent.putExtra("CONTENT_INFO", content);
		intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
				| Intent.FLAG_ACTIVITY_SINGLE_TOP);

		setActivityIntent(intent);

		solo = new Solo(getInstrumentation(), getActivity());
		solo.clearLog();

	}

	@Override
	protected void tearDown() throws Exception {

		solo.finishOpenedActivities();
		super.tearDown();
	}

}
