| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.autofill; | 5 package org.chromium.chrome.browser.autofill; |
| 6 | 6 |
| 7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
| 8 import android.view.View; |
| 8 | 9 |
| 9 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 10 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| 10 | 11 |
| 11 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
| 12 import org.chromium.base.annotations.SuppressFBWarnings; | 13 import org.chromium.base.annotations.SuppressFBWarnings; |
| 13 import org.chromium.base.test.util.Feature; | 14 import org.chromium.base.test.util.Feature; |
| 14 import org.chromium.chrome.browser.ChromeActivity; | 15 import org.chromium.chrome.browser.ChromeActivity; |
| 15 import org.chromium.chrome.test.ChromeActivityTestCaseBase; | 16 import org.chromium.chrome.test.ChromeActivityTestCaseBase; |
| 16 import org.chromium.content.browser.test.util.Criteria; | 17 import org.chromium.content.browser.test.util.Criteria; |
| 17 import org.chromium.content.browser.test.util.CriteriaHelper; | 18 import org.chromium.content.browser.test.util.CriteriaHelper; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 super.setUp(); | 52 super.setUp(); |
| 52 | 53 |
| 53 final ChromeActivity activity = getActivity(); | 54 final ChromeActivity activity = getActivity(); |
| 54 mMockAutofillCallback = new MockAutofillCallback(); | 55 mMockAutofillCallback = new MockAutofillCallback(); |
| 55 final ViewAndroidDelegate viewDelegate = | 56 final ViewAndroidDelegate viewDelegate = |
| 56 activity.getCurrentContentViewCore().getViewAndroidDelegate(); | 57 activity.getCurrentContentViewCore().getViewAndroidDelegate(); |
| 57 | 58 |
| 58 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 59 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 59 @Override | 60 @Override |
| 60 public void run() { | 61 public void run() { |
| 62 View anchorView = viewDelegate.acquireView(); |
| 63 viewDelegate.setViewPosition(anchorView, 50f, 500f, 500f, 500f,
1f, 10, 10); |
| 64 |
| 61 mWindowAndroid = new ActivityWindowAndroid(activity); | 65 mWindowAndroid = new ActivityWindowAndroid(activity); |
| 62 mAutofillPopup = new AutofillPopup(activity, viewDelegate, mMock
AutofillCallback); | 66 mAutofillPopup = new AutofillPopup(activity, anchorView, 500f, |
| 67 mMockAutofillCallback); |
| 63 mAutofillPopup.filterAndShow(new AutofillSuggestion[0], false); | 68 mAutofillPopup.filterAndShow(new AutofillSuggestion[0], false); |
| 64 mAutofillPopup.setAnchorRect(50, 500, 500, 50); | |
| 65 } | 69 } |
| 66 }); | 70 }); |
| 67 } | 71 } |
| 68 | 72 |
| 69 private static final long CALLBACK_TIMEOUT_MS = scaleTimeout(4000); | 73 private static final long CALLBACK_TIMEOUT_MS = scaleTimeout(4000); |
| 70 private static final int CHECK_INTERVAL_MS = 100; | 74 private static final int CHECK_INTERVAL_MS = 100; |
| 71 | 75 |
| 72 private class MockAutofillCallback implements AutofillDelegate { | 76 private class MockAutofillCallback implements AutofillDelegate { |
| 73 private final AtomicBoolean mGotPopupSelection = new AtomicBoolean(false
); | 77 private final AtomicBoolean mGotPopupSelection = new AtomicBoolean(false
); |
| 74 public int mListIndex = -1; | 78 public int mListIndex = -1; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 AutofillSuggestion[] suggestions = createTwoAutofillSuggestionArray(); | 155 AutofillSuggestion[] suggestions = createTwoAutofillSuggestionArray(); |
| 152 openAutofillPopupAndWaitUntilReady(suggestions); | 156 openAutofillPopupAndWaitUntilReady(suggestions); |
| 153 assertEquals(2, mAutofillPopup.getListView().getCount()); | 157 assertEquals(2, mAutofillPopup.getListView().getCount()); |
| 154 | 158 |
| 155 TouchCommon.singleClickView(mAutofillPopup.getListView().getChildAt(0)); | 159 TouchCommon.singleClickView(mAutofillPopup.getListView().getChildAt(0)); |
| 156 mMockAutofillCallback.waitForCallback(); | 160 mMockAutofillCallback.waitForCallback(); |
| 157 | 161 |
| 158 assertEquals(0, mMockAutofillCallback.mListIndex); | 162 assertEquals(0, mMockAutofillCallback.mListIndex); |
| 159 } | 163 } |
| 160 } | 164 } |
| OLD | NEW |