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

Side by Side Diff: build/android/pylib/android_commands.py

Issue 14601004: [Android] Only reinstall test apk if needed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 """Provides an interface to communicate with the device via the adb command. 5 """Provides an interface to communicate with the device via the adb command.
6 6
7 Assumes adb binary is currently on system path. 7 Assumes adb binary is currently on system path.
8 """ 8 """
9 9
10 import collections 10 import collections
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 self.RunShellCommand('pm clear ' + package) 665 self.RunShellCommand('pm clear ' + package)
666 666
667 def SendKeyEvent(self, keycode): 667 def SendKeyEvent(self, keycode):
668 """Sends keycode to the device. 668 """Sends keycode to the device.
669 669
670 Args: 670 Args:
671 keycode: Numeric keycode to send (see "enum" at top of file). 671 keycode: Numeric keycode to send (see "enum" at top of file).
672 """ 672 """
673 self.RunShellCommand('input keyevent %d' % keycode) 673 self.RunShellCommand('input keyevent %d' % keycode)
674 674
675 def CheckMd5Sum(self, local_path, device_path): 675 def CheckMd5Sum(self, local_path, device_path, ignore_paths=False):
craigdh 2013/05/06 16:59:56 please add a docstring for this function, includin
cjhopman 2013/05/06 22:32:18 Done.
676 assert os.path.exists(local_path), 'Local path not found %s' % local_path 676 assert os.path.exists(local_path), 'Local path not found %s' % local_path
677 677
678 if not self._md5sum_build_dir: 678 if not self._md5sum_build_dir:
679 default_build_type = os.environ.get('BUILD_TYPE', 'Debug') 679 default_build_type = os.environ.get('BUILD_TYPE', 'Debug')
680 build_dir = '%s/%s/' % ( 680 build_dir = '%s/%s/' % (
681 cmd_helper.OutDirectory().get(), default_build_type) 681 cmd_helper.OutDirectory().get(), default_build_type)
682 md5sum_dist_path = '%s/md5sum_dist' % build_dir 682 md5sum_dist_path = '%s/md5sum_dist' % build_dir
683 if not os.path.exists(md5sum_dist_path): 683 if not os.path.exists(md5sum_dist_path):
684 build_dir = '%s/Release/' % cmd_helper.OutDirectory().get() 684 build_dir = '%s/Release/' % cmd_helper.OutDirectory().get()
685 md5sum_dist_path = '%s/md5sum_dist' % build_dir 685 md5sum_dist_path = '%s/md5sum_dist' % build_dir
686 assert os.path.exists(md5sum_dist_path), 'Please build md5sum.' 686 assert os.path.exists(md5sum_dist_path), 'Please build md5sum.'
687 command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER) 687 command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER)
688 assert _HasAdbPushSucceeded(self._adb.SendCommand(command)) 688 assert _HasAdbPushSucceeded(self._adb.SendCommand(command))
689 self._md5sum_build_dir = build_dir 689 self._md5sum_build_dir = build_dir
690 690
691 self._pushed_files.append(device_path) 691 self._pushed_files.append(device_path)
692 hashes_on_device = _ComputeFileListHash( 692 hashes_on_device = _ComputeFileListHash(
693 self.RunShellCommand(MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper + 693 self.RunShellCommand(MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper +
694 ' ' + MD5SUM_DEVICE_PATH + ' ' + device_path)) 694 ' ' + MD5SUM_DEVICE_PATH + ' ' + device_path))
695 assert os.path.exists(local_path), 'Local path not found %s' % local_path 695 assert os.path.exists(local_path), 'Local path not found %s' % local_path
696 md5sum_output = cmd_helper.GetCmdOutput( 696 md5sum_output = cmd_helper.GetCmdOutput(
697 ['%s/md5sum_bin_host' % self._md5sum_build_dir, local_path]) 697 ['%s/md5sum_bin_host' % self._md5sum_build_dir, local_path])
698 hashes_on_host = _ComputeFileListHash(md5sum_output.splitlines()) 698 hashes_on_host = _ComputeFileListHash(md5sum_output.splitlines())
699 699
700 if ignore_paths:
701 hashes_on_device = [h.split()[0] for h in hashes_on_device]
702 hashes_on_host = [h.split()[0] for h in hashes_on_host]
703
700 return hashes_on_device == hashes_on_host 704 return hashes_on_device == hashes_on_host
701 705
702 def PushIfNeeded(self, local_path, device_path): 706 def PushIfNeeded(self, local_path, device_path):
703 """Pushes |local_path| to |device_path|. 707 """Pushes |local_path| to |device_path|.
704 708
705 Works for files and directories. This method skips copying any paths in 709 Works for files and directories. This method skips copying any paths in
706 |test_data_paths| that already exist on the device with the same hash. 710 |test_data_paths| that already exist on the device with the same hash.
707 711
708 All pushed files can be removed by calling RemovePushedFiles(). 712 All pushed files can be removed by calling RemovePushedFiles().
709 """ 713 """
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 """ 1301 """
1298 def __init__(self, output): 1302 def __init__(self, output):
1299 self._output = output 1303 self._output = output
1300 1304
1301 def write(self, data): 1305 def write(self, data):
1302 data = data.replace('\r\r\n', '\n') 1306 data = data.replace('\r\r\n', '\n')
1303 self._output.write(data) 1307 self._output.write(data)
1304 1308
1305 def flush(self): 1309 def flush(self):
1306 self._output.flush() 1310 self._output.flush()
OLDNEW
« no previous file with comments | « no previous file | build/android/pylib/gtest/test_package_apk.py » ('j') | build/android/pylib/gtest/test_package_apk.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698