|
| 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 | + * https://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 com.example.compose.snippets.deviceconfigurationoverride |
| 18 | + |
| 19 | +import androidx.compose.material3.Text |
| 20 | +import androidx.compose.ui.test.DeviceConfigurationOverride |
| 21 | +import androidx.compose.ui.test.FontScale |
| 22 | +import androidx.compose.ui.test.FontWeightAdjustment |
| 23 | +import androidx.compose.ui.test.ForcedSize |
| 24 | +import androidx.compose.ui.test.junit4.createComposeRule |
| 25 | +import androidx.compose.ui.test.then |
| 26 | +import androidx.compose.ui.unit.DpSize |
| 27 | +import androidx.compose.ui.unit.dp |
| 28 | +import com.example.compose.snippets.interop.MyScreen |
| 29 | +import org.junit.Ignore |
| 30 | +import org.junit.Rule |
| 31 | +import org.junit.Test |
| 32 | + |
| 33 | +class DeviceConfigurationOverrideSnippetsTest { |
| 34 | + @get:Rule |
| 35 | + val composeTestRule = createComposeRule() |
| 36 | + |
| 37 | + @Ignore("Snippet test") |
| 38 | + @Test |
| 39 | + fun forcedSize() { |
| 40 | + // [START android_compose_deviceconfigurationoverride_forcedsize] |
| 41 | + composeTestRule.setContent { |
| 42 | + DeviceConfigurationOverride( |
| 43 | + DeviceConfigurationOverride.ForcedSize(DpSize(1280.dp, 800.dp)) |
| 44 | + ) { |
| 45 | + MyScreen() // will be rendered in the space for 1280dp by 800dp without clipping |
| 46 | + } |
| 47 | + } |
| 48 | + // [END android_compose_deviceconfigurationoverride_forcedsize] |
| 49 | + } |
| 50 | + |
| 51 | + @Ignore("Snippet test") |
| 52 | + @Test |
| 53 | + fun then() { |
| 54 | + // [START android_compose_deviceconfigurationoverride_then] |
| 55 | + composeTestRule.setContent { |
| 56 | + DeviceConfigurationOverride( |
| 57 | + DeviceConfigurationOverride.FontScale(1.5f) then |
| 58 | + DeviceConfigurationOverride.FontWeightAdjustment(200) |
| 59 | + ) { |
| 60 | + Text(text = "text with increased scale and weight") |
| 61 | + } |
| 62 | + } |
| 63 | + // [END android_compose_deviceconfigurationoverride_then] |
| 64 | + } |
| 65 | +} |
0 commit comments