Esempio n. 1
0
 def testSetUpNetwork(self):
   connection = test_utils.MockConnection(self)
   connection.ExpectSyncRequest({'result': True},
                                'Network.canEmulateNetworkConditions')
   emulation.SetUpNetworkEmulation(connection, 120, 2048, 1024)
   self.assertTrue(connection.AllExpectationsUsed())
   self.assertEqual('Network.emulateNetworkConditions',
                    connection.no_response_requests_seen[0][0])
   self.assertEqual(
       1024,
       connection.no_response_requests_seen[0][1]['uploadThroughput'])
Esempio n. 2
0
 def _StartConnection(self, connection):
     """This should be called after opening an appropriate connection."""
     if self._emulated_device:
         self._metadata.update(
             emulation.SetUpDeviceEmulationAndReturnMetadata(
                 connection, self._emulated_device))
     if self._emulated_network:
         emulation.SetUpNetworkEmulation(connection,
                                         **self._emulated_network)
         self._metadata.update(self._emulated_network)
     self._metadata.update(date=datetime.datetime.utcnow().isoformat(),
                           seconds_since_epoch=time.time())
Esempio n. 3
0
 def _StartConnection(self, connection):
   """This should be called after opening an appropriate connection."""
   if self._emulated_device:
     self._metadata.update(emulation.SetUpDeviceEmulationAndReturnMetadata(
         connection, self._emulated_device))
   if self._network_name:
     network_condition = emulation.NETWORK_CONDITIONS[self._network_name]
     logging.info('Set up network emulation %s (latency=%dms, down=%d, up=%d)'
         % (self._network_name, network_condition['latency'],
             network_condition['download'], network_condition['upload']))
     emulation.SetUpNetworkEmulation(connection, **network_condition)
     self._metadata['network_emulation'] = copy.copy(network_condition)
     self._metadata['network_emulation']['name'] = self._network_name
   else:
     self._metadata['network_emulation'] = \
         {k: 'disabled' for k in ['name', 'download', 'upload', 'latency']}
   self._metadata.update(self.METADATA_GATHERER.GetMetadata())
   logging.info('Devtools connection success')