Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3393)

Unified Diff: chrome/browser/autofill/autofill_popup_view_browsertest.cc

Issue 9235072: Adding Mouse Support for new GTK Autofill (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: First Draft Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/autofill/autofill_popup_view_browsertest.cc
diff --git a/chrome/browser/autofill/autofill_popup_view_browsertest.cc b/chrome/browser/autofill/autofill_popup_view_browsertest.cc
index 5dda01ad5ab670800ef698a80b47c5bf58f6f3ad..0e88bf7c6d2cef0656664340a014a3c4e05e7559 100644
--- a/chrome/browser/autofill/autofill_popup_view_browsertest.cc
+++ b/chrome/browser/autofill/autofill_popup_view_browsertest.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/autofill/autofill_popup_view.h"
#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/autofill/autofill_external_delegate_unittest.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/navigation_controller.h"
@@ -18,16 +19,25 @@
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::AtLeast;
+using testing::_;
class TestAutofillPopupView : public AutofillPopupView {
public:
- explicit TestAutofillPopupView(content::WebContents* web_contents)
- : AutofillPopupView(web_contents) {}
+ explicit TestAutofillPopupView(
+ content::WebContents* web_contents,
+ AutofillExternalDelegate* autofill_external_delegate)
+ : AutofillPopupView(web_contents, autofill_external_delegate) {}
virtual ~TestAutofillPopupView() {}
- MOCK_METHOD0(Hide, void());
+ MOCK_METHOD0(HideInternal, void());
virtual void ShowInternal() OVERRIDE {}
+
+ MOCK_METHOD1(InvalidateRow, void(size_t));
+
+ void SetSelectedLine(size_t selected_line) {
+ AutofillPopupView::SetSelectedLine(selected_line);
+ }
Ilya Sherman 2012/02/04 04:10:52 nit: Is it not ok to just call AutofillPopupView::
csharp 2012/02/07 22:30:58 Nope, because it is a protected member.
};
Ilya Sherman 2012/02/04 04:10:52 nit: Can this class be moved into an anonymous nam
csharp 2012/02/07 22:30:58 Done.
class AutofillPopupViewBrowserTest : public InProcessBrowserTest {
@@ -35,21 +45,31 @@ class AutofillPopupViewBrowserTest : public InProcessBrowserTest {
AutofillPopupViewBrowserTest() {}
virtual ~AutofillPopupViewBrowserTest() {}
+ virtual void SetUpOnMainThread() OVERRIDE{
Ilya Sherman 2012/02/04 04:10:52 nit: "OVERRIDE{" -> "OVERRIDE {"
csharp 2012/02/07 22:30:58 Done.
+ web_contents_ = browser()->GetSelectedWebContents();
+ ASSERT_TRUE(web_contents_ != NULL);
+
+ autofill_external_delegate_.reset(
+ new MockAutofillExternalDelegate(NULL, NULL));
+
+ autofill_popup_view_.reset(new TestAutofillPopupView(
+ web_contents_,
+ autofill_external_delegate_.get()));
+ }
+
protected:
+ content::WebContents* web_contents_;
scoped_ptr<TestAutofillPopupView> autofill_popup_view_;
+ scoped_ptr<MockAutofillExternalDelegate> autofill_external_delegate_;
};
-IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, SwitchTabAndHideAutofillPopup) {
- content::WebContents* web_contents = browser()->GetSelectedWebContents();
- TestAutofillPopupView autofill_popup_view(web_contents);
-
- // Using AtLeast here because current Hide is called once on Linux and Mac,
- // and three times on Windows and ChromeOS. http://crbug.com/109269
- EXPECT_CALL(autofill_popup_view, Hide()).Times(AtLeast(1));
+IN_PROC_BROWSER_TEST_F(AutofillPopupViewBrowserTest,
+ SwitchTabAndHideAutofillPopup) {
+ EXPECT_CALL(*autofill_popup_view_, HideInternal()).Times(AtLeast(1));
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
- content::Source<content::WebContents>(web_contents));
+ content::Source<content::WebContents>(web_contents_));
browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
content::PAGE_TRANSITION_START_PAGE);
observer.Wait();
@@ -57,16 +77,14 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, SwitchTabAndHideAutofillPopup) {
// The mock verifies that the call was made.
}
-IN_PROC_BROWSER_TEST_F(InProcessBrowserTest,
+IN_PROC_BROWSER_TEST_F(AutofillPopupViewBrowserTest,
TestPageNavigationHidingAutofillPopup) {
- content::WebContents* web_contents = browser()->GetSelectedWebContents();
- TestAutofillPopupView autofill_popup_view(web_contents);
- EXPECT_CALL(autofill_popup_view, Hide());
+ EXPECT_CALL(*autofill_popup_view_, HideInternal()).Times(AtLeast(1));
ui_test_utils::WindowedNotificationObserver observer(
content::NOTIFICATION_NAV_ENTRY_COMMITTED,
content::Source<content::NavigationController>(
- &(web_contents->GetController())));
+ &(web_contents_->GetController())));
browser()->OpenURL(content::OpenURLParams(
GURL(chrome::kAboutBlankURL), content::Referrer(),
CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
@@ -77,3 +95,26 @@ IN_PROC_BROWSER_TEST_F(InProcessBrowserTest,
// The mock verifies that the call was made.
}
+
+IN_PROC_BROWSER_TEST_F(AutofillPopupViewBrowserTest,
+ SetSelectedAutofillLineAndCallInvalidate) {
+ std::vector<string16> autofill_value;
Ilya Sherman 2012/02/04 04:10:52 nit: Since this is a vector, let's call it |autofi
csharp 2012/02/07 22:30:58 Done.
+ autofill_value.push_back(string16());
+ std::vector<int> autofill_id;
+ autofill_id.push_back(0);
+ autofill_popup_view_->Show(
+ autofill_value, autofill_value, autofill_value, autofill_id, 0);
+
+ // Make sure that when a new line is selected, it is invalidated so it can
+ // be updated so so it is selected.
Ilya Sherman 2012/02/04 04:10:52 nit: "so so" -> "to show"?
csharp 2012/02/07 22:30:58 Done.
+ int selected_line = 0;
+ EXPECT_CALL(*autofill_popup_view_, InvalidateRow(selected_line));
+ autofill_popup_view_->SetSelectedLine(selected_line);
+
+ // Ensure that the row isn't invalidated if it didn't change.
Ilya Sherman 2012/02/04 04:10:52 If you want the test to actually fail if this does
csharp 2012/02/07 22:30:58 Done.
+ autofill_popup_view_->SetSelectedLine(selected_line);
+
+ // Change back to no selection.
+ EXPECT_CALL(*autofill_popup_view_, InvalidateRow(selected_line));
+ autofill_popup_view_->SetSelectedLine(-1);
+}

Powered by Google App Engine
This is Rietveld 408576698