Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 com.android.server.wm; |
| 18 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 19 | import org.junit.Test; |
| 20 | import org.junit.runner.RunWith; |
| 21 | |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 22 | import android.content.res.Configuration; |
Wale Ogunwale | 5fc7096 | 2016-09-09 22:36:19 -0700 | [diff] [blame] | 23 | import android.platform.test.annotations.Presubmit; |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 24 | import android.support.test.filters.SmallTest; |
| 25 | import android.support.test.runner.AndroidJUnit4; |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 26 | |
| 27 | import java.util.Comparator; |
| 28 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 29 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; |
| 30 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; |
| 31 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; |
Andrii Kulian | 441e449 | 2016-09-29 15:25:00 -0700 | [diff] [blame] | 32 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; |
| 33 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 34 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; |
| 35 | import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 36 | |
| 37 | import static com.android.server.wm.WindowContainer.POSITION_BOTTOM; |
| 38 | import static com.android.server.wm.WindowContainer.POSITION_TOP; |
| 39 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 40 | import static org.junit.Assert.assertEquals; |
| 41 | import static org.junit.Assert.assertFalse; |
| 42 | import static org.junit.Assert.assertNotNull; |
| 43 | import static org.junit.Assert.assertNull; |
| 44 | import static org.junit.Assert.assertTrue; |
| 45 | |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 46 | /** |
| 47 | * Test class for {@link WindowContainer}. |
| 48 | * |
Wale Ogunwale | f7cab10 | 2016-10-25 15:25:14 -0700 | [diff] [blame] | 49 | * Build/Install/Run: |
| 50 | * bit FrameworksServicesTests:com.android.server.wm.WindowContainerTests |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 51 | */ |
| 52 | @SmallTest |
Wale Ogunwale | 5fc7096 | 2016-09-09 22:36:19 -0700 | [diff] [blame] | 53 | @Presubmit |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 54 | @RunWith(AndroidJUnit4.class) |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 55 | public class WindowContainerTests extends WindowTestsBase { |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 56 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 57 | @Test |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 58 | public void testCreation() throws Exception { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 59 | final TestWindowContainer w = new TestWindowContainerBuilder().setLayer(0).build(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 60 | assertNull("window must have no parent", w.getParentWindow()); |
| 61 | assertEquals("window must have no children", 0, w.getChildrenCount()); |
| 62 | } |
| 63 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 64 | @Test |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 65 | public void testAdd() throws Exception { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 66 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 67 | final TestWindowContainer root = builder.setLayer(0).build(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 68 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 69 | final TestWindowContainer layer1 = root.addChildWindow(builder.setLayer(1)); |
| 70 | final TestWindowContainer secondLayer1 = root.addChildWindow(builder.setLayer(1)); |
| 71 | final TestWindowContainer layer2 = root.addChildWindow(builder.setLayer(2)); |
| 72 | final TestWindowContainer layerNeg1 = root.addChildWindow(builder.setLayer(-1)); |
| 73 | final TestWindowContainer layerNeg2 = root.addChildWindow(builder.setLayer(-2)); |
| 74 | final TestWindowContainer secondLayerNeg1 = root.addChildWindow(builder.setLayer(-1)); |
| 75 | final TestWindowContainer layer0 = root.addChildWindow(builder.setLayer(0)); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 76 | |
| 77 | assertEquals(7, root.getChildrenCount()); |
| 78 | |
| 79 | assertEquals(root, layer1.getParentWindow()); |
| 80 | assertEquals(root, secondLayer1.getParentWindow()); |
| 81 | assertEquals(root, layer2.getParentWindow()); |
| 82 | assertEquals(root, layerNeg1.getParentWindow()); |
| 83 | assertEquals(root, layerNeg2.getParentWindow()); |
| 84 | assertEquals(root, secondLayerNeg1.getParentWindow()); |
| 85 | assertEquals(root, layer0.getParentWindow()); |
| 86 | |
| 87 | assertEquals(layerNeg2, root.getChildAt(0)); |
| 88 | assertEquals(secondLayerNeg1, root.getChildAt(1)); |
| 89 | assertEquals(layerNeg1, root.getChildAt(2)); |
| 90 | assertEquals(layer0, root.getChildAt(3)); |
| 91 | assertEquals(layer1, root.getChildAt(4)); |
| 92 | assertEquals(secondLayer1, root.getChildAt(5)); |
| 93 | assertEquals(layer2, root.getChildAt(6)); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 94 | |
| 95 | assertTrue(layer1.mOnParentSetCalled); |
| 96 | assertTrue(secondLayer1.mOnParentSetCalled); |
| 97 | assertTrue(layer2.mOnParentSetCalled); |
| 98 | assertTrue(layerNeg1.mOnParentSetCalled); |
| 99 | assertTrue(layerNeg2.mOnParentSetCalled); |
| 100 | assertTrue(secondLayerNeg1.mOnParentSetCalled); |
| 101 | assertTrue(layer0.mOnParentSetCalled); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 102 | } |
| 103 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 104 | @Test |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 105 | public void testAdd_AlreadyHasParent() throws Exception { |
| 106 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 107 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 108 | |
| 109 | final TestWindowContainer child1 = root.addChildWindow(); |
| 110 | final TestWindowContainer child2 = root.addChildWindow(); |
| 111 | |
| 112 | boolean gotException = false; |
| 113 | try { |
| 114 | child1.addChildWindow(child2); |
| 115 | } catch (IllegalArgumentException e) { |
| 116 | gotException = true; |
| 117 | } |
| 118 | assertTrue(gotException); |
| 119 | |
| 120 | gotException = false; |
| 121 | try { |
| 122 | root.addChildWindow(child2); |
| 123 | } catch (IllegalArgumentException e) { |
| 124 | gotException = true; |
| 125 | } |
| 126 | assertTrue(gotException); |
| 127 | } |
| 128 | |
| 129 | @Test |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 130 | public void testHasChild() throws Exception { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 131 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 132 | final TestWindowContainer root = builder.setLayer(0).build(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 133 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 134 | final TestWindowContainer child1 = root.addChildWindow(); |
| 135 | final TestWindowContainer child2 = root.addChildWindow(); |
| 136 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 137 | final TestWindowContainer child12 = child1.addChildWindow(); |
| 138 | final TestWindowContainer child21 = child2.addChildWindow(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 139 | |
| 140 | assertEquals(2, root.getChildrenCount()); |
| 141 | assertEquals(2, child1.getChildrenCount()); |
| 142 | assertEquals(1, child2.getChildrenCount()); |
| 143 | |
| 144 | assertTrue(root.hasChild(child1)); |
| 145 | assertTrue(root.hasChild(child2)); |
| 146 | assertTrue(root.hasChild(child11)); |
| 147 | assertTrue(root.hasChild(child12)); |
| 148 | assertTrue(root.hasChild(child21)); |
| 149 | |
| 150 | assertTrue(child1.hasChild(child11)); |
| 151 | assertTrue(child1.hasChild(child12)); |
| 152 | assertFalse(child1.hasChild(child21)); |
| 153 | |
| 154 | assertTrue(child2.hasChild(child21)); |
| 155 | assertFalse(child2.hasChild(child11)); |
| 156 | assertFalse(child2.hasChild(child12)); |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 157 | } |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 158 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 159 | @Test |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 160 | public void testRemoveImmediately() throws Exception { |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 161 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 162 | final TestWindowContainer root = builder.setLayer(0).build(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 163 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 164 | final TestWindowContainer child1 = root.addChildWindow(); |
| 165 | final TestWindowContainer child2 = root.addChildWindow(); |
| 166 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 167 | final TestWindowContainer child12 = child1.addChildWindow(); |
| 168 | final TestWindowContainer child21 = child2.addChildWindow(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 169 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 170 | assertNotNull(child12.getParentWindow()); |
| 171 | child12.removeImmediately(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 172 | assertNull(child12.getParentWindow()); |
| 173 | assertEquals(1, child1.getChildrenCount()); |
| 174 | assertFalse(child1.hasChild(child12)); |
| 175 | assertFalse(root.hasChild(child12)); |
| 176 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 177 | assertTrue(root.hasChild(child2)); |
| 178 | assertNotNull(child2.getParentWindow()); |
| 179 | child2.removeImmediately(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 180 | assertNull(child2.getParentWindow()); |
| 181 | assertNull(child21.getParentWindow()); |
| 182 | assertEquals(0, child2.getChildrenCount()); |
| 183 | assertEquals(1, root.getChildrenCount()); |
| 184 | assertFalse(root.hasChild(child2)); |
| 185 | assertFalse(root.hasChild(child21)); |
| 186 | |
| 187 | assertTrue(root.hasChild(child1)); |
| 188 | assertTrue(root.hasChild(child11)); |
| 189 | |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 190 | root.removeImmediately(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 191 | assertEquals(0, root.getChildrenCount()); |
| 192 | } |
| 193 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 194 | @Test |
Wale Ogunwale | 26c0dfe | 2016-12-14 14:42:30 -0800 | [diff] [blame] | 195 | public void testRemoveImmediately_WithController() throws Exception { |
| 196 | final WindowContainer container = new WindowContainer(); |
| 197 | final WindowContainerController controller = new WindowContainerController(null, sWm); |
| 198 | |
| 199 | container.setController(controller); |
| 200 | assertEquals(controller, container.getController()); |
| 201 | assertEquals(container, controller.mContainer); |
| 202 | |
| 203 | container.removeImmediately(); |
| 204 | assertNull(container.getController()); |
| 205 | assertNull(controller.mContainer); |
| 206 | } |
| 207 | |
| 208 | @Test |
| 209 | public void testSetController() throws Exception { |
| 210 | final WindowContainerController controller = new WindowContainerController(null, sWm); |
| 211 | final WindowContainer container = new WindowContainer(); |
| 212 | |
| 213 | container.setController(controller); |
| 214 | assertEquals(controller, container.getController()); |
| 215 | assertEquals(container, controller.mContainer); |
| 216 | |
| 217 | // Assert we can't change the controller to another one once set |
| 218 | boolean gotException = false; |
| 219 | try { |
| 220 | container.setController(new WindowContainerController(null, sWm)); |
| 221 | } catch (IllegalArgumentException e) { |
| 222 | gotException = true; |
| 223 | } |
| 224 | assertTrue(gotException); |
| 225 | |
| 226 | // Assert that we can set the controller to null. |
| 227 | container.setController(null); |
| 228 | assertNull(container.getController()); |
| 229 | assertNull(controller.mContainer); |
| 230 | } |
| 231 | |
| 232 | @Test |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 233 | public void testPositionChildAt() throws Exception { |
| 234 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 235 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 236 | |
| 237 | final TestWindowContainer child1 = root.addChildWindow(); |
| 238 | final TestWindowContainer child2 = root.addChildWindow(); |
| 239 | final TestWindowContainer child3 = root.addChildWindow(); |
| 240 | |
| 241 | // Test position at top. |
| 242 | root.positionChildAt(POSITION_TOP, child1, false /* includingParents */); |
| 243 | assertEquals(child1, root.getChildAt(root.getChildrenCount() - 1)); |
| 244 | |
| 245 | // Test position at bottom. |
| 246 | root.positionChildAt(POSITION_BOTTOM, child1, false /* includingParents */); |
| 247 | assertEquals(child1, root.getChildAt(0)); |
| 248 | |
| 249 | // Test position in the middle. |
| 250 | root.positionChildAt(1, child3, false /* includingParents */); |
| 251 | assertEquals(child1, root.getChildAt(0)); |
| 252 | assertEquals(child3, root.getChildAt(1)); |
| 253 | assertEquals(child2, root.getChildAt(2)); |
| 254 | } |
| 255 | |
| 256 | @Test |
| 257 | public void testPositionChildAtIncludeParents() throws Exception { |
| 258 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 259 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 260 | |
| 261 | final TestWindowContainer child1 = root.addChildWindow(); |
| 262 | final TestWindowContainer child2 = root.addChildWindow(); |
| 263 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 264 | final TestWindowContainer child12 = child1.addChildWindow(); |
| 265 | final TestWindowContainer child13 = child1.addChildWindow(); |
| 266 | final TestWindowContainer child21 = child2.addChildWindow(); |
| 267 | final TestWindowContainer child22 = child2.addChildWindow(); |
| 268 | final TestWindowContainer child23 = child2.addChildWindow(); |
| 269 | |
| 270 | // Test moving to top. |
| 271 | child1.positionChildAt(POSITION_TOP, child11, true /* includingParents */); |
| 272 | assertEquals(child12, child1.getChildAt(0)); |
| 273 | assertEquals(child13, child1.getChildAt(1)); |
| 274 | assertEquals(child11, child1.getChildAt(2)); |
| 275 | assertEquals(child2, root.getChildAt(0)); |
| 276 | assertEquals(child1, root.getChildAt(1)); |
| 277 | |
| 278 | // Test moving to bottom. |
| 279 | child1.positionChildAt(POSITION_BOTTOM, child11, true /* includingParents */); |
| 280 | assertEquals(child11, child1.getChildAt(0)); |
| 281 | assertEquals(child12, child1.getChildAt(1)); |
| 282 | assertEquals(child13, child1.getChildAt(2)); |
| 283 | assertEquals(child1, root.getChildAt(0)); |
| 284 | assertEquals(child2, root.getChildAt(1)); |
| 285 | |
| 286 | // Test moving to middle, includeParents shouldn't do anything. |
| 287 | child2.positionChildAt(1, child21, true /* includingParents */); |
| 288 | assertEquals(child11, child1.getChildAt(0)); |
| 289 | assertEquals(child12, child1.getChildAt(1)); |
| 290 | assertEquals(child13, child1.getChildAt(2)); |
| 291 | assertEquals(child22, child2.getChildAt(0)); |
| 292 | assertEquals(child21, child2.getChildAt(1)); |
| 293 | assertEquals(child23, child2.getChildAt(2)); |
| 294 | assertEquals(child1, root.getChildAt(0)); |
| 295 | assertEquals(child2, root.getChildAt(1)); |
| 296 | } |
| 297 | |
| 298 | @Test |
| 299 | public void testPositionChildAtInvalid() throws Exception { |
| 300 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 301 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 302 | |
| 303 | final TestWindowContainer child1 = root.addChildWindow(); |
| 304 | final TestWindowContainer child2 = root.addChildWindow(); |
| 305 | |
| 306 | boolean gotException = false; |
| 307 | try { |
| 308 | // Check response to negative position. |
| 309 | root.positionChildAt(-1, child1, false /* includingParents */); |
| 310 | } catch (IllegalArgumentException e) { |
| 311 | gotException = true; |
| 312 | } |
| 313 | assertTrue(gotException); |
| 314 | |
| 315 | gotException = false; |
| 316 | try { |
| 317 | // Check response to position that's bigger than child number. |
Wale Ogunwale | c5cc301 | 2017-01-13 13:26:16 -0800 | [diff] [blame] | 318 | root.positionChildAt(3, child1, false /* includingParents */); |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 319 | } catch (IllegalArgumentException e) { |
| 320 | gotException = true; |
| 321 | } |
| 322 | assertTrue(gotException); |
| 323 | } |
| 324 | |
| 325 | @Test |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 326 | public void testIsAnimating() throws Exception { |
| 327 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 328 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 329 | |
| 330 | final TestWindowContainer child1 = root.addChildWindow(builder.setIsAnimating(true)); |
| 331 | final TestWindowContainer child2 = root.addChildWindow(); |
| 332 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 333 | final TestWindowContainer child12 = child1.addChildWindow(builder.setIsAnimating(true)); |
| 334 | final TestWindowContainer child21 = child2.addChildWindow(); |
| 335 | |
| 336 | assertTrue(root.isAnimating()); |
| 337 | assertTrue(child1.isAnimating()); |
| 338 | assertFalse(child11.isAnimating()); |
| 339 | assertTrue(child12.isAnimating()); |
| 340 | assertFalse(child2.isAnimating()); |
| 341 | assertFalse(child21.isAnimating()); |
| 342 | } |
| 343 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 344 | @Test |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 345 | public void testIsVisible() throws Exception { |
| 346 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 347 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 348 | |
| 349 | final TestWindowContainer child1 = root.addChildWindow(builder.setIsVisible(true)); |
| 350 | final TestWindowContainer child2 = root.addChildWindow(); |
| 351 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 352 | final TestWindowContainer child12 = child1.addChildWindow(builder.setIsVisible(true)); |
| 353 | final TestWindowContainer child21 = child2.addChildWindow(); |
| 354 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 355 | assertFalse(root.isVisible()); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 356 | assertTrue(child1.isVisible()); |
| 357 | assertFalse(child11.isVisible()); |
| 358 | assertTrue(child12.isVisible()); |
| 359 | assertFalse(child2.isVisible()); |
| 360 | assertFalse(child21.isVisible()); |
| 361 | } |
| 362 | |
Wale Ogunwale | a7e3b64 | 2016-08-29 10:15:34 -0700 | [diff] [blame] | 363 | @Test |
Wale Ogunwale | 55ddf8f | 2017-03-20 08:56:38 -0700 | [diff] [blame] | 364 | public void testOverrideConfigurationAncestorNotification() { |
| 365 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 366 | final TestWindowContainer grandparent = builder.setLayer(0).build(); |
| 367 | |
| 368 | final TestWindowContainer parent = grandparent.addChildWindow(); |
| 369 | final TestWindowContainer child = parent.addChildWindow(); |
| 370 | child.onOverrideConfigurationChanged(new Configuration()); |
| 371 | |
| 372 | assertTrue(grandparent.mOnDescendantOverrideCalled); |
| 373 | } |
| 374 | |
| 375 | @Test |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 376 | public void testRemoveChild() throws Exception { |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 377 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 378 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 379 | final TestWindowContainer child1 = root.addChildWindow(); |
| 380 | final TestWindowContainer child2 = root.addChildWindow(); |
| 381 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 382 | final TestWindowContainer child21 = child2.addChildWindow(); |
| 383 | |
| 384 | assertTrue(root.hasChild(child2)); |
| 385 | assertTrue(root.hasChild(child21)); |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 386 | root.removeChild(child2); |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 387 | assertFalse(root.hasChild(child2)); |
| 388 | assertFalse(root.hasChild(child21)); |
| 389 | assertNull(child2.getParentWindow()); |
| 390 | |
| 391 | boolean gotException = false; |
| 392 | assertTrue(root.hasChild(child11)); |
| 393 | try { |
| 394 | // Can only detach our direct children. |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 395 | root.removeChild(child11); |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 396 | } catch (IllegalArgumentException e) { |
| 397 | gotException = true; |
| 398 | } |
| 399 | assertTrue(gotException); |
| 400 | } |
| 401 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 402 | @Test |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 403 | public void testGetOrientation_childSpecified() throws Exception { |
| 404 | testGetOrientation_childSpecifiedConfig(false, SCREEN_ORIENTATION_LANDSCAPE, |
| 405 | SCREEN_ORIENTATION_LANDSCAPE); |
| 406 | testGetOrientation_childSpecifiedConfig(false, SCREEN_ORIENTATION_UNSET, |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 407 | SCREEN_ORIENTATION_UNSPECIFIED); |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | private void testGetOrientation_childSpecifiedConfig(boolean childVisible, int childOrientation, |
| 411 | int expectedOrientation) { |
| 412 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 413 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 414 | root.setFillsParent(true); |
| 415 | |
| 416 | builder.setIsVisible(childVisible); |
| 417 | |
| 418 | if (childOrientation != SCREEN_ORIENTATION_UNSET) { |
| 419 | builder.setOrientation(childOrientation); |
| 420 | } |
| 421 | |
| 422 | final TestWindowContainer child1 = root.addChildWindow(builder); |
| 423 | child1.setFillsParent(true); |
| 424 | |
Wale Ogunwale | 5e5a68d | 2017-03-24 17:36:38 -0700 | [diff] [blame] | 425 | assertEquals(expectedOrientation, root.getOrientation()); |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | @Test |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 429 | public void testGetOrientation_Unset() throws Exception { |
| 430 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 431 | final TestWindowContainer root = builder.setLayer(0).setIsVisible(true).build(); |
| 432 | // Unspecified well because we didn't specify anything... |
| 433 | assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, root.getOrientation()); |
| 434 | } |
| 435 | |
| 436 | @Test |
| 437 | public void testGetOrientation_InvisibleParentUnsetVisibleChildren() throws Exception { |
| 438 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 439 | final TestWindowContainer root = builder.setLayer(0).setIsVisible(true).build(); |
| 440 | |
| 441 | builder.setIsVisible(false).setLayer(-1); |
| 442 | final TestWindowContainer invisible = root.addChildWindow(builder); |
| 443 | builder.setIsVisible(true).setLayer(-2); |
| 444 | final TestWindowContainer invisibleChild1VisibleAndSet = invisible.addChildWindow(builder); |
| 445 | invisibleChild1VisibleAndSet.setOrientation(SCREEN_ORIENTATION_LANDSCAPE); |
| 446 | // Landscape well because the container is visible and that is what we set on it above. |
| 447 | assertEquals(SCREEN_ORIENTATION_LANDSCAPE, invisibleChild1VisibleAndSet.getOrientation()); |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 448 | // Landscape because even though the container isn't visible it has a child that is |
| 449 | // specifying it can influence the orientation by being visible. |
| 450 | assertEquals(SCREEN_ORIENTATION_LANDSCAPE, invisible.getOrientation()); |
| 451 | // Landscape because the grandchild is visible and therefore can participate. |
| 452 | assertEquals(SCREEN_ORIENTATION_LANDSCAPE, root.getOrientation()); |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 453 | |
| 454 | builder.setIsVisible(true).setLayer(-3); |
| 455 | final TestWindowContainer visibleUnset = root.addChildWindow(builder); |
| 456 | visibleUnset.setOrientation(SCREEN_ORIENTATION_UNSET); |
| 457 | assertEquals(SCREEN_ORIENTATION_UNSET, visibleUnset.getOrientation()); |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 458 | assertEquals(SCREEN_ORIENTATION_LANDSCAPE, root.getOrientation()); |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 459 | |
| 460 | } |
| 461 | |
| 462 | @Test |
| 463 | public void testGetOrientation_setBehind() throws Exception { |
| 464 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 465 | final TestWindowContainer root = builder.setLayer(0).setIsVisible(true).build(); |
| 466 | |
| 467 | builder.setIsVisible(true).setLayer(-1); |
| 468 | final TestWindowContainer visibleUnset = root.addChildWindow(builder); |
| 469 | visibleUnset.setOrientation(SCREEN_ORIENTATION_UNSET); |
| 470 | |
| 471 | builder.setIsVisible(true).setLayer(-2); |
| 472 | final TestWindowContainer visibleUnsetChild1VisibleSetBehind = |
| 473 | visibleUnset.addChildWindow(builder); |
| 474 | visibleUnsetChild1VisibleSetBehind.setOrientation(SCREEN_ORIENTATION_BEHIND); |
| 475 | // Setting to visible behind will be used by the parents if there isn't another other |
| 476 | // container behind this one that has an orientation set. |
| 477 | assertEquals(SCREEN_ORIENTATION_BEHIND, |
| 478 | visibleUnsetChild1VisibleSetBehind.getOrientation()); |
| 479 | assertEquals(SCREEN_ORIENTATION_BEHIND, visibleUnset.getOrientation()); |
| 480 | assertEquals(SCREEN_ORIENTATION_BEHIND, root.getOrientation()); |
| 481 | } |
| 482 | |
| 483 | @Test |
| 484 | public void testGetOrientation_fillsParent() throws Exception { |
| 485 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 486 | final TestWindowContainer root = builder.setLayer(0).setIsVisible(true).build(); |
| 487 | |
| 488 | builder.setIsVisible(true).setLayer(-1); |
| 489 | final TestWindowContainer visibleUnset = root.addChildWindow(builder); |
| 490 | visibleUnset.setOrientation(SCREEN_ORIENTATION_BEHIND); |
| 491 | |
| 492 | builder.setLayer(1).setIsVisible(true); |
| 493 | final TestWindowContainer visibleUnspecifiedRootChild = root.addChildWindow(builder); |
| 494 | visibleUnspecifiedRootChild.setFillsParent(false); |
| 495 | visibleUnspecifiedRootChild.setOrientation(SCREEN_ORIENTATION_UNSPECIFIED); |
| 496 | // Unset because the child doesn't fill the parent. May as well be invisible... |
| 497 | assertEquals(SCREEN_ORIENTATION_UNSET, visibleUnspecifiedRootChild.getOrientation()); |
| 498 | // The parent uses whatever orientation is set behind this container since it doesn't fill |
| 499 | // the parent. |
| 500 | assertEquals(SCREEN_ORIENTATION_BEHIND, root.getOrientation()); |
| 501 | |
| 502 | // Test case of child filling its parent, but its parent isn't filling its own parent. |
| 503 | builder.setLayer(2).setIsVisible(true); |
| 504 | final TestWindowContainer visibleUnspecifiedRootChildChildFillsParent = |
| 505 | visibleUnspecifiedRootChild.addChildWindow(builder); |
| 506 | visibleUnspecifiedRootChildChildFillsParent.setOrientation( |
| 507 | SCREEN_ORIENTATION_PORTRAIT); |
| 508 | assertEquals(SCREEN_ORIENTATION_PORTRAIT, |
| 509 | visibleUnspecifiedRootChildChildFillsParent.getOrientation()); |
| 510 | assertEquals(SCREEN_ORIENTATION_UNSET, visibleUnspecifiedRootChild.getOrientation()); |
| 511 | assertEquals(SCREEN_ORIENTATION_BEHIND, root.getOrientation()); |
| 512 | |
| 513 | |
| 514 | visibleUnspecifiedRootChild.setFillsParent(true); |
| 515 | assertEquals(SCREEN_ORIENTATION_PORTRAIT, visibleUnspecifiedRootChild.getOrientation()); |
| 516 | assertEquals(SCREEN_ORIENTATION_PORTRAIT, root.getOrientation()); |
| 517 | } |
| 518 | |
Wale Ogunwale | 63d4ecc | 2016-09-08 18:48:26 -0700 | [diff] [blame] | 519 | @Test |
| 520 | public void testCompareTo() throws Exception { |
| 521 | final TestWindowContainerBuilder builder = new TestWindowContainerBuilder(); |
| 522 | final TestWindowContainer root = builder.setLayer(0).build(); |
| 523 | |
| 524 | final TestWindowContainer child1 = root.addChildWindow(); |
| 525 | final TestWindowContainer child11 = child1.addChildWindow(); |
| 526 | final TestWindowContainer child12 = child1.addChildWindow(); |
| 527 | |
| 528 | final TestWindowContainer child2 = root.addChildWindow(); |
| 529 | final TestWindowContainer child21 = child2.addChildWindow(); |
| 530 | final TestWindowContainer child22 = child2.addChildWindow(); |
| 531 | final TestWindowContainer child23 = child2.addChildWindow(); |
| 532 | final TestWindowContainer child221 = child22.addChildWindow(); |
| 533 | final TestWindowContainer child222 = child22.addChildWindow(); |
| 534 | final TestWindowContainer child223 = child22.addChildWindow(); |
| 535 | final TestWindowContainer child2221 = child222.addChildWindow(); |
| 536 | final TestWindowContainer child2222 = child222.addChildWindow(); |
| 537 | final TestWindowContainer child2223 = child222.addChildWindow(); |
| 538 | |
| 539 | final TestWindowContainer root2 = builder.setLayer(0).build(); |
| 540 | |
| 541 | assertEquals(0, root.compareTo(root)); |
| 542 | assertEquals(-1, child1.compareTo(child2)); |
| 543 | assertEquals(1, child2.compareTo(child1)); |
| 544 | |
| 545 | boolean inTheSameTree = true; |
| 546 | try { |
| 547 | root.compareTo(root2); |
| 548 | } catch (IllegalArgumentException e) { |
| 549 | inTheSameTree = false; |
| 550 | } |
| 551 | assertFalse(inTheSameTree); |
| 552 | |
| 553 | assertEquals(-1, child1.compareTo(child11)); |
| 554 | assertEquals(1, child21.compareTo(root)); |
| 555 | assertEquals(1, child21.compareTo(child12)); |
| 556 | assertEquals(-1, child11.compareTo(child2)); |
| 557 | assertEquals(1, child2221.compareTo(child11)); |
| 558 | assertEquals(-1, child2222.compareTo(child223)); |
| 559 | assertEquals(1, child2223.compareTo(child21)); |
| 560 | } |
| 561 | |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 562 | /* Used so we can gain access to some protected members of the {@link WindowContainer} class */ |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 563 | private class TestWindowContainer extends WindowContainer<TestWindowContainer> { |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 564 | private final int mLayer; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 565 | private boolean mIsAnimating; |
| 566 | private boolean mIsVisible; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 567 | private boolean mFillsParent; |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 568 | private Integer mOrientation; |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 569 | |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 570 | private boolean mOnParentSetCalled; |
Wale Ogunwale | 55ddf8f | 2017-03-20 08:56:38 -0700 | [diff] [blame] | 571 | private boolean mOnDescendantOverrideCalled; |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 572 | |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 573 | /** |
| 574 | * Compares 2 window layers and returns -1 if the first is lesser than the second in terms |
| 575 | * of z-order and 1 otherwise. |
| 576 | */ |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 577 | private final Comparator<TestWindowContainer> mWindowSubLayerComparator = (w1, w2) -> { |
| 578 | final int layer1 = w1.mLayer; |
| 579 | final int layer2 = w2.mLayer; |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 580 | if (layer1 < layer2 || (layer1 == layer2 && layer2 < 0 )) { |
Wale Ogunwale | d90546a | 2016-09-09 23:28:03 -0700 | [diff] [blame] | 581 | // We insert the child window into the list ordered by the mLayer. For same layers, |
| 582 | // the negative one should go below others; the positive one should go above others. |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 583 | return -1; |
| 584 | } |
| 585 | return 1; |
| 586 | }; |
| 587 | |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 588 | TestWindowContainer(int layer, boolean isAnimating, boolean isVisible, |
| 589 | Integer orientation) { |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 590 | mLayer = layer; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 591 | mIsAnimating = isAnimating; |
| 592 | mIsVisible = isVisible; |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 593 | mFillsParent = true; |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 594 | mOrientation = orientation; |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 595 | } |
| 596 | |
| 597 | TestWindowContainer getParentWindow() { |
| 598 | return (TestWindowContainer) getParent(); |
| 599 | } |
| 600 | |
| 601 | int getChildrenCount() { |
| 602 | return mChildren.size(); |
| 603 | } |
| 604 | |
Wale Ogunwale | f619286 | 2016-09-10 13:42:30 -0700 | [diff] [blame] | 605 | TestWindowContainer addChildWindow(TestWindowContainer child) { |
| 606 | addChild(child, mWindowSubLayerComparator); |
| 607 | return child; |
| 608 | } |
| 609 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 610 | TestWindowContainer addChildWindow(TestWindowContainerBuilder childBuilder) { |
| 611 | TestWindowContainer child = childBuilder.build(); |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 612 | addChild(child, mWindowSubLayerComparator); |
| 613 | return child; |
| 614 | } |
| 615 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 616 | TestWindowContainer addChildWindow() { |
| 617 | return addChildWindow(new TestWindowContainerBuilder().setLayer(1)); |
| 618 | } |
| 619 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 620 | @Override |
Andrii Kulian | d276563 | 2016-12-12 22:26:34 -0800 | [diff] [blame] | 621 | void onParentSet() { |
| 622 | mOnParentSetCalled = true; |
| 623 | } |
| 624 | |
| 625 | @Override |
Wale Ogunwale | 55ddf8f | 2017-03-20 08:56:38 -0700 | [diff] [blame] | 626 | void onDescendantOverrideConfigurationChanged() { |
| 627 | mOnDescendantOverrideCalled = true; |
| 628 | super.onDescendantOverrideConfigurationChanged(); |
| 629 | } |
| 630 | |
| 631 | @Override |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 632 | boolean isAnimating() { |
| 633 | return mIsAnimating || super.isAnimating(); |
| 634 | } |
| 635 | |
| 636 | @Override |
| 637 | boolean isVisible() { |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 638 | return mIsVisible; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 639 | } |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 640 | |
| 641 | @Override |
Wale Ogunwale | 5e5a68d | 2017-03-24 17:36:38 -0700 | [diff] [blame] | 642 | int getOrientation(int candidate) { |
| 643 | return mOrientation != null ? mOrientation : super.getOrientation(candidate); |
| 644 | } |
| 645 | |
| 646 | @Override |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 647 | int getOrientation() { |
Wale Ogunwale | 5e5a68d | 2017-03-24 17:36:38 -0700 | [diff] [blame] | 648 | return getOrientation(super.mOrientation); |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 649 | } |
| 650 | |
| 651 | @Override |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 652 | boolean fillsParent() { |
| 653 | return mFillsParent; |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 654 | } |
| 655 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 656 | void setFillsParent(boolean fillsParent) { |
| 657 | mFillsParent = fillsParent; |
Wale Ogunwale | 571771c | 2016-08-26 13:18:50 -0700 | [diff] [blame] | 658 | } |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 659 | } |
| 660 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 661 | private class TestWindowContainerBuilder { |
| 662 | private int mLayer; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 663 | private boolean mIsAnimating; |
| 664 | private boolean mIsVisible; |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 665 | private Integer mOrientation; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 666 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 667 | public TestWindowContainerBuilder() { |
| 668 | reset(); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 669 | } |
| 670 | |
Wale Ogunwale | 5136249 | 2016-09-08 17:49:17 -0700 | [diff] [blame] | 671 | TestWindowContainerBuilder setLayer(int layer) { |
| 672 | mLayer = layer; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 673 | return this; |
| 674 | } |
| 675 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 676 | TestWindowContainerBuilder setIsAnimating(boolean isAnimating) { |
| 677 | mIsAnimating = isAnimating; |
| 678 | return this; |
| 679 | } |
| 680 | |
| 681 | TestWindowContainerBuilder setIsVisible(boolean isVisible) { |
| 682 | mIsVisible = isVisible; |
| 683 | return this; |
| 684 | } |
| 685 | |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 686 | TestWindowContainerBuilder setOrientation(int orientation) { |
| 687 | mOrientation = orientation; |
| 688 | return this; |
| 689 | } |
| 690 | |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 691 | TestWindowContainerBuilder reset() { |
| 692 | mLayer = 0; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 693 | mIsAnimating = false; |
| 694 | mIsVisible = false; |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 695 | mOrientation = null; |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 696 | return this; |
| 697 | } |
| 698 | |
| 699 | TestWindowContainer build() { |
Bryce Lee | a163b76 | 2017-01-24 11:05:01 -0800 | [diff] [blame] | 700 | return new TestWindowContainer(mLayer, mIsAnimating, mIsVisible, mOrientation); |
Wale Ogunwale | d1c3791 | 2016-08-16 03:19:39 -0700 | [diff] [blame] | 701 | } |
| 702 | } |
Wale Ogunwale | d63594a | 2016-07-18 07:48:30 -0700 | [diff] [blame] | 703 | } |