Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / tools / perf / page_sets / mobile_memory.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 from telemetry.page import page as page_module
5 from telemetry.page import page_set as page_set_module
6
7
8 class MobileMemoryPage(page_module.Page):
9
10   def __init__(self, url, page_set):
11     super(MobileMemoryPage, self).__init__(
12         url=url, page_set=page_set, credentials_path = 'data/credentials.json')
13     self.user_agent_type = 'mobile'
14     self.archive_data_file = 'data/mobile_memory.json'
15
16
17 class GmailPage(MobileMemoryPage):
18
19   def __init__(self, page_set):
20     super(GmailPage, self).__init__(
21         url='https://mail.google.com/mail/mu',
22         page_set=page_set)
23
24     self.reload_and_gc = [{'action': 'reload'},
25                           {'action': 'wait',
26                            'seconds': 15},
27                           {'action': 'js_collect_garbage'}]
28     self.credentials = 'google'
29
30   def ReloadAndGc(self, action_runner):
31     action_runner.ReloadPage()
32     action_runner.Wait(15)
33     action_runner.ForceGarbageCollection()
34
35   def RunPageInteractions(self, action_runner):
36     for _ in xrange(3):
37       self.ReloadAndGc(action_runner)
38
39
40 class GoogleSearchPage(MobileMemoryPage):
41
42   """ Why: Tests usage of discardable memory """
43
44   def __init__(self, page_set):
45     super(GoogleSearchPage, self).__init__(
46         url='https://www.google.com/search?site=&tbm=isch&q=google',
47         page_set=page_set)
48
49   def RunPageInteractions(self, action_runner):
50     interaction = action_runner.BeginGestureInteraction(
51         'ScrollAction', is_smooth=True)
52     action_runner.ScrollPage()
53     interaction.End()
54     action_runner.Wait(3)
55     interaction = action_runner.BeginGestureInteraction(
56         'ScrollAction', is_smooth=True)
57     action_runner.ScrollPage()
58     interaction.End()
59     action_runner.Wait(3)
60     interaction = action_runner.BeginGestureInteraction(
61         'ScrollAction', is_smooth=True)
62     action_runner.ScrollPage()
63     interaction.End()
64     action_runner.Wait(3)
65     interaction = action_runner.BeginGestureInteraction(
66         'ScrollAction', is_smooth=True)
67     action_runner.ScrollPage()
68     interaction.End()
69     action_runner.WaitForJavaScriptCondition(
70         'document.getElementById("rg_s").childElementCount > 300')
71
72
73 class ScrollPage(MobileMemoryPage):
74
75   def __init__(self, url, page_set):
76     super(ScrollPage, self).__init__(url=url, page_set=page_set)
77
78   def RunPageInteractions(self, action_runner):
79     interaction = action_runner.BeginGestureInteraction(
80         'ScrollAction', is_smooth=True)
81     action_runner.ScrollPage()
82     interaction.End()
83
84
85 class MobileMemoryPageSet(page_set_module.PageSet):
86
87   """ Mobile sites with interesting memory characteristics """
88
89   def __init__(self):
90     super(MobileMemoryPageSet, self).__init__(
91         user_agent_type='mobile',
92         archive_data_file='data/mobile_memory.json',
93         bucket=page_set_module.PARTNER_BUCKET)
94
95     self.AddPage(GmailPage(self))
96     self.AddPage(GoogleSearchPage(self))
97
98     urls_list = [
99       # Why: Renderer process memory bloat
100       'http://techcrunch.com',
101       # pylint: disable=C0301
102       'http://techcrunch.com/2014/02/17/pixel-brings-brings-old-school-video-game-art-to-life-in-your-home/',
103       'http://techcrunch.com/2014/02/15/kickstarter-coins-2/',
104       'http://techcrunch.com/2014/02/15/was-y-combinator-worth-it/',
105     ]
106
107     for url in urls_list:
108       self.AddPage(ScrollPage(url, self))