Add support for `SavedStateHandle` in `viewModelScenario`

* Includes `DefaultCreationExtras(defaultArgs: Bundle)` for Android, allowing you to pass arguments to a `SavedStateHandle`.

RelNote: "Add support for `SavedStateHandle` in `viewModelScenario`."
Bug: 264602919
Test: DefaultCreationExtrasInstrumentedTest
Test: ViewModelInstrumentedTest
Change-Id: Iea7aa28b52581509cfa9f0b7b5df5f7836c578e0
diff --git a/buildSrc/private/src/main/kotlin/androidx/build/ListTaskOutputsTask.kt b/buildSrc/private/src/main/kotlin/androidx/build/ListTaskOutputsTask.kt
index e1bff78..cf4573d 100644
--- a/buildSrc/private/src/main/kotlin/androidx/build/ListTaskOutputsTask.kt
+++ b/buildSrc/private/src/main/kotlin/androidx/build/ListTaskOutputsTask.kt
@@ -118,6 +118,8 @@
         "transformIosTestCInteropDependenciesMetadataForIde",
         "transformNativeTestCInteropDependenciesMetadataForIde",
         "transformNativeMainCInteropDependenciesMetadataForIde",
+        "transformLinuxMainCInteropDependenciesMetadataForIde",
+        "transformNonJvmCommonMainCInteropDependenciesMetadataForIde",
 
         // The following tests intentionally have the same output of golden images
         "updateGoldenDesktopTest",
diff --git a/lifecycle/lifecycle-viewmodel-testing/api/current.txt b/lifecycle/lifecycle-viewmodel-testing/api/current.txt
index 692fe49..567246e 100644
--- a/lifecycle/lifecycle-viewmodel-testing/api/current.txt
+++ b/lifecycle/lifecycle-viewmodel-testing/api/current.txt
@@ -1,6 +1,11 @@
 // Signature format: 4.0
 package androidx.lifecycle.viewmodel.testing {
 
+  public final class DefaultCreationExtrasKt {
+    method public static androidx.lifecycle.viewmodel.CreationExtras DefaultCreationExtras();
+    method public static androidx.lifecycle.viewmodel.CreationExtras DefaultCreationExtras(android.os.Bundle defaultArgs);
+  }
+
   public final class ViewModelScenario<VM extends androidx.lifecycle.ViewModel> implements java.lang.AutoCloseable {
     method public void close();
     method public VM getViewModel();
diff --git a/lifecycle/lifecycle-viewmodel-testing/api/restricted_current.txt b/lifecycle/lifecycle-viewmodel-testing/api/restricted_current.txt
index 9350715..f90ed9f 100644
--- a/lifecycle/lifecycle-viewmodel-testing/api/restricted_current.txt
+++ b/lifecycle/lifecycle-viewmodel-testing/api/restricted_current.txt
@@ -1,6 +1,11 @@
 // Signature format: 4.0
 package androidx.lifecycle.viewmodel.testing {
 
+  public final class DefaultCreationExtrasKt {
+    method public static androidx.lifecycle.viewmodel.CreationExtras DefaultCreationExtras();
+    method public static androidx.lifecycle.viewmodel.CreationExtras DefaultCreationExtras(android.os.Bundle defaultArgs);
+  }
+
   public final class ViewModelScenario<VM extends androidx.lifecycle.ViewModel> implements java.lang.AutoCloseable {
     ctor @kotlin.PublishedApi internal ViewModelScenario(kotlin.reflect.KClass<VM> modelClass, androidx.lifecycle.ViewModelStore modelStore, androidx.lifecycle.ViewModelProvider.Factory modelFactory, optional androidx.lifecycle.viewmodel.CreationExtras modelExtras);
     method public void close();
diff --git a/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt b/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt
index a4e3c57..d7cbc40 100644
--- a/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt
+++ b/lifecycle/lifecycle-viewmodel-testing/bcv/native/current.txt
@@ -12,5 +12,6 @@
     final val viewModel // androidx.lifecycle.viewmodel.testing/ViewModelScenario.viewModel|{}viewModel[0]
         final fun <get-viewModel>(): #A // androidx.lifecycle.viewmodel.testing/ViewModelScenario.viewModel.<get-viewModel>|<get-viewModel>(){}[0]
 }
+final fun androidx.lifecycle.viewmodel.testing/DefaultCreationExtras(): androidx.lifecycle.viewmodel/CreationExtras // androidx.lifecycle.viewmodel.testing/DefaultCreationExtras|DefaultCreationExtras(){}[0]
 final inline fun <#A: reified androidx.lifecycle/ViewModel> androidx.lifecycle.viewmodel.testing/viewModelScenario(androidx.lifecycle.viewmodel/CreationExtras =..., noinline kotlin/Function1<androidx.lifecycle.viewmodel/CreationExtras, #A>): androidx.lifecycle.viewmodel.testing/ViewModelScenario<#A> // androidx.lifecycle.viewmodel.testing/viewModelScenario|viewModelScenario(androidx.lifecycle.viewmodel.CreationExtras;kotlin.Function1<androidx.lifecycle.viewmodel.CreationExtras,0:0>){0§<androidx.lifecycle.ViewModel>}[0]
 final inline fun <#A: reified androidx.lifecycle/ViewModel> androidx.lifecycle.viewmodel.testing/viewModelScenario(androidx.lifecycle/ViewModelProvider.Factory, androidx.lifecycle.viewmodel/CreationExtras =...): androidx.lifecycle.viewmodel.testing/ViewModelScenario<#A> // androidx.lifecycle.viewmodel.testing/viewModelScenario|viewModelScenario(androidx.lifecycle.ViewModelProvider.Factory;androidx.lifecycle.viewmodel.CreationExtras){0§<androidx.lifecycle.ViewModel>}[0]
diff --git a/lifecycle/lifecycle-viewmodel-testing/build.gradle b/lifecycle/lifecycle-viewmodel-testing/build.gradle
index e3b75b0..d56e621 100644
--- a/lifecycle/lifecycle-viewmodel-testing/build.gradle
+++ b/lifecycle/lifecycle-viewmodel-testing/build.gradle
@@ -24,6 +24,8 @@
 
 import androidx.build.LibraryType
 import androidx.build.PlatformIdentifier
+import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
+import org.jetbrains.kotlin.konan.target.Family
 
 plugins {
     id("AndroidXPlugin")
@@ -31,7 +33,6 @@
 }
 
 androidXMultiplatform {
-
     android()
     desktop()
     mac()
@@ -56,15 +57,56 @@
                 implementation(libs.kotlinCoroutinesTest)
             }
         }
+
+        androidMain {
+            dependsOn(commonMain)
+            dependencies {
+                implementation(project(":lifecycle:lifecycle-runtime"))
+                implementation(project(":lifecycle:lifecycle-runtime-testing"))
+                implementation(project(":lifecycle:lifecycle-viewmodel-savedstate"))
+            }
+        }
+
+        androidInstrumentedTest {
+            dependsOn(commonTest)
+            dependencies {
+                implementation("androidx.core:core-ktx:1.2.0")
+                implementation(libs.testExtJunit)
+                implementation(libs.testCore)
+                implementation(libs.testRunner)
+            }
+        }
+
+        desktopMain.dependsOn(jvmCommonMain)
+        nonJvmCommonMain.dependsOn(commonMain)
+        nativeMain.dependsOn(nonJvmCommonMain)
+        darwinMain.dependsOn(nativeMain)
+        linuxMain.dependsOn(nativeMain)
+
+        targets.configureEach { target ->
+            if (target.platformType == KotlinPlatformType.native) {
+                target.compilations["main"].defaultSourceSet {
+                    def konanTargetFamily = target.konanTarget.family
+                    if (konanTargetFamily == Family.OSX || konanTargetFamily == Family.IOS) {
+                        dependsOn(darwinMain)
+                    } else if (konanTargetFamily == Family.LINUX) {
+                        dependsOn(linuxMain)
+                    } else {
+                        throw new GradleException("unknown native target ${target}")
+                    }
+                }
+            }
+        }
     }
 }
 
 androidx {
     name = "Lifecycle ViewModel Testing"
-    type = LibraryType.PUBLISHED_LIBRARY
+    type = LibraryType.PUBLISHED_TEST_LIBRARY
     inceptionYear = "2024"
     description = "Testing utilities for 'lifecycle-viewmodel' artifact"
-    metalavaK2UastEnabled = false // TODO(b/337268135): Temporarily disabled until issue fixed.
+    // TODO(b/337268135): Temporarily disabled until issue fixed.
+    // metalavaK2UastEnabled = false
 }
 
 android {
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtrasInstrumentedTest.kt b/lifecycle/lifecycle-viewmodel-testing/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtrasInstrumentedTest.kt
new file mode 100644
index 0000000..a3065bf
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-testing/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtrasInstrumentedTest.kt
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2024 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 androidx.lifecycle.viewmodel.testing
+
+import android.os.Bundle
+import androidx.kruth.assertThat
+import androidx.lifecycle.DEFAULT_ARGS_KEY
+import androidx.lifecycle.SAVED_STATE_REGISTRY_OWNER_KEY
+import androidx.lifecycle.VIEW_MODEL_STORE_OWNER_KEY
+import androidx.lifecycle.ViewModelProvider.Companion.VIEW_MODEL_KEY
+import androidx.lifecycle.createSavedStateHandle
+import androidx.lifecycle.viewmodel.MutableCreationExtras
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+@SmallTest
+internal class DefaultCreationExtrasInstrumentedTest {
+
+    @Test
+    fun creationExtras_hasAllExtras() {
+        val creationExtras = DefaultCreationExtras()
+
+        assertThat(creationExtras[SAVED_STATE_REGISTRY_OWNER_KEY]).isNotNull()
+        assertThat(creationExtras[VIEW_MODEL_STORE_OWNER_KEY]).isNotNull()
+        assertThat(creationExtras[DEFAULT_ARGS_KEY]).isNotNull()
+        assertThat(creationExtras[DEFAULT_ARGS_KEY]!!.isEmpty()).isTrue()
+    }
+
+    @Test
+    fun creationExtras_withCustomDefaultArgs() {
+        val defaultArgs = Bundle().apply { putString("key", "value") }
+        val creationExtras = DefaultCreationExtras(defaultArgs)
+
+        assertThat(creationExtras[DEFAULT_ARGS_KEY]).isEqualTo(defaultArgs)
+    }
+
+    @Test
+    fun creationExtras_savedStateHandle_isEnabled() {
+        val creationExtras = DefaultCreationExtras() as MutableCreationExtras
+        creationExtras[VIEW_MODEL_KEY] = "modelKey"
+
+        assertThat(creationExtras.createSavedStateHandle()).isNotNull()
+    }
+}
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioInstrumentedTest.kt b/lifecycle/lifecycle-viewmodel-testing/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioInstrumentedTest.kt
new file mode 100644
index 0000000..47d4f5f
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-testing/src/androidInstrumentedTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioInstrumentedTest.kt
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2024 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 androidx.lifecycle.viewmodel.testing
+
+import android.os.Bundle
+import androidx.kruth.assertThat
+import androidx.lifecycle.SavedStateHandle
+import androidx.lifecycle.ViewModel
+import androidx.lifecycle.createSavedStateHandle
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@RunWith(AndroidJUnit4::class)
+@SmallTest
+internal class ViewModelScenarioInstrumentedTest {
+
+    @Test
+    fun createSavedStateHandle_withDefaultExtras() {
+        val scenario = viewModelScenario { TestViewModel(createSavedStateHandle()) }
+
+        // assert `.viewModel` does not throw.
+        assertThat(scenario.viewModel.handle).isNotNull()
+    }
+
+    @Test
+    fun createSavedStateHandle_withInitialExtras() {
+        val defaultArgs = Bundle().apply { putString("key", "value") }
+        val creationExtras = DefaultCreationExtras(defaultArgs)
+        val scenario = viewModelScenario(creationExtras) { TestViewModel(createSavedStateHandle()) }
+
+        assertThat(scenario.viewModel.handle.get<String>("key")).isEqualTo("value")
+    }
+
+    private class TestViewModel(val handle: SavedStateHandle) : ViewModel()
+}
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/androidMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.android.kt b/lifecycle/lifecycle-viewmodel-testing/src/androidMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.android.kt
new file mode 100644
index 0000000..6e5a48c
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-testing/src/androidMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.android.kt
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2024 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.
+ */
+@file:JvmName("DefaultCreationExtrasKt")
+
+package androidx.lifecycle.viewmodel.testing
+
+import android.os.Bundle
+import androidx.lifecycle.DEFAULT_ARGS_KEY
+import androidx.lifecycle.Lifecycle
+import androidx.lifecycle.LifecycleOwner
+import androidx.lifecycle.LifecycleRegistry
+import androidx.lifecycle.SAVED_STATE_REGISTRY_OWNER_KEY
+import androidx.lifecycle.SavedStateHandle
+import androidx.lifecycle.VIEW_MODEL_STORE_OWNER_KEY
+import androidx.lifecycle.ViewModelStore
+import androidx.lifecycle.ViewModelStoreOwner
+import androidx.lifecycle.enableSavedStateHandles
+import androidx.lifecycle.testing.TestLifecycleOwner
+import androidx.lifecycle.viewmodel.CreationExtras
+import androidx.lifecycle.viewmodel.MutableCreationExtras
+import androidx.savedstate.SavedStateRegistryController
+import androidx.savedstate.SavedStateRegistryOwner
+
+/**
+ * Creates a default instance of [CreationExtras] pre-configured with all keys required to use
+ * [SavedStateHandle].
+ *
+ * This function sets up the instance with:
+ * - A fake [SavedStateRegistryOwner] assigned to [SAVED_STATE_REGISTRY_OWNER_KEY], delegating the
+ *   [LifecycleOwner] to a [TestLifecycleOwner].
+ * - A fake [ViewModelStoreOwner] assigned to [VIEW_MODEL_STORE_OWNER_KEY], containing an empty
+ *   [ViewModelStore].
+ */
+@Suppress("FunctionName")
+public actual fun DefaultCreationExtras(): CreationExtras {
+    return DefaultCreationExtras(defaultArgs = Bundle())
+}
+
+/**
+ * Creates a default instance of [CreationExtras] pre-configured with all keys required to use
+ * [SavedStateHandle], with the specified [defaultArgs] as the [DEFAULT_ARGS_KEY].
+ *
+ * This function sets up the instance with:
+ * - A fake [SavedStateRegistryOwner] assigned to [SAVED_STATE_REGISTRY_OWNER_KEY], delegating the
+ *   [LifecycleOwner] to a [TestLifecycleOwner].
+ * - A fake [ViewModelStoreOwner] assigned to [VIEW_MODEL_STORE_OWNER_KEY], containing an empty
+ *   [ViewModelStore].
+ */
+@Suppress("FunctionName")
+public fun DefaultCreationExtras(defaultArgs: Bundle): CreationExtras {
+    val owner =
+        object : ViewModelStoreOwner, LifecycleOwner, SavedStateRegistryOwner {
+            override val viewModelStore = ViewModelStore()
+
+            val lifecycleRegistry = LifecycleRegistry.createUnsafe(owner = this)
+            override val lifecycle: Lifecycle = lifecycleRegistry
+
+            val savedStateRegistryController = SavedStateRegistryController.create(owner = this)
+            override val savedStateRegistry = savedStateRegistryController.savedStateRegistry
+        }
+
+    owner.savedStateRegistryController.performAttach()
+    owner.savedStateRegistryController.performRestore(savedState = null)
+    owner.enableSavedStateHandles()
+
+    owner.lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
+
+    return MutableCreationExtras().apply {
+        this[SAVED_STATE_REGISTRY_OWNER_KEY] = owner
+        this[VIEW_MODEL_STORE_OWNER_KEY] = owner
+        this[DEFAULT_ARGS_KEY] = defaultArgs
+    }
+}
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt b/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt
new file mode 100644
index 0000000..5ca4b56
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2024 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 androidx.lifecycle.viewmodel.testing
+
+import androidx.lifecycle.viewmodel.CreationExtras
+
+/** Creates a default instance of [CreationExtras]. */
+@Suppress("FunctionName") public expect fun DefaultCreationExtras(): CreationExtras
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenario.kt b/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenario.kt
index 5f984f0..c60f7c8 100644
--- a/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenario.kt
+++ b/lifecycle/lifecycle-viewmodel-testing/src/commonMain/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenario.kt
@@ -71,7 +71,7 @@
  * @param initializer A [Factory] function to create a [ViewModel].
  */
 public inline fun <reified VM : ViewModel> viewModelScenario(
-    creationExtras: CreationExtras = Empty,
+    creationExtras: CreationExtras = DefaultCreationExtras(),
     noinline initializer: CreationExtras.() -> VM,
 ): ViewModelScenario<VM> {
     return viewModelScenario(
@@ -103,7 +103,7 @@
  */
 public inline fun <reified VM : ViewModel> viewModelScenario(
     factory: Factory,
-    creationExtras: CreationExtras = Empty,
+    creationExtras: CreationExtras = DefaultCreationExtras(),
 ): ViewModelScenario<VM> {
     return ViewModelScenario(
         modelClass = VM::class,
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/commonTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioTest.kt b/lifecycle/lifecycle-viewmodel-testing/src/commonTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioTest.kt
index 1e3825c..df656c0 100644
--- a/lifecycle/lifecycle-viewmodel-testing/src/commonTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioTest.kt
+++ b/lifecycle/lifecycle-viewmodel-testing/src/commonTest/kotlin/androidx/lifecycle/viewmodel/testing/ViewModelScenarioTest.kt
@@ -57,8 +57,7 @@
 
     @Test
     fun viewModel_whenNotCleared_usesCustomCreationExtras() {
-        val expectedExtras = MutableCreationExtras()
-        expectedExtras[CREATION_EXTRAS_KEY] = "one-two-three"
+        val expectedExtras = MutableCreationExtras().apply { this[CREATION_EXTRAS_KEY] = "value" }
         val scenario = viewModelScenario(expectedExtras) { TestViewModel(creationExtras = this) }
 
         val actualExtras = scenario.viewModel.creationExtras
@@ -68,8 +67,7 @@
 
     @Test
     fun viewModel_whenCleared_reusesCustomCreationExtras() {
-        val expectedExtras = MutableCreationExtras()
-        expectedExtras[CREATION_EXTRAS_KEY] = "one-two-three"
+        val expectedExtras = MutableCreationExtras().apply { this[CREATION_EXTRAS_KEY] = "value" }
         val scenario = viewModelScenario(expectedExtras) { TestViewModel(creationExtras = this) }
 
         val actualExtras1 = scenario.viewModel.creationExtras
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/desktopMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.desktop.kt b/lifecycle/lifecycle-viewmodel-testing/src/desktopMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.desktop.kt
new file mode 100644
index 0000000..43f80b4
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-testing/src/desktopMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.desktop.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2024 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.
+ */
+@file:JvmName("DefaultCreationExtrasKt")
+
+package androidx.lifecycle.viewmodel.testing
+
+import androidx.lifecycle.viewmodel.CreationExtras
+import androidx.lifecycle.viewmodel.CreationExtras.Empty
+
+@Suppress("FunctionName") public actual fun DefaultCreationExtras(): CreationExtras = Empty
diff --git a/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt b/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt
new file mode 100644
index 0000000..e220c67
--- /dev/null
+++ b/lifecycle/lifecycle-viewmodel-testing/src/nonJvmCommonMain/kotlin/androidx/lifecycle/viewmodel/testing/DefaultCreationExtras.nonJvm.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2024 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 androidx.lifecycle.viewmodel.testing
+
+import androidx.lifecycle.viewmodel.CreationExtras
+import androidx.lifecycle.viewmodel.CreationExtras.Empty
+
+@Suppress("FunctionName") public actual fun DefaultCreationExtras(): CreationExtras = Empty