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

Unified Diff: headless/lib/browser/devtools_api/client_api_generator_unittest.py

Issue 2473073003: [headless] Refactor headless devtools client API. (Closed)
Patch Set: Address nits Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: headless/lib/browser/devtools_api/client_api_generator_unittest.py
diff --git a/headless/lib/browser/client_api_generator_unittest.py b/headless/lib/browser/devtools_api/client_api_generator_unittest.py
similarity index 89%
rename from headless/lib/browser/client_api_generator_unittest.py
rename to headless/lib/browser/devtools_api/client_api_generator_unittest.py
index 93eb9e6e906a42fd3af1f0e9abc864ae59046b4a..f41ac0920a0d2a641be1c3a4c9c075fc0ecce3dd 100755
--- a/headless/lib/browser/client_api_generator_unittest.py
+++ b/headless/lib/browser/devtools_api/client_api_generator_unittest.py
@@ -352,6 +352,65 @@ class ClientApiGeneratorTest(unittest.TestCase):
types = json_api['domains'][0]['types']
self.assertListEqual(types, expected_types)
+ def test_InitializeDomainDependencies(self):
+ json_api = {
+ 'domains': [
+ {
+ 'domain': 'Domain1',
+ 'types': [
+ {
+ 'id': 'TestType',
+ 'type': 'object',
+ 'properties': [
+ {'name': 'p1', 'type': 'object', '$ref': 'Domain2.TestType'},
+ ],
+ },
+ ],
+ },
+ {
+ 'domain': 'Domain2',
+ 'dependencies': ['Domain3'],
+ 'types': [
+ {
+ 'id': 'TestType',
+ 'type': 'object',
+ 'properties': [
+ {'name': 'p1', 'type': 'object', '$ref': 'Domain1.TestType'},
+ ],
+ },
+ ],
+ },
+ {
+ 'domain': 'Domain3',
+ },
+ {
+ 'domain': 'Domain4',
+ 'dependencies': ['Domain1'],
+ },
+ ]
+ }
+ client_api_generator.InitializeDomainDependencies(json_api)
+
+ dependencies = [ {
+ 'domain': domain['domain'],
+ 'dependencies': domain['dependencies']
+ } for domain in json_api['domains'] ]
+
+ self.assertListEqual(dependencies, [ {
+ "domain": "Domain1",
+ "dependencies": ["Domain1", "Domain2", "Domain3"],
+ }, {
+ "domain": "Domain2",
+ "dependencies": ["Domain1", "Domain2", "Domain3"],
+ }, {
+ "domain": "Domain3",
+ "dependencies": ["Domain3"],
+ }, {
+ "domain": "Domain4",
+ "dependencies": ["Domain1", "Domain2", "Domain3", "Domain4"],
+ }
+ ])
+
def test_PatchExperimentalDomains(self):
json_api = {
'domains': [
@@ -455,10 +514,8 @@ class ClientApiGeneratorTest(unittest.TestCase):
dirname = tempfile.mkdtemp()
jinja_env = client_api_generator.InitializeJinjaEnv(dirname)
client_api_generator.CreateTypeDefinitions(json_api)
- client_api_generator.Generate(jinja_env, dirname, json_api, 'types',
- ['cc'])
- client_api_generator.Generate(jinja_env, dirname, json_api, 'types',
- ['h'])
+ client_api_generator.Generate(jinja_env, dirname, json_api,
+ 'deprecated_types', ['h'])
# This is just a smoke test; we don't actually verify the generated output
# here.
finally:
@@ -490,8 +547,9 @@ class ClientApiGeneratorTest(unittest.TestCase):
try:
dirname = tempfile.mkdtemp()
jinja_env = client_api_generator.InitializeJinjaEnv(dirname)
- client_api_generator.GenerateDomains(jinja_env, dirname, json_api,
- 'domain', ['cc', 'h'])
+ client_api_generator.GeneratePerDomain(
+ jinja_env, dirname, json_api,
+ 'domain', ['cc', 'h'], lambda domain_name: domain_name)
# This is just a smoke test; we don't actually verify the generated output
# here.
finally:

Powered by Google App Engine
This is Rietveld 408576698