Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 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 | package androidx.ui.material |
| 18 | |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 19 | import android.os.SystemClock.sleep |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 20 | import androidx.compose.emptyContent |
Leland Richardson | fcf76b3 | 2020-05-13 16:58:59 -0700 | [diff] [blame] | 21 | import androidx.compose.mutableStateOf |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 22 | import androidx.test.filters.MediumTest |
Adam Powell | 999a89b | 2020-03-11 09:08:07 -0700 | [diff] [blame] | 23 | import androidx.ui.core.LayoutCoordinates |
| 24 | import androidx.ui.core.Modifier |
George Mount | d02af60 | 2020-03-06 16:41:40 -0800 | [diff] [blame] | 25 | import androidx.ui.core.onPositioned |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 26 | import androidx.ui.core.testTag |
Louis Pullen-Freilich | ddda7be | 2020-07-17 18:28:12 +0100 | [diff] [blame] | 27 | import androidx.compose.foundation.Box |
| 28 | import androidx.compose.foundation.background |
| 29 | import androidx.compose.foundation.clickable |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 30 | import androidx.ui.geometry.Offset |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 31 | import androidx.ui.graphics.Color |
Louis Pullen-Freilich | 623e405 | 2020-07-19 20:24:03 +0100 | [diff] [blame] | 32 | import androidx.compose.foundation.layout.fillMaxSize |
| 33 | import androidx.compose.foundation.layout.rtl |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 34 | import androidx.ui.test.GestureScope |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 35 | import androidx.ui.test.assertIsEqualTo |
| 36 | import androidx.ui.test.assertLeftPositionInRootIsEqualTo |
| 37 | import androidx.ui.test.assertTopPositionInRootIsEqualTo |
| 38 | import androidx.ui.test.assertWidthIsEqualTo |
Jelle Fresen | 77f4418 | 2020-07-21 16:34:29 +0100 | [diff] [blame] | 39 | import androidx.ui.test.bottomCenter |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 40 | import androidx.ui.test.center |
Jelle Fresen | 77f4418 | 2020-07-21 16:34:29 +0100 | [diff] [blame] | 41 | import androidx.ui.test.centerLeft |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 42 | import androidx.ui.test.createComposeRule |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 43 | import androidx.ui.test.performGesture |
| 44 | import androidx.ui.test.onNodeWithTag |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 45 | import androidx.ui.test.runOnIdle |
Filip Pavlis | 6fdb250 | 2020-04-02 14:41:32 +0100 | [diff] [blame] | 46 | import androidx.ui.test.runOnUiThread |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 47 | import androidx.ui.test.click |
| 48 | import androidx.ui.test.swipe |
| 49 | import androidx.ui.test.swipeDown |
| 50 | import androidx.ui.test.swipeLeft |
| 51 | import androidx.ui.test.swipeRight |
| 52 | import androidx.ui.test.swipeUp |
George Mount | 842c8c1 | 2020-01-08 16:03:42 -0800 | [diff] [blame] | 53 | import androidx.ui.unit.dp |
Ryan Mentley | 7865a63 | 2019-08-20 20:10:29 -0700 | [diff] [blame] | 54 | import androidx.ui.unit.height |
Ryan Mentley | 7865a63 | 2019-08-20 20:10:29 -0700 | [diff] [blame] | 55 | import androidx.ui.unit.width |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 56 | import com.google.common.truth.Truth.assertThat |
Matvei Malkov | 886ec6a | 2020-02-03 01:45:29 +0000 | [diff] [blame] | 57 | import org.junit.Ignore |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 58 | import org.junit.Rule |
| 59 | import org.junit.Test |
| 60 | import org.junit.runner.RunWith |
| 61 | import org.junit.runners.JUnit4 |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 62 | import java.util.concurrent.CountDownLatch |
| 63 | import java.util.concurrent.TimeUnit |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 64 | import kotlin.math.roundToInt |
| 65 | |
| 66 | @MediumTest |
| 67 | @RunWith(JUnit4::class) |
| 68 | class DrawerTest { |
| 69 | |
| 70 | @get:Rule |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 71 | val composeTestRule = createComposeRule(disableTransitions = true) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 72 | |
| 73 | @Test |
| 74 | fun modalDrawer_testOffset_whenOpened() { |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 75 | composeTestRule.setMaterialContent { |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 76 | ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = { |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 77 | Box(Modifier.fillMaxSize().testTag("content")) |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 78 | }, bodyContent = emptyContent()) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 79 | } |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 80 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 81 | onNodeWithTag("content") |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 82 | .assertLeftPositionInRootIsEqualTo(0.dp) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | @Test |
| 86 | fun modalDrawer_testOffset_whenClosed() { |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 87 | var position: Offset? = null |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 88 | composeTestRule.setMaterialContent { |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 89 | ModalDrawerLayout(DrawerState.Closed, {}, drawerContent = { |
Adam Powell | 999a89b | 2020-03-11 09:08:07 -0700 | [diff] [blame] | 90 | Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates -> |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 91 | position = coords.localToRoot(Offset.Zero) |
Matvei Malkov | 201726d | 2020-03-13 14:03:54 +0000 | [diff] [blame] | 92 | }) |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 93 | }, bodyContent = emptyContent()) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 94 | } |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 95 | |
| 96 | val width = rootWidth() |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 97 | composeTestRule.runOnIdleWithDensity { |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 98 | position!!.x.toDp().assertIsEqualTo(-width) |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 99 | } |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 100 | } |
| 101 | |
| 102 | @Test |
| 103 | fun modalDrawer_testEndPadding_whenOpened() { |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 104 | composeTestRule.setMaterialContent { |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 105 | ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = { |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 106 | Box(Modifier.fillMaxSize().testTag("content")) |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 107 | }, bodyContent = emptyContent()) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 108 | } |
| 109 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 110 | onNodeWithTag("content") |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 111 | .assertWidthIsEqualTo(rootWidth() - 56.dp) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | @Test |
| 115 | fun bottomDrawer_testOffset_whenOpened() { |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 116 | composeTestRule.setMaterialContent { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 117 | BottomDrawerLayout(BottomDrawerState.Opened, {}, drawerContent = { |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 118 | Box(Modifier.fillMaxSize().testTag("content")) |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 119 | }, bodyContent = emptyContent()) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 120 | } |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 121 | |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 122 | val width = rootWidth() |
| 123 | val height = rootHeight() |
| 124 | val expectedHeight = if (width > height) 0.dp else (height / 2) |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 125 | onNodeWithTag("content") |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 126 | .assertTopPositionInRootIsEqualTo(expectedHeight) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | @Test |
| 130 | fun bottomDrawer_testOffset_whenClosed() { |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 131 | var position: Offset? = null |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 132 | composeTestRule.setMaterialContent { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 133 | BottomDrawerLayout(BottomDrawerState.Closed, {}, drawerContent = { |
Adam Powell | 999a89b | 2020-03-11 09:08:07 -0700 | [diff] [blame] | 134 | Box(Modifier.fillMaxSize().onPositioned { coords: LayoutCoordinates -> |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 135 | position = coords.localToRoot(Offset.Zero) |
Matvei Malkov | 201726d | 2020-03-13 14:03:54 +0000 | [diff] [blame] | 136 | }) |
Louis Pullen-Freilich | e46bcf0 | 2020-02-12 16:06:21 +0000 | [diff] [blame] | 137 | }, bodyContent = emptyContent()) |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 138 | } |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 139 | |
| 140 | val height = rootHeight() |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 141 | composeTestRule.runOnIdleWithDensity { |
Filip Pavlis | 028c0d5 | 2020-06-29 15:07:53 +0100 | [diff] [blame] | 142 | position!!.y.toDp().assertIsEqualTo(height) |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 143 | } |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | @Test |
Matvei Malkov | 886ec6a | 2020-02-03 01:45:29 +0000 | [diff] [blame] | 147 | @Ignore("failing in postsubmit, fix in b/148751721") |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 148 | fun modalDrawer_openAndClose() { |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 149 | var contentWidth: Int? = null |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 150 | var openedLatch: CountDownLatch? = null |
| 151 | var closedLatch: CountDownLatch? = CountDownLatch(1) |
Leland Richardson | fcf76b3 | 2020-05-13 16:58:59 -0700 | [diff] [blame] | 152 | val drawerState = mutableStateOf(DrawerState.Closed) |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 153 | composeTestRule.setMaterialContent { |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 154 | ModalDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 155 | drawerContent = { |
| 156 | Box( |
| 157 | Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates -> |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 158 | val pos = info.localToGlobal(Offset.Zero) |
Nader Jawad | e6a9b33 | 2020-05-21 13:49:20 -0700 | [diff] [blame] | 159 | if (pos.x == 0.0f) { |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 160 | // If fully opened, mark the openedLatch if present |
| 161 | openedLatch?.countDown() |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 162 | } else if (-pos.x.roundToInt() == contentWidth) { |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 163 | // If fully closed, mark the closedLatch if present |
| 164 | closedLatch?.countDown() |
Matvei Malkov | 9f27abf | 2020-05-19 15:15:56 +0100 | [diff] [blame] | 165 | } |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 166 | } |
| 167 | ) |
| 168 | }, |
| 169 | bodyContent = { |
| 170 | Box(Modifier.fillMaxSize() |
| 171 | .onPositioned { contentWidth = it.size.width }) |
| 172 | }) |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 173 | } |
| 174 | // Drawer should start in closed state |
| 175 | assertThat(closedLatch!!.await(5, TimeUnit.SECONDS)).isTrue() |
| 176 | |
| 177 | // When the drawer state is set to Opened |
| 178 | openedLatch = CountDownLatch(1) |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 179 | runOnIdle { |
Leland Richardson | fcf76b3 | 2020-05-13 16:58:59 -0700 | [diff] [blame] | 180 | drawerState.value = DrawerState.Opened |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 181 | } |
| 182 | // Then the drawer should be opened |
| 183 | assertThat(openedLatch.await(5, TimeUnit.SECONDS)).isTrue() |
| 184 | |
| 185 | // When the drawer state is set to Closed |
| 186 | closedLatch = CountDownLatch(1) |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 187 | runOnIdle { |
Leland Richardson | fcf76b3 | 2020-05-13 16:58:59 -0700 | [diff] [blame] | 188 | drawerState.value = DrawerState.Closed |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 189 | } |
| 190 | // Then the drawer should be closed |
| 191 | assertThat(closedLatch.await(5, TimeUnit.SECONDS)).isTrue() |
| 192 | } |
| 193 | |
| 194 | @Test |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 195 | fun modalDrawer_bodyContent_clickable() { |
| 196 | var drawerClicks = 0 |
| 197 | var bodyClicks = 0 |
Leland Richardson | fcf76b3 | 2020-05-13 16:58:59 -0700 | [diff] [blame] | 198 | val drawerState = mutableStateOf(DrawerState.Closed) |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 199 | composeTestRule.setMaterialContent { |
Aurimas Liutikas | 7a828d3 | 2019-10-07 17:16:05 -0700 | [diff] [blame] | 200 | // emulate click on the screen |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 201 | ModalDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 202 | drawerContent = { |
| 203 | Box( |
| 204 | Modifier.fillMaxSize().clickable { drawerClicks += 1 }, |
| 205 | children = emptyContent() |
| 206 | ) |
| 207 | }, |
| 208 | bodyContent = { |
| 209 | Box( |
| 210 | Modifier.testTag("Drawer").fillMaxSize().clickable { bodyClicks += 1 }, |
| 211 | children = emptyContent() |
| 212 | ) |
| 213 | }) |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 214 | } |
| 215 | |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 216 | // Click in the middle of the drawer (which is the middle of the body) |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 217 | onNodeWithTag("Drawer").performGesture { click() } |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 218 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 219 | runOnIdle { |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 220 | assertThat(drawerClicks).isEqualTo(0) |
| 221 | assertThat(bodyClicks).isEqualTo(1) |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 222 | |
Leland Richardson | fcf76b3 | 2020-05-13 16:58:59 -0700 | [diff] [blame] | 223 | drawerState.value = DrawerState.Opened |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 224 | } |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 225 | sleep(100) // TODO(147586311): remove this sleep when opening the drawer triggers a wait |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 226 | |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 227 | // Click on the left-center pixel of the drawer |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 228 | onNodeWithTag("Drawer").performGesture { |
Jelle Fresen | 77f4418 | 2020-07-21 16:34:29 +0100 | [diff] [blame] | 229 | click(centerLeft) |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 230 | } |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 231 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 232 | runOnIdle { |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 233 | assertThat(drawerClicks).isEqualTo(1) |
| 234 | assertThat(bodyClicks).isEqualTo(1) |
Filip Pavlis | 2b161e4 | 2019-11-22 17:40:08 +0000 | [diff] [blame] | 235 | } |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | @Test |
Matvei Malkov | 886ec6a | 2020-02-03 01:45:29 +0000 | [diff] [blame] | 239 | @Ignore("failing in postsubmit, fix in b/148751721") |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 240 | fun bottomDrawer_openAndClose() { |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 241 | var contentHeight: Int? = null |
| 242 | var openedHeight: Int? = null |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 243 | var openedLatch: CountDownLatch? = null |
| 244 | var closedLatch: CountDownLatch? = CountDownLatch(1) |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 245 | val drawerState = mutableStateOf(BottomDrawerState.Closed) |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 246 | composeTestRule.setMaterialContent { |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 247 | BottomDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 248 | drawerContent = { |
| 249 | Box(Modifier.fillMaxSize().onPositioned { info: LayoutCoordinates -> |
Nader Jawad | 6df0612 | 2020-06-03 15:27:08 -0700 | [diff] [blame] | 250 | val pos = info.localToGlobal(Offset.Zero) |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 251 | if (pos.y.roundToInt() == openedHeight) { |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 252 | // If fully opened, mark the openedLatch if present |
| 253 | openedLatch?.countDown() |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 254 | } else if (pos.y.roundToInt() == contentHeight) { |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 255 | // If fully closed, mark the closedLatch if present |
| 256 | closedLatch?.countDown() |
| 257 | } |
| 258 | }) |
| 259 | }, |
| 260 | bodyContent = { |
| 261 | Box(Modifier.fillMaxSize().onPositioned { |
| 262 | contentHeight = it.size.height |
George Mount | 8f23757 | 2020-04-30 12:08:30 -0700 | [diff] [blame] | 263 | openedHeight = (it.size.height * BottomDrawerOpenFraction).roundToInt() |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 264 | }) |
| 265 | } |
| 266 | ) |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 267 | } |
| 268 | // Drawer should start in closed state |
| 269 | assertThat(closedLatch!!.await(5, TimeUnit.SECONDS)).isTrue() |
| 270 | |
| 271 | // When the drawer state is set to Opened |
| 272 | openedLatch = CountDownLatch(1) |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 273 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 274 | drawerState.value = BottomDrawerState.Opened |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 275 | } |
| 276 | // Then the drawer should be opened |
| 277 | assertThat(openedLatch.await(5, TimeUnit.SECONDS)).isTrue() |
| 278 | |
| 279 | // When the drawer state is set to Closed |
| 280 | closedLatch = CountDownLatch(1) |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 281 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 282 | drawerState.value = BottomDrawerState.Closed |
Jelle Fresen | 4c56631 | 2020-01-16 10:32:40 +0000 | [diff] [blame] | 283 | } |
| 284 | // Then the drawer should be closed |
| 285 | assertThat(closedLatch.await(5, TimeUnit.SECONDS)).isTrue() |
| 286 | } |
| 287 | |
| 288 | @Test |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 289 | fun bottomDrawer_bodyContent_clickable() { |
| 290 | var drawerClicks = 0 |
| 291 | var bodyClicks = 0 |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 292 | val drawerState = mutableStateOf(BottomDrawerState.Closed) |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 293 | composeTestRule.setMaterialContent { |
Aurimas Liutikas | 7a828d3 | 2019-10-07 17:16:05 -0700 | [diff] [blame] | 294 | // emulate click on the screen |
Filip Pavlis | 1d4d1b83 | 2020-05-27 14:45:15 +0100 | [diff] [blame] | 295 | BottomDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 296 | drawerContent = { |
| 297 | Box( |
| 298 | Modifier.fillMaxSize().clickable { drawerClicks += 1 }, |
| 299 | children = emptyContent() |
| 300 | ) |
| 301 | }, |
| 302 | bodyContent = { |
| 303 | Box( |
| 304 | Modifier.testTag("Drawer").fillMaxSize().clickable { bodyClicks += 1 }, |
| 305 | children = emptyContent() |
| 306 | ) |
| 307 | }) |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 308 | } |
| 309 | |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 310 | // Click in the middle of the drawer (which is the middle of the body) |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 311 | onNodeWithTag("Drawer").performGesture { click() } |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 312 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 313 | runOnIdle { |
Filip Pavlis | e63b30c | 2020-01-09 16:21:07 +0000 | [diff] [blame] | 314 | assertThat(drawerClicks).isEqualTo(0) |
| 315 | assertThat(bodyClicks).isEqualTo(1) |
| 316 | } |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 317 | |
Filip Pavlis | 6fdb250 | 2020-04-02 14:41:32 +0100 | [diff] [blame] | 318 | runOnUiThread { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 319 | drawerState.value = BottomDrawerState.Opened |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 320 | } |
| 321 | sleep(100) // TODO(147586311): remove this sleep when opening the drawer triggers a wait |
| 322 | |
| 323 | // Click on the bottom-center pixel of the drawer |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 324 | onNodeWithTag("Drawer").performGesture { |
Jelle Fresen | 77f4418 | 2020-07-21 16:34:29 +0100 | [diff] [blame] | 325 | click(bottomCenter) |
Jelle Fresen | 11fc706 | 2020-01-13 16:53:55 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | assertThat(drawerClicks).isEqualTo(1) |
| 329 | assertThat(bodyClicks).isEqualTo(1) |
Matvei Malkov | 7aa7fd2 | 2019-08-16 16:52:59 +0100 | [diff] [blame] | 330 | } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 331 | |
| 332 | @Test |
| 333 | fun modalDrawer_openBySwipe() { |
| 334 | val drawerState = mutableStateOf(DrawerState.Closed) |
| 335 | composeTestRule.setMaterialContent { |
| 336 | // emulate click on the screen |
| 337 | Box(Modifier.testTag("Drawer")) { |
| 338 | ModalDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 339 | drawerContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 340 | Box(Modifier.fillMaxSize().background(color = Color.Magenta)) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 341 | }, |
| 342 | bodyContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 343 | Box(Modifier.fillMaxSize().background(color = Color.Red)) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 344 | }) |
| 345 | } |
| 346 | } |
| 347 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 348 | onNodeWithTag("Drawer") |
| 349 | .performGesture { swipeRight() } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 350 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 351 | runOnIdle { |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 352 | assertThat(drawerState.value).isEqualTo(DrawerState.Opened) |
| 353 | } |
| 354 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 355 | onNodeWithTag("Drawer") |
| 356 | .performGesture { swipeLeft() } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 357 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 358 | runOnIdle { |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 359 | assertThat(drawerState.value).isEqualTo(DrawerState.Closed) |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | @Test |
| 364 | fun modalDrawer_openBySwipe_rtl() { |
| 365 | val drawerState = mutableStateOf(DrawerState.Closed) |
| 366 | composeTestRule.setMaterialContent { |
| 367 | // emulate click on the screen |
| 368 | Box(Modifier.testTag("Drawer").rtl) { |
| 369 | ModalDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 370 | drawerContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 371 | Box(Modifier.fillMaxSize().background(color = Color.Magenta)) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 372 | }, |
| 373 | bodyContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 374 | Box(Modifier.fillMaxSize().background(color = Color.Red)) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 375 | }) |
| 376 | } |
| 377 | } |
| 378 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 379 | onNodeWithTag("Drawer") |
| 380 | .performGesture { swipeLeft() } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 381 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 382 | runOnIdle { |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 383 | assertThat(drawerState.value).isEqualTo(DrawerState.Opened) |
| 384 | } |
| 385 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 386 | onNodeWithTag("Drawer") |
| 387 | .performGesture { swipeRight() } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 388 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 389 | runOnIdle { |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 390 | assertThat(drawerState.value).isEqualTo(DrawerState.Closed) |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | @Test |
| 395 | fun bottomDrawer_openBySwipe() { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 396 | val drawerState = mutableStateOf(BottomDrawerState.Closed) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 397 | composeTestRule.setMaterialContent { |
| 398 | // emulate click on the screen |
| 399 | Box(Modifier.testTag("Drawer")) { |
| 400 | BottomDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 401 | drawerContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 402 | Box(Modifier.fillMaxSize().background(color = Color.Magenta)) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 403 | }, |
| 404 | bodyContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 405 | Box(Modifier.fillMaxSize().background(color = Color.Red)) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 406 | }) |
| 407 | } |
| 408 | } |
| 409 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 410 | onNodeWithTag("Drawer") |
| 411 | .performGesture { swipeUp() } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 412 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 413 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 414 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 415 | } |
| 416 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 417 | onNodeWithTag("Drawer") |
| 418 | .performGesture { swipeDown() } |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 419 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 420 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 421 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed) |
Matvei Malkov | 11fcc133 | 2020-06-25 18:03:03 +0100 | [diff] [blame] | 422 | } |
| 423 | } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 424 | |
| 425 | @Test |
| 426 | fun bottomDrawer_openBySwipe_thresholds() { |
| 427 | val drawerState = mutableStateOf(BottomDrawerState.Closed) |
| 428 | composeTestRule.setMaterialContent { |
| 429 | // emulate click on the screen |
| 430 | Box(Modifier.testTag("Drawer")) { |
| 431 | BottomDrawerLayout(drawerState.value, { drawerState.value = it }, |
| 432 | drawerContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 433 | Box(Modifier.fillMaxSize().background(Color.Magenta)) |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 434 | }, |
| 435 | bodyContent = { |
Matvei Malkov | bf014c1 | 2020-07-09 17:40:10 +0100 | [diff] [blame] | 436 | Box(Modifier.fillMaxSize().background(Color.Red)) |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 437 | }) |
| 438 | } |
| 439 | } |
| 440 | val threshold = with (composeTestRule.density) { BottomDrawerThreshold.toPx() } |
| 441 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 442 | onNodeWithTag("Drawer") |
| 443 | .performGesture { swipeUpBy(threshold / 2) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 444 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 445 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 446 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed) |
| 447 | } |
| 448 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 449 | onNodeWithTag("Drawer") |
| 450 | .performGesture { swipeUpBy(threshold) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 451 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 452 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 453 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened) |
| 454 | } |
| 455 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 456 | onNodeWithTag("Drawer") |
| 457 | .performGesture { swipeUpBy(threshold / 2) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 458 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 459 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 460 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened) |
| 461 | } |
| 462 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 463 | onNodeWithTag("Drawer") |
| 464 | .performGesture { swipeUpBy(threshold) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 465 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 466 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 467 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded) |
| 468 | } |
| 469 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 470 | onNodeWithTag("Drawer") |
| 471 | .performGesture { swipeDownBy(threshold / 2) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 472 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 473 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 474 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded) |
| 475 | } |
| 476 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 477 | onNodeWithTag("Drawer") |
| 478 | .performGesture { swipeDownBy(threshold) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 479 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 480 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 481 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened) |
| 482 | } |
| 483 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 484 | onNodeWithTag("Drawer") |
| 485 | .performGesture { swipeDownBy(threshold / 2) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 486 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 487 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 488 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened) |
| 489 | } |
| 490 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 491 | onNodeWithTag("Drawer") |
| 492 | .performGesture { swipeDownBy(threshold) } |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 493 | |
Filip Pavlis | a4d73a5 | 2020-07-14 11:30:00 +0100 | [diff] [blame] | 494 | runOnIdle { |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 495 | assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed) |
| 496 | } |
| 497 | } |
| 498 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 499 | private fun GestureScope.swipeUpBy(offset: Float) { |
| 500 | swipe(center, center.copy(y = center.y - offset)) |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 501 | } |
| 502 | |
Filip Pavlis | 659ea72 | 2020-07-13 14:14:32 +0100 | [diff] [blame] | 503 | private fun GestureScope.swipeDownBy(offset: Float) { |
| 504 | swipe(center, center.copy(y = center.y + offset)) |
Calin Tataru | dcde340 | 2020-07-08 11:44:22 +0100 | [diff] [blame] | 505 | } |
Matvei Malkov | 2d37cbd | 2019-07-04 15:15:20 +0100 | [diff] [blame] | 506 | } |