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 android.os.RemoteException; 20 import android.provider.Settings; 21 import android.support.test.InstrumentationRegistry; 22 import android.support.test.filters.MediumTest; 23 import android.support.test.runner.AndroidJUnit4; 24 import android.support.test.uiautomator.By; 25 import android.support.test.uiautomator.UiDevice; 26 import android.support.test.uiautomator.UiObject2; 27 import android.support.test.uiautomator.Until; 28 import android.system.helpers.SettingsHelper; 29 30 import org.junit.After; 31 import org.junit.Before; 32 import org.junit.Test; 33 import org.junit.runner.RunWith; 34 35 import static junit.framework.Assert.assertTrue; 36 37 @MediumTest 38 @RunWith(AndroidJUnit4.class) 39 public class SyncSettingsTest { 40 private static final int TIMEOUT = 2000; 41 42 private UiDevice mDevice; 43 44 @Before setUp()45 public void setUp() throws Exception { 46 mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); 47 48 try { 49 mDevice.setOrientationNatural(); 50 } catch (RemoteException e) { 51 throw new RuntimeException("failed to freeze device orientaion", e); 52 } 53 } 54 55 @After tearDown()56 public void tearDown() throws Exception { 57 // Need to finish settings activity 58 mDevice.pressHome(); 59 } 60 61 @Test syncPageShouldHaveAddAccountButton()62 public void syncPageShouldHaveAddAccountButton() throws Exception { 63 // Launch Settings 64 SettingsHelper.launchSettingsPage( 65 InstrumentationRegistry.getContext(), Settings.ACTION_SYNC_SETTINGS); 66 UiObject2 addAccount = mDevice.wait( 67 Until.findObject(By.text("Add account")), TIMEOUT); 68 assertTrue(addAccount != null); 69 } 70 } 71