Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(546)

Side by Side Diff: tools/perf/page_sets/indexeddb_offline.py

Issue 321563003: Add Wait* API to ActionRunner to wrap over WaitAction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebasing to head. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4
5 import re
6
4 # pylint: disable=W0401,W0614 7 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import * 8 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module 9 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module 10 from telemetry.page import page_set as page_set_module
8 11
9 12
13 def _CreateXpathFunction(xpath):
14 return ('document.evaluate(%s, document, null, '
15 'XPathResult.FIRST_ORDERED_NODE_TYPE, null)'
16 '.singleNodeEvaluate') % re.escape(xpath)
17
18
10 class IndexeddbOfflinePage(page_module.Page): 19 class IndexeddbOfflinePage(page_module.Page):
11 20
12 """ Why: Simulates user input while offline and sync while online. """ 21 """ Why: Simulates user input while offline and sync while online. """
13 22
14 def __init__(self, page_set): 23 def __init__(self, page_set):
15 super(IndexeddbOfflinePage, self).__init__( 24 super(IndexeddbOfflinePage, self).__init__(
16 url='file://endure/indexeddb_app.html', 25 url='file://endure/indexeddb_app.html',
17 page_set=page_set, 26 page_set=page_set,
18 name='indexeddb_offline') 27 name='indexeddb_offline')
19 self.user_agent_type = 'desktop' 28 self.user_agent_type = 'desktop'
20 29
21 def RunNavigateSteps(self, action_runner): 30 def RunNavigateSteps(self, action_runner):
22 action_runner.NavigateToPage(self) 31 action_runner.NavigateToPage(self)
23 action_runner.RunAction(WaitAction( 32 action_runner.WaitForElement(text='initialized')
24 {
25 'text': 'initialized',
26 'condition': 'element'
27 }))
28 33
29 def RunEndure(self, action_runner): 34 def RunEndure(self, action_runner):
30 action_runner.RunAction(WaitAction( 35 action_runner.WaitForElement('button[id="online"]:not(disabled)')
31 {
32 'condition': 'element',
33 'selector': 'button[id="online"]:not(disabled)'
34 }))
35 action_runner.RunAction(ClickElementAction( 36 action_runner.RunAction(ClickElementAction(
36 { 37 {
37 'selector': 'button[id="online"]:not(disabled)' 38 'selector': 'button[id="online"]:not(disabled)'
38 })) 39 }))
39 action_runner.RunAction(WaitAction( 40 action_runner.WaitForElement(
40 { 41 element_function=_CreateXpathFunction('id("state")[text()="online"]'))
41 'xpath': 'id("state")[text()="online"]', 42 action_runner.Wait(1)
42 'condition': 'element' 43 action_runner.WaitForElement('button[id="offline"]:not(disabled)')
43 }))
44 action_runner.RunAction(WaitAction(
45 {
46 "seconds": 1
47 }))
48 action_runner.RunAction(WaitAction(
49 {
50 'condition': 'element',
51 'selector': 'button[id="offline"]:not(disabled)'
52 }))
53 action_runner.RunAction(ClickElementAction( 44 action_runner.RunAction(ClickElementAction(
54 { 45 {
55 'selector': 'button[id="offline"]:not(disabled)' 46 'selector': 'button[id="offline"]:not(disabled)'
56 })) 47 }))
57 action_runner.RunAction(WaitAction( 48 action_runner.WaitForElement(
58 { 49 element_function=_CreateXpathFunction('id("state")[text()="offline"]'))
59 'xpath': 'id("state")[text()="offline"]',
60 'condition': 'element'
61 }))
62 50
63 51
64 class IndexeddbOfflinePageSet(page_set_module.PageSet): 52 class IndexeddbOfflinePageSet(page_set_module.PageSet):
65 53
66 """ Chrome Endure test for IndexedDB. """ 54 """ Chrome Endure test for IndexedDB. """
67 55
68 def __init__(self): 56 def __init__(self):
69 super(IndexeddbOfflinePageSet, self).__init__( 57 super(IndexeddbOfflinePageSet, self).__init__(
70 user_agent_type='desktop') 58 user_agent_type='desktop')
71 59
72 self.AddPage(IndexeddbOfflinePage(self)) 60 self.AddPage(IndexeddbOfflinePage(self))
OLDNEW
« no previous file with comments | « tools/perf/page_sets/image_decoding_measurement.py ('k') | tools/perf/page_sets/key_desktop_sites.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698