Fix broken MenuItem coretests
- Fix MenuItemImpl setShortcut bug caused when method signature was
changed after API review
- Remove outdated MenuItem coretests and move others to CTS
Bug: 38114634
Test: Run `cts-tradefed run cts-dev -m CtsViewTestCases -t
android.view.cts.MenuTest`
Change-Id: Iebb7e314cbb3f812fcfeb3f95797f1cf1bcfbae2
(cherry picked from commit d70d2e6efc)
This commit is contained in:
@@ -240,14 +240,17 @@ public final class MenuItemImpl implements MenuItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getAlphabeticShortcut() {
|
||||
return mShortcutAlphabeticChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAlphabeticModifiers() {
|
||||
return mShortcutAlphabeticModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem setAlphabeticShortcut(char alphaChar) {
|
||||
if (mShortcutAlphabeticChar == alphaChar) return this;
|
||||
|
||||
@@ -258,6 +261,7 @@ public final class MenuItemImpl implements MenuItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem setAlphabeticShortcut(char alphaChar, int alphaModifiers){
|
||||
if (mShortcutAlphabeticChar == alphaChar &&
|
||||
mShortcutAlphabeticModifiers == alphaModifiers) {
|
||||
@@ -272,14 +276,17 @@ public final class MenuItemImpl implements MenuItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getNumericShortcut() {
|
||||
return mShortcutNumericChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumericModifiers() {
|
||||
return mShortcutNumericModifiers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem setNumericShortcut(char numericChar) {
|
||||
if (mShortcutNumericChar == numericChar) return this;
|
||||
|
||||
@@ -290,6 +297,7 @@ public final class MenuItemImpl implements MenuItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem setNumericShortcut(char numericChar, int numericModifiers){
|
||||
if (mShortcutNumericChar == numericChar && mShortcutNumericModifiers == numericModifiers) {
|
||||
return this;
|
||||
@@ -303,6 +311,7 @@ public final class MenuItemImpl implements MenuItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MenuItem setShortcut(char numericChar, char alphaChar) {
|
||||
mShortcutNumericChar = numericChar;
|
||||
mShortcutAlphabeticChar = Character.toLowerCase(alphaChar);
|
||||
@@ -312,7 +321,8 @@ public final class MenuItemImpl implements MenuItem {
|
||||
return this;
|
||||
}
|
||||
|
||||
public MenuItem setShortcut(char numericChar, int numericModifiers, char alphaChar,
|
||||
@Override
|
||||
public MenuItem setShortcut(char numericChar, char alphaChar, int numericModifiers,
|
||||
int alphaModifiers) {
|
||||
mShortcutNumericChar = numericChar;
|
||||
mShortcutNumericModifiers = KeyEvent.normalizeMetaState(numericModifiers);
|
||||
|
||||
@@ -16,21 +16,14 @@
|
||||
|
||||
package android.view;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.frameworks.coretests.R;
|
||||
import com.android.internal.view.menu.MenuBuilder;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.MoreAsserts;
|
||||
import android.test.suitebuilder.annotation.LargeTest;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.SubMenu;
|
||||
|
||||
import com.android.frameworks.coretests.R;
|
||||
|
||||
public class MenuTest extends AndroidTestCase {
|
||||
|
||||
private MenuBuilder mMenu;
|
||||
@@ -84,80 +77,6 @@ public class MenuTest extends AndroidTestCase {
|
||||
//adding and removing, hiding and showing, etc.
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsShortcutWithAlpha() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', 'a');
|
||||
Assert.assertTrue(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A, 0)));
|
||||
Assert.assertFalse(mMenu.isShortcutKey(KeyEvent.KEYCODE_B,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_B, 0)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsShortcutWithNumeric() throws Exception {
|
||||
mMenu.setQwertyMode(false);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', 'a');
|
||||
Assert.assertTrue(mMenu.isShortcutKey(KeyEvent.KEYCODE_2,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_2, 0)));
|
||||
Assert.assertFalse(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A, 0)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsShortcutWithAlt() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', 'a');
|
||||
Assert.assertTrue(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A,
|
||||
KeyEvent.META_ALT_ON)));
|
||||
Assert.assertFalse(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A,
|
||||
KeyEvent.META_SYM_ON)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsNotShortcutWithShift() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', 'a');
|
||||
Assert.assertFalse(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A,
|
||||
KeyEvent.META_SHIFT_ON)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsNotShortcutWithSym() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', 'a');
|
||||
Assert.assertFalse(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A,
|
||||
KeyEvent.META_SYM_ON)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsShortcutWithUpperCaseAlpha() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', 'A');
|
||||
Assert.assertTrue(mMenu.isShortcutKey(KeyEvent.KEYCODE_A,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_A, 0)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsShortcutWithBackspace() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', '\b');
|
||||
Assert.assertTrue(mMenu.isShortcutKey(KeyEvent.KEYCODE_DEL,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_DEL, 0)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testIsShortcutWithNewline() throws Exception {
|
||||
mMenu.setQwertyMode(true);
|
||||
mMenu.add(0, 0, 0, "test").setShortcut('2', '\n');
|
||||
Assert.assertTrue(mMenu.isShortcutKey(KeyEvent.KEYCODE_ENTER,
|
||||
makeKeyEvent(KeyEvent.KEYCODE_ENTER, 0)));
|
||||
}
|
||||
|
||||
@SmallTest
|
||||
public void testOrder() {
|
||||
final String a = "a", b = "b", c = "c";
|
||||
|
||||
Reference in New Issue
Block a user