summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVadim Tryshev <vadimt@google.com>2018-11-09 16:38:34 -0800
committerVadim Tryshev <vadimt@google.com>2018-12-06 16:11:18 -0800
commit0d4ac5712809632aed4ac9b67414444227ea0f45 (patch)
tree526b8201834db8646931935113c2eeb4a73e85a9 /src
parentde78d7ca78b457c057f91ba838ea5c7c0f14c2dd (diff)
downloadandroid_packages_apps_Trebuchet-0d4ac5712809632aed4ac9b67414444227ea0f45.tar.gz
android_packages_apps_Trebuchet-0d4ac5712809632aed4ac9b67414444227ea0f45.tar.bz2
android_packages_apps_Trebuchet-0d4ac5712809632aed4ac9b67414444227ea0f45.zip
Add framework for reliably reproducing race conditions.
Bug: 120628042 Test: RaceConditionReproducerTest Change-Id: Id658e2b0da6af186b76501ff16edbd135dda3c9b
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/util/RaceConditionTracker.java38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/com/android/launcher3/util/RaceConditionTracker.java b/src/com/android/launcher3/util/RaceConditionTracker.java
new file mode 100644
index 000000000..8eafb551d
--- /dev/null
+++ b/src/com/android/launcher3/util/RaceConditionTracker.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher3.util;
+
+/**
+ * Event tracker for reliably reproducing race conditions in tests.
+ * The app should call onEvent() for events that the test will try to reproduce in all possible
+ * orders.
+ */
+public class RaceConditionTracker {
+ public interface EventProcessor {
+ void onEvent(String eventName);
+ }
+
+ private static EventProcessor sEventProcessor;
+
+ static void setEventProcessor(EventProcessor eventProcessor) {
+ sEventProcessor = eventProcessor;
+ }
+
+ public static void onEvent(String eventName) {
+ if (sEventProcessor != null) sEventProcessor.onEvent(eventName);
+ }
+}