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

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

Issue 2606473003: Use AutofillDriver* in ContentAutofillDriverFactory when possible (Closed)
Patch Set: Fix Android compilation Created 3 years, 12 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 void SetUp() override { 119 void SetUp() override {
120 ChromeRenderViewHostTestHarness::SetUp(); 120 ChromeRenderViewHostTestHarness::SetUp();
121 121
122 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate( 122 ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
123 web_contents(), autofill_client_.get(), "en-US", 123 web_contents(), autofill_client_.get(), "en-US",
124 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); 124 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER);
125 // Make sure RenderFrame is created. 125 // Make sure RenderFrame is created.
126 NavigateAndCommit(GURL("about:blank")); 126 NavigateAndCommit(GURL("about:blank"));
127 ContentAutofillDriverFactory* factory = 127 ContentAutofillDriverFactory* factory =
128 ContentAutofillDriverFactory::FromWebContents(web_contents()); 128 ContentAutofillDriverFactory::FromWebContents(web_contents());
129 ContentAutofillDriver* driver = 129 ContentAutofillDriver* driver = static_cast<ContentAutofillDriver*>(
130 factory->DriverForFrame(web_contents()->GetMainFrame()); 130 factory->DriverForFrame(web_contents()->GetMainFrame()));
131 external_delegate_.reset( 131 external_delegate_.reset(
132 new NiceMock<MockAutofillExternalDelegate>( 132 new NiceMock<MockAutofillExternalDelegate>(
133 driver->autofill_manager(), 133 driver->autofill_manager(),
134 driver)); 134 driver));
135 135
136 autofill_popup_controller_ = 136 autofill_popup_controller_ =
137 new testing::NiceMock<TestAutofillPopupController>( 137 new testing::NiceMock<TestAutofillPopupController>(
138 external_delegate_->GetWeakPtr(), gfx::RectF()); 138 external_delegate_->GetWeakPtr(), gfx::RectF());
139 } 139 }
140 140
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // Clear datalist values and check that the popup becomes hidden. 355 // Clear datalist values and check that the popup becomes hidden.
356 EXPECT_CALL(*autofill_popup_controller_, Hide()); 356 EXPECT_CALL(*autofill_popup_controller_, Hide());
357 data_list_values.clear(); 357 data_list_values.clear();
358 autofill_popup_controller_->UpdateDataListValues(data_list_values, 358 autofill_popup_controller_->UpdateDataListValues(data_list_values,
359 data_list_values); 359 data_list_values);
360 } 360 }
361 361
362 TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) { 362 TEST_F(AutofillPopupControllerUnitTest, GetOrCreate) {
363 ContentAutofillDriverFactory* factory = 363 ContentAutofillDriverFactory* factory =
364 ContentAutofillDriverFactory::FromWebContents(web_contents()); 364 ContentAutofillDriverFactory::FromWebContents(web_contents());
365 ContentAutofillDriver* driver = 365 ContentAutofillDriver* driver = static_cast<ContentAutofillDriver*>(
366 factory->DriverForFrame(web_contents()->GetMainFrame()); 366 factory->DriverForFrame(web_contents()->GetMainFrame()));
367 MockAutofillExternalDelegate delegate(driver->autofill_manager(), driver); 367 MockAutofillExternalDelegate delegate(driver->autofill_manager(), driver);
368 368
369 WeakPtr<AutofillPopupControllerImpl> controller = 369 WeakPtr<AutofillPopupControllerImpl> controller =
370 AutofillPopupControllerImpl::GetOrCreate( 370 AutofillPopupControllerImpl::GetOrCreate(
371 WeakPtr<AutofillPopupControllerImpl>(), delegate.GetWeakPtr(), NULL, 371 WeakPtr<AutofillPopupControllerImpl>(), delegate.GetWeakPtr(), NULL,
372 NULL, gfx::RectF(), base::i18n::UNKNOWN_DIRECTION); 372 NULL, gfx::RectF(), base::i18n::UNKNOWN_DIRECTION);
373 EXPECT_TRUE(controller.get()); 373 EXPECT_TRUE(controller.get());
374 374
375 controller->Hide(); 375 controller->Hide();
376 376
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 461
462 // The second element was shorter so it should be unchanged. 462 // The second element was shorter so it should be unchanged.
463 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).value, 463 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).value,
464 autofill_popup_controller_->GetElidedValueAt(1)); 464 autofill_popup_controller_->GetElidedValueAt(1));
465 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).label, 465 EXPECT_EQ(autofill_popup_controller_->GetSuggestionAt(1).label,
466 autofill_popup_controller_->GetElidedLabelAt(1)); 466 autofill_popup_controller_->GetElidedLabelAt(1));
467 } 467 }
468 #endif 468 #endif
469 469
470 } // namespace autofill 470 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698