Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(673)

Unified Diff: third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/constraints.py

Issue 2166463002: bluetooth: Basic Web Bluetooth Fuzzer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Move to testing/clusterfuzz directory Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/constraints.py
diff --git a/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/constraints.py b/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/constraints.py
new file mode 100644
index 0000000000000000000000000000000000000000..6bc36dd58a53bc2ef2fa18eafffa690a63481250
--- /dev/null
+++ b/third_party/WebKit/Source/modules/bluetooth/testing/clusterfuzz/constraints.py
@@ -0,0 +1,34 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Module to get random numbers, strings, etc.
+
+ The values returned by the various functions can be replaced in
+ templates to generate test cases.
+"""
+
+import random
+
+
+def GetValidUUIDString():
+ """Constructs a valid UUID string.
+
+ Returns:
+ A string representating a valid UUID according to:
+ https://webbluetoothcg.github.io/web-bluetooth/#valid-uuid
+ """
+
+ return '\'{:08x}-{:04x}-{:04x}-{:04x}-{:012x}\''.format(
+ random.getrandbits(32),
+ random.getrandbits(16),
+ random.getrandbits(16),
+ random.getrandbits(16),
+ random.getrandbits(48))
+
+
+def GetRequestDeviceOptions():
+ """Returns an object used by navigator.bluetooth.requestDevice."""
+ # TODO(ortuno): Randomize the members, number of filters, services, etc.
+
+ return '{filters: [{services: [ %s ]}]}' % GetValidUUIDString()

Powered by Google App Engine
This is Rietveld 408576698