1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4from telemetry.page import page as page_module
5from telemetry.page import page_set as page_set_module
6
7
8class WebrtcCasesPage(page_module.Page):
9
10  def __init__(self, url, page_set):
11    super(WebrtcCasesPage, self).__init__(url=url, page_set=page_set)
12
13
14class Page1(WebrtcCasesPage):
15
16  """ Why: Simple test page only showing a local video stream """
17
18  def __init__(self, page_set):
19    super(Page1, self).__init__(
20      url='file://webrtc/local-video.html',
21      page_set=page_set)
22
23  def RunWebrtc(self, action_runner):
24    action_runner.NavigateToPage(self)
25    action_runner.Wait(10)
26    action_runner.ExecuteJavaScript('checkForErrors();')
27
28
29class Page2(WebrtcCasesPage):
30
31  """ Why: Loopback video call using the PeerConnection API. """
32
33  def __init__(self, page_set):
34    super(Page2, self).__init__(
35      url='file://third_party/webrtc/samples/js/demos/html/pc1.html',
36      page_set=page_set)
37
38  def RunWebrtc(self, action_runner):
39    action_runner.ClickElement('button[id="btn1"]')
40    action_runner.Wait(2)
41    action_runner.ClickElement('button[id="btn2"]')
42    action_runner.Wait(10)
43    action_runner.ClickElement('button[id="btn3"]')
44
45class Page3(WebrtcCasesPage):
46
47  """ Why: Acquires a high definition local stream. """
48
49  def __init__(self, page_set):
50    super(Page3, self).__init__(
51      url=('http://googlechrome.github.io/webrtc/samples/web/content/'
52           'getusermedia-resolution/'),
53      page_set=page_set)
54
55  def RunWebrtc(self, action_runner):
56    action_runner.ClickElement('button[id="hd"]')
57    action_runner.Wait(10)
58
59
60class WebrtcCasesPageSet(page_set_module.PageSet):
61
62  """ WebRTC tests for Real-time audio and video communication. """
63
64  def __init__(self):
65    super(WebrtcCasesPageSet, self).__init__(
66      archive_data_file='data/webrtc_cases.json',
67      bucket=page_set_module.PUBLIC_BUCKET,
68      serving_dirs=['third_party/webrtc/samples/js'])
69
70    self.AddPage(Page1(self))
71    self.AddPage(Page2(self))
72    self.AddPage(Page3(self))
73