Skip to content

Commit

Permalink
Merge pull request #1075 from google/ben/compose1.2alpha5
Browse files Browse the repository at this point in the history
Compose 1.2.0-alpha05
  • Loading branch information
bentrengrove committed Mar 10, 2022
2 parents b9a44ab + 182891b commit 175fee3
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 20 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ systemProp.org.gradle.internal.http.socketTimeout=120000

GROUP=com.google.accompanist
# !! No longer need to update this manually when using a Compose SNAPSHOT
VERSION_NAME=0.24.4-SNAPSHOT
VERSION_NAME=0.24.4-alpha

POM_DESCRIPTION=Utilities for Jetpack Compose

Expand Down
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[versions]
compose = "1.2.0-alpha04"
compose = "1.2.0-alpha05"
composesnapshot = "-" # a single character = no snapshot

# gradlePlugin and lint need to be updated together
gradlePlugin = "7.1.1"
gradlePlugin = "7.1.2"
lint = "30.0.3"

ktlint = "0.42.1"
kotlin = "1.6.10"
coroutines = "1.5.2"
coroutines = "1.6.0"
okhttp = "3.12.13"
coil = "1.3.2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveableStateHolder
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.TestMonotonicFrameClock
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
Expand All @@ -43,11 +42,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.runBlockingTest
import kotlinx.coroutines.test.runTest
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -60,16 +57,13 @@ import org.junit.runner.RunWith
ExperimentalMaterialNavigationApi::class
)
internal class SheetContentHostTest {

private val testDispatcher = TestCoroutineDispatcher()
private val testClock = TestMonotonicFrameClock(CoroutineScope(testDispatcher))
private val bodyContentTag = "testBodyContent"

@get:Rule
val composeTestRule = createComposeRule()

@Test
fun testSheetShownAndHidden() = runBlockingTest {
fun testSheetShownAndHidden() = runTest {
val backStackEntryState = mutableStateOf<NavBackStackEntry?>(null)
val sheetState = ModalBottomSheetState(ModalBottomSheetValue.Hidden)

Expand All @@ -94,7 +88,7 @@ internal class SheetContentHostTest {
}

@Test
fun testOnSheetDismissedCalled_ManualDismiss() = runBlockingTest(testClock) {
fun testOnSheetDismissedCalled_ManualDismiss() = runTest {
val sheetState = ModalBottomSheetState(ModalBottomSheetValue.Hidden)
val backStackEntry = createBackStackEntry(sheetState)

Expand All @@ -119,7 +113,7 @@ internal class SheetContentHostTest {
}

@Test
fun testOnSheetDismissedCalled_initiallyExpanded() = runBlockingTest(testClock) {
fun testOnSheetDismissedCalled_initiallyExpanded() = runTest {
val sheetState = ModalBottomSheetState(ModalBottomSheetValue.Expanded)
val backStackEntry = createBackStackEntry(sheetState)

Expand All @@ -144,7 +138,7 @@ internal class SheetContentHostTest {
}

@Test
fun testOnSheetShownCalled_onBackStackEntryEnter() = runBlockingTest(testClock) {
fun testOnSheetShownCalled_onBackStackEntryEnter() = runTest {
val sheetState = ModalBottomSheetState(ModalBottomSheetValue.Hidden)
val backStackEntryState = mutableStateOf<NavBackStackEntry?>(null)
val shownBackStackEntries = mutableListOf<NavBackStackEntry>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class PagerStateUnitTest {

@OptIn(ExperimentalCoroutinesApi::class)
@Ignore // Not currently working after migration to Lazy
@Suppress("DEPRECATION")
@Test
fun store_restore_state() = runBlockingTest {
val stateRestoration = StateRestorationTester(composeTestRule)
Expand Down
5 changes: 4 additions & 1 deletion permissions/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

<application>

<activity
android:name=".PermissionsTestActivity"
android:exported="true"
android:theme="@android:style/Theme.Material.NoActionBar" />
<activity
android:name=".EmptyPermissionsTestActivity"
android:exported="true"
android:theme="@android:style/Theme.Material.NoActionBar" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.google.accompanist.permissions
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.filters.SdkSuppress
import androidx.test.rule.GrantPermissionRule
import com.google.accompanist.permissions.test.PermissionsTestActivity
import com.google.accompanist.permissions.test.EmptyPermissionsTestActivity
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
Expand All @@ -32,7 +32,7 @@ import org.junit.Test
class MultiplePermissionsStateTest {

@get:Rule
val composeTestRule = createAndroidComposeRule<PermissionsTestActivity>()
val composeTestRule = createAndroidComposeRule<EmptyPermissionsTestActivity>()

@get:Rule
val permissionRule: GrantPermissionRule = GrantPermissionRule.grant(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package com.google.accompanist.permissions
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.test.filters.SdkSuppress
import androidx.test.rule.GrantPermissionRule
import com.google.accompanist.permissions.test.PermissionsTestActivity
import com.google.accompanist.permissions.test.EmptyPermissionsTestActivity
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
Expand All @@ -32,7 +32,7 @@ import org.junit.Test
class PermissionStateTest {

@get:Rule
val composeTestRule = createAndroidComposeRule<PermissionsTestActivity>()
val composeTestRule = createAndroidComposeRule<EmptyPermissionsTestActivity>()

@get:Rule
val permissionRule: GrantPermissionRule =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2022 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
*
* https://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 com.google.accompanist.permissions.test

import androidx.activity.ComponentActivity
import com.google.accompanist.permissions.ExperimentalPermissionsApi

@OptIn(ExperimentalPermissionsApi::class)
class EmptyPermissionsTestActivity : ComponentActivity() {

var shouldShowRequestPermissionRationale: Map<String, Boolean> = emptyMap()

override fun shouldShowRequestPermissionRationale(permission: String): Boolean {
if (permission in shouldShowRequestPermissionRationale.keys) {
return shouldShowRequestPermissionRationale[permission]!!
}
return super.shouldShowRequestPermissionRationale(permission)
}
}

0 comments on commit 175fee3

Please sign in to comment.