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

Side by Side Diff: components/autofill/content/browser/content_autofill_driver_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: update tests some more 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 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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 29 matching lines...) Expand all
40 public: 40 public:
41 MockAutofillManager(AutofillDriver* driver, AutofillClient* client) 41 MockAutofillManager(AutofillDriver* driver, AutofillClient* client)
42 : AutofillManager(driver, client, kAppLocale, kDownloadState) {} 42 : AutofillManager(driver, client, kAppLocale, kDownloadState) {}
43 virtual ~MockAutofillManager() {} 43 virtual ~MockAutofillManager() {}
44 44
45 MOCK_METHOD0(Reset, void()); 45 MOCK_METHOD0(Reset, void());
46 }; 46 };
47 47
48 class TestContentAutofillDriver : public ContentAutofillDriver { 48 class TestContentAutofillDriver : public ContentAutofillDriver {
49 public: 49 public:
50 TestContentAutofillDriver(content::WebContents* contents, 50 TestContentAutofillDriver(content::RenderFrameHost* rfh,
51 AutofillClient* client) 51 AutofillClient* client)
52 : ContentAutofillDriver(contents, client, kAppLocale, kDownloadState) { 52 : ContentAutofillDriver(rfh, client, kAppLocale, kDownloadState) {
53 scoped_ptr<AutofillManager> autofill_manager( 53 scoped_ptr<AutofillManager> autofill_manager(
54 new MockAutofillManager(this, client)); 54 new MockAutofillManager(this, client));
55 SetAutofillManager(autofill_manager.Pass()); 55 SetAutofillManager(autofill_manager.Pass());
56 } 56 }
57 ~TestContentAutofillDriver() override {} 57 ~TestContentAutofillDriver() override {}
58 58
59 virtual MockAutofillManager* mock_autofill_manager() { 59 virtual MockAutofillManager* mock_autofill_manager() {
60 return static_cast<MockAutofillManager*>(autofill_manager()); 60 return static_cast<MockAutofillManager*>(autofill_manager());
61 } 61 }
62 62
63 using ContentAutofillDriver::DidNavigateMainFrame; 63 using ContentAutofillDriver::DidNavigateFrame;
64 }; 64 };
65 65
66 class ContentAutofillDriverTest : public content::RenderViewHostTestHarness { 66 class ContentAutofillDriverTest : public content::RenderViewHostTestHarness {
67 public: 67 public:
68 void SetUp() override { 68 void SetUp() override {
69 content::RenderViewHostTestHarness::SetUp(); 69 content::RenderViewHostTestHarness::SetUp();
70 70
71 test_autofill_client_.reset(new TestAutofillClient()); 71 test_autofill_client_.reset(new TestAutofillClient());
72 driver_.reset(new TestContentAutofillDriver(web_contents(), 72 driver_.reset(new TestContentAutofillDriver(web_contents()->GetMainFrame(),
73 test_autofill_client_.get())); 73 test_autofill_client_.get()));
74 } 74 }
75 75
76 void TearDown() override { 76 void TearDown() override {
77 // Reset the driver now to cause all pref observers to be removed and avoid 77 // Reset the driver now to cause all pref observers to be removed and avoid
78 // crashes that otherwise occur in the destructor. 78 // crashes that otherwise occur in the destructor.
79 driver_.reset(); 79 driver_.reset();
80 content::RenderViewHostTestHarness::TearDown(); 80 content::RenderViewHostTestHarness::TearDown();
81 } 81 }
82 82
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 EXPECT_EQ(request_context, expected_request_context); 203 EXPECT_EQ(request_context, expected_request_context);
204 } 204 }
205 205
206 TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) { 206 TEST_F(ContentAutofillDriverTest, NavigatedToDifferentPage) {
207 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()); 207 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset());
208 content::LoadCommittedDetails details = content::LoadCommittedDetails(); 208 content::LoadCommittedDetails details = content::LoadCommittedDetails();
209 details.is_main_frame = true; 209 details.is_main_frame = true;
210 details.is_in_page = false; 210 details.is_in_page = false;
211 ASSERT_TRUE(details.is_navigation_to_different_page()); 211 ASSERT_TRUE(details.is_navigation_to_different_page());
212 content::FrameNavigateParams params = content::FrameNavigateParams(); 212 content::FrameNavigateParams params = content::FrameNavigateParams();
213 driver_->DidNavigateMainFrame(details, params); 213 driver_->DidNavigateFrame(details, params);
214 } 214 }
215 215
216 TEST_F(ContentAutofillDriverTest, NavigatedWithinSamePage) { 216 TEST_F(ContentAutofillDriverTest, NavigatedWithinSamePage) {
217 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()).Times(0); 217 EXPECT_CALL(*driver_->mock_autofill_manager(), Reset()).Times(0);
218 content::LoadCommittedDetails details = content::LoadCommittedDetails(); 218 content::LoadCommittedDetails details = content::LoadCommittedDetails();
219 details.is_main_frame = false; 219 details.is_main_frame = false;
220 ASSERT_TRUE(!details.is_navigation_to_different_page()); 220 ASSERT_TRUE(!details.is_navigation_to_different_page());
221 content::FrameNavigateParams params = content::FrameNavigateParams(); 221 content::FrameNavigateParams params = content::FrameNavigateParams();
222 driver_->DidNavigateMainFrame(details, params); 222 driver_->DidNavigateFrame(details, params);
223 } 223 }
224 224
225 TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) { 225 TEST_F(ContentAutofillDriverTest, FormDataSentToRenderer_FillForm) {
226 int input_page_id = 42; 226 int input_page_id = 42;
227 FormData input_form_data; 227 FormData input_form_data;
228 test::CreateTestAddressFormData(&input_form_data); 228 test::CreateTestAddressFormData(&input_form_data);
229 driver_->SendFormDataToRenderer( 229 driver_->SendFormDataToRenderer(
230 input_page_id, AutofillDriver::FORM_DATA_ACTION_FILL, input_form_data); 230 input_page_id, AutofillDriver::FORM_DATA_ACTION_FILL, input_form_data);
231 231
232 int output_page_id = 0; 232 int output_page_id = 0;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 base::string16 input_value(base::ASCIIToUTF16("barqux")); 314 base::string16 input_value(base::ASCIIToUTF16("barqux"));
315 base::string16 output_value; 315 base::string16 output_value;
316 driver_->RendererShouldPreviewFieldWithValue(input_value); 316 driver_->RendererShouldPreviewFieldWithValue(input_value);
317 EXPECT_TRUE(GetString16FromMessageWithID( 317 EXPECT_TRUE(GetString16FromMessageWithID(
318 AutofillMsg_PreviewFieldWithValue::ID, 318 AutofillMsg_PreviewFieldWithValue::ID,
319 &output_value)); 319 &output_value));
320 EXPECT_EQ(input_value, output_value); 320 EXPECT_EQ(input_value, output_value);
321 } 321 }
322 322
323 } // namespace autofill 323 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698