summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-23 09:20:10 +0000
committermarja@chromium.org <marja@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-11-23 09:20:10 +0000
commit7e0088fd44631669894798dc23b4faf146e9ab8d (patch)
tree6f9c0a767d584fcdda6dbc60c3e55bb35fcdb68c
parentdb4aacf545e3a9a47f25affeef20c479b673bc91 (diff)
downloadchromium_src-7e0088fd44631669894798dc23b4faf146e9ab8d.zip
chromium_src-7e0088fd44631669894798dc23b4faf146e9ab8d.tar.gz
chromium_src-7e0088fd44631669894798dc23b4faf146e9ab8d.tar.bz2
Telemetry: adding memory tests & solving problems on the go.
BUG=158323 Review URL: https://codereview.chromium.org/11416134 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169322 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--tools/perf/page_sets/top_25.json136
-rw-r--r--tools/telemetry/telemetry/click_element_interaction.py51
-rw-r--r--tools/telemetry/telemetry/click_element_interaction_unittest.py42
-rw-r--r--tools/telemetry/telemetry/click_to_navigate_interaction.py16
-rw-r--r--tools/telemetry/telemetry/click_to_navigate_interaction_unittest.py25
5 files changed, 223 insertions, 47 deletions
diff --git a/tools/perf/page_sets/top_25.json b/tools/perf/page_sets/top_25.json
index c35bde7..2d46487 100644
--- a/tools/perf/page_sets/top_25.json
+++ b/tools/perf/page_sets/top_25.json
@@ -8,6 +8,67 @@
"why": "top google property; a google tab is often open",
"scrolling": {
"action": "scrolling_interaction"
+ },
+ "stress_memory": {
+ "action": "compound_interaction",
+ "actions": [
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Next",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Next",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Next",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Previous",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Previous",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Previous",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "scrolling_interaction"
+ },
+ {
+ "action": "click_element_interaction",
+ "text": "Images",
+ "wait_for_href_change": true
+ }
+ ]
}
},
{
@@ -18,6 +79,21 @@
"scrolling": {
"action": "scrolling_interaction",
"scrollable_element_function": "function(callback) { gmonkey.load('2.0', function(api) { callback(api.getScrollableElement()); }); }"
+ },
+ "stress_memory": {
+ "action": "compound_interaction",
+ "actions": [
+ {
+ "action": "click_element_interaction",
+ "selector": "a[href=\"https://mail.google.com/mail/u/0/?shva=1#starred\"]",
+ "wait_for_href_change": true
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "a[href=\"https://mail.google.com/mail/u/0/?shva=1#inbox\"]",
+ "wait_for_href_change": true
+ }
+ ]
}
},
{
@@ -27,6 +103,51 @@
"scrolling": {
"action": "scrolling_interaction",
"scrollable_element_function": "function(callback) { callback(document.getElementById('scrolltimedeventswk')); }"
+ },
+ "stress_memory": {
+ "action": "compound_interaction",
+ "actions": [
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navForward\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navForward\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navForward\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navForward\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navBack\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navBack\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navBack\"]",
+ "wait_for_seconds": 0.1
+ },
+ {
+ "action": "click_element_interaction",
+ "selector": "div[class~=\"navBack\"]",
+ "wait_for_seconds": 0.1
+ }
+ ]
}
},
{
@@ -94,16 +215,19 @@
"action": "compound_interaction",
"actions": [
{
- "action": "click_to_navigate_interaction",
- "selector": "a[href=\"http://www.facebook.com/WomenforObama\"]"
+ "action": "click_element_interaction",
+ "selector": "a[href=\"http://www.facebook.com/WomenforObama\"]",
+ "wait_for_navigate": true
},
{
- "action": "click_to_navigate_interaction",
- "selector": "a[href=\"http://www.facebook.com/WomenforObama/info\"]"
+ "action": "click_element_interaction",
+ "selector": "a[href=\"http://www.facebook.com/WomenforObama/info\"]",
+ "wait_for_navigate": true
},
{
- "action": "click_to_navigate_interaction",
- "selector": "a[href=\"http://www.facebook.com/?ref=tn_tnmn\"]"
+ "action": "click_element_interaction",
+ "selector": "a[href=\"http://www.facebook.com/?ref=tn_tnmn\"]",
+ "wait_for_navigate": true
}
]
}
diff --git a/tools/telemetry/telemetry/click_element_interaction.py b/tools/telemetry/telemetry/click_element_interaction.py
new file mode 100644
index 0000000..33f714c
--- /dev/null
+++ b/tools/telemetry/telemetry/click_element_interaction.py
@@ -0,0 +1,51 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import time
+
+from telemetry import page_interaction
+from telemetry import util
+
+class ClickElementInteraction(page_interaction.PageInteraction):
+ def __init__(self, attributes=None):
+ super(ClickElementInteraction, self).__init__(attributes)
+
+ def PerformInteraction(self, page, tab):
+ def DoClick():
+ assert hasattr(self, 'selector') or hasattr(self, 'text')
+ if hasattr(self, 'selector'):
+ code = 'document.querySelector(\'' + self.selector + '\').click();'
+ tab.runtime.Execute(code)
+ else:
+ click_element = """
+ function clickElement(element, text) {
+ if (element.innerHTML == text) {
+ element.click();
+ return true;
+ }
+ for (var i in element.childNodes) {
+ if (clickElement(element.childNodes[i], text))
+ return true;
+ }
+ return false;
+ }"""
+ tab.runtime.Execute(click_element)
+ code = 'clickElement(document, "' + self.text + '");'
+ if not tab.runtime.Evaluate(code):
+ raise page_interaction.PageInteractionFailed(
+ 'Cannot find element with text ' + self.text)
+
+ if hasattr(self, 'wait_for_navigate'):
+ tab.page.PerformActionAndWaitForNavigate(DoClick)
+ elif hasattr(self, 'wait_for_href_change'):
+ old_url = tab.runtime.Evaluate('document.location.href')
+ DoClick()
+ util.WaitFor(lambda: tab.runtime.Evaluate(
+ 'document.location.href') != old_url, 60)
+ elif hasattr(self, 'wait_seconds'):
+ time.sleep(self.wait_seconds)
+ DoClick()
+ else:
+ DoClick()
+
+ tab.WaitForDocumentReadyStateToBeComplete()
diff --git a/tools/telemetry/telemetry/click_element_interaction_unittest.py b/tools/telemetry/telemetry/click_element_interaction_unittest.py
new file mode 100644
index 0000000..ebfb240
--- /dev/null
+++ b/tools/telemetry/telemetry/click_element_interaction_unittest.py
@@ -0,0 +1,42 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import os
+
+from telemetry import click_element_interaction
+from telemetry import tab_test_case
+
+class ClickElementInteractionTest(tab_test_case.TabTestCase):
+ def testClickWithSelectorWaitForNavigation(self):
+ unittest_data_dir = os.path.join(os.path.dirname(__file__),
+ '..', 'unittest_data')
+ self._browser.SetHTTPServerDirectory(unittest_data_dir)
+ self._tab.page.Navigate(
+ self._browser.http_server.UrlOf('page_with_link.html'))
+ self._tab.WaitForDocumentReadyStateToBeComplete()
+ self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'),
+ '/page_with_link.html')
+
+ data = {'selector': 'a[id="clickme"]', 'wait_for_navigation': True}
+ i = click_element_interaction.ClickElementInteraction(data)
+ i.PerformInteraction({}, self._tab)
+
+ self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'),
+ '/blank.html')
+
+ def testClickWithTextWaitForRefChange(self):
+ unittest_data_dir = os.path.join(os.path.dirname(__file__),
+ '..', 'unittest_data')
+ self._browser.SetHTTPServerDirectory(unittest_data_dir)
+ self._tab.page.Navigate(
+ self._browser.http_server.UrlOf('page_with_link.html'))
+ self._tab.WaitForDocumentReadyStateToBeComplete()
+ self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'),
+ '/page_with_link.html')
+
+ data = {'text': 'Click me', 'wait_for_href_change': True}
+ i = click_element_interaction.ClickElementInteraction(data)
+ i.PerformInteraction({}, self._tab)
+
+ self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'),
+ '/blank.html')
diff --git a/tools/telemetry/telemetry/click_to_navigate_interaction.py b/tools/telemetry/telemetry/click_to_navigate_interaction.py
deleted file mode 100644
index 3eafcf8..0000000
--- a/tools/telemetry/telemetry/click_to_navigate_interaction.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-from telemetry import page_interaction
-
-class ClickToNavigateInteraction(page_interaction.PageInteraction):
- def __init__(self, attributes=None):
- super(ClickToNavigateInteraction, self).__init__(attributes)
-
- def PerformInteraction(self, page, tab):
- assert self.selector
- code = 'document.querySelector(\'' + self.selector + '\').click();'
- def DoClick():
- tab.runtime.Execute(code)
- tab.page.PerformActionAndWaitForNavigate(DoClick)
- tab.WaitForDocumentReadyStateToBeComplete()
diff --git a/tools/telemetry/telemetry/click_to_navigate_interaction_unittest.py b/tools/telemetry/telemetry/click_to_navigate_interaction_unittest.py
deleted file mode 100644
index f631c2a..0000000
--- a/tools/telemetry/telemetry/click_to_navigate_interaction_unittest.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright (c) 2012 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-import os
-
-from telemetry import click_to_navigate_interaction
-from telemetry import tab_test_case
-
-class ClickToNavigateInteractionTest(tab_test_case.TabTestCase):
- def testClickToNavigateInteraction(self):
- unittest_data_dir = os.path.join(os.path.dirname(__file__),
- '..', 'unittest_data')
- self._browser.SetHTTPServerDirectory(unittest_data_dir)
- self._tab.page.Navigate(
- self._browser.http_server.UrlOf('page_with_link.html'))
- self._tab.WaitForDocumentReadyStateToBeComplete()
- self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'),
- '/page_with_link.html')
-
- data = {'selector': 'a[id="clickme"]'}
- i = click_to_navigate_interaction.ClickToNavigateInteraction(data)
- i.PerformInteraction({}, self._tab)
-
- self.assertEquals(self._tab.runtime.Evaluate('document.location.pathname;'),
- '/blank.html')