| 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 from datetime import datetime | 5 from datetime import datetime |
| 6 | 6 |
| 7 from crash.chrome_crash_buffer import ChromeCrashBuffer |
| 7 from crash.test.predator_testcase import PredatorTestCase | 8 from crash.test.predator_testcase import PredatorTestCase |
| 8 from model import analysis_status | 9 from model import analysis_status |
| 9 from model import result_status | 10 from model import result_status |
| 10 from model.crash.chrome_crash_analysis import ChromeCrashAnalysis | 11 from model.crash.chrome_crash_analysis import ChromeCrashAnalysis |
| 11 | 12 |
| 12 | 13 |
| 13 class ChromeCrashAnalysisTest(PredatorTestCase): | 14 class ChromeCrashAnalysisTest(PredatorTestCase): |
| 14 | 15 |
| 15 def testDoNotUseIdentifiersToSetProperties(self): | 16 def testDoNotUseIdentifiersToSetProperties(self): |
| 16 crash_identifiers = { | 17 crash_identifiers = { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 36 | 37 |
| 37 def testChromeCrashAnalysisCustomizedProperty(self): | 38 def testChromeCrashAnalysisCustomizedProperty(self): |
| 38 analysis = ChromeCrashAnalysis() | 39 analysis = ChromeCrashAnalysis() |
| 39 analysis.historical_metadata = {'chrome_version': '50.0.1200.0', | 40 analysis.historical_metadata = {'chrome_version': '50.0.1200.0', |
| 40 'cpm': 0.5} | 41 'cpm': 0.5} |
| 41 analysis.channel = 'canary' | 42 analysis.channel = 'canary' |
| 42 self.assertEqual(analysis.customized_data, | 43 self.assertEqual(analysis.customized_data, |
| 43 {'historical_metadata': {'chrome_version': '50.0.1200.0', | 44 {'historical_metadata': {'chrome_version': '50.0.1200.0', |
| 44 'cpm': 0.5}, | 45 'cpm': 0.5}, |
| 45 'channel': 'canary'}) | 46 'channel': 'canary'}) |
| 47 |
| 48 def testInitializeWithCrashBuffer(self): |
| 49 findit = self.GetMockFindit() |
| 50 channel = 'dummy channel' |
| 51 historical_metadata = [] |
| 52 crash_data = self.GetDummyCrashData(channel=channel, |
| 53 historical_metadata=historical_metadata) |
| 54 class MockChromeCrashBuffer(ChromeCrashBuffer): |
| 55 |
| 56 def __init__(self, crash_data): |
| 57 super(MockChromeCrashBuffer, self).__init__(crash_data, None) |
| 58 |
| 59 @property |
| 60 def stacktrace(self): |
| 61 return None |
| 62 |
| 63 @property |
| 64 def regression_range(self): |
| 65 return None |
| 66 |
| 67 @property |
| 68 def dependencies(self): |
| 69 return {} |
| 70 |
| 71 @property |
| 72 def dependency_rolls(self): |
| 73 return {} |
| 74 |
| 75 self.mock(findit, 'GetCrashBuffer', |
| 76 lambda crash_data: MockChromeCrashBuffer( # pylint: disable=W0108 |
| 77 crash_data)) |
| 78 |
| 79 crash_buffer = findit.GetCrashBuffer(crash_data) |
| 80 analysis = ChromeCrashAnalysis() |
| 81 analysis.Initialize(crash_buffer) |
| 82 self.assertEqual(analysis.channel, channel) |
| 83 self.assertEqual(analysis.historical_metadata, historical_metadata) |
| OLD | NEW |