1 /*
2  * Copyright (C) 2015 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.tv;
18 
19 import static androidx.test.ext.truth.content.IntentSubject.assertThat;
20 
21 import android.content.Intent;
22 
23 import com.android.tv.testing.constants.ConfigConstants;
24 import com.android.tv.util.Utils;
25 
26 import com.google.common.truth.Truth;
27 
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.robolectric.Robolectric;
31 import org.robolectric.RobolectricTestRunner;
32 import org.robolectric.annotation.Config;
33 import org.robolectric.shadows.ShadowApplication;
34 
35 /** Test for {@link TvActivity}. */
36 @RunWith(RobolectricTestRunner.class)
37 @Config(sdk = ConfigConstants.SDK)
38 public class TvActivityTest {
39 
40     @Test
testLifeCycle()41     public void testLifeCycle() {
42         TvActivity activity = Robolectric.setupActivity(TvActivity.class);
43         Truth.assertThat(activity.isFinishing()).isTrue();
44 
45         Intent nextStartedActivity = ShadowApplication.getInstance().getNextStartedActivity();
46         assertThat(nextStartedActivity).hasComponentClass(MainActivity.class);
47         assertThat(nextStartedActivity).extras().bool(Utils.EXTRA_KEY_FROM_LAUNCHER).isTrue();
48     }
49 }
50