• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 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.ui;
18 
19 import static com.android.settings.ui.testutils.SettingsTestUtils.SETTINGS_PACKAGE;
20 import static com.android.settings.ui.testutils.SettingsTestUtils.TIMEOUT;
21 
22 import android.os.RemoteException;
23 import android.platform.test.annotations.Presubmit;
24 import android.provider.Settings;
25 import android.support.test.InstrumentationRegistry;
26 import android.support.test.filters.MediumTest;
27 import android.support.test.runner.AndroidJUnit4;
28 import android.support.test.uiautomator.By;
29 import android.support.test.uiautomator.Direction;
30 import android.support.test.uiautomator.UiDevice;
31 import android.support.test.uiautomator.UiObject2;
32 import android.support.test.uiautomator.Until;
33 import android.system.helpers.SettingsHelper;
34 
35 import com.android.settings.ui.testutils.SettingsTestUtils;
36 
37 import org.junit.After;
38 import org.junit.Before;
39 import org.junit.Test;
40 import org.junit.runner.RunWith;
41 
42 @MediumTest
43 @RunWith(AndroidJUnit4.class)
44 public class HomepageDisplayTests {
45 
46     private static final String[] HOMEPAGE_ITEMS = {
47             "Network & internet",
48             "Connected devices",
49             "Apps & notifications",
50             "Battery",
51             "Display",
52             "Sound",
53             "Storage",
54             "Security & location",
55             "Accounts",
56             "Accessibility",
57             "System",
58             "Support & tips"
59     };
60 
61     private UiDevice mDevice;
62 
63     @Before
setUp()64     public void setUp() throws Exception {
65         mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
66         try {
67             mDevice.setOrientationNatural();
68         } catch (RemoteException e) {
69             throw new RuntimeException("failed to freeze device orientaion", e);
70         }
71     }
72 
73     @After
tearDown()74     public void tearDown() throws Exception {
75         // Need to finish settings activity
76         mDevice.pressHome();
77     }
78 
79     @Presubmit
80     @Test
testHomepageCategory()81     public void testHomepageCategory() throws Exception {
82         // Launch Settings
83         SettingsHelper.launchSettingsPage(
84                 InstrumentationRegistry.getContext(), Settings.ACTION_SETTINGS);
85 
86         // Scroll to top
87         final UiObject2 view = mDevice.wait(
88                 Until.findObject(By.res(SETTINGS_PACKAGE, "main_content")),
89                 TIMEOUT);
90         view.scroll(Direction.UP, 100f);
91 
92         // Inspect each item
93         for (String item : HOMEPAGE_ITEMS) {
94             SettingsTestUtils.assertTitleMatch(mDevice, item);
95         }
96     }
97 }
98