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