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 5 from telemetry.page.actions.all_page_actions import * 6 from telemetry.page import page as page_module 7 from telemetry.page import page_set as page_set_module 8 9 10 class ToughVideoCasesPage(page_module.Page): 11 12 def __init__(self, url, page_set): 13 super(ToughVideoCasesPage, self).__init__(url=url, page_set=page_set) 14 15 def LoopMixedAudio(self, action_runner): 16 action_runner.RunAction(PlayAction( 17 { 18 'wait_for_playing': True, 19 'wait_for_ended': False, 20 'selector': '#background_audio' 21 })) 22 action_runner.RunAction(LoopAction( 23 { 24 'loop_count': 50, 25 'selector': '#mixed_audio' 26 })) 27 28 def LoopSingleAudio(self, action_runner): 29 action_runner.RunAction(LoopAction( 30 { 31 'loop_count': 50, 32 'selector': '#single_audio' 33 })) 34 35 def PlayAction(self, action_runner): 36 action_runner.RunAction(PlayAction( 37 { 38 'wait_for_playing': True, 39 'wait_for_ended': True 40 })) 41 42 def SeekBeforeAndAfterPlayhead(self, action_runner): 43 action_runner.RunAction(PlayAction( 44 { 45 'wait_for_playing': True, 46 'wait_for_ended': False 47 })) 48 # Wait for 1 second so that we know the play-head is at ~1s. 49 action_runner.Wait(1) 50 # Seek to before the play-head location. 51 action_runner.RunAction(SeekAction( 52 { 53 'seek_time': '0.5', 54 'wait_for_seeked': True, 55 'seek_label': 'seek_warm' 56 })) 57 # Seek to after the play-head location. 58 action_runner.RunAction(SeekAction( 59 { 60 'seek_time': '9', 61 'wait_for_seeked': True, 62 'seek_label': 'seek_cold' 63 })) 64 65 66 class Page1(ToughVideoCasesPage): 67 68 def __init__(self, page_set): 69 super(Page1, self).__init__( 70 url='file://tough_video_cases/video.html?src=crowd.wav&type=audio', 71 page_set=page_set) 72 73 self.add_browser_metrics = True 74 75 def RunMediaMetrics(self, action_runner): 76 self.PlayAction(action_runner) 77 78 79 class Page2(ToughVideoCasesPage): 80 81 def __init__(self, page_set): 82 super(Page2, self).__init__( 83 url='file://tough_video_cases/video.html?src=crowd.ogg&type=audio', 84 page_set=page_set) 85 86 self.add_browser_metrics = True 87 88 def RunMediaMetrics(self, action_runner): 89 self.PlayAction(action_runner) 90 91 92 class Page3(ToughVideoCasesPage): 93 94 def __init__(self, page_set): 95 super(Page3, self).__init__( 96 url='file://tough_video_cases/video.html?src=crowd1080.ogv', 97 page_set=page_set) 98 99 self.add_browser_metrics = True 100 self.is_50fps = True 101 102 def RunMediaMetrics(self, action_runner): 103 self.PlayAction(action_runner) 104 105 106 class Page4(ToughVideoCasesPage): 107 108 def __init__(self, page_set): 109 super(Page4, self).__init__( 110 url='file://tough_video_cases/video.html?src=crowd1080.webm', 111 page_set=page_set) 112 113 self.add_browser_metrics = True 114 self.is_50fps = True 115 116 def RunMediaMetrics(self, action_runner): 117 self.PlayAction(action_runner) 118 119 120 class Page5(ToughVideoCasesPage): 121 122 def __init__(self, page_set): 123 super(Page5, self).__init__( 124 url='file://tough_video_cases/video.html?src=crowd2160.ogv', 125 page_set=page_set) 126 127 self.add_browser_metrics = True 128 self.is_4k = True 129 self.is_50fps = True 130 131 def RunMediaMetrics(self, action_runner): 132 self.PlayAction(action_runner) 133 134 135 class Page6(ToughVideoCasesPage): 136 137 def __init__(self, page_set): 138 super(Page6, self).__init__( 139 url='file://tough_video_cases/video.html?src=crowd2160.webm', 140 page_set=page_set) 141 142 self.add_browser_metrics = True 143 self.is_4k = True 144 self.is_50fps = True 145 146 def RunMediaMetrics(self, action_runner): 147 self.PlayAction(action_runner) 148 149 150 class Page7(ToughVideoCasesPage): 151 152 def __init__(self, page_set): 153 super(Page7, self).__init__( 154 url='file://tough_video_cases/video.html?src=tulip2.ogg&type=audio', 155 page_set=page_set) 156 157 self.add_browser_metrics = True 158 159 def RunMediaMetrics(self, action_runner): 160 self.PlayAction(action_runner) 161 162 163 class Page8(ToughVideoCasesPage): 164 165 def __init__(self, page_set): 166 super(Page8, self).__init__( 167 url='file://tough_video_cases/video.html?src=tulip2.wav&type=audio', 168 page_set=page_set) 169 170 self.add_browser_metrics = True 171 172 def RunMediaMetrics(self, action_runner): 173 self.PlayAction(action_runner) 174 175 176 class Page9(ToughVideoCasesPage): 177 178 def __init__(self, page_set): 179 super(Page9, self).__init__( 180 url='file://tough_video_cases/video.html?src=tulip2.ogv', 181 page_set=page_set) 182 183 self.add_browser_metrics = True 184 185 def RunMediaMetrics(self, action_runner): 186 self.PlayAction(action_runner) 187 188 189 class Page10(ToughVideoCasesPage): 190 191 def __init__(self, page_set): 192 super(Page10, self).__init__( 193 url='file://tough_video_cases/video.html?src=tulip2.webm', 194 page_set=page_set) 195 196 self.add_browser_metrics = True 197 198 def RunMediaMetrics(self, action_runner): 199 self.PlayAction(action_runner) 200 201 202 class Page11(ToughVideoCasesPage): 203 204 def __init__(self, page_set): 205 super(Page11, self).__init__( 206 url='file://tough_video_cases/video.html?src=crowd1080.mp4', 207 page_set=page_set) 208 209 self.add_browser_metrics = True 210 self.is_50fps = True 211 212 def RunMediaMetrics(self, action_runner): 213 self.PlayAction(action_runner) 214 215 216 class Page12(ToughVideoCasesPage): 217 218 def __init__(self, page_set): 219 super(Page12, self).__init__( 220 url='file://tough_video_cases/video.html?src=crowd2160.mp4', 221 page_set=page_set) 222 223 self.add_browser_metrics = True 224 self.is_4k = True 225 self.is_50fps = True 226 227 def RunMediaMetrics(self, action_runner): 228 self.PlayAction(action_runner) 229 230 231 class Page13(ToughVideoCasesPage): 232 233 def __init__(self, page_set): 234 super(Page13, self).__init__( 235 url='file://tough_video_cases/video.html?src=tulip2.mp3&type=audio', 236 page_set=page_set) 237 238 self.add_browser_metrics = True 239 240 def RunMediaMetrics(self, action_runner): 241 self.PlayAction(action_runner) 242 243 244 class Page14(ToughVideoCasesPage): 245 246 def __init__(self, page_set): 247 super(Page14, self).__init__( 248 url='file://tough_video_cases/video.html?src=tulip2.mp4', 249 page_set=page_set) 250 251 self.add_browser_metrics = True 252 253 def RunMediaMetrics(self, action_runner): 254 self.PlayAction(action_runner) 255 256 257 class Page15(ToughVideoCasesPage): 258 259 def __init__(self, page_set): 260 super(Page15, self).__init__( 261 url='file://tough_video_cases/video.html?src=tulip2.m4a&type=audio', 262 page_set=page_set) 263 264 self.add_browser_metrics = True 265 266 def RunMediaMetrics(self, action_runner): 267 self.PlayAction(action_runner) 268 269 270 class Page16(ToughVideoCasesPage): 271 272 def __init__(self, page_set): 273 super(Page16, self).__init__( 274 url='file://tough_video_cases/video.html?src=garden2_10s.webm', 275 page_set=page_set) 276 277 self.is_4k = True 278 self.add_browser_metrics = True 279 280 def RunMediaMetrics(self, action_runner): 281 self.PlayAction(action_runner) 282 283 284 class Page17(ToughVideoCasesPage): 285 286 def __init__(self, page_set): 287 super(Page17, self).__init__( 288 url='file://tough_video_cases/video.html?src=garden2_10s.mp4', 289 page_set=page_set) 290 291 self.is_4k = True 292 self.add_browser_metrics = True 293 294 def RunMediaMetrics(self, action_runner): 295 self.PlayAction(action_runner) 296 297 298 class Page18(ToughVideoCasesPage): 299 300 def __init__(self, page_set): 301 super(Page18, self).__init__( 302 url='file://tough_video_cases/video.html?src=garden2_10s.ogv', 303 page_set=page_set) 304 305 self.is_4k = True 306 self.add_browser_metrics = True 307 308 def RunMediaMetrics(self, action_runner): 309 self.PlayAction(action_runner) 310 311 312 class Page19(ToughVideoCasesPage): 313 314 def __init__(self, page_set): 315 super(Page19, self).__init__( 316 url='file://tough_video_cases/video.html?src=tulip2.ogg&type=audio', 317 page_set=page_set) 318 319 self.skip_basic_metrics = True 320 321 def RunMediaMetrics(self, action_runner): 322 self.SeekBeforeAndAfterPlayhead(action_runner) 323 324 325 class Page20(ToughVideoCasesPage): 326 327 def __init__(self, page_set): 328 super(Page20, self).__init__( 329 url='file://tough_video_cases/video.html?src=tulip2.wav&type=audio', 330 page_set=page_set) 331 332 self.skip_basic_metrics = True 333 334 def RunMediaMetrics(self, action_runner): 335 self.SeekBeforeAndAfterPlayhead(action_runner) 336 337 338 class Page21(ToughVideoCasesPage): 339 340 def __init__(self, page_set): 341 super(Page21, self).__init__( 342 url='file://tough_video_cases/video.html?src=tulip2.ogv', 343 page_set=page_set) 344 345 self.skip_basic_metrics = True 346 347 def RunMediaMetrics(self, action_runner): 348 self.SeekBeforeAndAfterPlayhead(action_runner) 349 350 351 class Page22(ToughVideoCasesPage): 352 353 def __init__(self, page_set): 354 super(Page22, self).__init__( 355 url='file://tough_video_cases/video.html?src=tulip2.webm', 356 page_set=page_set) 357 358 self.skip_basic_metrics = True 359 360 def RunMediaMetrics(self, action_runner): 361 self.SeekBeforeAndAfterPlayhead(action_runner) 362 363 364 class Page23(ToughVideoCasesPage): 365 366 def __init__(self, page_set): 367 super(Page23, self).__init__( 368 url='file://tough_video_cases/video.html?src=tulip2.mp3&type=audio', 369 page_set=page_set) 370 371 self.skip_basic_metrics = True 372 373 def RunMediaMetrics(self, action_runner): 374 self.SeekBeforeAndAfterPlayhead(action_runner) 375 376 377 class Page24(ToughVideoCasesPage): 378 379 def __init__(self, page_set): 380 super(Page24, self).__init__( 381 url='file://tough_video_cases/video.html?src=tulip2.mp4', 382 page_set=page_set) 383 384 self.skip_basic_metrics = True 385 386 def RunMediaMetrics(self, action_runner): 387 self.SeekBeforeAndAfterPlayhead(action_runner) 388 389 390 class Page25(ToughVideoCasesPage): 391 392 def __init__(self, page_set): 393 super(Page25, self).__init__( 394 url='file://tough_video_cases/video.html?src=garden2_10s.webm', 395 page_set=page_set) 396 397 self.skip_basic_metrics = True 398 self.is_4k = True 399 400 def RunMediaMetrics(self, action_runner): 401 self.SeekBeforeAndAfterPlayhead(action_runner) 402 403 404 class Page26(ToughVideoCasesPage): 405 406 def __init__(self, page_set): 407 super(Page26, self).__init__( 408 url='file://tough_video_cases/video.html?src=garden2_10s.mp4', 409 page_set=page_set) 410 411 self.skip_basic_metrics = True 412 self.is_4k = True 413 414 def RunMediaMetrics(self, action_runner): 415 self.SeekBeforeAndAfterPlayhead(action_runner) 416 417 418 class Page27(ToughVideoCasesPage): 419 420 def __init__(self, page_set): 421 super(Page27, self).__init__( 422 url='file://tough_video_cases/video.html?src=garden2_10s.ogv', 423 page_set=page_set) 424 425 self.skip_basic_metrics = True 426 self.is_4k = True 427 428 def RunMediaMetrics(self, action_runner): 429 self.SeekBeforeAndAfterPlayhead(action_runner) 430 431 432 class Page28(ToughVideoCasesPage): 433 434 def __init__(self, page_set): 435 super(Page28, self).__init__( 436 url='file://tough_video_cases/audio_playback.html?id=single_audio', 437 page_set=page_set) 438 439 self.skip_basic_metrics = True 440 441 def RunMediaMetrics(self, action_runner): 442 self.LoopSingleAudio(action_runner) 443 444 445 class Page29(ToughVideoCasesPage): 446 447 def __init__(self, page_set): 448 super(Page29, self).__init__( 449 url='file://tough_video_cases/audio_playback.html?id=mixed_audio', 450 page_set=page_set) 451 452 self.skip_basic_metrics = True 453 454 def RunMediaMetrics(self, action_runner): 455 self.LoopMixedAudio(action_runner) 456 457 458 class ToughVideoCasesPageSet(page_set_module.PageSet): 459 460 """ 461 Description: Video Stack Perf benchmark 462 """ 463 def __init__(self): 464 super(ToughVideoCasesPageSet, self).__init__( 465 bucket=page_set_module.INTERNAL_BUCKET) 466 467 self.AddPage(Page1(self)) 468 self.AddPage(Page2(self)) 469 self.AddPage(Page3(self)) 470 self.AddPage(Page4(self)) 471 self.AddPage(Page5(self)) 472 self.AddPage(Page6(self)) 473 self.AddPage(Page7(self)) 474 self.AddPage(Page8(self)) 475 self.AddPage(Page9(self)) 476 self.AddPage(Page10(self)) 477 self.AddPage(Page11(self)) 478 self.AddPage(Page12(self)) 479 self.AddPage(Page13(self)) 480 self.AddPage(Page14(self)) 481 self.AddPage(Page15(self)) 482 self.AddPage(Page16(self)) 483 self.AddPage(Page17(self)) 484 self.AddPage(Page18(self)) 485 self.AddPage(Page19(self)) 486 self.AddPage(Page20(self)) 487 self.AddPage(Page21(self)) 488 self.AddPage(Page22(self)) 489 self.AddPage(Page23(self)) 490 self.AddPage(Page24(self)) 491 self.AddPage(Page25(self)) 492 self.AddPage(Page26(self)) 493 self.AddPage(Page27(self)) 494 self.AddPage(Page28(self)) 495 self.AddPage(Page29(self)) 496