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

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

Issue 1859453002: components/autofill: scoped_ptr -> unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on password_manager changes Created 4 years, 8 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 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/request_autocomplete_manager.h"
Mathieu 2016/04/04 13:36:16 in another CL, https://codereview.chromium.org/185
vabr (Chromium) 2016/04/04 14:29:04 I agree, will change the other file. To explain:
6
5 #include <stdint.h> 7 #include <stdint.h>
6 8
7 #include <tuple> 9 #include <tuple>
Mathieu 2016/04/04 13:36:16 do you think we have to include <memory> for the u
vabr (Chromium) 2016/04/04 14:29:04 The style guide does not specify this, as far as I
8 10
9 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h"
10 #include "components/autofill/content/browser/content_autofill_driver.h" 13 #include "components/autofill/content/browser/content_autofill_driver.h"
11 #include "components/autofill/content/browser/request_autocomplete_manager.h"
12 #include "components/autofill/content/common/autofill_messages.h" 14 #include "components/autofill/content/common/autofill_messages.h"
13 #include "components/autofill/core/browser/test_autofill_client.h" 15 #include "components/autofill/core/browser/test_autofill_client.h"
14 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/mock_render_process_host.h" 17 #include "content/public/test/mock_render_process_host.h"
16 #include "content/public/test/test_renderer_host.h" 18 #include "content/public/test/test_renderer_host.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 20
19 namespace autofill { 21 namespace autofill {
20 22
21 namespace { 23 namespace {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 bool should_simulate_success_; 75 bool should_simulate_success_;
74 76
75 DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillClient); 77 DISALLOW_COPY_AND_ASSIGN(CustomTestAutofillClient);
76 }; 78 };
77 79
78 class TestContentAutofillDriver : public ContentAutofillDriver { 80 class TestContentAutofillDriver : public ContentAutofillDriver {
79 public: 81 public:
80 TestContentAutofillDriver(content::RenderFrameHost* rfh, 82 TestContentAutofillDriver(content::RenderFrameHost* rfh,
81 AutofillClient* client) 83 AutofillClient* client)
82 : ContentAutofillDriver(rfh, client, kAppLocale, kDownloadState) { 84 : ContentAutofillDriver(rfh, client, kAppLocale, kDownloadState) {
83 SetAutofillManager(make_scoped_ptr<AutofillManager>( 85 SetAutofillManager(base::WrapUnique<AutofillManager>(
84 new TestAutofillManager(this, client))); 86 new TestAutofillManager(this, client)));
85 } 87 }
86 ~TestContentAutofillDriver() override {} 88 ~TestContentAutofillDriver() override {}
87 89
88 TestAutofillManager* mock_autofill_manager() { 90 TestAutofillManager* mock_autofill_manager() {
89 return static_cast<TestAutofillManager*>(autofill_manager()); 91 return static_cast<TestAutofillManager*>(autofill_manager());
90 } 92 }
91 93
92 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver); 94 DISALLOW_COPY_AND_ASSIGN(TestContentAutofillDriver);
93 }; 95 };
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 std::tuple<blink::WebFormElement::AutocompleteResult, base::string16, 132 std::tuple<blink::WebFormElement::AutocompleteResult, base::string16,
131 FormData> autofill_param; 133 FormData> autofill_param;
132 AutofillMsg_RequestAutocompleteResult::Read(message, &autofill_param); 134 AutofillMsg_RequestAutocompleteResult::Read(message, &autofill_param);
133 *result = std::get<0>(autofill_param); 135 *result = std::get<0>(autofill_param);
134 process()->sink().ClearMessages(); 136 process()->sink().ClearMessages();
135 return true; 137 return true;
136 } 138 }
137 139
138 protected: 140 protected:
139 CustomTestAutofillClient autofill_client_; 141 CustomTestAutofillClient autofill_client_;
140 scoped_ptr<TestContentAutofillDriver> driver_; 142 std::unique_ptr<TestContentAutofillDriver> driver_;
141 scoped_ptr<RequestAutocompleteManager> request_autocomplete_manager_; 143 std::unique_ptr<RequestAutocompleteManager> request_autocomplete_manager_;
142 144
143 DISALLOW_COPY_AND_ASSIGN(RequestAutocompleteManagerTest); 145 DISALLOW_COPY_AND_ASSIGN(RequestAutocompleteManagerTest);
144 }; 146 };
145 147
146 TEST_F(RequestAutocompleteManagerTest, OnRequestAutocompleteSuccess) { 148 TEST_F(RequestAutocompleteManagerTest, OnRequestAutocompleteSuccess) {
147 blink::WebFormElement::AutocompleteResult result; 149 blink::WebFormElement::AutocompleteResult result;
148 request_autocomplete_manager_->OnRequestAutocomplete(FormData()); 150 request_autocomplete_manager_->OnRequestAutocomplete(FormData());
149 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); 151 EXPECT_TRUE(GetAutocompleteResultMessage(&result));
150 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result); 152 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result);
151 } 153 }
(...skipping 11 matching lines...) Expand all
163 TEST_F(RequestAutocompleteManagerTest, 165 TEST_F(RequestAutocompleteManagerTest,
164 OnRequestAutocompleteWithAutofillDisabled) { 166 OnRequestAutocompleteWithAutofillDisabled) {
165 blink::WebFormElement::AutocompleteResult result; 167 blink::WebFormElement::AutocompleteResult result;
166 driver_->mock_autofill_manager()->set_autofill_enabled(false); 168 driver_->mock_autofill_manager()->set_autofill_enabled(false);
167 request_autocomplete_manager_->OnRequestAutocomplete(FormData()); 169 request_autocomplete_manager_->OnRequestAutocomplete(FormData());
168 EXPECT_TRUE(GetAutocompleteResultMessage(&result)); 170 EXPECT_TRUE(GetAutocompleteResultMessage(&result));
169 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result); 171 EXPECT_EQ(blink::WebFormElement::AutocompleteResultSuccess, result);
170 } 172 }
171 173
172 } // namespace autofill 174 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698