| 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 import android.view.View; |
| 9 | 9 |
| 10 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; | 10 import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 activity.getCurrentContentViewCore().getContainerView())
; | 60 activity.getCurrentContentViewCore().getContainerView())
; |
| 61 | 61 |
| 62 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 62 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 63 @Override | 63 @Override |
| 64 public void run() { | 64 public void run() { |
| 65 View anchorView = viewDelegate.acquireView(); | 65 View anchorView = viewDelegate.acquireView(); |
| 66 viewDelegate.setViewPosition(anchorView, 50f, 500f, 500f, 500f,
1f, 10, 10); | 66 viewDelegate.setViewPosition(anchorView, 50f, 500f, 500f, 500f,
1f, 10, 10); |
| 67 | 67 |
| 68 mWindowAndroid = new ActivityWindowAndroid(activity); | 68 mWindowAndroid = new ActivityWindowAndroid(activity); |
| 69 mAutofillPopup = new AutofillPopup(activity, anchorView, mMockAu
tofillCallback); | 69 mAutofillPopup = new AutofillPopup(activity, anchorView, mMockAu
tofillCallback); |
| 70 mAutofillPopup.filterAndShow(new AutofillSuggestion[0], false); | 70 mAutofillPopup.filterAndShow(new AutofillSuggestion[0], false /*
isRtl */, |
| 71 Color.TRANSPARENT /* backgroundColor */, |
| 72 Color.TRANSPARENT /* dividerColor */, 0 /* dropdownItemH
eight */); |
| 71 } | 73 } |
| 72 }); | 74 }); |
| 73 } | 75 } |
| 74 | 76 |
| 75 private static final long CALLBACK_TIMEOUT_MS = scaleTimeout(4000); | 77 private static final long CALLBACK_TIMEOUT_MS = scaleTimeout(4000); |
| 76 private static final int CHECK_INTERVAL_MS = 100; | 78 private static final int CHECK_INTERVAL_MS = 100; |
| 77 | 79 |
| 78 private class MockAutofillCallback implements AutofillDelegate { | 80 private class MockAutofillCallback implements AutofillDelegate { |
| 79 private final AtomicBoolean mGotPopupSelection = new AtomicBoolean(false
); | 81 private final AtomicBoolean mGotPopupSelection = new AtomicBoolean(false
); |
| 80 public int mListIndex = -1; | 82 public int mListIndex = -1; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 100 } | 102 } |
| 101 | 103 |
| 102 @Override | 104 @Override |
| 103 public void dismissed() { | 105 public void dismissed() { |
| 104 } | 106 } |
| 105 } | 107 } |
| 106 | 108 |
| 107 private AutofillSuggestion[] createTwoAutofillSuggestionArray() { | 109 private AutofillSuggestion[] createTwoAutofillSuggestionArray() { |
| 108 return new AutofillSuggestion[] { | 110 return new AutofillSuggestion[] { |
| 109 new AutofillSuggestion("Sherlock Holmes", "221B Baker Street", D
ropdownItem.NO_ICON, | 111 new AutofillSuggestion("Sherlock Holmes", "221B Baker Street", D
ropdownItem.NO_ICON, |
| 110 42, false, false), | 112 false, 42, false, false, false), |
| 111 new AutofillSuggestion( | 113 new AutofillSuggestion("Arthur Dent", "West Country", DropdownIt
em.NO_ICON, |
| 112 "Arthur Dent", "West Country", DropdownItem.NO_ICON, 43,
false, false), | 114 false, 43, false, false, false), |
| 113 }; | 115 }; |
| 114 } | 116 } |
| 115 | 117 |
| 116 private AutofillSuggestion[] createFiveAutofillSuggestionArray() { | 118 private AutofillSuggestion[] createFiveAutofillSuggestionArray() { |
| 117 return new AutofillSuggestion[] { | 119 return new AutofillSuggestion[] { |
| 118 new AutofillSuggestion("Sherlock Holmes", "221B Baker Street", D
ropdownItem.NO_ICON, | 120 new AutofillSuggestion("Sherlock Holmes", "221B Baker Street", D
ropdownItem.NO_ICON, |
| 119 42, false, false), | 121 false, 42, false, false, false), |
| 120 new AutofillSuggestion( | 122 new AutofillSuggestion("Arthur Dent", "West Country", DropdownIt
em.NO_ICON, |
| 121 "Arthur Dent", "West Country", DropdownItem.NO_ICON, 43,
false, false), | 123 false, 43, false, false, false), |
| 122 new AutofillSuggestion("Arthos", "France", DropdownItem.NO_ICON,
44, false, false), | 124 new AutofillSuggestion("Arthos", "France", DropdownItem.NO_ICON, |
| 123 new AutofillSuggestion("Porthos", "France", DropdownItem.NO_ICON
, 45, false, false), | 125 false, 44, false, false, false), |
| 124 new AutofillSuggestion("Aramis", "France", DropdownItem.NO_ICON,
46, false, false), | 126 new AutofillSuggestion("Porthos", "France", DropdownItem.NO_ICON
, |
| 127 false, 45, false, false, false), |
| 128 new AutofillSuggestion("Aramis", "France", DropdownItem.NO_ICON, |
| 129 false, 46, false, false, false), |
| 125 }; | 130 }; |
| 126 } | 131 } |
| 127 | 132 |
| 128 public void openAutofillPopupAndWaitUntilReady(final AutofillSuggestion[] su
ggestions) | 133 public void openAutofillPopupAndWaitUntilReady(final AutofillSuggestion[] su
ggestions) |
| 129 throws InterruptedException { | 134 throws InterruptedException { |
| 130 ThreadUtils.runOnUiThreadBlocking(new Runnable() { | 135 ThreadUtils.runOnUiThreadBlocking(new Runnable() { |
| 131 @Override | 136 @Override |
| 132 public void run() { | 137 public void run() { |
| 133 mAutofillPopup.filterAndShow(suggestions, false); | 138 mAutofillPopup.filterAndShow(suggestions, false /* isRtl */, |
| 139 Color.TRANSPARENT /* backgroundColor */, |
| 140 Color.TRANSPARENT /* dividerColor */, 0 /* dropdownItemH
eight */); |
| 134 } | 141 } |
| 135 }); | 142 }); |
| 136 CriteriaHelper.pollInstrumentationThread(new Criteria() { | 143 CriteriaHelper.pollInstrumentationThread(new Criteria() { |
| 137 @Override | 144 @Override |
| 138 public boolean isSatisfied() { | 145 public boolean isSatisfied() { |
| 139 return mAutofillPopup.getListView().getChildCount() > 0; | 146 return mAutofillPopup.getListView().getChildCount() > 0; |
| 140 } | 147 } |
| 141 }); | 148 }); |
| 142 } | 149 } |
| 143 | 150 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 157 AutofillSuggestion[] suggestions = createTwoAutofillSuggestionArray(); | 164 AutofillSuggestion[] suggestions = createTwoAutofillSuggestionArray(); |
| 158 openAutofillPopupAndWaitUntilReady(suggestions); | 165 openAutofillPopupAndWaitUntilReady(suggestions); |
| 159 assertEquals(2, mAutofillPopup.getListView().getCount()); | 166 assertEquals(2, mAutofillPopup.getListView().getCount()); |
| 160 | 167 |
| 161 TouchCommon.singleClickView(mAutofillPopup.getListView().getChildAt(0)); | 168 TouchCommon.singleClickView(mAutofillPopup.getListView().getChildAt(0)); |
| 162 mMockAutofillCallback.waitForCallback(); | 169 mMockAutofillCallback.waitForCallback(); |
| 163 | 170 |
| 164 assertEquals(0, mMockAutofillCallback.mListIndex); | 171 assertEquals(0, mMockAutofillCallback.mListIndex); |
| 165 } | 172 } |
| 166 } | 173 } |
| OLD | NEW |