예제 #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'])
예제 #2
0
 def testSetUpDevice(self):
   registry = StringIO("""{
     "extensions": [
         {
             "type": "emulated-device",
             "device": {
                 "show-by-default": false,
                 "title": "mattPhone" ,
                 "screen": {
                     "horizontal": {
                         "width": 480,
                         "height": 320
                     },
                     "device-pixel-ratio": 2,
                     "vertical": {
                         "width": 320,
                         "height": 480
                     }
                 },
                 "capabilities": [
                     "touch",
                     "mobile"
                 ],
                 "user-agent": "James Bond"
             }
         } ]}""")
   devices = emulation.LoadEmulatedDevices(registry)
   connection = test_utils.MockConnection(self)
   connection.ExpectSyncRequest({'result': True}, 'Emulation.canEmulate')
   metadata = emulation.SetUpDeviceEmulationAndReturnMetadata(
       connection, devices['mattPhone'])
   self.assertEqual(320, metadata['width'])
   self.assertEqual('James Bond', metadata['userAgent'])
   self.assertTrue(connection.AllExpectationsUsed())
   self.assertEqual('Emulation.setDeviceMetricsOverride',
                    connection.no_response_requests_seen[0][0])