| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 copy | 5 import copy |
| 6 from datetime import datetime | 6 from datetime import datetime |
| 7 | 7 |
| 8 from crash.crash_report import CrashReport |
| 8 from crash.type_enums import CrashClient | 9 from crash.type_enums import CrashClient |
| 9 from crash.test.predator_testcase import PredatorTestCase | 10 from crash.test.predator_testcase import PredatorTestCase |
| 10 from model import analysis_status | 11 from model import analysis_status |
| 11 from model import result_status | 12 from model import result_status |
| 12 from model import triage_status | 13 from model import triage_status |
| 13 from model.crash.crash_analysis import CrashAnalysis | 14 from model.crash.crash_analysis import CrashAnalysis |
| 14 from model.crash.fracas_crash_analysis import FracasCrashAnalysis | 15 from model.crash.fracas_crash_analysis import FracasCrashAnalysis |
| 15 | 16 |
| 16 | 17 |
| 17 class CrashAnalysisTest(PredatorTestCase): | 18 class CrashAnalysisTest(PredatorTestCase): |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 analysis = CrashAnalysis() | 98 analysis = CrashAnalysis() |
| 98 analysis.Update(update) | 99 analysis.Update(update) |
| 99 self.assertFalse(hasattr(analysis, 'dummy')) | 100 self.assertFalse(hasattr(analysis, 'dummy')) |
| 100 | 101 |
| 101 def testCreateCrashAnalysis(self): | 102 def testCreateCrashAnalysis(self): |
| 102 crash_identifiers = {'signature': 'sig'} | 103 crash_identifiers = {'signature': 'sig'} |
| 103 analysis = CrashAnalysis.Create(crash_identifiers) | 104 analysis = CrashAnalysis.Create(crash_identifiers) |
| 104 analysis.put() | 105 analysis.put() |
| 105 self.assertIsNotNone(analysis) | 106 self.assertIsNotNone(analysis) |
| 106 self.assertEqual(CrashAnalysis.Get(crash_identifiers), analysis) | 107 self.assertEqual(CrashAnalysis.Get(crash_identifiers), analysis) |
| 108 |
| 109 def testInitializeByCrashBuffer(self): |
| 110 chrome_version = '50.2500.0.0' |
| 111 signature = 'signature/here' |
| 112 channel = 'canary' |
| 113 platform = 'mac' |
| 114 crash_data = self.GetDummyCrashData( |
| 115 client_id=CrashClient.FRACAS, |
| 116 channel=channel, platform=platform, |
| 117 signature=signature, version=chrome_version, |
| 118 crash_identifiers={'chrome_version': chrome_version, |
| 119 'signature': signature, |
| 120 'channel': channel, |
| 121 'platform': platform, |
| 122 'process_type': 'renderer'}) |
| 123 findit = self.GetMockFindit(client_id=CrashClient.FRACAS) |
| 124 crash_buffer = findit.GetCrashBuffer(crash_data) |
| 125 analysis = CrashAnalysis() |
| 126 analysis.Initialize(crash_buffer) |
| 127 |
| 128 self.assertEqual(analysis.stack_trace, crash_buffer.stacktrace) |
| 129 self.assertEqual(analysis.signature, crash_buffer.signature) |
| 130 self.assertEqual(analysis.platform, crash_buffer.platform) |
| 131 self.assertEqual(analysis.regression_range, crash_buffer.regression_range) |
| 132 self.assertEqual(analysis.dependencies, crash_buffer.dependencies) |
| 133 self.assertEqual(analysis.dependency_rolls, crash_buffer.dependency_rolls) |
| 134 |
| 135 def testToCrashReport(self): |
| 136 chrome_version = '50.2500.0.0' |
| 137 signature = 'signature/here' |
| 138 channel = 'canary' |
| 139 platform = 'mac' |
| 140 regression_range = ('50.2450.0.2', '50.2982.0.0') |
| 141 crash_data = self.GetDummyCrashData( |
| 142 client_id=CrashClient.FRACAS, |
| 143 channel=channel, platform=platform, |
| 144 signature=signature, version=chrome_version, |
| 145 regression_range=regression_range, |
| 146 crash_identifiers={'chrome_version': chrome_version, |
| 147 'signature': signature, |
| 148 'channel': channel, |
| 149 'platform': platform, |
| 150 'process_type': 'renderer'}) |
| 151 findit = self.GetMockFindit(client_id=CrashClient.FRACAS) |
| 152 crash_buffer = findit.GetCrashBuffer(crash_data) |
| 153 analysis = CrashAnalysis() |
| 154 analysis.Initialize(crash_buffer) |
| 155 |
| 156 expected_crash_report = CrashReport(chrome_version, signature, platform, |
| 157 None, regression_range, {}, {}) |
| 158 self.assertTupleEqual(analysis.ToCrashReport(), expected_crash_report) |
| OLD | NEW |