1 /* <lambda>null2 * Copyright (C) 2023 The Dagger Authors. 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 dagger.android.ksp 18 19 import android.content.Context 20 import androidx.test.core.app.ActivityScenario 21 import androidx.test.core.app.ApplicationProvider 22 import androidx.test.espresso.Espresso.onView 23 import androidx.test.espresso.assertion.ViewAssertions.matches 24 import androidx.test.espresso.matcher.ViewMatchers.withId 25 import androidx.test.espresso.matcher.ViewMatchers.withText 26 import androidx.test.ext.junit.runners.AndroidJUnit4 27 import com.google.common.truth.Truth.assertThat 28 import org.junit.Test 29 import org.junit.runner.RunWith 30 31 @RunWith(AndroidJUnit4::class) 32 class SimpleActivityTest { 33 @Test 34 fun testActivityInject() { 35 ActivityScenario.launch(SimpleActivity::class.java).onActivity { activity -> 36 onView(withId(R.id.greeting)) 37 .check(matches(withText("Hello, ProdUser! You are on build robolectric."))) 38 } 39 } 40 41 @Test 42 fun verifyApplicationInstance() { 43 assertThat((ApplicationProvider.getApplicationContext() as Context) is SimpleApplication) 44 .isTrue() 45 } 46 } 47