summaryrefslogtreecommitdiff
path: root/source/storage/Vault.mc
diff options
context:
space:
mode:
Diffstat (limited to 'source/storage/Vault.mc')
-rw-r--r--source/storage/Vault.mc14
1 files changed, 13 insertions, 1 deletions
diff --git a/source/storage/Vault.mc b/source/storage/Vault.mc
index 0bb3cbc..95f77c9 100644
--- a/source/storage/Vault.mc
+++ b/source/storage/Vault.mc
@@ -352,7 +352,7 @@ class Vault {
private function newId() as String {
var id = "";
do {
- var random = Cryptography.randomBytes(Entry.ID_LENGTH);
+ var random = TestMode.ON ? testIdBytes() : Cryptography.randomBytes(Entry.ID_LENGTH);
var alphabetSize = Entry.ID_ALPHABET.length();
id = "";
for (var i = 0; i < Entry.ID_LENGTH; i++) {
@@ -364,6 +364,18 @@ class Vault {
return id;
}
+ // UI-test build only: predictable IDs, so screenshots are reproducible.
+ private var _testIdCounter as Number = 0;
+
+ private function testIdBytes() as ByteArray {
+ _testIdCounter++;
+ var out = new [Entry.ID_LENGTH]b;
+ for (var i = 0; i < Entry.ID_LENGTH; i++) {
+ out[i] = (_testIdCounter * (7 + i * 3) + i * 11) & 0xFF;
+ }
+ return out;
+ }
+
// Store a value, turning a store-full error into VaultError FULL.
private function write(key as String, value as Application.Storage.ValueType) as Void {
try {