/*
 * ***********************************************************************
 *
 *  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.ads;

import com.adobe.mediacore.MediaPlayer;
import junit.framework.Assert;

import org.json.JSONObject;

public class LiveAuditudeAdsEndToEndTest extends
		PlaybackWithAdsEndToEndTestBase {
	private final String PLAYBACK_START = "Player state changed to ["
			+ MediaPlayer.PlayerStatus.PLAYING + "].";
	private final String AUDITUDE_AD_START = "Reporting AD-START";

	public LiveAuditudeAdsEndToEndTest() throws Exception {
		contentUrl = "http://d398890tia84ty.cloudfront.net/cloudfront_hls.m3u8";

		String json = "{\"id\":\"vid2\",\"title\":\"LIVE - AUDITUDE ADS\",\"description\": \"This is an episode with primetime ads.\",\"categories\":\"documentary, educational, children\",\"keywords\":\"List, of, comma, separated, keywords\",\"isLive\": true,\"content\":[{\"format\":\"M3U8\",\"url\":\"http://d398890tia84ty.cloudfront.net/cloudfront_hls.m3u8\",\"language\": \"en\"}],\"thumbnails\":[{\"format\":\"JPEG\",\"height\":\"90\",\"width\":\"160\",\"url\":\"http://example.com/small.jpg\"},{\"format\": \"JPEG\",\"height\":\"180\",\"width\":\"320\",\"url\":\"http://example.com/medium.jpg\"}],\"metadata\":{\"ad\":{\"type\":\"Primetime Ads\",\"details\":{\"domain\":\"auditude.com\",\"mediaid\":\"adbe_tearsofsteel2\",\"zoneid\":\"123869\"}}}}";
		jsonObject = new JSONObject(json);
	}

	/**
	 * Test player activity loads and play the video item correctly
	 */
	public void testLoadAndPlayLiveAuditudeAds() throws InterruptedException {
		// Wait until video starts playing
		Assert.assertTrue(solo.waitForLogMessage(PLAYBACK_START));

		// Test pre-roll ad plays
		Assert.assertTrue(solo.waitForLogMessage(AUDITUDE_AD_START));
	}
}
