| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 import logging | 6 import logging |
| 7 import os | 7 import os |
| 8 import pickle | 8 import pickle |
| 9 import re | 9 import re |
| 10 import shutil |
| 11 import tempfile |
| 10 | 12 |
| 11 from devil.android import apk_helper | 13 from devil.android import apk_helper |
| 12 from devil.android import md5sum | 14 from devil.android import md5sum |
| 13 from pylib import constants | 15 from pylib import constants |
| 14 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
| 15 from pylib.base import test_exception | 17 from pylib.base import test_exception |
| 16 from pylib.base import test_instance | 18 from pylib.base import test_instance |
| 17 from pylib.constants import host_paths | 19 from pylib.constants import host_paths |
| 18 from pylib.instrumentation import test_result | 20 from pylib.instrumentation import test_result |
| 19 from pylib.instrumentation import instrumentation_parser | 21 from pylib.instrumentation import instrumentation_parser |
| 20 from pylib.utils import dexdump | 22 from pylib.utils import dexdump |
| 21 from pylib.utils import proguard | 23 from pylib.utils import proguard |
| 22 from pylib.utils import shared_preference_utils | 24 from pylib.utils import shared_preference_utils |
| 23 | 25 |
| 26 import tombstones_helper |
| 27 |
| 24 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): | 28 with host_paths.SysPath(host_paths.BUILD_COMMON_PATH): |
| 25 import unittest_util # pylint: disable=import-error | 29 import unittest_util # pylint: disable=import-error |
| 26 | 30 |
| 27 # Ref: http://developer.android.com/reference/android/app/Activity.html | 31 # Ref: http://developer.android.com/reference/android/app/Activity.html |
| 28 _ACTIVITY_RESULT_CANCELED = 0 | 32 _ACTIVITY_RESULT_CANCELED = 0 |
| 29 _ACTIVITY_RESULT_OK = -1 | 33 _ACTIVITY_RESULT_OK = -1 |
| 30 | 34 |
| 31 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' | 35 _COMMAND_LINE_PARAMETER = 'cmdlinearg-parameter' |
| 32 _DEFAULT_ANNOTATIONS = [ | 36 _DEFAULT_ANNOTATIONS = [ |
| 33 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', 'IntegrationTest'] | 37 'SmallTest', 'MediumTest', 'LargeTest', 'EnormousTest', 'IntegrationTest'] |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 440 |
| 437 self._render_results_dir = None | 441 self._render_results_dir = None |
| 438 self._screenshot_dir = None | 442 self._screenshot_dir = None |
| 439 self._timeout_scale = None | 443 self._timeout_scale = None |
| 440 self._initializeTestControlAttributes(args) | 444 self._initializeTestControlAttributes(args) |
| 441 | 445 |
| 442 self._coverage_directory = None | 446 self._coverage_directory = None |
| 443 self._initializeTestCoverageAttributes(args) | 447 self._initializeTestCoverageAttributes(args) |
| 444 | 448 |
| 445 self._store_tombstones = False | 449 self._store_tombstones = False |
| 450 self._unzipped_files_dir = None |
| 451 self._tombstones_helper = tombstones_helper.TombstonesHelper() |
| 446 self._initializeTombstonesAttributes(args) | 452 self._initializeTombstonesAttributes(args) |
| 447 | 453 |
| 448 self._gs_results_bucket = None | 454 self._gs_results_bucket = None |
| 449 self._should_save_logcat = None | 455 self._should_save_logcat = None |
| 450 self._initializeLogAttributes(args) | 456 self._initializeLogAttributes(args) |
| 451 | 457 |
| 452 self._edit_shared_prefs = [] | 458 self._edit_shared_prefs = [] |
| 453 self._initializeEditPrefsAttributes(args) | 459 self._initializeEditPrefsAttributes(args) |
| 454 | 460 |
| 455 self._replace_system_package = None | 461 self._replace_system_package = None |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 self._render_results_dir = args.render_results_dir | 623 self._render_results_dir = args.render_results_dir |
| 618 self._screenshot_dir = args.screenshot_dir | 624 self._screenshot_dir = args.screenshot_dir |
| 619 self._timeout_scale = args.timeout_scale or 1 | 625 self._timeout_scale = args.timeout_scale or 1 |
| 620 self._ui_screenshot_dir = args.ui_screenshot_dir | 626 self._ui_screenshot_dir = args.ui_screenshot_dir |
| 621 | 627 |
| 622 def _initializeTestCoverageAttributes(self, args): | 628 def _initializeTestCoverageAttributes(self, args): |
| 623 self._coverage_directory = args.coverage_dir | 629 self._coverage_directory = args.coverage_dir |
| 624 | 630 |
| 625 def _initializeTombstonesAttributes(self, args): | 631 def _initializeTombstonesAttributes(self, args): |
| 626 self._store_tombstones = args.store_tombstones | 632 self._store_tombstones = args.store_tombstones |
| 633 self._unzipped_files_dir = tempfile.mkdtemp() |
| 634 self._tombstones_helper = tombstones_helper.TombstonesHelper( |
| 635 self.apk_under_test.path if self.apk_under_test else None, |
| 636 args.enable_relocation_packing, |
| 637 self._unzipped_files_dir) |
| 627 | 638 |
| 628 def _initializeLogAttributes(self, args): | 639 def _initializeLogAttributes(self, args): |
| 629 self._gs_results_bucket = args.gs_results_bucket | 640 self._gs_results_bucket = args.gs_results_bucket |
| 630 self._should_save_logcat = bool(args.json_results_file) | 641 self._should_save_logcat = bool(args.json_results_file) |
| 631 | 642 |
| 632 def _initializeEditPrefsAttributes(self, args): | 643 def _initializeEditPrefsAttributes(self, args): |
| 633 if not hasattr(args, 'shared_prefs_file') or not args.shared_prefs_file: | 644 if not hasattr(args, 'shared_prefs_file') or not args.shared_prefs_file: |
| 634 return | 645 return |
| 635 if not isinstance(args.shared_prefs_file, str): | 646 if not isinstance(args.shared_prefs_file, str): |
| 636 logging.warning("Given non-string for a filepath") | 647 logging.warning("Given non-string for a filepath") |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 | 721 |
| 711 @property | 722 @property |
| 712 def store_tombstones(self): | 723 def store_tombstones(self): |
| 713 return self._store_tombstones | 724 return self._store_tombstones |
| 714 | 725 |
| 715 @property | 726 @property |
| 716 def suite(self): | 727 def suite(self): |
| 717 return self._suite | 728 return self._suite |
| 718 | 729 |
| 719 @property | 730 @property |
| 731 def tombstones_helper(self): |
| 732 return self._tombstones_helper |
| 733 |
| 734 @property |
| 720 def test_apk(self): | 735 def test_apk(self): |
| 721 return self._test_apk | 736 return self._test_apk |
| 722 | 737 |
| 723 @property | 738 @property |
| 724 def test_apk_incremental_install_script(self): | 739 def test_apk_incremental_install_script(self): |
| 725 return self._test_apk_incremental_install_script | 740 return self._test_apk_incremental_install_script |
| 726 | 741 |
| 727 @property | 742 @property |
| 728 def test_jar(self): | 743 def test_jar(self): |
| 729 return self._test_jar | 744 return self._test_jar |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 return ParseAmInstrumentRawOutput(raw_output) | 854 return ParseAmInstrumentRawOutput(raw_output) |
| 840 | 855 |
| 841 @staticmethod | 856 @staticmethod |
| 842 def GenerateTestResults( | 857 def GenerateTestResults( |
| 843 result_code, result_bundle, statuses, start_ms, duration_ms): | 858 result_code, result_bundle, statuses, start_ms, duration_ms): |
| 844 return GenerateTestResults(result_code, result_bundle, statuses, | 859 return GenerateTestResults(result_code, result_bundle, statuses, |
| 845 start_ms, duration_ms) | 860 start_ms, duration_ms) |
| 846 | 861 |
| 847 #override | 862 #override |
| 848 def TearDown(self): | 863 def TearDown(self): |
| 849 pass | 864 if self._unzipped_files_dir: |
| 865 shutil.rmtree(self._unzipped_files_dir) |
| OLD | NEW |