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

Side by Side Diff: chrome/browser/ui/autofill/autofill_popup_controller_unittest.cc

Issue 306053008: Rename AutofillManagerDelegate to AutofillClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/memory/weak_ptr.h" 6 #include "base/memory/weak_ptr.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" 9 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h"
10 #include "chrome/browser/ui/autofill/autofill_popup_view.h" 10 #include "chrome/browser/ui/autofill/autofill_popup_view.h"
11 #include "chrome/browser/ui/autofill/popup_constants.h" 11 #include "chrome/browser/ui/autofill/popup_constants.h"
12 #include "chrome/browser/ui/autofill/test_popup_controller_common.h" 12 #include "chrome/browser/ui/autofill/test_popup_controller_common.h"
13 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 13 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
14 #include "chrome/test/base/testing_profile.h" 14 #include "chrome/test/base/testing_profile.h"
15 #include "components/autofill/content/browser/content_autofill_driver.h" 15 #include "components/autofill/content/browser/content_autofill_driver.h"
16 #include "components/autofill/core/browser/autofill_external_delegate.h" 16 #include "components/autofill/core/browser/autofill_external_delegate.h"
17 #include "components/autofill/core/browser/autofill_manager.h" 17 #include "components/autofill/core/browser/autofill_manager.h"
18 #include "components/autofill/core/browser/autofill_test_utils.h" 18 #include "components/autofill/core/browser/autofill_test_utils.h"
19 #include "components/autofill/core/browser/popup_item_ids.h" 19 #include "components/autofill/core/browser/popup_item_ids.h"
20 #include "components/autofill/core/browser/test_autofill_client.h"
20 #include "components/autofill/core/browser/test_autofill_external_delegate.h" 21 #include "components/autofill/core/browser/test_autofill_external_delegate.h"
21 #include "components/autofill/core/browser/test_autofill_manager_delegate.h"
22 #include "grit/component_scaled_resources.h" 22 #include "grit/component_scaled_resources.h"
23 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
25 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
26 #include "ui/gfx/display.h" 26 #include "ui/gfx/display.h"
27 #include "ui/gfx/rect.h" 27 #include "ui/gfx/rect.h"
28 #include "ui/gfx/text_utils.h" 28 #include "ui/gfx/text_utils.h"
29 29
30 using ::testing::_; 30 using ::testing::_;
31 using ::testing::AtLeast; 31 using ::testing::AtLeast;
(...skipping 14 matching lines...) Expand all
46 virtual void DidSelectSuggestion(const base::string16& value, 46 virtual void DidSelectSuggestion(const base::string16& value,
47 int identifier) OVERRIDE {} 47 int identifier) OVERRIDE {}
48 virtual void RemoveSuggestion(const base::string16& value, 48 virtual void RemoveSuggestion(const base::string16& value,
49 int identifier) OVERRIDE {} 49 int identifier) OVERRIDE {}
50 virtual void ClearPreviewedForm() OVERRIDE {} 50 virtual void ClearPreviewedForm() OVERRIDE {}
51 base::WeakPtr<AutofillExternalDelegate> GetWeakPtr() { 51 base::WeakPtr<AutofillExternalDelegate> GetWeakPtr() {
52 return AutofillExternalDelegate::GetWeakPtr(); 52 return AutofillExternalDelegate::GetWeakPtr();
53 } 53 }
54 }; 54 };
55 55
56 class MockAutofillManagerDelegate 56 class MockAutofillClient : public autofill::TestAutofillClient {
57 : public autofill::TestAutofillManagerDelegate {
58 public: 57 public:
59 MockAutofillManagerDelegate() 58 MockAutofillClient() : prefs_(autofill::test::PrefServiceForTesting()) {}
60 : prefs_(autofill::test::PrefServiceForTesting()) { 59 virtual ~MockAutofillClient() {}
61 }
62 virtual ~MockAutofillManagerDelegate() {}
63 60
64 virtual PrefService* GetPrefs() OVERRIDE { return prefs_.get(); } 61 virtual PrefService* GetPrefs() OVERRIDE { return prefs_.get(); }
65 62
66 private: 63 private:
67 scoped_ptr<PrefService> prefs_; 64 scoped_ptr<PrefService> prefs_;
68 65
69 DISALLOW_COPY_AND_ASSIGN(MockAutofillManagerDelegate); 66 DISALLOW_COPY_AND_ASSIGN(MockAutofillClient);
70 }; 67 };
71 68
72 class TestAutofillPopupController : public AutofillPopupControllerImpl { 69 class TestAutofillPopupController : public AutofillPopupControllerImpl {
73 public: 70 public:
74 explicit TestAutofillPopupController( 71 explicit TestAutofillPopupController(
75 base::WeakPtr<AutofillExternalDelegate> external_delegate, 72 base::WeakPtr<AutofillExternalDelegate> external_delegate,
76 const gfx::RectF& element_bounds) 73 const gfx::RectF& element_bounds)
77 : AutofillPopupControllerImpl( 74 : AutofillPopupControllerImpl(
78 external_delegate, NULL, NULL, element_bounds, 75 external_delegate, NULL, NULL, element_bounds,
79 base::i18n::UNKNOWN_DIRECTION), 76 base::i18n::UNKNOWN_DIRECTION),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 virtual void ShowView() OVERRIDE {} 116 virtual void ShowView() OVERRIDE {}
120 117
121 TestPopupControllerCommon* test_controller_common_; 118 TestPopupControllerCommon* test_controller_common_;
122 }; 119 };
123 120
124 } // namespace 121 } // namespace
125 122
126 class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness { 123 class AutofillPopupControllerUnitTest : public ChromeRenderViewHostTestHarness {
127 public: 124 public:
128 AutofillPopupControllerUnitTest() 125 AutofillPopupControllerUnitTest()
129 : manager_delegate_(new MockAutofillManagerDelegate()), 126 : autofill_client_(new MockAutofillClient()),
130 autofill_popup_controller_(NULL) {} 127 autofill_popup_controller_(NULL) {}
131 virtual ~AutofillPopupControllerUnitTest() {} 128 virtual ~AutofillPopupControllerUnitTest() {}
132 129
133 virtual void SetUp() OVERRIDE { 130 virtual void SetUp() OVERRIDE {
134 ChromeRenderViewHostTestHarness::SetUp(); 131 ChromeRenderViewHostTestHarness::SetUp();
135 132
136 ContentAutofillDriver::CreateForWebContentsAndDelegate( 133 ContentAutofillDriver::CreateForWebContentsAndDelegate(
137 web_contents(), 134 web_contents(),
138 manager_delegate_.get(), 135 autofill_client_.get(),
139 "en-US", 136 "en-US",
140 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); 137 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER);
141 ContentAutofillDriver* driver = 138 ContentAutofillDriver* driver =
142 ContentAutofillDriver::FromWebContents(web_contents()); 139 ContentAutofillDriver::FromWebContents(web_contents());
143 external_delegate_.reset( 140 external_delegate_.reset(
144 new NiceMock<MockAutofillExternalDelegate>( 141 new NiceMock<MockAutofillExternalDelegate>(
145 driver->autofill_manager(), 142 driver->autofill_manager(),
146 driver)); 143 driver));
147 144
148 autofill_popup_controller_ = 145 autofill_popup_controller_ =
(...skipping 13 matching lines...) Expand all
162 159
163 TestAutofillPopupController* popup_controller() { 160 TestAutofillPopupController* popup_controller() {
164 return autofill_popup_controller_; 161 return autofill_popup_controller_;
165 } 162 }
166 163
167 MockAutofillExternalDelegate* delegate() { 164 MockAutofillExternalDelegate* delegate() {
168 return external_delegate_.get(); 165 return external_delegate_.get();
169 } 166 }
170 167
171 protected: 168 protected:
172 scoped_ptr<MockAutofillManagerDelegate> manager_delegate_; 169 scoped_ptr<MockAutofillClient> autofill_client_;
173 scoped_ptr<NiceMock<MockAutofillExternalDelegate> > external_delegate_; 170 scoped_ptr<NiceMock<MockAutofillExternalDelegate> > external_delegate_;
174 testing::NiceMock<TestAutofillPopupController>* autofill_popup_controller_; 171 testing::NiceMock<TestAutofillPopupController>* autofill_popup_controller_;
175 }; 172 };
176 173
177 TEST_F(AutofillPopupControllerUnitTest, SetBounds) { 174 TEST_F(AutofillPopupControllerUnitTest, SetBounds) {
178 // Ensure the popup size can be set and causes a redraw. 175 // Ensure the popup size can be set and causes a redraw.
179 gfx::Rect popup_bounds(10, 10, 100, 100); 176 gfx::Rect popup_bounds(10, 10, 100, 100);
180 177
181 EXPECT_CALL(*autofill_popup_controller_, 178 EXPECT_CALL(*autofill_popup_controller_,
182 UpdateBoundsAndRedrawPopup()); 179 UpdateBoundsAndRedrawPopup());
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 EXPECT_NE(names[0], autofill_popup_controller_->names()[0]); 527 EXPECT_NE(names[0], autofill_popup_controller_->names()[0]);
531 EXPECT_NE(subtexts[0], autofill_popup_controller_->subtexts()[0]); 528 EXPECT_NE(subtexts[0], autofill_popup_controller_->subtexts()[0]);
532 529
533 // The second element was shorter so it should be unchanged. 530 // The second element was shorter so it should be unchanged.
534 EXPECT_EQ(names[1], autofill_popup_controller_->names()[1]); 531 EXPECT_EQ(names[1], autofill_popup_controller_->names()[1]);
535 EXPECT_EQ(subtexts[1], autofill_popup_controller_->subtexts()[1]); 532 EXPECT_EQ(subtexts[1], autofill_popup_controller_->subtexts()[1]);
536 } 533 }
537 #endif 534 #endif
538 535
539 } // namespace autofill 536 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc ('k') | chrome/browser/ui/autofill/chrome_autofill_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698