summaryrefslogtreecommitdiffstats
path: root/tools/telemetry
diff options
context:
space:
mode:
authordtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-20 21:12:49 +0000
committerdtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-20 21:12:49 +0000
commitfc779cfea4cc72c51c96385d57b028c64d647c7c (patch)
tree030e442b12e7d0a4b9d1635b7b51638bd63fd7df /tools/telemetry
parent53d90b1b59f79b025b3dc2fe7b0188979efb61ea (diff)
downloadchromium_src-fc779cfea4cc72c51c96385d57b028c64d647c7c.zip
chromium_src-fc779cfea4cc72c51c96385d57b028c64d647c7c.tar.gz
chromium_src-fc779cfea4cc72c51c96385d57b028c64d647c7c.tar.bz2
[telemetry] Move actions into page/actions. Drop the _action suffix for them.
Also, remove the "ing" from "scrolling," condense the page sets, and normalize them to use 2-space indent. BUG=168431 TEST=./run_multipage_benchmarks --browser=release smoothness_benchmark page_sets/top_25.json Review URL: https://codereview.chromium.org/12760010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@189403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/telemetry')
-rw-r--r--tools/telemetry/telemetry/page/actions/all_page_actions.py (renamed from tools/telemetry/telemetry/page/all_page_actions.py)6
-rw-r--r--tools/telemetry/telemetry/page/actions/click_element.py (renamed from tools/telemetry/telemetry/page/click_element_action.py)2
-rw-r--r--tools/telemetry/telemetry/page/actions/click_element_unittest.py (renamed from tools/telemetry/telemetry/page/click_element_action_unittest.py)10
-rw-r--r--tools/telemetry/telemetry/page/actions/page_action.py (renamed from tools/telemetry/telemetry/page/page_action.py)0
-rw-r--r--tools/telemetry/telemetry/page/actions/scroll.js (renamed from tools/telemetry/telemetry/page/scrolling_action.js)28
-rw-r--r--tools/telemetry/telemetry/page/actions/scroll.py (renamed from tools/telemetry/telemetry/page/scrolling_action.py)26
-rw-r--r--tools/telemetry/telemetry/page/actions/scroll_unittest.py (renamed from tools/telemetry/telemetry/page/scrolling_action_unittest.py)28
-rw-r--r--tools/telemetry/telemetry/page/actions/wait.py (renamed from tools/telemetry/telemetry/page/wait_action.py)2
-rw-r--r--tools/telemetry/telemetry/page/actions/wait_unittest.py (renamed from tools/telemetry/telemetry/page/wait_action_unittest.py)6
-rwxr-xr-xtools/telemetry/telemetry/page/page_benchmark_runner.py1
-rw-r--r--tools/telemetry/telemetry/page/page_benchmark_unittest.py4
-rw-r--r--tools/telemetry/telemetry/page/page_benchmark_unittest_base.py2
-rw-r--r--tools/telemetry/telemetry/page/page_test.py4
-rw-r--r--tools/telemetry/telemetry/page/page_test_unittest.py4
14 files changed, 61 insertions, 62 deletions
diff --git a/tools/telemetry/telemetry/page/all_page_actions.py b/tools/telemetry/telemetry/page/actions/all_page_actions.py
index 6803069..9d49c2f 100644
--- a/tools/telemetry/telemetry/page/all_page_actions.py
+++ b/tools/telemetry/telemetry/page/actions/all_page_actions.py
@@ -3,13 +3,13 @@
# found in the LICENSE file.
import os
+from telemetry.page.actions import page_action
from telemetry.test import discover
-from telemetry.page import page_action
_page_action_classes = discover.Discover(
os.path.dirname(__file__),
- os.path.join(os.path.dirname(__file__), '..', '..'),
- 'action',
+ os.path.join(os.path.dirname(__file__), '..', '..', '..'),
+ '',
page_action.PageAction,
import_error_should_raise=True)
diff --git a/tools/telemetry/telemetry/page/click_element_action.py b/tools/telemetry/telemetry/page/actions/click_element.py
index ff1784c..8d4aa79 100644
--- a/tools/telemetry/telemetry/page/click_element_action.py
+++ b/tools/telemetry/telemetry/page/actions/click_element.py
@@ -4,7 +4,7 @@
from telemetry.core import util
from telemetry.core import exceptions
from telemetry.page import page as page_module
-from telemetry.page import page_action
+from telemetry.page.actions import page_action
class ClickElementAction(page_action.PageAction):
def __init__(self, attributes=None):
diff --git a/tools/telemetry/telemetry/page/click_element_action_unittest.py b/tools/telemetry/telemetry/page/actions/click_element_unittest.py
index 89a622aeb..c65561e 100644
--- a/tools/telemetry/telemetry/page/click_element_action_unittest.py
+++ b/tools/telemetry/telemetry/page/actions/click_element_unittest.py
@@ -3,13 +3,13 @@
# found in the LICENSE file.
import os
-from telemetry.page import click_element_action
+from telemetry.page.actions import click_element
from telemetry.test import tab_test_case
class ClickElementActionTest(tab_test_case.TabTestCase):
def testClickWithSelectorWaitForNavigation(self):
unittest_data_dir = os.path.join(os.path.dirname(__file__),
- '..', '..', 'unittest_data')
+ '..', '..', '..', 'unittest_data')
self._browser.SetHTTPServerDirectory(unittest_data_dir)
self._tab.Navigate(
self._browser.http_server.UrlOf('page_with_link.html'))
@@ -19,7 +19,7 @@ class ClickElementActionTest(tab_test_case.TabTestCase):
'/page_with_link.html')
data = {'selector': 'a[id="clickme"]', 'wait_for_navigation': True}
- i = click_element_action.ClickElementAction(data)
+ i = click_element.ClickElementAction(data)
i.RunAction(None, self._tab, None)
self.assertEquals(
@@ -28,7 +28,7 @@ class ClickElementActionTest(tab_test_case.TabTestCase):
def testClickWithTextWaitForRefChange(self):
unittest_data_dir = os.path.join(os.path.dirname(__file__),
- '..', '..', 'unittest_data')
+ '..', '..', '..', 'unittest_data')
self._browser.SetHTTPServerDirectory(unittest_data_dir)
self._tab.Navigate(
self._browser.http_server.UrlOf('page_with_link.html'))
@@ -38,7 +38,7 @@ class ClickElementActionTest(tab_test_case.TabTestCase):
'/page_with_link.html')
data = {'text': 'Click me', 'wait_for_href_change': True}
- i = click_element_action.ClickElementAction(data)
+ i = click_element.ClickElementAction(data)
i.RunAction(None, self._tab, None)
self.assertEquals(
diff --git a/tools/telemetry/telemetry/page/page_action.py b/tools/telemetry/telemetry/page/actions/page_action.py
index 8ac0f65..8ac0f65 100644
--- a/tools/telemetry/telemetry/page/page_action.py
+++ b/tools/telemetry/telemetry/page/actions/page_action.py
diff --git a/tools/telemetry/telemetry/page/scrolling_action.js b/tools/telemetry/telemetry/page/actions/scroll.js
index 34362d6..2ccfece 100644
--- a/tools/telemetry/telemetry/page/scrolling_action.js
+++ b/tools/telemetry/telemetry/page/actions/scroll.js
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This file provides the ScrollingAction object, which scrolls a page
+// This file provides the ScrollAction object, which scrolls a page
// from top to bottom:
-// 1. var action = new __ScrollingAction(callback)
+// 1. var action = new __ScrollAction(callback)
// 2. action.start(element_to_scroll)
'use strict';
@@ -34,8 +34,8 @@
})().bind(window);
/**
- * Scrolls a given element down a certain amount to emulate user scrolling.
- * Uses smooth scrolling capabilities provided by the platform, if available.
+ * Scrolls a given element down a certain amount to emulate user scroll.
+ * Uses smooth scroll capabilities provided by the platform, if available.
* @constructor
*/
function SmoothScrollDownGesture(opt_element) {
@@ -89,9 +89,9 @@
// The page is scrolled down by a set of scroll gestures. These gestures
// correspond to a reading gesture on that platform.
//
- // start -> startPass_ -> ...scrolling... -> onGestureComplete_ ->
- // -> startPass_ -> .. scrolling... -> onGestureComplete_ -> callback_
- function ScrollingAction(opt_callback) {
+ // start -> startPass_ -> ...scroll... -> onGestureComplete_ ->
+ // -> startPass_ -> .. scroll... -> onGestureComplete_ -> callback_
+ function ScrollAction(opt_callback) {
var self = this;
this.beginMeasuringHook = function() {}
@@ -100,7 +100,7 @@
this.callback_ = opt_callback;
}
- ScrollingAction.prototype.getRemainingScrollDistance_ = function() {
+ ScrollAction.prototype.getRemainingScrollDistance_ = function() {
var clientHeight;
// clientHeight is "special" for the body element.
if (this.element_ == document.body)
@@ -111,7 +111,7 @@
return this.scrollHeight_ - this.element_.scrollTop - clientHeight;
}
- ScrollingAction.prototype.start = function(opt_element) {
+ ScrollAction.prototype.start = function(opt_element) {
// Assign this.element_ here instead of constructor, because the constructor
// ensures this method will be called after the document is loaded.
this.element_ = opt_element || document.body;
@@ -123,7 +123,7 @@
requestAnimationFrame(this.startPass_.bind(this));
};
- ScrollingAction.prototype.startPass_ = function() {
+ ScrollAction.prototype.startPass_ = function() {
this.element_.scrollTop = 0;
this.beginMeasuringHook();
@@ -133,11 +133,11 @@
this.onGestureComplete_.bind(this));
};
- ScrollingAction.prototype.getResults = function() {
+ ScrollAction.prototype.getResults = function() {
return this.renderingStats_;
}
- ScrollingAction.prototype.onGestureComplete_ = function(timestamp) {
+ ScrollAction.prototype.onGestureComplete_ = function(timestamp) {
// If the scrollHeight went down, only scroll to the new scrollHeight.
// -1 to allow for rounding errors on scaled viewports (like mobile).
this.scrollHeight_ = Math.min(this.scrollHeight_,
@@ -156,6 +156,6 @@
this.callback_();
};
- window.__ScrollingAction = ScrollingAction;
- window.__ScrollingAction_GetBoundingVisibleRect = getBoundingVisibleRect;
+ window.__ScrollAction = ScrollAction;
+ window.__ScrollAction_GetBoundingVisibleRect = getBoundingVisibleRect;
})();
diff --git a/tools/telemetry/telemetry/page/scrolling_action.py b/tools/telemetry/telemetry/page/actions/scroll.py
index 6e1d293..6d12feb2 100644
--- a/tools/telemetry/telemetry/page/scrolling_action.py
+++ b/tools/telemetry/telemetry/page/actions/scroll.py
@@ -4,23 +4,23 @@
import os
from telemetry.core import util
-from telemetry.page import page_action
+from telemetry.page.actions import page_action
-class ScrollingAction(page_action.PageAction):
+class ScrollAction(page_action.PageAction):
def __init__(self, attributes=None):
- super(ScrollingAction, self).__init__(attributes)
+ super(ScrollAction, self).__init__(attributes)
def WillRunAction(self, page, tab):
with open(
os.path.join(os.path.dirname(__file__),
- 'scrolling_action.js')) as f:
+ 'scroll.js')) as f:
js = f.read()
tab.ExecuteJavaScript(js)
tab.ExecuteJavaScript("""
- window.__scrollingActionDone = false;
- window.__scrollingAction = new __ScrollingAction(function() {
- window.__scrollingActionDone = true;
+ window.__scrollActionDone = false;
+ window.__scrollAction = new __ScrollAction(function() {
+ window.__scrollActionDone = true;
});
""")
@@ -33,22 +33,22 @@ class ScrollingAction(page_action.PageAction):
if hasattr(self, 'scrollable_element_function'):
tab.ExecuteJavaScript("""
(%s)(function(element) {
- window.__scrollingAction.start(element);
+ window.__scrollAction.start(element);
});""" % (self.scrollable_element_function))
else:
tab.ExecuteJavaScript(
- 'window.__scrollingAction.start(document.body);')
+ 'window.__scrollAction.start(document.body);')
# Poll for scroll benchmark completion.
util.WaitFor(lambda: tab.EvaluateJavaScript(
- 'window.__scrollingActionDone'), 60)
+ 'window.__scrollActionDone'), 60)
def CanBeBound(self):
return True
def BindMeasurementJavaScript(self, tab, start_js, stop_js):
- # Make the scrolling action start and stop measurement automatically.
+ # Make the scroll action start and stop measurement automatically.
tab.ExecuteJavaScript("""
- window.__scrollingAction.beginMeasuringHook = function() { %s };
- window.__scrollingAction.endMeasuringHook = function() { %s };
+ window.__scrollAction.beginMeasuringHook = function() { %s };
+ window.__scrollAction.endMeasuringHook = function() { %s };
""" % (start_js, stop_js))
diff --git a/tools/telemetry/telemetry/page/scrolling_action_unittest.py b/tools/telemetry/telemetry/page/actions/scroll_unittest.py
index ac4c491..aff65b5 100644
--- a/tools/telemetry/telemetry/page/scrolling_action_unittest.py
+++ b/tools/telemetry/telemetry/page/actions/scroll_unittest.py
@@ -4,14 +4,14 @@
import os
from telemetry.page import page as page_module
-from telemetry.page import scrolling_action
+from telemetry.page.actions import scroll
from telemetry.test import tab_test_case
-class ScrollingActionTest(tab_test_case.TabTestCase):
+class ScrollActionTest(tab_test_case.TabTestCase):
def CreateAndNavigateToPageFromUnittestDataDir(
self, filename, page_attributes):
unittest_data_dir = os.path.join(os.path.dirname(__file__),
- '..', '..', 'unittest_data')
+ '..', '..', '..', 'unittest_data')
self._browser.SetHTTPServerDirectory(unittest_data_dir)
page = page_module.Page(
self._browser.http_server.UrlOf(filename),
@@ -23,11 +23,11 @@ class ScrollingActionTest(tab_test_case.TabTestCase):
return page
- def testScrollingAction(self):
+ def testScrollAction(self):
page = self.CreateAndNavigateToPageFromUnittestDataDir(
"blank.html",
page_attributes={"smoothness": {
- "action": "scrolling_action"
+ "action": "scroll"
}})
# Make page bigger than window so it's scrollable.
self._tab.ExecuteJavaScript("""document.body.style.height =
@@ -36,14 +36,14 @@ class ScrollingActionTest(tab_test_case.TabTestCase):
self.assertEquals(
self._tab.EvaluateJavaScript('document.body.scrollTop'), 0)
- i = scrolling_action.ScrollingAction()
+ i = scroll.ScrollAction()
i.WillRunAction(page, self._tab)
self._tab.ExecuteJavaScript("""
- window.__scrollingAction.beginMeasuringHook = function() {
+ window.__scrollAction.beginMeasuringHook = function() {
window.__didBeginMeasuring = true;
};
- window.__scrollingAction.endMeasuringHook = function() {
+ window.__scrollAction.endMeasuringHook = function() {
window.__didEndMeasuring = true;
};""")
i.RunAction(page, self._tab, None)
@@ -62,7 +62,7 @@ class ScrollingActionTest(tab_test_case.TabTestCase):
self.CreateAndNavigateToPageFromUnittestDataDir('blank.html', {})
with open(
os.path.join(os.path.dirname(__file__),
- 'scrolling_action.js')) as f:
+ 'scroll.js')) as f:
js = f.read()
self._tab.ExecuteJavaScript(js)
@@ -71,7 +71,7 @@ class ScrollingActionTest(tab_test_case.TabTestCase):
# events dispatched by the benchmarks use the center of this rect
# as their location, and this location needs to be within the
# viewport bounds to correctly decide between main-thread and
- # impl-thread scrolling. If the scrollable area were not clipped
+ # impl-thread scroll. If the scrollable area were not clipped
# to the viewport bounds, then the instance used here (the scrollable
# area being more than twice as tall as the viewport) would
# result in a scroll location outside of the viewport bounds.
@@ -79,11 +79,11 @@ class ScrollingActionTest(tab_test_case.TabTestCase):
(2 * window.innerHeight + 1) + 'px';""")
rect_bottom = int(self._tab.EvaluateJavaScript("""
- __ScrollingAction_GetBoundingVisibleRect(document.body).top +
- __ScrollingAction_GetBoundingVisibleRect(document.body).height"""))
+ __ScrollAction_GetBoundingVisibleRect(document.body).top +
+ __ScrollAction_GetBoundingVisibleRect(document.body).height"""))
rect_right = int(self._tab.EvaluateJavaScript("""
- __ScrollingAction_GetBoundingVisibleRect(document.body).left +
- __ScrollingAction_GetBoundingVisibleRect(document.body).width"""))
+ __ScrollAction_GetBoundingVisibleRect(document.body).left +
+ __ScrollAction_GetBoundingVisibleRect(document.body).width"""))
viewport_width = int(self._tab.EvaluateJavaScript('window.innerWidth'))
viewport_height = int(self._tab.EvaluateJavaScript('window.innerHeight'))
diff --git a/tools/telemetry/telemetry/page/wait_action.py b/tools/telemetry/telemetry/page/actions/wait.py
index 2f6afbef..bfe0b27 100644
--- a/tools/telemetry/telemetry/page/wait_action.py
+++ b/tools/telemetry/telemetry/page/actions/wait.py
@@ -4,7 +4,7 @@
import time
from telemetry.core import util
-from telemetry.page import page_action
+from telemetry.page.actions import page_action
class WaitAction(page_action.PageAction):
DEFAULT_TIMEOUT = 60
diff --git a/tools/telemetry/telemetry/page/wait_action_unittest.py b/tools/telemetry/telemetry/page/actions/wait_unittest.py
index 8d6b433..f3d111a 100644
--- a/tools/telemetry/telemetry/page/wait_action_unittest.py
+++ b/tools/telemetry/telemetry/page/actions/wait_unittest.py
@@ -4,13 +4,13 @@
import os
import time
-from telemetry.page import wait_action
+from telemetry.page.actions import wait
from telemetry.test import tab_test_case
class WaitActionTest(tab_test_case.TabTestCase):
def testWaitAction(self):
unittest_data_dir = os.path.join(os.path.dirname(__file__),
- '..', '..', 'unittest_data')
+ '..', '..', '..', 'unittest_data')
self._browser.SetHTTPServerDirectory(unittest_data_dir)
self._tab.Navigate(
self._browser.http_server.UrlOf('blank.html'))
@@ -19,7 +19,7 @@ class WaitActionTest(tab_test_case.TabTestCase):
self._tab.EvaluateJavaScript('document.location.pathname;'),
'/blank.html')
- i = wait_action.WaitAction({ 'condition': 'duration', 'seconds': 1 })
+ i = wait.WaitAction({ 'condition': 'duration', 'seconds': 1 })
start_time = time.time()
i.RunAction(None, self._tab, None)
diff --git a/tools/telemetry/telemetry/page/page_benchmark_runner.py b/tools/telemetry/telemetry/page/page_benchmark_runner.py
index 5ba4591..4899e99f 100755
--- a/tools/telemetry/telemetry/page/page_benchmark_runner.py
+++ b/tools/telemetry/telemetry/page/page_benchmark_runner.py
@@ -9,7 +9,6 @@ import sys
from telemetry.core import browser_finder
from telemetry.core import browser_options
-from telemetry.page import all_page_actions # pylint: disable=W0611
from telemetry.page import block_page_benchmark_results
from telemetry.page import csv_page_benchmark_results
from telemetry.page import page_benchmark
diff --git a/tools/telemetry/telemetry/page/page_benchmark_unittest.py b/tools/telemetry/telemetry/page/page_benchmark_unittest.py
index 09becec..5ab908f 100644
--- a/tools/telemetry/telemetry/page/page_benchmark_unittest.py
+++ b/tools/telemetry/telemetry/page/page_benchmark_unittest.py
@@ -8,9 +8,10 @@ from telemetry.core import wpr_modes
from telemetry.page import page_benchmark
from telemetry.page import page_benchmark_unittest_base
from telemetry.page import page as page_module
-from telemetry.page import page_action
from telemetry.page import page_set
from telemetry.page import page_set_archive_info
+from telemetry.page.actions import all_page_actions
+from telemetry.page.actions import page_action
from telemetry.test import options_for_unittests
class BenchThatFails(page_benchmark.PageBenchmark):
@@ -137,7 +138,6 @@ class PageBenchmarkUnitTest(
class MockAction(page_action.PageAction):
def RunAction(self, page, tab, previous_action):
action_called[0] = True
- from telemetry.page import all_page_actions
all_page_actions.RegisterClassForTest('mock', MockAction)
ps = self.CreatePageSetFromFileInUnittestDataDir('blank.html')
diff --git a/tools/telemetry/telemetry/page/page_benchmark_unittest_base.py b/tools/telemetry/telemetry/page/page_benchmark_unittest_base.py
index 2cf1026..5face3e 100644
--- a/tools/telemetry/telemetry/page/page_benchmark_unittest_base.py
+++ b/tools/telemetry/telemetry/page/page_benchmark_unittest_base.py
@@ -23,7 +23,7 @@ class PageBenchmarkUnitTestBase(unittest.TestCase):
base_dir = os.path.dirname(__file__)
ps = page_set.PageSet(file_path=os.path.join(base_dir, 'foo.json'))
page = page_module.Page(test_filename, ps, base_dir=base_dir)
- setattr(page, 'smoothness', {'action': 'scrolling_action'})
+ setattr(page, 'smoothness', {'action': 'scroll'})
ps.pages.append(page)
return ps
diff --git a/tools/telemetry/telemetry/page/page_test.py b/tools/telemetry/telemetry/page/page_test.py
index bb0753d..2e9390b 100644
--- a/tools/telemetry/telemetry/page/page_test.py
+++ b/tools/telemetry/telemetry/page/page_test.py
@@ -3,8 +3,8 @@
# found in the LICENSE file.
import logging
-from telemetry.page import all_page_actions
-from telemetry.page import page_action
+from telemetry.page.actions import all_page_actions
+from telemetry.page.actions import page_action
def _GetActionFromData(action_data):
action_name = action_data['action']
diff --git a/tools/telemetry/telemetry/page/page_test_unittest.py b/tools/telemetry/telemetry/page/page_test_unittest.py
index 7530d4e..6b68d9d2 100644
--- a/tools/telemetry/telemetry/page/page_test_unittest.py
+++ b/tools/telemetry/telemetry/page/page_test_unittest.py
@@ -4,10 +4,10 @@
import os
import unittest
-from telemetry.page import all_page_actions
from telemetry.page import page as page_module
-from telemetry.page import page_action
from telemetry.page import page_test
+from telemetry.page.actions import all_page_actions
+from telemetry.page.actions import page_action
def _CreatePage(test_filename):
url = 'file:///' + os.path.join('..', '..', 'unittest_data', test_filename)