OLD | NEW |
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/test/mock_render_process_host.h" | 9 #include "content/public/test/mock_render_process_host.h" |
10 #include "content/public/test/test_renderer_host.h" | 10 #include "content/public/test/test_renderer_host.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); | 88 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); |
89 }; | 89 }; |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 class RequestAutocompleteManagerTest : | 93 class RequestAutocompleteManagerTest : |
94 public content::RenderViewHostTestHarness { | 94 public content::RenderViewHostTestHarness { |
95 public: | 95 public: |
96 RequestAutocompleteManagerTest() {} | 96 RequestAutocompleteManagerTest() {} |
97 | 97 |
98 virtual void SetUp() override { | 98 void SetUp() override { |
99 content::RenderViewHostTestHarness::SetUp(); | 99 content::RenderViewHostTestHarness::SetUp(); |
100 | 100 |
101 driver_.reset( | 101 driver_.reset( |
102 new TestContentAutofillDriver(web_contents(), &autofill_client_)); | 102 new TestContentAutofillDriver(web_contents(), &autofill_client_)); |
103 request_autocomplete_manager_.reset( | 103 request_autocomplete_manager_.reset( |
104 new RequestAutocompleteManager(driver_.get())); | 104 new RequestAutocompleteManager(driver_.get())); |
105 } | 105 } |
106 | 106 |
107 virtual void TearDown() override { | 107 void TearDown() override { |
108 // Reset the driver now to cause all pref observers to be removed and avoid | 108 // Reset the driver now to cause all pref observers to be removed and avoid |
109 // crashes that otherwise occur in the destructor. | 109 // crashes that otherwise occur in the destructor. |
110 driver_.reset(); | 110 driver_.reset(); |
111 content::RenderViewHostTestHarness::TearDown(); | 111 content::RenderViewHostTestHarness::TearDown(); |
112 } | 112 } |
113 | 113 |
114 // Searches for an |AutofillMsg_RequestAutocompleteResult| message in the | 114 // Searches for an |AutofillMsg_RequestAutocompleteResult| message in the |
115 // queue of sent IPC messages. If none is present, returns false. Otherwise, | 115 // queue of sent IPC messages. If none is present, returns false. Otherwise, |
116 // extracts the first |AutofillMsg_RequestAutocompleteResult| message, fills | 116 // extracts the first |AutofillMsg_RequestAutocompleteResult| message, fills |
117 // the output parameter with the value of the message's parameter, and | 117 // the output parameter with the value of the message's parameter, and |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 TEST_F(RequestAutocompleteManagerTest, | 159 TEST_F(RequestAutocompleteManagerTest, |
160 OnRequestAutocompleteWithAutofillDisabled) { | 160 OnRequestAutocompleteWithAutofillDisabled) { |
161 blink::WebFormElement::AutocompleteResult result; | 161 blink::WebFormElement::AutocompleteResult result; |
162 driver_->mock_autofill_manager()->set_autofill_enabled(false); | 162 driver_->mock_autofill_manager()->set_autofill_enabled(false); |
163 request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL()); | 163 request_autocomplete_manager_->OnRequestAutocomplete(FormData(), GURL()); |
164 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); | 164 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); |
165 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result); | 165 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result); |
166 } | 166 } |
167 | 167 |
168 } // namespace autofill | 168 } // namespace autofill |
OLD | NEW |