Ejemplo n.º 1
0
    def testExtractsInterestingMetricsOnly(self):
        stats_metric = webrtc_stats.WebRtcStatisticsMetric()
        results = self._RunMetricOnJson(SAMPLE_JSON, stats_metric)

        self.assertTrue(len(results.received_values) > 0)
        self.assertIn(
            'peer_connection_0', results.received_values[0].name,
            'The result should be a ListOfScalarValues instance with '
            'a name <peer connection id>_<statistic>.')
        all_names = [value.name for value in results.received_values]
        self.assertIn('peer_connection_0_audio_goog_rtt', all_names)
        self.assertNotIn(
            'peer_connection_1_audio_goog_rtt', all_names,
            'Peer connection 1 does not have a goog-rtt in '
            'the JSON above, unlike peer connection 0 which does.')
        self.assertIn('peer_connection_0_video_goog_rtt', all_names)
        self.assertIn('peer_connection_1_video_goog_rtt', all_names)
        # The audio_audio is intentional since the code distinguishes audio reports
        # from video reports (even though audio_input_level is quite obvious).
        self.assertNotIn(
            'peer_connection_0_audio_audio_input_level', all_names,
            'Input level is in the JSON for both connections but '
            'should not be reported since it is not interesting.')
        self.assertNotIn('peer_connection_1_audio_audio_input_level',
                         all_names)
Ejemplo n.º 2
0
  def testExtractsParticularMetricsOnlyIfSpecified(self):
    only_goog_rtt_and_max_decode = ['googRtt', 'googMaxDecodeMs']
    stats_metric = webrtc_stats.WebRtcStatisticsMetric(
        particular_metrics=only_goog_rtt_and_max_decode)
    results = self._RunMetricOnJson(SAMPLE_JSON, stats_metric)

    received_names = [value.name for value in results.received_values]
    expected_names = ['peer_connection_0_audio_goog_rtt',
                      'peer_connection_0_video_goog_rtt',
                      'peer_connection_1_video_goog_max_decode_ms',
                      'peer_connection_1_video_goog_rtt']
    self.assertEqual(expected_names, received_names)
Ejemplo n.º 3
0
    def testExtractsValuesAsTimeSeries(self):
        stats_metric = webrtc_stats.WebRtcStatisticsMetric()
        results = self._RunMetricOnJson(SAMPLE_JSON, stats_metric)

        self.assertTrue(
            results.received_values,
            'Expected values for googDecodeMs and others, got none.')
        self.assertEqual(results.received_values[1].name,
                         'peer_connection_0_audio_goog_rtt')
        self.assertEqual(results.received_values[1].values, [20.0, 17.0])
        self.assertEqual(results.received_values[7].name,
                         'peer_connection_1_video_goog_rtt')
        self.assertEqual(results.received_values[7].values, [100.0, 101.0])
Ejemplo n.º 4
0
  def _RunMetricOnJson(self, json_to_return):
    stats_metric = webrtc_stats.WebRtcStatisticsMetric()

    tab = simple_mock.MockObject()
    page = simple_mock.MockObject()

    stats_metric.Start(page, tab)

    tab.ExpectCall('EvaluateJavaScript',
                   simple_mock.DONT_CARE).WillReturn(json_to_return)
    stats_metric.Stop(page, tab)

    page.url = simple_mock.MockObject()
    results = FakeResults(page)
    stats_metric.AddResults(tab, results)
    return results
Ejemplo n.º 5
0
 def DidStartBrowser(self, browser):
   self._cpu_metric = cpu.CpuMetric(browser)
   self._memory_metric = memory.MemoryMetric(browser)
   self._webrtc_stats_metric = webrtc_stats.WebRtcStatisticsMetric()
Ejemplo n.º 6
0
 def testReturnsIfJsonIsEmpty(self):
     stats_metric = webrtc_stats.WebRtcStatisticsMetric()
     results = self._RunMetricOnJson('[]', stats_metric)
     self.assertFalse(results.received_values)
Ejemplo n.º 7
0
 def DidStartBrowser(self, browser):
     self._cpu_metric = cpu.CpuMetric(browser)
     self._webrtc_stats_metric = webrtc_stats.WebRtcStatisticsMetric(
         self._particular_metrics)
Ejemplo n.º 8
0
 def DidStartBrowser(self, browser):
     self._cpu_metric = cpu.CpuMetric(browser)
     if self._use_webrtc_stats:
         self._webrtc_stats_metric = webrtc_stats.WebRtcStatisticsMetric()