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

Side by Side Diff: tools/variations/fieldtrial_to_struct_unittest.py

Issue 2319293006: Use Study and Experiment Terminology on the C++ Side For Fieldtrials (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import unittest 5 import unittest
6 6
7 import fieldtrial_to_struct 7 import fieldtrial_to_struct
8 import os 8 import os
9 9
10 10
(...skipping 30 matching lines...) Expand all
41 { 41 {
42 'platforms': ['win'], 42 'platforms': ['win'],
43 'experiments': [{'name': 'OtherGroup'}] 43 'experiments': [{'name': 'OtherGroup'}]
44 } 44 }
45 ] 45 ]
46 } 46 }
47 result = fieldtrial_to_struct._FieldTrialConfigToDescription(config, 'win') 47 result = fieldtrial_to_struct._FieldTrialConfigToDescription(config, 'win')
48 expected = { 48 expected = {
49 'elements': { 49 'elements': {
50 'kFieldTrialConfig': { 50 'kFieldTrialConfig': {
51 'trials': [ 51 'studies': [
52 { 52 {
53 'name': 'Trial1', 53 'name': 'Trial1',
54 'groups': [ 54 'experiments': [
55 { 55 {
56 'name': 'Group1', 56 'name': 'Group1',
57 'params': [ 57 'params': [
58 {'key': 'x', 'value': '1'}, 58 {'key': 'x', 'value': '1'},
59 {'key': 'y', 'value': '2'} 59 {'key': 'y', 'value': '2'}
60 ], 60 ],
61 'enable_features': ['A', 'B'], 61 'enable_features': ['A', 'B'],
62 'disable_features': ['C'] 62 'disable_features': ['C']
63 }, 63 },
64 { 64 {
65 'name': 'Group2', 65 'name': 'Group2',
66 'params': [ 66 'params': [
67 {'key': 'x', 'value': '3'}, 67 {'key': 'x', 'value': '3'},
68 {'key': 'y', 'value': '4'} 68 {'key': 'y', 'value': '4'}
69 ], 69 ],
70 'enable_features': ['D', 'E'], 70 'enable_features': ['D', 'E'],
71 'disable_features': ['F'] 71 'disable_features': ['F']
72 }, 72 },
73 ], 73 ],
74 }, 74 },
75 { 75 {
76 'name': 'Trial2', 76 'name': 'Trial2',
77 'groups': [{'name': 'OtherGroup'}] 77 'experiments': [{'name': 'OtherGroup'}]
78 }, 78 },
79 ] 79 ]
80 } 80 }
81 } 81 }
82 } 82 }
83 self.maxDiff = None 83 self.maxDiff = None
84 self.assertEqual(expected, result) 84 self.assertEqual(expected, result)
85 85
86 _MULTIPLE_PLATFORM_CONFIG = { 86 _MULTIPLE_PLATFORM_CONFIG = {
87 'Trial1': [ 87 'Trial1': [
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 } 124 }
125 ] 125 ]
126 } 126 }
127 127
128 def test_FieldTrialToDescriptionMultipleSinglePlatformMultipleTrial(self): 128 def test_FieldTrialToDescriptionMultipleSinglePlatformMultipleTrial(self):
129 result = fieldtrial_to_struct._FieldTrialConfigToDescription( 129 result = fieldtrial_to_struct._FieldTrialConfigToDescription(
130 self._MULTIPLE_PLATFORM_CONFIG, 'ios') 130 self._MULTIPLE_PLATFORM_CONFIG, 'ios')
131 expected = { 131 expected = {
132 'elements': { 132 'elements': {
133 'kFieldTrialConfig': { 133 'kFieldTrialConfig': {
134 'trials': [ 134 'studies': [
135 { 135 {
136 'name': 'Trial1', 136 'name': 'Trial1',
137 'groups': [ 137 'experiments': [
138 { 138 {
139 'name': 'Group1', 139 'name': 'Group1',
140 'params': [ 140 'params': [
141 {'key': 'x', 'value': '1'}, 141 {'key': 'x', 'value': '1'},
142 {'key': 'y', 'value': '2'} 142 {'key': 'y', 'value': '2'}
143 ], 143 ],
144 'enable_features': ['A', 'B'], 144 'enable_features': ['A', 'B'],
145 'disable_features': ['C'] 145 'disable_features': ['C']
146 }, 146 },
147 { 147 {
(...skipping 16 matching lines...) Expand all
164 } 164 }
165 self.maxDiff = None 165 self.maxDiff = None
166 self.assertEqual(expected, result) 166 self.assertEqual(expected, result)
167 167
168 def test_FieldTrialToDescriptionMultipleSinglePlatformSingleTrial(self): 168 def test_FieldTrialToDescriptionMultipleSinglePlatformSingleTrial(self):
169 result = fieldtrial_to_struct._FieldTrialConfigToDescription( 169 result = fieldtrial_to_struct._FieldTrialConfigToDescription(
170 self._MULTIPLE_PLATFORM_CONFIG, 'mac') 170 self._MULTIPLE_PLATFORM_CONFIG, 'mac')
171 expected = { 171 expected = {
172 'elements': { 172 'elements': {
173 'kFieldTrialConfig': { 173 'kFieldTrialConfig': {
174 'trials': [ 174 'studies': [
175 { 175 {
176 'name': 'Trial2', 176 'name': 'Trial2',
177 'groups': [ 177 'experiments': [
178 { 178 {
179 'name': 'OtherGroup', 179 'name': 'OtherGroup',
180 }, 180 },
181 ], 181 ],
182 }, 182 },
183 ] 183 ]
184 } 184 }
185 } 185 }
186 } 186 }
187 self.maxDiff = None 187 self.maxDiff = None
(...skipping 21 matching lines...) Expand all
209 cc_filename = test_output_filename + '.cc' 209 cc_filename = test_output_filename + '.cc'
210 with open(cc_filename, 'r') as cc: 210 with open(cc_filename, 'r') as cc:
211 test_cc = cc.read() 211 test_cc = cc.read()
212 with open('unittest_data/expected_output.cc', 'r') as expected: 212 with open('unittest_data/expected_output.cc', 'r') as expected:
213 expected_cc = expected.read() 213 expected_cc = expected.read()
214 self.assertEqual(expected_cc, test_cc) 214 self.assertEqual(expected_cc, test_cc)
215 os.unlink(cc_filename) 215 os.unlink(cc_filename)
216 216
217 if __name__ == '__main__': 217 if __name__ == '__main__':
218 unittest.main() 218 unittest.main()
OLDNEW
« no previous file with comments | « tools/variations/fieldtrial_to_struct.py ('k') | tools/variations/unittest_data/expected_output.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698