package org.openqa.selenium.qtwebkit;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.testing.JUnit4TestBase;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class HTML5VideoTagTest extends JUnit4TestBase {
  @Before
  public void setUp() throws Exception {
    driver.get(pages.html5VideoTest);
    try {Thread.sleep(3000);} catch (InterruptedException ex){}
  }

  @AfterClass
  public static void cleanUpDriver() {
    JUnit4TestBase.removeDriver();
  }

  @Test
  public void testRemotePlayerState(){
    WebElement element = driver.findElement(By.id("videoPlayer"));
    if(element instanceof RemotePlayer){
      RemotePlayer player = (RemotePlayer)element;
      player.setState(Player.PlayerState.playing);
      Player.PlayerState state = player.getState();
      assertEquals(Player.PlayerState.playing, state);
      assertEquals(null, player.getAttribute("paused"));

      try{
        Thread.sleep(5000);
      } catch (InterruptedException ex){}

      player.setState(Player.PlayerState.paused);
      state = player.getState();
      assertEquals(Player.PlayerState.paused, state);
      assertEquals("true", player.getAttribute("paused"));

      player.setState(Player.PlayerState.stopped);
      state = player.getState();
      assertEquals("true", player.getAttribute("paused"));
      assertEquals(0, player.currentPlayingPosition(), 0.01);
      assertEquals(Player.PlayerState.stopped, state);
      }
    }

    @Test
  public void testRemotePlayerSetMute(){
    WebElement element = driver.findElement(By.id("videoPlayer"));
    if(element instanceof RemotePlayer){
      RemotePlayer player = (RemotePlayer)element;
      player.setMute(true);
      assertEquals("true", player.getAttribute("muted"));

      player.setMute(false);
      assertEquals(null, player.getAttribute("muted"));
    }

  }

  @Test
  public void testRemotePlayerGetMute(){
    WebElement element = driver.findElement(By.id("videoPlayer"));
    if(element instanceof RemotePlayer){
      RemotePlayer player = (RemotePlayer)element;
      assertEquals(player.isMuted() ? "true" : null , player.getAttribute("muted"));
      player.setMute(true);
      assertEquals(player.isMuted() ? "true" : null , player.getAttribute("muted"));
    }
  }

  @Test
  public void testRemotePlayerSeek(){
    WebElement element = driver.findElement(By.id("videoPlayer"));
    if(element instanceof RemotePlayer){
      RemotePlayer player = (RemotePlayer)element;
      assertEquals(player.currentPlayingPosition(), 0, 0.1);

      player.setState(Player.PlayerState.playing);
      assertNotEquals(player.currentPlayingPosition(), 0);
    }
  }

}

@@ -2911,10 +2911,1379 @@
  %7D%0A  %7D%0A%0A
+  @Test%0A  public void testRemotePlayerVolume()%7B%0A    WebElement element = driver.findElement(By.id(%22videoPlayer%22));%0A    if(element instanceof  RemotePlayer)%7B%0A      RemotePlayer player = (RemotePlayer)element;%0A      player.setVolume(0.5);%0A      assertEquals(0.5 ,player.getVolume(), 0);%0A      assertEquals(%220.5%22, player.getAttribute(%22volume%22));%0A%0A      player.setVolume(0);%0A      assertEquals(0 ,player.getVolume(), 0);%0A      assertEquals(%220%22, player.getAttribute(%22volume%22));%0A%0A      player.setVolume(1.0);%0A      assertEquals(1.0 ,player.getVolume(), 0);%0A      assertEquals(%221%22, player.getAttribute(%22volume%22));%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void testRemotePlayerVolumeAndMute()%7B%0A    WebElement element = driver.findElement(By.id(%22videoPlayer%22));%0A    if(element instanceof  RemotePlayer)%7B%0A      RemotePlayer player = (RemotePlayer)element;%0A      player.setVolume(0.5);%0A      player.setMute(true);%0A      assertEquals(%22true%22, player.getAttribute(%22muted%22));%0A      assertEquals(true, player.isMuted());%0A      assertEquals(0.5 ,player.getVolume(), 0);%0A      assertEquals(%220.5%22, player.getAttribute(%22volume%22));%0A%0A      player.setVolume(0);%0A      player.setMute(false);%0A      assertEquals(null, player.getAttribute(%22muted%22));%0A      assertEquals(false, player.isMuted());%0A      assertEquals(0 ,player.getVolume(), 0);%0A      assertEquals(%220%22, player.getAttribute(%22volume%22));%0A    %7D%0A  %7D%0A%0A
 %7D%0A

Add volume tests to HTML5VideoTest