115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka/*
215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * Copyright (C) 2014 The Android Open Source Project
315a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka *
415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * Licensed under the Apache License, Version 2.0 (the "License");
515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * you may not use this file except in compliance with the License.
615a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * You may obtain a copy of the License at
715a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka *
815a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka *      http://www.apache.org/licenses/LICENSE-2.0
915a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka *
1015a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * Unless required by applicable law or agreed to in writing, software
1115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * distributed under the License is distributed on an "AS IS" BASIS,
1215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1315a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * See the License for the specific language governing permissions and
1415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * limitations under the License.
1515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka */
1615a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
1715a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaokapackage com.android.inputmethod.keyboard.layout.expected;
1815a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
190dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaokaimport com.android.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey;
2015a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
2115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka/**
2215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka * Base class to create an expected keyboard for unit test.
2315a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka */
2415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaokapublic abstract class AbstractLayoutBase {
2515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    // Those helper methods have a lower case name to be readable when defining expected keyboard
2615a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    // layouts.
2715a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
28746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object that has the label.
2915a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey key(final String label, final ExpectedKey ... moreKeys) {
3015a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(label, moreKeys);
3115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
3215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
33746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object that has the label and the output text.
3415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey key(final String label, final String outputText,
3515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka            final ExpectedKey ... moreKeys) {
3615a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(label, outputText, moreKeys);
3715a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
3815a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
39746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object that has the label and the output code.
4015a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey key(final String label, final int code,
4115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka            final ExpectedKey ... moreKeys) {
4215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(label, code, moreKeys);
4315a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
4415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
45746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object that has the icon and the output text.
46746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    public static ExpectedKey key(final int iconId, final String outputText,
47746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka            final ExpectedKey ... moreKeys) {
48746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka        return ExpectedKey.newInstance(iconId, outputText, moreKeys);
49746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    }
50746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka
51746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object that has the icon and the output code.
5215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey key(final int iconId, final int code,
5315a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka            final ExpectedKey ... moreKeys) {
5415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(iconId, code, moreKeys);
5515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
5615a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
57746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object that has new "more keys".
5815a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey key(final ExpectedKey key, final ExpectedKey ... moreKeys) {
5915a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(key.getVisual(), key.getOutput(), moreKeys);
6015a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
6115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
620dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    // Helper method to create an {@link ExpectedAdditionalMoreKey} object for an
630dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    // "additional more key" that has the label.
640dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    // The additional more keys can be defined independently from other more keys. The position of
650dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    // the additional more keys in the long press popup keyboard can be controlled by specifying
660dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    // special marker "%" in the usual more keys definitions.
670dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    public static ExpectedAdditionalMoreKey additionalMoreKey(final String label) {
680dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka        return ExpectedAdditionalMoreKey.newInstance(label);
690dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka    }
700dabae720a83f9099667dea4de002007fdf35d60Tadashi G. Takaoka
71746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object for a "more key" that has the label.
7215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey moreKey(final String label) {
7315a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(label);
7415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
7515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
76746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
77746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // and the output text.
7815a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey moreKey(final String label, final String outputText) {
7915a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(label, outputText);
8015a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
8115a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
82746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
83746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // and the output code.
8415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey moreKey(final String label, final int code) {
8515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka        return ExpectedKey.newInstance(label, code);
8615a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
8715a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka
88746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // Helper method to create an {@link ExpectedKey} object for a "more key" that has the icon
89746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    // and the output text.
90746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    public static ExpectedKey moreKey(final int iconId, final String outputText) {
91746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka        return ExpectedKey.newInstance(iconId, outputText);
92746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    }
93746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka
9415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey},
9515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    // {@link ExpectedKey} array, and {@link String}.
96746f94c671607521f66fd3c989072b5ec7c390c4Tadashi G. Takaoka    public static ExpectedKey[] joinMoreKeys(final Object ... moreKeys) {
9774f259a74ee600d742072361d074493f892eb1b7Tadashi G. Takaoka        return joinKeys(moreKeys);
9874f259a74ee600d742072361d074493f892eb1b7Tadashi G. Takaoka    }
9974f259a74ee600d742072361d074493f892eb1b7Tadashi G. Takaoka
10074f259a74ee600d742072361d074493f892eb1b7Tadashi G. Takaoka    // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey},
10174f259a74ee600d742072361d074493f892eb1b7Tadashi G. Takaoka    // {@link ExpectedKey} array, and {@link String}.
10215a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    public static ExpectedKey[] joinKeys(final Object ... keys) {
1036d44cb512239a11572ec18b850d609bacc3267beTadashi G. Takaoka        return ExpectedKeyboardBuilder.joinKeys(keys);
10415a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka    }
10515a6b66ddaee302fc539311201b2b9f76778fd78Tadashi G. Takaoka}
106