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
3 # found in the LICENSE file.
10 class FieldTrialUtilUnittest(unittest
.TestCase
):
12 def test_GenArgsEmptyPaths(self
):
13 args
= fieldtrial_util
.GenerateArgs('', '')
14 self
.assertEqual([], args
)
16 def test_GenArgsOneConfig(self
):
17 with tempfile
.NamedTemporaryFile('w') as base_file
:
20 { "group_name": "Enabled" }
25 "params": {"url": "http://www.google.com"}
30 "group_name": "Default",
31 "params": {"id": "abc"}
35 base_file
.write(config
)
38 result
= fieldtrial_util
.GenerateArgs(base_file
.name
)
39 self
.assertEqual(['--force-fieldtrials='
40 'BrowserBlackList/Enabled/c/d./SimpleParams/Default',
41 '--force-fieldtrial-params='
42 'c.d%2E:url/http%3A%2F%2Fwww%2Egoogle%2Ecom,'
43 'SimpleParams.Default:id/abc'], result
)
45 def test_GenArgsOverrideConfig(self
):
46 with tempfile
.NamedTemporaryFile('w') as base_file
:
55 base_file
.write(config
)
57 with tempfile
.NamedTemporaryFile('w') as platform_file
:
63 { "group_name": "bgroup" }
66 platform_file
.write(config
)
68 result
= fieldtrial_util
.GenerateArgs(base_file
.name
,
70 self
.assertEqual(['--force-fieldtrials='
71 'a/1/c/d/b/bgroup'], result
)
73 if __name__
== '__main__':