1 /*
2  * Copyright 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 androidx.xr.runtime.testing
18 
19 import androidx.annotation.RestrictTo
20 import androidx.xr.runtime.internal.Component
21 import androidx.xr.runtime.internal.Entity
22 import androidx.xr.runtime.internal.InputEventListener
23 import androidx.xr.runtime.internal.SpaceValue
24 import androidx.xr.runtime.math.Pose
25 import androidx.xr.runtime.math.Vector3
26 import java.util.concurrent.Executor
27 
28 // TODO: b/405218432 - Implement this correctly instead of stubbing it out.
29 /** Test-only implementation of [Entity] */
30 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
31 public open class FakeEntity : Entity, FakeActivityPose() {
32     override val children: List<Entity> = emptyList()
33 
34     override var parent: Entity? = null
35 
36     override var contentDescription: String = ""
37 
setHiddennull38     override fun setHidden(hidden: Boolean): Unit {}
39 
addChildnull40     override fun addChild(child: Entity): Unit {}
41 
getPosenull42     override fun getPose(@SpaceValue relativeTo: Int): Pose = Pose()
43 
44     override fun setPose(pose: Pose, @SpaceValue relativeTo: Int) {}
45 
getScalenull46     override fun getScale(@SpaceValue relativeTo: Int): Vector3 = Vector3()
47 
48     override fun setScale(scale: Vector3, @SpaceValue relativeTo: Int) {}
49 
getAlphanull50     override fun getAlpha(@SpaceValue relativeTo: Int): Float = 1.0f
51 
52     override fun setAlpha(alpha: Float, @SpaceValue relativeTo: Int) {}
53 
addChildrennull54     override fun addChildren(children: List<Entity>): Unit {}
55 
isHiddennull56     override fun isHidden(includeParents: Boolean): Boolean = false
57 
58     @Suppress("ExecutorRegistration")
59     override fun addInputEventListener(executor: Executor, listener: InputEventListener) {}
60 
removeInputEventListenernull61     override fun removeInputEventListener(listener: InputEventListener) {}
62 
disposenull63     override fun dispose() {}
64 
addComponentnull65     override fun addComponent(component: Component): Boolean = true
66 
67     override fun getComponents(): List<Component> = emptyList()
68 
69     override fun <T : Component> getComponentsOfType(type: Class<out T>): List<T> = emptyList()
70 
71     override fun removeComponent(component: Component) {}
72 
removeAllComponentsnull73     override fun removeAllComponents() {}
74 }
75