1 /* <lambda>null2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.launcher3.debug 18 19 import android.content.Context 20 import android.util.Log 21 import com.android.launcher3.util.MainThreadInitializedObject 22 import com.android.launcher3.util.SafeCloseable 23 24 /** Events fired by the launcher. */ 25 enum class TestEvent(val event: String) { 26 LAUNCHER_ON_CREATE("LAUNCHER_ON_CREATE"), 27 WORKSPACE_ON_DROP("WORKSPACE_ON_DROP"), 28 RESIZE_FRAME_SHOWING("RESIZE_FRAME_SHOWING"), 29 WORKSPACE_FINISH_LOADING("WORKSPACE_FINISH_LOADING"), 30 SPRING_LOADED_STATE_STARTED("SPRING_LOADED_STATE_STARTED"), 31 SPRING_LOADED_STATE_COMPLETED("SPRING_LOADED_STATE_COMPLETED"), 32 } 33 34 /** Interface to create TestEventEmitters. */ 35 interface TestEventEmitter : SafeCloseable { 36 37 companion object { 38 @JvmField 39 val INSTANCE = _null40 MainThreadInitializedObject<TestEventEmitter> { _: Context? -> 41 TestEventsEmitterProduction() 42 } 43 } 44 sendEventnull45 fun sendEvent(event: TestEvent) 46 } 47 48 /** 49 * TestEventsEmitterProduction shouldn't do anything since it runs on the launcher code and not on 50 * tests. This is just a placeholder and test should override this class. 51 */ 52 class TestEventsEmitterProduction : TestEventEmitter { 53 54 override fun close() {} 55 56 override fun sendEvent(event: TestEvent) { 57 Log.d("TestEventsEmitterProduction", "Event sent ${event.event}") 58 } 59 } 60