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

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

Issue 1864583006: Simplify BrowserContext by removing redundant methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <tuple> 11 #include <tuple>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/command_line.h" 15 #include "base/command_line.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "components/autofill/content/common/autofill_messages.h" 17 #include "components/autofill/content/common/autofill_messages.h"
18 #include "components/autofill/core/browser/autofill_external_delegate.h" 18 #include "components/autofill/core/browser/autofill_external_delegate.h"
19 #include "components/autofill/core/browser/autofill_manager.h" 19 #include "components/autofill/core/browser/autofill_manager.h"
20 #include "components/autofill/core/browser/autofill_test_utils.h" 20 #include "components/autofill/core/browser/autofill_test_utils.h"
21 #include "components/autofill/core/browser/test_autofill_client.h" 21 #include "components/autofill/core/browser/test_autofill_client.h"
22 #include "components/autofill/core/common/autofill_switches.h" 22 #include "components/autofill/core/common/autofill_switches.h"
23 #include "components/autofill/core/common/form_data_predictions.h" 23 #include "components/autofill/core/common/form_data_predictions.h"
24 #include "content/public/browser/browser_context.h" 24 #include "content/public/browser/browser_context.h"
25 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
26 #include "content/public/browser/storage_partition.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "content/public/common/frame_navigate_params.h" 28 #include "content/public/common/frame_navigate_params.h"
28 #include "content/public/test/mock_render_process_host.h" 29 #include "content/public/test/mock_render_process_host.h"
29 #include "content/public/test/test_renderer_host.h" 30 #include "content/public/test/test_renderer_host.h"
30 #include "ipc/ipc_test_sink.h" 31 #include "ipc/ipc_test_sink.h"
31 #include "testing/gmock/include/gmock/gmock.h" 32 #include "testing/gmock/include/gmock/gmock.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 34
34 namespace autofill { 35 namespace autofill {
35 36
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 } 198 }
198 199
199 std::unique_ptr<TestAutofillClient> test_autofill_client_; 200 std::unique_ptr<TestAutofillClient> test_autofill_client_;
200 std::unique_ptr<TestContentAutofillDriver> driver_; 201 std::unique_ptr<TestContentAutofillDriver> driver_;
201 }; 202 };
202 203
203 TEST_F(ContentAutofillDriverTest, GetURLRequestContext) { 204 TEST_F(ContentAutofillDriverTest, GetURLRequestContext) {
204 net::URLRequestContextGetter* request_context = 205 net::URLRequestContextGetter* request_context =
205 driver_->GetURLRequestContext(); 206 driver_->GetURLRequestContext();
206 net::URLRequestContextGetter* expected_request_context = 207 net::URLRequestContextGetter* expected_request_context =
207 web_contents()->GetBrowserContext()->GetRequestContext(); 208 content::BrowserContext::GetDefaultStoragePartition(
209 web_contents()->GetBrowserContext())->GetURLRequestContext();
208 EXPECT_EQ(request_context, expected_request_context); 210 EXPECT_EQ(request_context, expected_request_context);
209 } 211 }
210 212
211 TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) { 213 TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) {
212 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); 214 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset());
213 content::LoadCommittedDetails details = content::LoadCommittedDetails(); 215 content::LoadCommittedDetails details = content::LoadCommittedDetails();
214 details.is_main_frame = true; 216 details.is_main_frame = true;
215 details.is_in_page = false; 217 details.is_in_page = false;
216 ASSERT_TRUE(details.is_navigation_to_different_page()); 218 ASSERT_TRUE(details.is_navigation_to_different_page());
217 content::FrameNavigateParams params = content::FrameNavigateParams(); 219 content::FrameNavigateParams params = content::FrameNavigateParams();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 base::string16 input_value(base::ASCIIToUTF16("barqux")); 321 base::string16 input_value(base::ASCIIToUTF16("barqux"));
320 base::string16 output_value; 322 base::string16 output_value;
321 driver_->RendererShouldPreviewFieldWithValue(input_value); 323 driver_->RendererShouldPreviewFieldWithValue(input_value);
322 EXPECT_TRUE(GetString16FromMessageWithID( 324 EXPECT_TRUE(GetString16FromMessageWithID(
323 AutofillMsg_PreviewFieldWithValue::ID, 325 AutofillMsg_PreviewFieldWithValue::ID,
324 &output_value)); 326 &output_value));
325 EXPECT_EQ(input_value, output_value); 327 EXPECT_EQ(input_value, output_value);
326 } 328 }
327 329
328 } // namespace autofill 330 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698