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

Side by Side Diff: tools/telemetry/telemetry/compound_action_unittest.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 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
5 from telemetry import all_page_actions
6 from telemetry import compound_action
7 from telemetry import page_action
8 from telemetry import tab_test_case
9
10 class AppendAction(page_action.PageAction):
11 def RunAction(self, page, tab, previous_action):
12 self.var.append(True)
13
14 class WrapAppendAction(page_action.PageAction):
15 def RunsPreviousAction(self):
16 return True
17
18 def RunAction(self, page, tab, previous_action):
19 self.var.append('before')
20 previous_action.WillRunAction(page, tab)
21 previous_action.RunAction(page, tab, None)
22 self.var.append('after')
23
24 class CompoundActionTest(tab_test_case.TabTestCase):
25 def __init__(self, *args):
26 super(CompoundActionTest, self).__init__(*args)
27
28 def setUp(self):
29 super(CompoundActionTest, self).setUp()
30 all_page_actions.RegisterClassForTest('append', AppendAction)
31 all_page_actions.RegisterClassForTest('wrap_append', WrapAppendAction)
32
33 def testCompoundAction(self):
34 action1_called = []
35 action2_called = []
36 action = compound_action.CompoundAction({
37 'actions': [
38 { 'action': 'append', 'var': action1_called },
39 { 'action': 'append', 'var': action2_called }
40 ]
41 })
42 action.RunAction(None, self._tab, None)
43 self.assertTrue(action1_called)
44 self.assertTrue(action2_called)
45
46 def testNestedAction(self):
47 action = compound_action.CompoundAction({
48 'actions': [
49 { 'action': 'compound_action', 'actions': [] }
50 ]
51 })
52 action.RunAction(None, self._tab, None)
53
54 def testPreviousAction(self):
55 action_list = []
56 action = compound_action.CompoundAction({
57 'actions': [
58 { 'action': 'append', 'var': action_list },
59 { 'action': 'wrap_append', 'var': action_list }
60 ]
61 })
62 action.RunAction(None, self._tab, None)
63 self.assertEqual(action_list, ['before', True, 'after'])
64
65 def testNestedPreviousAction(self):
66 action_list = []
67 action = compound_action.CompoundAction({
68 'actions': [
69 { 'action': 'append', 'var': action_list },
70 {
71 'action': 'compound_action',
72 'actions': [
73 { 'action': 'wrap_append', 'var': action_list }
74 ]
75 }
76 ]
77 })
78 action.RunAction(None, self._tab, None)
79 self.assertEqual(action_list, ['before', True, 'after'])
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/compound_action.py ('k') | tools/telemetry/telemetry/core/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698