<commit_before># Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from telemetry import test
from telemetry.page import page_measurement

from measurements import media


class MSEMeasurement(page_measurement.PageMeasurement):
  def MeasurePage(self, page, tab, results):
    media_metric = tab.EvaluateJavaScript('window.__testMetrics')
    trace = media_metric['id']
    metrics = media_metric['metrics']
    for m in metrics:
      if isinstance(metrics[m], list):
        values = [float(v) for v in metrics[m]]
      else:
        values = float(metrics[m])
      results.Add(trace, 'ms', values, chart_name=m)


class Media(test.Test):
  """Obtains media metrics for key user scenarios."""
  test = media.Media
  page_set = 'page_sets/tough_video_cases.json'

class MediaNetworkSimulation(test.Test):
  """Obtains media metrics under different network simulations."""
  test = media.Media
  enabled = not sys.platform.startswith('linux')
  page_set = 'page_sets/media_cns_cases.json'

class MediaAndroid(test.Test):
  """Obtains media metrics for key user scenarios on Android."""
  test = media.Media
  tag = 'android'
  # Disable media-tests on Android: crbug/329691
  enabled = not sys.platform.startswith('linux')
  page_set = 'page_sets/tough_video_cases.json'
  # Exclude crowd* media files (50fps 2160p).
  options = {
      'page_filter_exclude': '.*crowd.*'
  }

  def CustomizeBrowserOptions(self, options):
    # Needed to run media actions in JS in Android.
    options.AppendExtraBrowserArgs(
        '--disable-gesture-requirement-for-media-playback')

class MediaChromeOS(test.Test):
  """Obtains media metrics for key user scenarios on ChromeOS."""
  test = media.Media
  tag = 'chromeOS'
  page_set = 'page_sets/tough_video_cases.json'
  # Exclude crowd* media files (50fps 2160p): crbug/331816
  options = {
      'page_filter_exclude': '.*crowd.*'
  }

  def CustomizeBrowserOptions(self, options):<commit_msg>Enable media_cns_cases on Linux (Android is excluded on the bot).<commit_after># Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from telemetry import test
from telemetry.page import page_measurement

from measurements import media


class MSEMeasurement(page_measurement.PageMeasurement):
  def MeasurePage(self, page, tab, results):
    media_metric = tab.EvaluateJavaScript('window.__testMetrics')
    trace = media_metric['id']
    metrics = media_metric['metrics']
    for m in metrics:
      if isinstance(metrics[m], list):
        values = [float(v) for v in metrics[m]]
      else:
        values = float(metrics[m])
      results.Add(trace, 'ms', values, chart_name=m)


class Media(test.Test):
  """Obtains media metrics for key user scenarios."""
  test = media.Media
  page_set = 'page_sets/tough_video_cases.json'

class MediaNetworkSimulation(test.Test):
  """Obtains media metrics under different network simulations."""
  test = media.Media
  page_set = 'page_sets/media_cns_cases.json'

class MediaAndroid(test.Test):
  """Obtains media metrics for key user scenarios on Android."""
  test = media.Media
  tag = 'android'
  # Disable media-tests on Android: crbug/329691
  enabled = not sys.platform.startswith('linux')
  page_set = 'page_sets/tough_video_cases.json'
  # Exclude crowd* media files (50fps 2160p).
  options = {
      'page_filter_exclude': '.*crowd.*'
  }

  def CustomizeBrowserOptions(self, options):
    # Needed to run media actions in JS in Android.
    options.AppendExtraBrowserArgs(
        '--disable-gesture-requirement-for-media-playback')

class MediaChromeOS(test.Test):
  """Obtains media metrics for key user scenarios on ChromeOS."""
  test = media.Media
  tag = 'chromeOS'
  page_set = 'page_sets/tough_video_cases.json'
  # Exclude crowd* media files (50fps 2160p): crbug/331816
  options = {
      'page_filter_exclude': '.*crowd.*'
  }

  def CustomizeBrowserOptions(self, options):
{'fraction_non_alphanumeric': 0.10579956321281242, 'fraction_numerical': 0.013588934724581413, 'mean_word_length': 4.107806691449814, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6062523', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1259, 'n_words': 369}