1 /* 2 * Copyright 2018 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 @file:Suppress("NOTHING_TO_INLINE") 18 19 package androidx.navigation.testing 20 21 import android.support.annotation.IdRes 22 import androidx.navigation.NavDestinationBuilder 23 import androidx.navigation.NavDestinationDsl 24 import androidx.navigation.NavGraphBuilder 25 import androidx.navigation.get 26 27 /** 28 * Construct a new [TestNavigator.Destination] 29 */ 30 inline fun NavGraphBuilder.test(@IdRes id: Int) = test(id) {} 31 32 /** 33 * Construct a new [TestNavigator.Destination] 34 */ 35 inline fun NavGraphBuilder.test( 36 @IdRes id: Int, 37 block: TestNavigatorDestinationBuilder.() -> Unit 38 ) = destination(TestNavigatorDestinationBuilder(provider[TestNavigator::class], id).apply(block)) 39 40 /** 41 * DSL for constructing a new [TestNavigator.Destination] 42 */ 43 @NavDestinationDsl 44 class TestNavigatorDestinationBuilder( 45 navigator: TestNavigator, 46 @IdRes id: Int 47 ) : NavDestinationBuilder<TestNavigator.Destination>(navigator, id) 48