Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 a variety of device interactions based on adb. | 5 """Provides a variety of device interactions based on adb. |
| 6 | 6 |
| 7 Eventually, this will be based on adb_wrapper. | 7 Eventually, this will be based on adb_wrapper. |
| 8 """ | 8 """ |
| 9 # pylint: disable=W0613 | 9 # pylint: disable=W0613 |
| 10 | 10 |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 593 Args: | 593 Args: |
| 594 property_name: A string containing the name of the property to set on | 594 property_name: A string containing the name of the property to set on |
| 595 the device. | 595 the device. |
| 596 value: A string containing the value to set to the property on the | 596 value: A string containing the value to set to the property on the |
| 597 device. | 597 device. |
| 598 timeout: Same as for |IsOnline|. | 598 timeout: Same as for |IsOnline|. |
| 599 retries: Same as for |IsOnline|. | 599 retries: Same as for |IsOnline|. |
| 600 """ | 600 """ |
| 601 self.old_interface.system_properties[property_name] = value | 601 self.old_interface.system_properties[property_name] = value |
| 602 | 602 |
| 603 @decorators.WithTimeoutAndRetriesFromInstance() | |
| 604 def GetPid(self, process_name, timeout=None, retries=None): | |
|
frankf
2014/07/11 20:22:53
this should be plural to match the return value
jbudorick
2014/07/14 16:15:11
Done.
| |
| 605 """Returns the PIDs of processes with the given name. | |
| 606 | |
| 607 Note that the |process_name| is often the package name. | |
|
frankf
2014/07/11 20:29:07
Also isn't this the app package name and not the p
jbudorick
2014/07/14 16:15:11
Not necessarily, though it can be, e.g. these can
| |
| 608 | |
| 609 Args: | |
| 610 process_name: A string containing the process name to get the PIDs for. | |
| 611 timeout: Same as for |IsOnline|. | |
|
frankf
2014/07/11 20:22:53
I'd change all these to:
timeout: timeout in <som
jbudorick
2014/07/14 16:15:11
I don't really have an objection to this, but...
frankf
2014/07/14 17:04:10
Yea, the spirit of that comment was to cut down on
jbudorick
2014/07/15 15:52:56
Makes sense.
| |
| 612 retries: Same as for |IsOnline|. | |
| 613 Returns: | |
| 614 A list containing the PIDs of processes with the given name. | |
|
frankf
2014/07/11 20:22:53
are there any assumptions on the ordering here? Fo
jbudorick
2014/07/14 16:15:11
I don't think that the interface should guarantee
frankf
2014/07/14 17:04:10
For example, in monkey test runner, we take the fi
jbudorick
2014/07/15 15:52:56
Ah, ok.
Switched to having GetPids return a dict
| |
| 615 """ | |
|
frankf
2014/07/11 20:22:53
you should add raises section to all methods
jbudorick
2014/07/14 16:15:11
Done.
| |
| 616 return self.old_interface.ExtractPid(process_name) | |
| 617 | |
| 618 @decorators.WithTimeoutAndRetriesFromInstance() | |
| 619 def TakeScreenshot(self, host_path=None, timeout=None, retries=None): | |
| 620 """Takes a screenshot of the device. | |
| 621 | |
| 622 Args: | |
| 623 host_path: A string containing the path on the host to save the | |
| 624 screenshot to. If None, a file name will be generated. | |
|
frankf
2014/07/11 20:22:53
is this a temp file?
jbudorick
2014/07/14 16:15:11
No.
The AndroidCommands implementation uses ${PWD
frankf
2014/07/14 17:04:10
So my point was: is the user expected to clean thi
jbudorick
2014/07/15 15:52:56
Yes, the user is expected to clean up the screensh
| |
| 625 timeout: Same as for |IsOnline|. | |
| 626 retries: Same as for |IsOnline|. | |
| 627 Returns: | |
| 628 The name of the file on the host to which the screenshot was saved. | |
| 629 """ | |
| 630 return self.old_interface.TakeScreenshot(host_path) | |
| 631 | |
| 632 @decorators.WithTimeoutAndRetriesFromInstance() | |
| 633 def GetIOStats(self, timeout=None, retries=None): | |
| 634 """Gets cumulative disk IO stats since boot for all processes. | |
| 635 | |
| 636 Args: | |
| 637 timeout: Same as for |IsOnline|. | |
| 638 retries: Same as for |IsOnline|. | |
| 639 Returns: | |
| 640 A dict containing |num_reads|, |num_writes|, |read_ms|, and |write_ms|. | |
| 641 """ | |
| 642 return self.old_interface.GetIoStats() | |
| 643 | |
| 603 def __str__(self): | 644 def __str__(self): |
| 604 """Returns the device serial.""" | 645 """Returns the device serial.""" |
| 605 return self.old_interface.GetDevice() | 646 return self.old_interface.GetDevice() |
| 606 | 647 |
| 607 @staticmethod | 648 @staticmethod |
| 608 def parallel(devices=None, async=False): | 649 def parallel(devices=None, async=False): |
| 609 """Creates a Parallelizer to operate over the provided list of devices. | 650 """Creates a Parallelizer to operate over the provided list of devices. |
| 610 | 651 |
| 611 If |devices| is either |None| or an empty list, the Parallelizer will | 652 If |devices| is either |None| or an empty list, the Parallelizer will |
| 612 operate over all attached devices. | 653 operate over all attached devices. |
| 613 | 654 |
| 614 Args: | 655 Args: |
| 615 devices: A list of either DeviceUtils instances or objects from | 656 devices: A list of either DeviceUtils instances or objects from |
| 616 from which DeviceUtils instances can be constructed. If None, | 657 from which DeviceUtils instances can be constructed. If None, |
| 617 all attached devices will be used. | 658 all attached devices will be used. |
| 618 async: If true, returns a Parallelizer that runs operations | 659 async: If true, returns a Parallelizer that runs operations |
| 619 asynchronously. | 660 asynchronously. |
| 620 Returns: | 661 Returns: |
| 621 A Parallelizer operating over |devices|. | 662 A Parallelizer operating over |devices|. |
| 622 """ | 663 """ |
| 623 if not devices or len(devices) == 0: | 664 if not devices or len(devices) == 0: |
| 624 devices = pylib.android_commands.GetAttachedDevices() | 665 devices = pylib.android_commands.GetAttachedDevices() |
| 625 parallelizer_type = (parallelizer.Parallelizer if async | 666 parallelizer_type = (parallelizer.Parallelizer if async |
| 626 else parallelizer.SyncParallelizer) | 667 else parallelizer.SyncParallelizer) |
| 627 return parallelizer_type([ | 668 return parallelizer_type([ |
| 628 d if isinstance(d, DeviceUtils) else DeviceUtils(d) | 669 d if isinstance(d, DeviceUtils) else DeviceUtils(d) |
| 629 for d in devices]) | 670 for d in devices]) |
| 630 | 671 |
| OLD | NEW |