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

Side by Side 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, 10 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 unified diff | Download patch
OLDNEW
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 #include "chrome/browser/autofill/autofill_popup_view.h" 5 #include "chrome/browser/autofill/autofill_popup_view.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/autofill/autofill_external_delegate_unittest.h"
8 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
9 #include "chrome/test/base/ui_test_utils.h" 10 #include "chrome/test/base/ui_test_utils.h"
10 #include "content/public/browser/navigation_controller.h" 11 #include "content/public/browser/navigation_controller.h"
11 #include "content/public/browser/notification_service.h" 12 #include "content/public/browser/notification_service.h"
12 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
13 #include "content/public/browser/page_navigator.h" 14 #include "content/public/browser/page_navigator.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/common/url_constants.h" 16 #include "content/public/common/url_constants.h"
16 #include "content/test/browser_test.h" 17 #include "content/test/browser_test.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 using ::testing::AtLeast; 21 using ::testing::AtLeast;
22 using testing::_;
21 23
22 class TestAutofillPopupView : public AutofillPopupView { 24 class TestAutofillPopupView : public AutofillPopupView {
23 public: 25 public:
24 explicit TestAutofillPopupView(content::WebContents* web_contents) 26 explicit TestAutofillPopupView(
25 : AutofillPopupView(web_contents) {} 27 content::WebContents* web_contents,
28 AutofillExternalDelegate* autofill_external_delegate)
29 : AutofillPopupView(web_contents, autofill_external_delegate) {}
26 virtual ~TestAutofillPopupView() {} 30 virtual ~TestAutofillPopupView() {}
27 31
28 MOCK_METHOD0(Hide, void()); 32 MOCK_METHOD0(HideInternal, void());
29 33
30 virtual void ShowInternal() OVERRIDE {} 34 virtual void ShowInternal() OVERRIDE {}
35
36 MOCK_METHOD1(InvalidateRow, void(size_t));
37
38 void SetSelectedLine(size_t selected_line) {
39 AutofillPopupView::SetSelectedLine(selected_line);
40 }
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.
31 }; 41 };
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.
32 42
33 class AutofillPopupViewBrowserTest : public InProcessBrowserTest { 43 class AutofillPopupViewBrowserTest : public InProcessBrowserTest {
34 public: 44 public:
35 AutofillPopupViewBrowserTest() {} 45 AutofillPopupViewBrowserTest() {}
36 virtual ~AutofillPopupViewBrowserTest() {} 46 virtual ~AutofillPopupViewBrowserTest() {}
37 47
48 virtual void SetUpOnMainThread() OVERRIDE{
Ilya Sherman 2012/02/04 04:10:52 nit: "OVERRIDE{" -> "OVERRIDE {"
csharp 2012/02/07 22:30:58 Done.
49 web_contents_ = browser()->GetSelectedWebContents();
50 ASSERT_TRUE(web_contents_ != NULL);
51
52 autofill_external_delegate_.reset(
53 new MockAutofillExternalDelegate(NULL, NULL));
54
55 autofill_popup_view_.reset(new TestAutofillPopupView(
56 web_contents_,
57 autofill_external_delegate_.get()));
58 }
59
38 protected: 60 protected:
61 content::WebContents* web_contents_;
39 scoped_ptr<TestAutofillPopupView> autofill_popup_view_; 62 scoped_ptr<TestAutofillPopupView> autofill_popup_view_;
63 scoped_ptr<MockAutofillExternalDelegate> autofill_external_delegate_;
40 }; 64 };
41 65
42 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, SwitchTabAndHideAutofillPopup) { 66 IN_PROC_BROWSER_TEST_F(AutofillPopupViewBrowserTest,
43 content::WebContents* web_contents = browser()->GetSelectedWebContents(); 67 SwitchTabAndHideAutofillPopup) {
44 TestAutofillPopupView autofill_popup_view(web_contents); 68 EXPECT_CALL(*autofill_popup_view_, HideInternal()).Times(AtLeast(1));
45
46 // Using AtLeast here because current Hide is called once on Linux and Mac,
47 // and three times on Windows and ChromeOS. http://crbug.com/109269
48 EXPECT_CALL(autofill_popup_view, Hide()).Times(AtLeast(1));
49 69
50 ui_test_utils::WindowedNotificationObserver observer( 70 ui_test_utils::WindowedNotificationObserver observer(
51 content::NOTIFICATION_WEB_CONTENTS_HIDDEN, 71 content::NOTIFICATION_WEB_CONTENTS_HIDDEN,
52 content::Source<content::WebContents>(web_contents)); 72 content::Source<content::WebContents>(web_contents_));
53 browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL), 73 browser()->AddSelectedTabWithURL(GURL(chrome::kAboutBlankURL),
54 content::PAGE_TRANSITION_START_PAGE); 74 content::PAGE_TRANSITION_START_PAGE);
55 observer.Wait(); 75 observer.Wait();
56 76
57 // The mock verifies that the call was made. 77 // The mock verifies that the call was made.
58 } 78 }
59 79
60 IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, 80 IN_PROC_BROWSER_TEST_F(AutofillPopupViewBrowserTest,
61 TestPageNavigationHidingAutofillPopup) { 81 TestPageNavigationHidingAutofillPopup) {
62 content::WebContents* web_contents = browser()->GetSelectedWebContents(); 82 EXPECT_CALL(*autofill_popup_view_, HideInternal()).Times(AtLeast(1));
63 TestAutofillPopupView autofill_popup_view(web_contents);
64 EXPECT_CALL(autofill_popup_view, Hide());
65 83
66 ui_test_utils::WindowedNotificationObserver observer( 84 ui_test_utils::WindowedNotificationObserver observer(
67 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 85 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
68 content::Source<content::NavigationController>( 86 content::Source<content::NavigationController>(
69 &(web_contents->GetController()))); 87 &(web_contents_->GetController())));
70 browser()->OpenURL(content::OpenURLParams( 88 browser()->OpenURL(content::OpenURLParams(
71 GURL(chrome::kAboutBlankURL), content::Referrer(), 89 GURL(chrome::kAboutBlankURL), content::Referrer(),
72 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 90 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
73 browser()->OpenURL(content::OpenURLParams( 91 browser()->OpenURL(content::OpenURLParams(
74 GURL(chrome::kAboutCrashURL), content::Referrer(), 92 GURL(chrome::kAboutCrashURL), content::Referrer(),
75 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); 93 CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false));
76 observer.Wait(); 94 observer.Wait();
77 95
78 // The mock verifies that the call was made. 96 // The mock verifies that the call was made.
79 } 97 }
98
99 IN_PROC_BROWSER_TEST_F(AutofillPopupViewBrowserTest,
100 SetSelectedAutofillLineAndCallInvalidate) {
101 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.
102 autofill_value.push_back(string16());
103 std::vector<int> autofill_id;
104 autofill_id.push_back(0);
105 autofill_popup_view_->Show(
106 autofill_value, autofill_value, autofill_value, autofill_id, 0);
107
108 // Make sure that when a new line is selected, it is invalidated so it can
109 // 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.
110 int selected_line = 0;
111 EXPECT_CALL(*autofill_popup_view_, InvalidateRow(selected_line));
112 autofill_popup_view_->SetSelectedLine(selected_line);
113
114 // 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.
115 autofill_popup_view_->SetSelectedLine(selected_line);
116
117 // Change back to no selection.
118 EXPECT_CALL(*autofill_popup_view_, InvalidateRow(selected_line));
119 autofill_popup_view_->SetSelectedLine(-1);
120 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698