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. 4# pylint: disable=W0401,W0614 5from telemetry.page.actions.all_page_actions import * 6from telemetry.page import page as page_module 7from telemetry.page import page_set as page_set_module 8 9 10class BasicPlayPage(page_module.Page): 11 12 def __init__(self, url, page_set): 13 super(BasicPlayPage, self).__init__(url=url, page_set=page_set) 14 self.add_browser_metrics = True 15 16 def PlayAction(self, action_runner): 17 action_runner.RunAction(PlayAction( 18 { 19 'wait_for_playing': True, 20 'wait_for_ended': True 21 })) 22 23 def RunMediaMetrics(self, action_runner): 24 self.PlayAction(action_runner) 25 26 def SeekBeforeAndAfterPlayhead(self, action_runner): 27 action_runner.RunAction(PlayAction( 28 { 29 'wait_for_playing': True, 30 'wait_for_ended': False 31 })) 32 # Wait for 1 second so that we know the play-head is at ~1s. 33 action_runner.Wait(1) 34 # Seek to before the play-head location. 35 action_runner.RunAction(SeekAction( 36 { 37 'seek_time': '0.5', 38 'wait_for_seeked': True, 39 'seek_label': 'seek_warm' 40 })) 41 # Seek to after the play-head location. 42 action_runner.RunAction(SeekAction( 43 { 44 'seek_time': 15, 45 'wait_for_seeked': True, 46 'seek_label': 'seek_cold' 47 })) 48 49class SeekBeforeAndAfterPlayheadPage(BasicPlayPage): 50 51 def __init__(self, url, page_set): 52 super(SeekBeforeAndAfterPlayheadPage, self).__init__(url=url, 53 page_set=page_set) 54 self.add_browser_metrics = False 55 56 def RunMediaMetrics(self, action_runner): 57 self.SeekBeforeAndAfterPlayhead(action_runner) 58 59 60class MediaCnsCasesPageSet(page_set_module.PageSet): 61 62 """ Media benchmark on network constrained conditions. """ 63 64 def __init__(self): 65 super(MediaCnsCasesPageSet, self).__init__() 66 67 urls_list = [ 68 # pylint: disable=C0301 69 'file://tough_video_cases/video.html?id=no_constraints_webm&src=tulip2.webm&net=none', 70 # pylint: disable=C0301 71 'file://tough_video_cases/video.html?id=cable_webm&src=tulip2.webm&net=cable', 72 # pylint: disable=C0301 73 'file://tough_video_cases/video.html?id=wifi_webm&src=tulip2.webm&net=wifi', 74 # pylint: disable=C0301 75 'file://tough_video_cases/video.html?id=no_constraints_ogv&src=tulip2.ogv&net=none', 76 # pylint: disable=C0301 77 'file://tough_video_cases/video.html?id=cable_ogv&src=tulip2.ogv&net=cable', 78 # pylint: disable=C0301 79 'file://tough_video_cases/video.html?id=wifi_ogv&src=tulip2.ogv&net=wifi', 80 # pylint: disable=C0301 81 'file://tough_video_cases/video.html?id=no_constraints_mp4&src=tulip2.mp4&net=none', 82 # pylint: disable=C0301 83 'file://tough_video_cases/video.html?id=cable_mp4&src=tulip2.mp4&net=cable', 84 # pylint: disable=C0301 85 'file://tough_video_cases/video.html?id=wifi_mp4&src=tulip2.mp4&net=wifi', 86 # pylint: disable=C0301 87 'file://tough_video_cases/video.html?id=no_constraints_wav&src=tulip2.wav&type=audio&net=none', 88 # pylint: disable=C0301 89 'file://tough_video_cases/video.html?id=cable_wav&src=tulip2.wav&type=audio&net=cable', 90 # pylint: disable=C0301 91 'file://tough_video_cases/video.html?id=wifi_wav&src=tulip2.wav&type=audio&net=wifi', 92 # pylint: disable=C0301 93 'file://tough_video_cases/video.html?id=no_constraints_ogg&src=tulip2.ogg&type=audio&net=none', 94 # pylint: disable=C0301 95 'file://tough_video_cases/video.html?id=cable_ogg&src=tulip2.ogg&type=audio&net=cable', 96 # pylint: disable=C0301 97 'file://tough_video_cases/video.html?id=wifi_ogg&src=tulip2.ogg&type=audio&net=wifi', 98 # pylint: disable=C0301 99 'file://tough_video_cases/video.html?id=no_constraints_mp3&src=tulip2.mp3&type=audio&net=none', 100 # pylint: disable=C0301 101 'file://tough_video_cases/video.html?id=cable_mp3&src=tulip2.mp3&type=audio&net=cable', 102 # pylint: disable=C0301 103 'file://tough_video_cases/video.html?id=wifi_mp3&src=tulip2.mp3&type=audio&net=wifi', 104 # pylint: disable=C0301 105 'file://tough_video_cases/video.html?id=no_constraints_m4a&src=tulip2.m4a&type=audio&net=none', 106 # pylint: disable=C0301 107 'file://tough_video_cases/video.html?id=cable_m4a&src=tulip2.m4a&type=audio&net=cable', 108 # pylint: disable=C0301 109 'file://tough_video_cases/video.html?id=wifi_m4a&src=tulip2.m4a&type=audio&net=wifi' 110 ] 111 112 for url in urls_list: 113 self.AddPage(BasicPlayPage(url, self)) 114 115 urls_list2 = [ 116 # pylint: disable=C0301 117 'file://tough_video_cases/video.html?id=wifi_mp3&src=tulip2.mp3&type=audio&net=wifi', 118 # pylint: disable=C0301 119 'file://tough_video_cases/video.html?id=wifi_m4a&src=tulip2.m4a&type=audio&net=wifi', 120 # pylint: disable=C0301 121 'file://tough_video_cases/video.html?id=wifi_ogg&src=tulip2.ogg&type=audio&net=wifi', 122 # pylint: disable=C0301 123 'file://tough_video_cases/video.html?id=wifi_wav&src=tulip2.wav&type=audio&net=wifi', 124 # pylint: disable=C0301 125 'file://tough_video_cases/video.html?id=wifi_mp4&src=tulip2.mp4&type=audio&net=wifi', 126 # pylint: disable=C0301 127 'file://tough_video_cases/video.html?id=wifi_ogv&src=tulip2.ogv&type=audio&net=wifi', 128 # pylint: disable=C0301 129 'file://tough_video_cases/video.html?id=wifi_webm&src=tulip2.webm&type=audio&net=wifi' 130 ] 131 132 for url in urls_list2: 133 self.AddPage(SeekBeforeAndAfterPlayheadPage(url, self)) 134