Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [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 | |
| 19 | import static junit.framework.Assert.assertTrue; |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 20 | |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 21 | import android.platform.test.annotations.Presubmit; |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 22 | import android.support.test.filters.SmallTest; |
| 23 | import android.support.test.runner.AndroidJUnit4; |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 24 | |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 25 | import org.junit.Before; |
| 26 | import org.junit.Test; |
| 27 | import org.junit.runner.RunWith; |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 28 | |
| 29 | /** |
| 30 | * Test class for {@link AppTransition}. |
| 31 | * |
Jorim Jaggi | 46a26a8 | 2016-12-15 17:45:41 -0800 | [diff] [blame] | 32 | * runtest frameworks-services -c com.android.server.wm.UnknownAppVisibilityControllerTest |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 33 | */ |
| 34 | @SmallTest |
Jorim Jaggi | 46a26a8 | 2016-12-15 17:45:41 -0800 | [diff] [blame] | 35 | @Presubmit |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 36 | @RunWith(AndroidJUnit4.class) |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 37 | public class UnknownAppVisibilityControllerTest extends WindowTestsBase { |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 38 | |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 39 | @Before |
| 40 | public void setUp() throws Exception { |
Jorim Jaggi | 9bafc71 | 2017-01-19 17:28:30 +0100 | [diff] [blame] | 41 | super.setUp(); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 42 | sWm.mUnknownAppVisibilityController.clear(); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | @Test |
| 46 | public void testFlow() throws Exception { |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame^] | 47 | final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 48 | sWm.mUnknownAppVisibilityController.notifyLaunched(token); |
| 49 | sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token); |
| 50 | sWm.mUnknownAppVisibilityController.notifyRelayouted(token); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 51 | |
| 52 | // Make sure our handler processed the message. |
| 53 | Thread.sleep(100); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 54 | assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | @Test |
| 58 | public void testMultiple() throws Exception { |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame^] | 59 | final AppWindowToken token1 = new WindowTestUtils.TestAppWindowToken(mDisplayContent); |
| 60 | final AppWindowToken token2 = new WindowTestUtils.TestAppWindowToken(mDisplayContent); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 61 | sWm.mUnknownAppVisibilityController.notifyLaunched(token1); |
| 62 | sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token1); |
| 63 | sWm.mUnknownAppVisibilityController.notifyLaunched(token2); |
| 64 | sWm.mUnknownAppVisibilityController.notifyRelayouted(token1); |
| 65 | sWm.mUnknownAppVisibilityController.notifyAppResumedFinished(token2); |
| 66 | sWm.mUnknownAppVisibilityController.notifyRelayouted(token2); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 67 | |
| 68 | // Make sure our handler processed the message. |
| 69 | Thread.sleep(100); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 70 | assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | @Test |
| 74 | public void testClear() throws Exception { |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame^] | 75 | final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 76 | sWm.mUnknownAppVisibilityController.notifyLaunched(token); |
| 77 | sWm.mUnknownAppVisibilityController.clear();; |
| 78 | assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | @Test |
| 82 | public void testAppRemoved() throws Exception { |
Wale Ogunwale | 11cc516 | 2017-04-25 20:29:13 -0700 | [diff] [blame^] | 83 | final AppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent); |
Wale Ogunwale | 17f175c | 2017-02-07 16:54:10 -0800 | [diff] [blame] | 84 | sWm.mUnknownAppVisibilityController.notifyLaunched(token); |
| 85 | sWm.mUnknownAppVisibilityController.appRemoved(token); |
| 86 | assertTrue(sWm.mUnknownAppVisibilityController.allResolved()); |
Jorim Jaggi | 5a108c2 | 2016-10-13 14:33:27 +0200 | [diff] [blame] | 87 | } |
| 88 | } |