OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 logging | 5 import logging |
6 import os | 6 import os |
7 import unittest | 7 import unittest |
8 | 8 |
9 from telemetry.core import browser_credentials | 9 from telemetry.core import browser_credentials |
10 from telemetry.core import discover | 10 from telemetry.core import discover |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 except browser_credentials.CredentialsError: | 54 except browser_credentials.CredentialsError: |
55 self.fail(fail_message) | 55 self.fail(fail_message) |
56 | 56 |
57 def CheckAttributes(self, page_set): | 57 def CheckAttributes(self, page_set): |
58 """Verify that page_set and its page's base attributes have the right types. | 58 """Verify that page_set and its page's base attributes have the right types. |
59 """ | 59 """ |
60 self.CheckAttributesOfPageSetBasicAttributes(page_set) | 60 self.CheckAttributesOfPageSetBasicAttributes(page_set) |
61 for page in page_set.pages: | 61 for page in page_set.pages: |
62 self.CheckAttributesOfPageBasicAttributes(page) | 62 self.CheckAttributesOfPageBasicAttributes(page) |
63 | 63 |
| 64 def CheckNoMixedInBetweenLegacyRunMethodsAndRunPageInteractions( |
| 65 self, page_set): |
| 66 # This test is to make sure that page has been converted to use single |
| 67 # RunPageInteractions does not contain legacy run method. |
| 68 # For more context see: crbug.com/418375 |
| 69 # TODO(nednguyen, ernstm): remove this test when crbug.com/418375 is marked |
| 70 # fixed. |
| 71 LEGACY_RUN_METHODS = [ |
| 72 'RunMediaMetrics', |
| 73 'RunNoOp', |
| 74 'RunRepaint', |
| 75 'RunPrepareForScreenShot', |
| 76 'RunSmoothness', |
| 77 'RunWebrtc' |
| 78 ] |
| 79 for page in page_set.pages: |
| 80 if hasattr(page, 'RunPageInteractions'): |
| 81 for legacy_run_method in LEGACY_RUN_METHODS: |
| 82 self.assertTrue( |
| 83 not hasattr(page, legacy_run_method), |
| 84 msg=('page %s in page_set %s has both legacy Run.. methods and ' |
| 85 'RunPageInteractions defined. ' % ( |
| 86 page, page_set.file_path))) |
| 87 |
64 def CheckAttributesOfPageSetBasicAttributes(self, page_set): | 88 def CheckAttributesOfPageSetBasicAttributes(self, page_set): |
65 if page_set.file_path is not None: | 89 if page_set.file_path is not None: |
66 self.assertTrue( | 90 self.assertTrue( |
67 isinstance(page_set.file_path, str), | 91 isinstance(page_set.file_path, str), |
68 msg='page_set %\'s file_path must have type string') | 92 msg='page_set %\'s file_path must have type string') |
69 | 93 |
70 self.assertTrue( | 94 self.assertTrue( |
71 isinstance(page_set.archive_data_file, str), | 95 isinstance(page_set.archive_data_file, str), |
72 msg='page_set\'s archive_data_file path must have type string') | 96 msg='page_set\'s archive_data_file path must have type string') |
73 | 97 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 for page_set_class in page_sets: | 132 for page_set_class in page_sets: |
109 if not classes.IsDirectlyConstructable(page_set_class): | 133 if not classes.IsDirectlyConstructable(page_set_class): |
110 # We can't test page sets that aren't directly constructable since we | 134 # We can't test page sets that aren't directly constructable since we |
111 # don't know what arguments to put for the constructor. | 135 # don't know what arguments to put for the constructor. |
112 continue | 136 continue |
113 page_set = page_set_class() | 137 page_set = page_set_class() |
114 logging.info('Testing %s', page_set.file_path) | 138 logging.info('Testing %s', page_set.file_path) |
115 self.CheckArchive(page_set) | 139 self.CheckArchive(page_set) |
116 self.CheckCredentials(page_set) | 140 self.CheckCredentials(page_set) |
117 self.CheckAttributes(page_set) | 141 self.CheckAttributes(page_set) |
| 142 self.CheckNoMixedInBetweenLegacyRunMethodsAndRunPageInteractions(page_set) |
OLD | NEW |