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

Side by Side Diff: build/android/pylib/gtest/test_package_apk.py

Issue 19799003: [android] Instumentation tests determine whether to install test apk based on Md5Sum. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unnecessary import Created 7 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 """Defines TestPackageApk to help run APK-based native tests.""" 5 """Defines TestPackageApk to help run APK-based native tests."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import shlex 9 import shlex
10 import sys 10 import sys
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile) 81 return pexpect.spawn('adb', args, timeout=timeout, logfile=logfile)
82 82
83 def _StartActivity(self): 83 def _StartActivity(self):
84 self.adb.StartActivity( 84 self.adb.StartActivity(
85 self._test_apk_package_name, 85 self._test_apk_package_name,
86 self._test_activity_name, 86 self._test_activity_name,
87 wait_for_completion=True, 87 wait_for_completion=True,
88 action='android.intent.action.MAIN', 88 action='android.intent.action.MAIN',
89 force_stop=True) 89 force_stop=True)
90 90
91 def _NeedsInstall(self):
92 installed_apk_path = self.adb.GetApplicationPath(
93 self._test_apk_package_name)
94 if installed_apk_path:
95 return not self.adb.CheckMd5Sum(
96 self.suite_path_full, installed_apk_path, ignore_paths=True)
97 else:
98 return True
99
100 def _GetTestSuiteBaseName(self): 91 def _GetTestSuiteBaseName(self):
101 """Returns the base name of the test suite.""" 92 """Returns the base name of the test suite."""
102 # APK test suite names end with '-debug.apk' 93 # APK test suite names end with '-debug.apk'
103 return os.path.basename(self.suite_path).rsplit('-debug', 1)[0] 94 return os.path.basename(self.suite_path).rsplit('-debug', 1)[0]
104 95
105 #override 96 #override
106 def ClearApplicationState(self): 97 def ClearApplicationState(self):
107 self.adb.ClearApplicationState(self._test_apk_package_name) 98 self.adb.ClearApplicationState(self._test_apk_package_name)
108 99
109 #override 100 #override
(...skipping 26 matching lines...) Expand all
136 self._ClearFifo() 127 self._ClearFifo()
137 self._StartActivity() 128 self._StartActivity()
138 finally: 129 finally:
139 self.tool.CleanUpEnvironment() 130 self.tool.CleanUpEnvironment()
140 logfile = android_commands.NewLineNormalizer(sys.stdout) 131 logfile = android_commands.NewLineNormalizer(sys.stdout)
141 return self._WatchFifo(timeout=10, logfile=logfile) 132 return self._WatchFifo(timeout=10, logfile=logfile)
142 133
143 #override 134 #override
144 def Install(self): 135 def Install(self):
145 self.tool.CopyFiles() 136 self.tool.CopyFiles()
146 if self._NeedsInstall(): 137 self.adb.ManagedInstall(self.suite_path_full, False,
147 # Always uninstall the previous one (by activity name); we don't 138 package_name=self._test_apk_package_name)
148 # know what was embedded in it. 139
149 self.adb.ManagedInstall(self.suite_path_full, False,
150 package_name=self._test_apk_package_name)
OLDNEW
« no previous file with comments | « build/android/pylib/android_commands.py ('k') | build/android/pylib/host_driven/python_test_base.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698