def __init__(self, device, tool, shard_index, build_type):
     """
   Args:
     device: Tests will run on the device of this ID.
     shard_index: Index number of the shard on which the test suite will run.
     build_type: 'Release' or 'Debug'.
 """
     self.device = device
     self.adb = android_commands.AndroidCommands(device=device)
     self.tool = CreateTool(tool, self.adb)
     self._http_server = None
     self._forwarder = None
     self._forwarder_device_port = 8000
     self.forwarder_base_url = ('http://localhost:%d' %
                                self._forwarder_device_port)
     self.flags = FlagChanger(self.adb)
     self.shard_index = shard_index
     self.flags.AddFlags(['--disable-fre'])
     self._spawning_server = None
     self._spawner_forwarder = None
     # We will allocate port for test server spawner when calling method
     # LaunchChromeTestServerSpawner and allocate port for test server when
     # starting it in TestServerThread.
     self.test_server_spawner_port = 0
     self.test_server_port = 0
     self.build_type = build_type
Exemple #2
0
 def __init__(self, device, tool, shard_index):
     """
   Args:
     device: Tests will run on the device of this ID.
     shard_index: Index number of the shard on which the test suite will run.
 """
     self.device = device
     self.adb = android_commands.AndroidCommands(device=device)
     self.tool = CreateTool(tool, self.adb)
     # Synchronize date/time between host and device. Otherwise same file on
     # host and device may have different timestamp which may cause
     # AndroidCommands.PushIfNeeded failed, or a test which may compare timestamp
     # got from http head and local time could be failed.
     self.adb.SynchronizeDateTime()
     self._http_server = None
     self._forwarder = None
     self._forwarder_device_port = 8000
     self.forwarder_base_url = ('http://localhost:%d' %
                                self._forwarder_device_port)
     self.flags = FlagChanger(self.adb)
     self.shard_index = shard_index
     self.flags.AddFlags(['--disable-fre'])
     self._spawning_server = None
     self._spawner_forwarder = None
     # We will allocate port for test server spawner when calling method
     # LaunchChromeTestServerSpawner and allocate port for test server when
     # starting it in TestServerThread.
     self.test_server_spawner_port = 0
     self.test_server_port = 0
Exemple #3
0
    def Launch(self):
        """Launches the emulator and waits for package manager to startup.

    If fails, an exception will be raised.
    """
        port = _GetAvailablePort()
        self.device = "emulator-%d" % port
        self.popen = subprocess.Popen(
            args=[self.emulator, '-avd', 'buildbot', '-port',
                  str(port)])
        # This will not return until device's package manager starts up or an
        # exception is raised.
        android_commands.AndroidCommands(self.device, True)
Exemple #4
0
 def __init__(self, device):
     """
   Args:
     device: Tests will run on the device of this ID.
 """
     self.device = device
     self.adb = android_commands.AndroidCommands(device=device)
     # Synchronize date/time between host and device. Otherwise same file on
     # host and device may have different timestamp which may cause
     # AndroidCommands.PushIfNeeded failed, or a test which may compare timestamp
     # got from http head and local time could be failed.
     self.adb.SynchronizeDateTime()
     self._http_server = None
     self._forwarder = None
     self._spawning_server = None
     self._spawner_forwarder = None
     self._forwarder_device_port = 8000
     self.forwarder_base_url = ('http://localhost:%d' %
                                self._forwarder_device_port)
     self.flags = FlagChanger(self.adb)
Exemple #5
0
    def ConfirmLaunch(self, wait_for_boot=False):
        """Confirm the emulator launched properly.

    Loop on a wait-for-device with a very small timeout.  On each
    timeout, check the emulator process is still alive.
    After confirming a wait-for-device can be successful, make sure
    it returns the right answer.
    """
        a = android_commands.AndroidCommands(self.device, False)
        seconds_waited = 0
        number_of_waits = 2  # Make sure we can wfd twice
        adb_cmd = "adb -s %s %s" % (self.device, 'wait-for-device')
        while seconds_waited < self._LAUNCH_TIMEOUT:
            try:
                run_command.RunCommand(
                    adb_cmd,
                    timeout_time=self._WAITFORDEVICE_TIMEOUT,
                    retry_count=1)
                number_of_waits -= 1
                if not number_of_waits:
                    break
            except errors.WaitForResponseTimedOutError as e:
                seconds_waited += self._WAITFORDEVICE_TIMEOUT
                adb_cmd = "adb -s %s %s" % (self.device, 'kill-server')
                run_command.RunCommand(adb_cmd)
            self.popen.poll()
            if self.popen.returncode != None:
                raise EmulatorLaunchException('EMULATOR DIED')
        if seconds_waited >= self._LAUNCH_TIMEOUT:
            raise EmulatorLaunchException('TIMEOUT with wait-for-device')
        logging.info('Seconds waited on wait-for-device: %d', seconds_waited)
        if wait_for_boot:
            # Now that we checked for obvious problems, wait for a boot complete.
            # Waiting for the package manager is sometimes problematic.
            # TODO(jrg): for reasons I don't understand, sometimes this
            # gives an "error: device not found" which is only fixed with an
            # 'adb kill-server' command.  Fix.
            a.Adb().SetTargetSerial(self.device)
            a.Adb().WaitForBootComplete(self._WAITFORBOOT_TIMEOUT)
 def SetUp(self, options):
   self.options = options
   self.shard_index = self.options.shard_index
   self.device_id = self.options.device_id
   self.adb = android_commands.AndroidCommands(self.device_id)
   self.ports_to_forward = []
Exemple #7
0
 def SetUp(self, device_id, shard_index):
     self.shard_index = shard_index
     self.device_id = device_id
     self.adb = android_commands.AndroidCommands(self.device_id)
# -*- coding:UTF-8 -*-
#获取androidFPS值
import sys
import traceback
sys.path.append('C:\\Users\\youwei\\Desktop\\chromiummaster\\build\\android\\pylib')
import os,time
import android_commands
from perf import surface_stats_collector

resultList = []
deviceText = os.popen('adb devices')
textList = deviceText.readlines()
deviceName = textList[1].split()[0]
activityName = 'com.moji.mjweather'
adb = android_commands.AndroidCommands(deviceName)
collector = surface_stats_collector.SurfaceStatsCollector(adb)
collector.DisableWarningAboutEmptyData()
collector.Start()
#循环10次,主要方便自己的实现,其他实现方法请另行实现;
for i in range(10):
    time.sleep(0.3)
    results = collector.SampleResults()
    if not results:
        pass
    else:
        resultList.append(int(results[0].value))
        results[0].print_str()
    collector.Stop()
    a = resultList[3:-3]
    print u"平均值:"+str(float(sum(a)/len(a)))+u" ; 最小值:"+str(min(a))