1 /* 2 * Copyright (C) 2014 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.inputmethod.keyboard.layout.tests; 18 19 import android.test.suitebuilder.annotation.SmallTest; 20 import android.text.InputType; 21 import android.view.inputmethod.EditorInfo; 22 import android.view.inputmethod.InputMethodSubtype; 23 24 import com.android.inputmethod.keyboard.KeyboardLayoutSet; 25 import com.android.inputmethod.keyboard.layout.LayoutBase; 26 import com.android.inputmethod.keyboard.layout.Qwerty; 27 import com.android.inputmethod.keyboard.layout.customizer.EnglishCustomizer; 28 import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; 29 30 import java.util.Locale; 31 32 /** 33 * en_US: English (United States)/qwerty, URL input field. 34 */ 35 @SmallTest 36 public class TestsQwertyUrl extends LayoutTestsBase { 37 private static final Locale LOCALE = new Locale("en", "US"); 38 private static final LayoutBase LAYOUT = new Qwerty(new EnglishUrlCustomizer(LOCALE)); 39 40 @Override 41 LayoutBase getLayout() { return LAYOUT; } 42 43 @Override 44 protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, 45 final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, 46 final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { 47 final EditorInfo emailField = new EditorInfo(); 48 emailField.inputType = 49 InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; 50 return super.createKeyboardLayoutSet( 51 subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled, 52 splitLayoutEnabled); 53 } 54 55 private static class EnglishUrlCustomizer extends EnglishCustomizer { 56 EnglishUrlCustomizer(final Locale locale) { super(locale); } 57 58 @Override 59 public ExpectedKey getEnterKey(final boolean isPhone) { 60 return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); 61 } 62 63 @Override 64 public ExpectedKey getEmojiKey(final boolean isPhone) { 65 return DOMAIN_KEY; 66 } 67 68 @Override 69 public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { 70 return joinKeys(key("/", SETTINGS_KEY)); 71 } 72 } 73 } 74