Home | History | Annotate | Download | only in inputmethods
      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.inputmethods;
     18 
     19 import static com.android.settings.ui.testutils.SettingsTestUtils.TIMEOUT;
     20 import static com.google.common.truth.Truth.assertThat;
     21 
     22 import android.app.Instrumentation;
     23 import android.content.Intent;
     24 import android.support.test.InstrumentationRegistry;
     25 import android.support.test.runner.AndroidJUnit4;
     26 import android.support.test.uiautomator.By;
     27 import android.support.test.uiautomator.UiDevice;
     28 import android.support.test.uiautomator.UiObject2;
     29 import android.support.test.uiautomator.Until;
     30 
     31 import org.junit.Before;
     32 import org.junit.Test;
     33 import org.junit.runner.RunWith;
     34 
     35 @RunWith(AndroidJUnit4.class)
     36 public class SpellCheckerSettingsUITest {
     37 
     38     private Instrumentation mInstrumentation;
     39     private Intent mIntent;
     40     private UiDevice mUiDevice;
     41 
     42     @Before
     43     public void setUp() {
     44         mInstrumentation = InstrumentationRegistry.getInstrumentation();
     45         mUiDevice = UiDevice.getInstance(mInstrumentation);
     46         mIntent = new Intent().setClassName("com.android.settings",
     47                 "com.android.settings.Settings$SpellCheckersSettingsActivity")
     48                 .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     49     }
     50 
     51     @Test
     52     public void launchSettings_hasSwitchBar() {
     53         mInstrumentation.getContext().startActivity(mIntent);
     54         final UiObject2 switchBar =
     55                 mUiDevice.wait(Until.findObject(By.text("Use spell checker")), TIMEOUT);
     56 
     57         assertThat(switchBar).isNotNull();
     58     }
     59 }
     60