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.
5 from core
import perf_benchmark
7 from telemetry
import benchmark
8 from telemetry
.timeline
import tracing_category_filter
9 from telemetry
.web_perf
import timeline_based_measurement
13 TEXT_SELECTION_CATEGORY
= 'blink'
14 TIMELINE_REQUIRED_CATEGORY
= 'blink.console'
17 class _TextSelection(perf_benchmark
.PerfBenchmark
):
18 page_set
= page_sets
.TextSelectionSitesPageSet
20 def CreateTimelineBasedMeasurementOptions(self
):
21 cat_filter
= tracing_category_filter
.CreateMinimalOverheadFilter()
22 cat_filter
.AddIncludedCategory(TEXT_SELECTION_CATEGORY
)
23 cat_filter
.AddIncludedCategory(TIMELINE_REQUIRED_CATEGORY
)
25 return timeline_based_measurement
.Options(
26 overhead_level
=cat_filter
)
30 return 'text_selection'
33 def ValueCanBeAddedPredicate(cls
, value
, is_first_result
):
34 if 'text-selection' not in value
.name
:
36 return value
.values
!= None
39 @benchmark.Enabled('android')
40 class TextSelectionDirection(_TextSelection
):
41 """Measure text selection metrics while dragging a touch selection handle on a
42 subset of top ten mobile sites and using the 'direction' touch selection
44 def SetExtraBrowserOptions(self
, options
):
45 options
.AppendExtraBrowserArgs(['--touch-selection-strategy=direction'])
49 return 'text_selection.direction'
52 @benchmark.Enabled('android')
53 class TextSelectionCharacter(_TextSelection
):
54 """Measure text selection metrics while dragging a touch selection handle on a
55 subset of top ten mobile sites and using the 'character' touch selection
57 def SetExtraBrowserOptions(self
, options
):
58 options
.AppendExtraBrowserArgs(['--touch-selection-strategy=character'])
62 return 'text_selection.character'