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

Side by Side Diff: components/autofill/content/browser/request_autocomplete_manager_unittest.cc

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/autofill/content/browser/content_autofill_driver.h" 5 #include "components/autofill/content/browser/content_autofill_driver.h"
6 #include "components/autofill/content/browser/request_autocomplete_manager.h" 6 #include "components/autofill/content/browser/request_autocomplete_manager.h"
7 #include "components/autofill/content/common/autofill_messages.h" 7 #include "components/autofill/content/common/autofill_messages.h"
8 #include "components/autofill/core/browser/test_autofill_client.h" 8 #include "components/autofill/core/browser/test_autofill_client.h"
9 #include "content/public/browser/web_contents.h"
9 #include "content/public/test/mock_render_process_host.h" 10 #include "content/public/test/mock_render_process_host.h"
10 #include "content/public/test/test_renderer_host.h" 11 #include "content/public/test/test_renderer_host.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace autofill { 14 namespace autofill {
14 15
15 namespace { 16 namespace {
16 17
17 const char kAppLocale[] = "en-US"; 18 const char kAppLocale[] = "en-US";
18 const AutofillManager::AutofillDownloadManagerState kDownloadState = 19 const AutofillManager::AutofillDownloadManagerState kDownloadState =
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 private: 65 private:
65 // Enable testing the path where a callback is called without a 66 // Enable testing the path where a callback is called without a
66 // valid FormStructure. 67 // valid FormStructure.
67 bool should_simulate_success_; 68 bool should_simulate_success_;
68 69
69 DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillClient); 70 DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillClient);
70 }; 71 };
71 72
72 class TestContentAutofillDriver : public ContentAutofillDriver { 73 class TestContentAutofillDriver : public ContentAutofillDriver {
73 public: 74 public:
74 TestContentAutofillDriver(content::WebContents* contents, 75 TestContentAutofillDriver(content::RenderFrameHost* rfh,
75 AutofillClient* client) 76 AutofillClient* client)
76 : ContentAutofillDriver(contents, client, kAppLocale, kDownloadState) { 77 : ContentAutofillDriver(rfh, client, kAppLocale, kDownloadState) {
77 SetAutofillManager(make_scoped_ptr<AutofillManager>( 78 SetAutofillManager(make_scoped_ptr<AutofillManager>(
78 new TestAutofillManager(this, client))); 79 new TestAutofillManager(this, client)));
79 } 80 }
80 ~TestContentAutofillDriver() override {} 81 ~TestContentAutofillDriver() override {}
81 82
82 TestAutofillManager* mock_autofill_manager() { 83 TestAutofillManager* mock_autofill_manager() {
83 return static_cast<TestAutofillManager*>(autofill_manager()); 84 return static_cast<TestAutofillManager*>(autofill_manager());
84 } 85 }
85 86
86 using ContentAutofillDriver::DidNavigateMainFrame;
87
88 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); 87 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver);
89 }; 88 };
90 89
91 } // namespace 90 } // namespace
92 91
93 class RequestAutocompleteManagerTest : 92 class RequestAutocompleteManagerTest :
94 public content::RenderViewHostTestHarness { 93 public content::RenderViewHostTestHarness {
95 public: 94 public:
96 RequestAutocompleteManagerTest() {} 95 RequestAutocompleteManagerTest() {}
97 96
98 void SetUp() override { 97 void SetUp() override {
99 content::RenderViewHostTestHarness::SetUp(); 98 content::RenderViewHostTestHarness::SetUp();
100 99
101 driver_.reset( 100 driver_.reset(new TestContentAutofillDriver(web_contents()->GetMainFrame(),
102 new TestContentAutofillDriver(web_contents(), &autofill_client_)); 101 &autofill_client_));
103 request_autocomplete_manager_.reset( 102 request_autocomplete_manager_.reset(
104 new RequestAutocompleteManager(driver_.get())); 103 new RequestAutocompleteManager(driver_.get()));
105 } 104 }
106 105
107 void TearDown() override { 106 void TearDown() override {
108 // Reset the driver now to cause all pref observers to be removed and avoid 107 // Reset the driver now to cause all pref observers to be removed and avoid
109 // crashes that otherwise occur in the destructor. 108 // crashes that otherwise occur in the destructor.
110 driver_.reset(); 109 driver_.reset();
111 content::RenderViewHostTestHarness::TearDown(); 110 content::RenderViewHostTestHarness::TearDown();
112 } 111 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 TEST_F(RequestAutocompleteManagerTest, 158 TEST_F(RequestAutocompleteManagerTest,
160 OnRequestAutocompleteWithAutofillDisabled) { 159 OnRequestAutocompleteWithAutofillDisabled) {
161 blink::WebFormElement::AutocompleteResult result; 160 blink::WebFormElement::AutocompleteResult result;
162 driver_->mock_autofill_manager()->set_autofill_enabled(false); 161 driver_->mock_autofill_manager()->set_autofill_enabled(false);
163 request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL()); 162 request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL());
164 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); 163 EXPECT_TRUE(GetAutocompleteResultMessage(&result));
165 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result); 164 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result);
166 } 165 }
167 166
168 } // namespace autofill 167 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698