Commit 2508b5fb authored by Changwan Ryu's avatar Changwan Ryu Committed by Commit Bot

Fix AwAutofillTest failure on L

On L devices, declaring fields mTestViewStructure, mChangedValues inside
a test class raises NoClassDefFoundError. Hiding them inside a wrapper
class fixes this.

Note: tested on O and L locally.

BUG=776230

Change-Id: Ie31da26482fbe8136ae0efcaf2964217be1fb18f
Reviewed-on: https://chromium-review.googlesource.com/729205Reviewed-by: default avatarYoland Yan <yolandyan@chromium.org>
Reviewed-by: default avatarTao Bai <michaelbai@chromium.org>
Commit-Queue: Changwan Ryu <changwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510278}
parent a9a6608f
...@@ -398,6 +398,13 @@ public class AwAutofillTest { ...@@ -398,6 +398,13 @@ public class AwAutofillTest {
private boolean mChecked; private boolean mChecked;
} }
// crbug.com/776230: On Android L, declaring variables of unsupported classes causes an error.
// Wrapped them in a class to avoid it.
private static class TestValues {
public TestViewStructure testViewStructure;
public ArrayList<Pair<Integer, AutofillValue>> changedValues;
}
private class TestAwAutofillManager extends AwAutofillManager { private class TestAwAutofillManager extends AwAutofillManager {
public TestAwAutofillManager(Context context) { public TestAwAutofillManager(Context context) {
super(context); super(context);
...@@ -417,10 +424,10 @@ public class AwAutofillTest { ...@@ -417,10 +424,10 @@ public class AwAutofillTest {
@Override @Override
public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) { public void notifyVirtualValueChanged(View parent, int childId, AutofillValue value) {
if (mChangedValues == null) { if (mTestValues.changedValues == null) {
mChangedValues = new ArrayList<Pair<Integer, AutofillValue>>(); mTestValues.changedValues = new ArrayList<Pair<Integer, AutofillValue>>();
} }
mChangedValues.add(new Pair<Integer, AutofillValue>(childId, value)); mTestValues.changedValues.add(new Pair<Integer, AutofillValue>(childId, value));
mEventQueue.add(AUTOFILL_VALUE_CHANGED); mEventQueue.add(AUTOFILL_VALUE_CHANGED);
mCallbackHelper.notifyCalled(); mCallbackHelper.notifyCalled();
} }
...@@ -454,9 +461,8 @@ public class AwAutofillTest { ...@@ -454,9 +461,8 @@ public class AwAutofillTest {
private TestAwContentsClient mContentsClient; private TestAwContentsClient mContentsClient;
private CallbackHelper mCallbackHelper = new CallbackHelper(); private CallbackHelper mCallbackHelper = new CallbackHelper();
private AwContents mAwContents; private AwContents mAwContents;
private TestViewStructure mTestViewStructure;
private ArrayList<Pair<Integer, AutofillValue>> mChangedValues;
private ConcurrentLinkedQueue<Integer> mEventQueue = new ConcurrentLinkedQueue<>(); private ConcurrentLinkedQueue<Integer> mEventQueue = new ConcurrentLinkedQueue<>();
private TestValues mTestValues = new TestValues();
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
...@@ -553,7 +559,7 @@ public class AwAutofillTest { ...@@ -553,7 +559,7 @@ public class AwAutofillTest {
new Integer[] {AUTOFILL_CANCEL, AUTOFILL_VIEW_ENTERED, AUTOFILL_VIEW_EXITED, new Integer[] {AUTOFILL_CANCEL, AUTOFILL_VIEW_ENTERED, AUTOFILL_VIEW_EXITED,
AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED}); AUTOFILL_VIEW_ENTERED, AUTOFILL_VALUE_CHANGED});
invokeOnProvideAutoFillVirtualStructure(); invokeOnProvideAutoFillVirtualStructure();
TestViewStructure viewStructure = mTestViewStructure; TestViewStructure viewStructure = mTestValues.testViewStructure;
assertNotNull(viewStructure); assertNotNull(viewStructure);
assertEquals(totalControls, viewStructure.getChildCount()); assertEquals(totalControls, viewStructure.getChildCount());
...@@ -845,16 +851,16 @@ public class AwAutofillTest { ...@@ -845,16 +851,16 @@ public class AwAutofillTest {
} }
private ArrayList<Pair<Integer, AutofillValue>> getChangedValues() { private ArrayList<Pair<Integer, AutofillValue>> getChangedValues() {
return mChangedValues; return mTestValues.changedValues;
} }
private void clearChangedValues() { private void clearChangedValues() {
if (mChangedValues != null) mChangedValues.clear(); if (mTestValues.changedValues != null) mTestValues.changedValues.clear();
} }
private void invokeOnProvideAutoFillVirtualStructure() { private void invokeOnProvideAutoFillVirtualStructure() {
mTestViewStructure = new TestViewStructure(); mTestValues.testViewStructure = new TestViewStructure();
mAwContents.onProvideAutoFillVirtualStructure(mTestViewStructure, 1); mAwContents.onProvideAutoFillVirtualStructure(mTestValues.testViewStructure, 1);
} }
private void invokeAutofill(SparseArray<AutofillValue> values) { private void invokeAutofill(SparseArray<AutofillValue> values) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment