| OLD | NEW |
| 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" | |
| 27 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/frame_navigate_params.h" | 27 #include "content/public/common/frame_navigate_params.h" |
| 29 #include "content/public/test/mock_render_process_host.h" | 28 #include "content/public/test/mock_render_process_host.h" |
| 30 #include "content/public/test/test_renderer_host.h" | 29 #include "content/public/test/test_renderer_host.h" |
| 31 #include "ipc/ipc_test_sink.h" | 30 #include "ipc/ipc_test_sink.h" |
| 32 #include "testing/gmock/include/gmock/gmock.h" | 31 #include "testing/gmock/include/gmock/gmock.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 32 #include "testing/gtest/include/gtest/gtest.h" |
| 34 | 33 |
| 35 namespace autofill { | 34 namespace autofill { |
| 36 | 35 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 197 } |
| 199 | 198 |
| 200 std::unique_ptr<TestAutofillClient> test_autofill_client_; | 199 std::unique_ptr<TestAutofillClient> test_autofill_client_; |
| 201 std::unique_ptr<TestContentAutofillDriver> driver_; | 200 std::unique_ptr<TestContentAutofillDriver> driver_; |
| 202 }; | 201 }; |
| 203 | 202 |
| 204 TEST_F(ContentAutofillDriverTest, GetURLRequestContext) { | 203 TEST_F(ContentAutofillDriverTest, GetURLRequestContext) { |
| 205 net::URLRequestContextGetter* request_context = | 204 net::URLRequestContextGetter* request_context = |
| 206 driver_->GetURLRequestContext(); | 205 driver_->GetURLRequestContext(); |
| 207 net::URLRequestContextGetter* expected_request_context = | 206 net::URLRequestContextGetter* expected_request_context = |
| 208 content::BrowserContext::GetDefaultStoragePartition( | 207 web_contents()->GetBrowserContext()->GetRequestContext(); |
| 209 web_contents()->GetBrowserContext())->GetURLRequestContext(); | |
| 210 EXPECT_EQ(request_context, expected_request_context); | 208 EXPECT_EQ(request_context, expected_request_context); |
| 211 } | 209 } |
| 212 | 210 |
| 213 TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) { | 211 TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) { |
| 214 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); | 212 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); |
| 215 content::LoadCommittedDetails details = content::LoadCommittedDetails(); | 213 content::LoadCommittedDetails details = content::LoadCommittedDetails(); |
| 216 details.is_main_frame = true; | 214 details.is_main_frame = true; |
| 217 details.is_in_page = false; | 215 details.is_in_page = false; |
| 218 ASSERT_TRUE(details.is_navigation_to_different_page()); | 216 ASSERT_TRUE(details.is_navigation_to_different_page()); |
| 219 content::FrameNavigateParams params = content::FrameNavigateParams(); | 217 content::FrameNavigateParams params = content::FrameNavigateParams(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 base::string16 input_value(base::ASCIIToUTF16("barqux")); | 319 base::string16 input_value(base::ASCIIToUTF16("barqux")); |
| 322 base::string16 output_value; | 320 base::string16 output_value; |
| 323 driver_->RendererShouldPreviewFieldWithValue(input_value); | 321 driver_->RendererShouldPreviewFieldWithValue(input_value); |
| 324 EXPECT_TRUE(GetString16FromMessageWithID( | 322 EXPECT_TRUE(GetString16FromMessageWithID( |
| 325 AutofillMsg_PreviewFieldWithValue::ID, | 323 AutofillMsg_PreviewFieldWithValue::ID, |
| 326 &output_value)); | 324 &output_value)); |
| 327 EXPECT_EQ(input_value, output_value); | 325 EXPECT_EQ(input_value, output_value); |
| 328 } | 326 } |
| 329 | 327 |
| 330 } // namespace autofill | 328 } // namespace autofill |
| OLD | NEW |