• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.settings.wallpaper;
18 
19 import android.content.Context;
20 import android.content.Intent;
21 import android.content.pm.PackageManager;
22 
23 import com.android.settings.SettingsRobolectricTestRunner;
24 import com.android.settings.SubSettings;
25 import com.android.settings.TestConfig;
26 
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30 import org.mockito.Mock;
31 import org.mockito.MockitoAnnotations;
32 import org.robolectric.Robolectric;
33 import org.robolectric.annotation.Config;
34 import org.robolectric.shadows.ShadowActivity;
35 import org.robolectric.util.ActivityController;
36 
37 import static com.google.common.truth.Truth.assertThat;
38 import static org.mockito.Mockito.when;
39 import static org.robolectric.Shadows.shadowOf;
40 
41 @RunWith(SettingsRobolectricTestRunner.class)
42 @Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
43 public class WallpaperSuggestionActivityTest {
44 
45     @Mock
46     private Context mContext;
47     @Mock
48     private PackageManager mPackageManager;
49     private ActivityController<WallpaperSuggestionActivity> mController;
50 
51     @Before
setUp()52     public void setUp() {
53         MockitoAnnotations.initMocks(this);
54         when(mContext.getPackageManager()).thenReturn(mPackageManager);
55         mController = Robolectric.buildActivity(WallpaperSuggestionActivity.class);
56     }
57 
58     @Test
launch_primarySuggestionActivityDoesNotExist_shouldFallback()59     public void launch_primarySuggestionActivityDoesNotExist_shouldFallback() {
60         ShadowActivity activity = shadowOf(mController.setup().get());
61         final Intent intent = activity.getNextStartedActivity();
62 
63         assertThat(intent.getComponent().getClassName()).isEqualTo(SubSettings.class.getName());
64     }
65 }
66