| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 | 8 |
| 9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
| 10 import org.chromium.chrome.testshell.ChromiumTestShellActivity; | 10 import org.chromium.chrome.testshell.ChromiumTestShellActivity; |
| 11 import org.chromium.chrome.testshell.ChromiumTestShellTestBase; | 11 import org.chromium.chrome.testshell.ChromiumTestShellTestBase; |
| 12 import org.chromium.content.browser.test.util.TouchCommon; | 12 import org.chromium.content.browser.test.util.TouchCommon; |
| 13 import org.chromium.content.browser.test.util.UiUtils; | 13 import org.chromium.content.browser.test.util.UiUtils; |
| 14 import org.chromium.content.browser.test.util.Criteria; | 14 import org.chromium.content.browser.test.util.Criteria; |
| 15 import org.chromium.content.browser.test.util.CriteriaHelper; | 15 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 16 import org.chromium.ui.ActivityWindowAndroid; |
| 16 import org.chromium.ui.ViewAndroidDelegate; | 17 import org.chromium.ui.ViewAndroidDelegate; |
| 17 import org.chromium.ui.WindowAndroid; | 18 import org.chromium.ui.WindowAndroid; |
| 18 import org.chromium.ui.autofill.AutofillPopup; | 19 import org.chromium.ui.autofill.AutofillPopup; |
| 19 import org.chromium.ui.autofill.AutofillPopup.AutofillPopupDelegate; | 20 import org.chromium.ui.autofill.AutofillPopup.AutofillPopupDelegate; |
| 20 import org.chromium.ui.autofill.AutofillSuggestion; | 21 import org.chromium.ui.autofill.AutofillSuggestion; |
| 21 | 22 |
| 22 import java.util.concurrent.atomic.AtomicBoolean; | 23 import java.util.concurrent.atomic.AtomicBoolean; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Tests the Autofill's java code for creating the AutofillPopup object, opening
and selecting | 26 * Tests the Autofill's java code for creating the AutofillPopup object, opening
and selecting |
| 26 * popups. | 27 * popups. |
| 27 */ | 28 */ |
| 28 public class AutofillTest extends ChromiumTestShellTestBase { | 29 public class AutofillTest extends ChromiumTestShellTestBase { |
| 29 | 30 |
| 30 private AutofillPopup mAutofillPopup; | 31 private AutofillPopup mAutofillPopup; |
| 31 private WindowAndroid mWindowAndroid; | 32 private WindowAndroid mWindowAndroid; |
| 32 private MockAutofillCallback mMockAutofillCallback; | 33 private MockAutofillCallback mMockAutofillCallback; |
| 33 | 34 |
| 34 @Override | 35 @Override |
| 35 public void setUp() throws Exception { | 36 public void setUp() throws Exception { |
| 36 super.setUp(); | 37 super.setUp(); |
| 37 ChromiumTestShellActivity activity = launchChromiumTestShellWithBlankPag
e(); | 38 ChromiumTestShellActivity activity = launchChromiumTestShellWithBlankPag
e(); |
| 38 assertNotNull(activity); | 39 assertNotNull(activity); |
| 39 waitForActiveShellToBeDoneLoading(); | 40 waitForActiveShellToBeDoneLoading(); |
| 40 | 41 |
| 41 mMockAutofillCallback = new MockAutofillCallback(); | 42 mMockAutofillCallback = new MockAutofillCallback(); |
| 42 mWindowAndroid = new WindowAndroid(activity); | 43 mWindowAndroid = new ActivityWindowAndroid(activity); |
| 43 final ViewAndroidDelegate viewDelegate = | 44 final ViewAndroidDelegate viewDelegate = |
| 44 activity.getActiveContentView().getContentViewCore().getViewAndr
oidDelegate(); | 45 activity.getActiveContentView().getContentViewCore().getViewAndr
oidDelegate(); |
| 45 | 46 |
| 46 UiUtils.runOnUiThread(getActivity(), new Runnable() { | 47 UiUtils.runOnUiThread(getActivity(), new Runnable() { |
| 47 @Override | 48 @Override |
| 48 public void run() { | 49 public void run() { |
| 49 mAutofillPopup = new AutofillPopup(mWindowAndroid.getContext(), | 50 mAutofillPopup = new AutofillPopup(mWindowAndroid.getContext(), |
| 50 viewDelegate, | 51 viewDelegate, |
| 51 mMockAutofillCallback); | 52 mMockAutofillCallback); |
| 52 mAutofillPopup.setAnchorRect(50, 500, 500, 50); | 53 mAutofillPopup.setAnchorRect(50, 500, 500, 50); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 assertTrue(openAutofillPopupAndWaitUntilReady(suggestions)); | 133 assertTrue(openAutofillPopupAndWaitUntilReady(suggestions)); |
| 133 assertEquals(2, mAutofillPopup.getListView().getCount()); | 134 assertEquals(2, mAutofillPopup.getListView().getCount()); |
| 134 | 135 |
| 135 TouchCommon touchCommon = new TouchCommon(this); | 136 TouchCommon touchCommon = new TouchCommon(this); |
| 136 touchCommon.singleClickViewRelative(mAutofillPopup.getListView(), 10, 10
); | 137 touchCommon.singleClickViewRelative(mAutofillPopup.getListView(), 10, 10
); |
| 137 assertTrue(mMockAutofillCallback.waitForCallback()); | 138 assertTrue(mMockAutofillCallback.waitForCallback()); |
| 138 | 139 |
| 139 assertEquals(0, mMockAutofillCallback.mListIndex); | 140 assertEquals(0, mMockAutofillCallback.mListIndex); |
| 140 } | 141 } |
| 141 } | 142 } |
| OLD | NEW |