def test_init_set_missing_unit(self): self.assertEqual( PerfTestMetric('Time', iterations=[1, 2, 3, 4, 5]).unit(), 'ms') self.assertEqual( PerfTestMetric('Malloc', iterations=[1, 2, 3, 4, 5]).unit(), 'bytes') self.assertEqual( PerfTestMetric('JSHeap', iterations=[1, 2, 3, 4, 5]).unit(), 'bytes')
def test_has_values(self): self.assertFalse( PerfTestMetric(['some', 'test'], 'some/test.html', 'Time').has_values()) self.assertTrue( PerfTestMetric(['some', 'test'], 'some/test.html', 'Time', iterations=[1]).has_values())
def test_init_set_time_metric(self): self.assertEqual( PerfTestMetric(['some', 'test'], 'some/test.html', 'Time', 'ms').name(), 'Time') self.assertEqual( PerfTestMetric(['some', 'test'], 'some/test.html', 'Time', 'fps').name(), 'FrameRate') self.assertEqual( PerfTestMetric(['some', 'test'], 'some/test.html', 'Time', 'runs/s').name(), 'Runs')
def test_init_set_missing_unit(self): self.assertEqual( PerfTestMetric(['some', 'test'], 'some/test.html', 'Time', iterations=[1, 2, 3, 4, 5]).unit(), 'ms') self.assertEqual( PerfTestMetric(['some', 'test'], 'some/test.html', 'Malloc', iterations=[1, 2, 3, 4, 5]).unit(), 'bytes') self.assertEqual( PerfTestMetric(['some', 'test'], 'some/test.html', 'JSHeap', iterations=[1, 2, 3, 4, 5]).unit(), 'bytes')
def test_append(self): metric = PerfTestMetric('Time') metric2 = PerfTestMetric('Time') self.assertFalse(metric.has_values()) self.assertFalse(metric2.has_values()) metric.append(1) self.assertTrue(metric.has_values()) self.assertFalse(metric2.has_values()) self.assertEqual(metric.to_dict()['values'], [1]) metric.append(2) self.assertEqual(metric.to_dict()['values'], [1, 2]) metric2.append(3) self.assertTrue(metric2.has_values()) self.assertEqual(metric.to_dict()['values'], [1, 2]) self.assertEqual(metric2.to_dict()['values'], [3])
def test_append(self): metric = PerfTestMetric('Time') metric2 = PerfTestMetric('Time') self.assertFalse(metric.has_values()) self.assertFalse(metric2.has_values()) metric.append_group([1]) self.assertTrue(metric.has_values()) self.assertFalse(metric2.has_values()) self.assertEqual(metric.grouped_iteration_values(), [[1]]) self.assertEqual(metric.flattened_iteration_values(), [1]) metric.append_group([2]) self.assertEqual(metric.grouped_iteration_values(), [[1], [2]]) self.assertEqual(metric.flattened_iteration_values(), [1, 2]) metric2.append_group([3]) self.assertTrue(metric2.has_values()) self.assertEqual(metric.flattened_iteration_values(), [1, 2]) self.assertEqual(metric2.flattened_iteration_values(), [3]) metric.append_group([4, 5]) self.assertEqual(metric.grouped_iteration_values(), [[1], [2], [4, 5]]) self.assertEqual(metric.flattened_iteration_values(), [1, 2, 4, 5])
def test_has_values(self): self.assertFalse(PerfTestMetric('Time').has_values()) self.assertTrue(PerfTestMetric('Time', iterations=[1]).has_values())
def test_legacy_chromium_bot_compatible_test_name(self): self.assertEqual(PerfTestMetric('Time').legacy_chromium_bot_compatible_test_name('test'), 'test') self.assertEqual(PerfTestMetric('Malloc').legacy_chromium_bot_compatible_test_name('test'), 'test:Malloc') self.assertEqual(PerfTestMetric('JSHeap').legacy_chromium_bot_compatible_test_name('test'), 'test:JSHeap') self.assertEqual(PerfTestMetric('FontSize', unit='em').legacy_chromium_bot_compatible_test_name('test'), 'test:FontSize')