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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_external_delegate_views_browsertest.cc

Issue 10825324: Start of New Autofill UI for Windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/views/autofill/autofill_external_delegate_views.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/ui/tab_contents/tab_contents.h"
9 #include "chrome/browser/ui/browser_tabstrip.h"
10 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
11 #include "chrome/test/base/in_process_browser_test.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gfx/rect.h"
14
15 namespace {
16
17 class MockAutofillExternalDelegateViews : public AutofillExternalDelegateViews {
18 public:
19 MockAutofillExternalDelegateViews(TabContents* tab_contents) :
20 AutofillExternalDelegateViews(tab_contents, NULL),
21 popup_hidden_(false) {}
22 ~MockAutofillExternalDelegateViews() {}
23
24 void HideAutofillPopupInternal() OVERRIDE {
25 popup_hidden_ = true;
26 AutofillExternalDelegateViews::HideAutofillPopupInternal();
27 }
28
29 AutofillPopupViewViews* GetPopup() {
30 return AutofillExternalDelegateViews::GetPopup();
31 }
32
33 bool popup_hidden_;
34 };
35
36 } // namespace
37
38 class AutofillExternalDelegateViewsBrowserTest : public InProcessBrowserTest {
39 public:
40 AutofillExternalDelegateViewsBrowserTest() {}
41 virtual ~AutofillExternalDelegateViewsBrowserTest() {}
42
43 virtual void SetUpOnMainThread() OVERRIDE {
44 tab_contents_ = chrome::GetActiveTabContents(browser());
45 ASSERT_TRUE(tab_contents_ != NULL);
46
47 autofill_external_delegate_.reset(
48 new MockAutofillExternalDelegateViews(tab_contents_));
49 }
50
51 protected:
52 TabContents* tab_contents_;
53 scoped_ptr<MockAutofillExternalDelegateViews> autofill_external_delegate_;
54 };
55
56 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateViewsBrowserTest,
57 OpenAndClosePopup) {
58 int query_id = 1;
59 webkit::forms::FormData form;
60 webkit::forms::FormField field;
61 field.is_focusable = true;
62 field.should_autocomplete = true;
63 gfx::Rect bounds(100, 100);
64
65 // Ensure that we can populate the popup through the delegate without any
66 // and then close it.
67 autofill_external_delegate_->OnQuery(query_id, form, field, bounds, false);
68
69 std::vector<string16> autofill_item;
70 autofill_item.push_back(string16());
71 std::vector<int> autofill_id;
72 autofill_id.push_back(0);
73 autofill_external_delegate_->OnSuggestionsReturned(
74 query_id, autofill_item, autofill_item, autofill_item, autofill_id);
75
76 autofill_external_delegate_->HideAutofillPopup();
77 EXPECT_TRUE(autofill_external_delegate_->popup_hidden_);
78 }
79
80 IN_PROC_BROWSER_TEST_F(AutofillExternalDelegateViewsBrowserTest,
81 CloseWidgetAndNoLeaking) {
82 int query_id = 1;
83 webkit::forms::FormData form;
84 webkit::forms::FormField field;
85 field.is_focusable = true;
86 field.should_autocomplete = true;
87 gfx::Rect bounds(100, 100);
88
89 // Ensure that we can populate the popup through the delegate without any
90 // and then close it.
91 autofill_external_delegate_->OnQuery(query_id, form, field, bounds, false);
92
93 std::vector<string16> autofill_item;
94 autofill_item.push_back(string16());
95 std::vector<int> autofill_id;
96 autofill_id.push_back(0);
97 autofill_external_delegate_->OnSuggestionsReturned(
98 query_id, autofill_item, autofill_item, autofill_item, autofill_id);
99
100 // Delete the popup tyo ensure that the external delegate can handle the
101 // popup getting deleted elsewhere.
102 views::View* popup_view =
csharp 2012/08/20 20:59:00 I tried to just close the parent widget, but that
103 autofill_external_delegate_->GetPopup();
104 delete popup_view;
105
106 EXPECT_TRUE(autofill_external_delegate_->popup_hidden_);
107 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698