| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Module to get random numbers, strings, etc. |
| 6 |
| 7 The values returned by the various functions can be replaced in |
| 8 templates to generate test cases. |
| 9 """ |
| 10 |
| 11 import random |
| 12 |
| 13 |
| 14 def GetValidUUIDString(): |
| 15 """Constructs a valid UUID string. |
| 16 |
| 17 Returns: |
| 18 A string representating a valid UUID according to: |
| 19 https://webbluetoothcg.github.io/web-bluetooth/#valid-uuid |
| 20 """ |
| 21 |
| 22 return '\'{:08x}-{:04x}-{:04x}-{:04x}-{:012x}\''.format( |
| 23 random.getrandbits(32), |
| 24 random.getrandbits(16), |
| 25 random.getrandbits(16), |
| 26 random.getrandbits(16), |
| 27 random.getrandbits(48)) |
| 28 |
| 29 |
| 30 def GetRequestDeviceOptions(): |
| 31 """Returns an object used by navigator.bluetooth.requestDevice.""" |
| 32 # TODO(ortuno): Randomize the members, number of filters, services, etc. |
| 33 |
| 34 return '{filters: [{services: [ %s ]}]}' % GetValidUUIDString() |
| OLD | NEW |