Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / indexeddb_offline.py
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.
4 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
8
9
10 class IndexeddbOfflinePage(page_module.Page):
11
12   """ Why: Simulates user input while offline and sync while online. """
13
14   def __init__(self, page_set):
15     super(IndexeddbOfflinePage, self).__init__(
16       url='file://endure/indexeddb_app.html',
17       page_set=page_set,
18       name='indexeddb_offline')
19     self.user_agent_type = 'desktop'
20
21   def RunNavigateSteps(self, action_runner):
22     action_runner.RunAction(NavigateAction())
23     action_runner.RunAction(WaitAction(
24         {
25             'text': 'initialized',
26             'condition': 'element'
27         }))
28
29   def RunEndure(self, action_runner):
30     action_runner.RunAction(WaitAction(
31         {
32             'condition': 'element',
33             'selector': 'button[id="online"]:not(disabled)'
34         }))
35     action_runner.RunAction(ClickElementAction(
36         {
37             'selector': 'button[id="online"]:not(disabled)'
38         }))
39     action_runner.RunAction(WaitAction(
40         {
41             'xpath': 'id("state")[text()="online"]',
42             'condition': 'element'
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(
54         {
55             'selector': 'button[id="offline"]:not(disabled)'
56         }))
57     action_runner.RunAction(WaitAction(
58         {
59             'xpath': 'id("state")[text()="offline"]',
60             'condition': 'element'
61         }))
62
63
64 class IndexeddbOfflinePageSet(page_set_module.PageSet):
65
66   """ Chrome Endure test for IndexedDB. """
67
68   def __init__(self):
69     super(IndexeddbOfflinePageSet, self).__init__(
70         user_agent_type='desktop')
71
72     self.AddPage(IndexeddbOfflinePage(self))