Package com.kurento.kmf.test.media

Source Code of com.kurento.kmf.test.media.MediaApiPlayerBrowserTest

/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
package com.kurento.kmf.test.media;

import java.awt.Color;

import org.junit.Assert;
import org.junit.Test;

import com.kurento.kmf.media.HttpGetEndpoint;
import com.kurento.kmf.media.MediaPipeline;
import com.kurento.kmf.media.PlayerEndpoint;
import com.kurento.kmf.test.base.BrowserMediaApiTest;
import com.kurento.kmf.test.client.Browser;
import com.kurento.kmf.test.client.BrowserClient;
import com.kurento.kmf.test.client.Client;

/**
*
* <strong>Description</strong>: Test of a HTTP Player, using directly a
* MediaPipeline and Selenium.<br/>
* <strong>Pipeline</strong>:
* <ul>
* <li>PlayerEndpoint -> HttpGetEndpoint</li>
* </ul>
* <strong>Pass criteria</strong>:
* <ul>
* <li>Browser starts before default timeout</li>
* <li>Play time should be the expected</li>
* <li>Color of the video should be the expected</li>
* <li>Browser ends before default timeout</li>
* </ul>
*
* @author Micael Gallego (micael.gallego@gmail.com)
* @author Boni Garcia (bgarcia@gsyc.es)
* @since 4.2.3
*/
public class MediaApiPlayerBrowserTest extends BrowserMediaApiTest {

  @Test
  public void testPlayerChrome() throws Exception {
    doTest(Browser.CHROME);
  }

  @Test
  public void testPlayerFirefox() throws Exception {
    doTest(Browser.FIREFOX);
  }

  public void doTest(Browser browserType) throws Exception {
    // Media Pipeline
    MediaPipeline mp = pipelineFactory.create();
    PlayerEndpoint playerEP = mp.newPlayerEndpoint(
        "http://files.kurento.org/video/10sec/blue.webm").build();
    HttpGetEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS()
        .build();
    playerEP.connect(httpEP);

    // Test execution
    try (BrowserClient browser = new BrowserClient.Builder()
        .browser(browserType).client(Client.PLAYER).build()) {
      browser.setURL(httpEP.getUrl());
      browser.subscribeEvents("playing", "ended");
      playerEP.play();
      browser.start();

      // Assertions
      Assert.assertTrue("Timeout waiting playing event",
          browser.waitForEvent("playing"));
      Assert.assertTrue("Timeout waiting ended event",
          browser.waitForEvent("ended"));
      Assert.assertTrue("Play time must be at least 8 seconds",
          browser.getCurrentTime() >= 8);
      Assert.assertTrue("The color of the video should be blue",
          browser.colorSimilarTo(Color.BLUE));
    }
  }

}
TOP

Related Classes of com.kurento.kmf.test.media.MediaApiPlayerBrowserTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.