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.CoreState
21 import androidx.xr.runtime.StateExtender
22 import androidx.xr.runtime.internal.Runtime
23 
24 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
25 public class FakeStateExtender() : StateExtender {
26 
27     /** Whether the [StateExtender] has been initialized or not. */
28     public var isInitialized: Boolean = false
29 
30     /** List of [CoreState] instances that have been extended. */
31     public val extended: MutableList<CoreState> = mutableListOf<CoreState>()
32 
initializenull33     override fun initialize(runtime: Runtime) {
34         isInitialized = true
35     }
36 
extendnull37     override suspend fun extend(coreState: CoreState) {
38         extended.add(coreState)
39     }
40 }
41 
42 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
43 public class AnotherFakeStateExtender() : StateExtender {
44 
45     /** Whether the [StateExtender] has been initialized or not. */
46     public var isInitialized: Boolean = false
47 
48     /** List of [CoreState] instances that have been extended. */
49     public val extended: MutableList<CoreState> = mutableListOf<CoreState>()
50 
initializenull51     override fun initialize(runtime: Runtime) {
52         isInitialized = true
53     }
54 
extendnull55     override suspend fun extend(coreState: CoreState) {
56         extended.add(coreState)
57     }
58 }
59