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

Side by Side Diff: chrome/renderer/autofill/page_click_tracker_browsertest.cc

Issue 2853623002: [refactor] Fix autofill features for payments when the form is inside an OOPIF (Closed)
Patch Set: Created 3 years, 7 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <memory> 5 #include <memory>
6 6
7 #include "chrome/test/base/chrome_render_view_test.h" 7 #include "chrome/test/base/chrome_render_view_test.h"
8 #include "components/autofill/content/renderer/autofill_agent.h"
8 #include "components/autofill/content/renderer/page_click_listener.h" 9 #include "components/autofill/content/renderer/page_click_listener.h"
9 #include "components/autofill/content/renderer/page_click_tracker.h" 10 #include "components/autofill/content/renderer/page_click_tracker.h"
10 #include "content/public/renderer/render_view.h" 11 #include "content/public/renderer/render_view.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" 13 #include "third_party/WebKit/public/platform/WebFloatPoint.h"
13 #include "third_party/WebKit/public/platform/WebSize.h" 14 #include "third_party/WebKit/public/platform/WebSize.h"
14 #include "third_party/WebKit/public/web/WebDocument.h" 15 #include "third_party/WebKit/public/web/WebDocument.h"
15 #include "third_party/WebKit/public/web/WebInputElement.h" 16 #include "third_party/WebKit/public/web/WebInputElement.h"
16 #include "third_party/WebKit/public/web/WebSettings.h" 17 #include "third_party/WebKit/public/web/WebSettings.h"
17 #include "third_party/WebKit/public/web/WebView.h" 18 #include "third_party/WebKit/public/web/WebView.h"
(...skipping 23 matching lines...) Expand all
41 bool form_control_element_clicked_called_; 42 bool form_control_element_clicked_called_;
42 blink::WebFormControlElement form_control_element_clicked_; 43 blink::WebFormControlElement form_control_element_clicked_;
43 bool was_focused_; 44 bool was_focused_;
44 }; 45 };
45 46
46 class PageClickTrackerTest : public ChromeRenderViewTest { 47 class PageClickTrackerTest : public ChromeRenderViewTest {
47 protected: 48 protected:
48 void SetUp() override { 49 void SetUp() override {
49 ChromeRenderViewTest::SetUp(); 50 ChromeRenderViewTest::SetUp();
50 51
51 // RenderView creates PageClickTracker but it doesn't keep it around. 52 // PageClickTracker is created and owned by AutofillAgent. To setup our test
52 // Rather than make it do so for the test, we create a new object. 53 // listener we need to use our copy of PageClickTracker and set it up for
53 page_click_tracker_.reset(new PageClickTracker(view_->GetMainRenderFrame(), 54 // testing. The ownership will be transfered to AutofillAgent.
54 &test_listener_)); 55 auto page_click_tracker = base::MakeUnique<PageClickTracker>(
56 view_->GetMainRenderFrame(), &test_listener_);
57 autofill_agent_->set_page_click_tracker_for_testing(
58 std::move(page_click_tracker));
55 59
56 // Must be set before loading HTML. 60 // Must be set before loading HTML.
57 view_->GetWebView()->SetDefaultPageScaleLimits(1, 4); 61 view_->GetWebView()->SetDefaultPageScaleLimits(1, 4);
58 62
59 LoadHTML("<form>" 63 LoadHTML("<form>"
60 " <input type='text' id='text_1'></input><br>" 64 " <input type='text' id='text_1'></input><br>"
61 " <input type='text' id='text_2'></input><br>" 65 " <input type='text' id='text_2'></input><br>"
62 " <textarea id='textarea_1'></textarea><br>" 66 " <textarea id='textarea_1'></textarea><br>"
63 " <textarea id='textarea_2'></textarea><br>" 67 " <textarea id='textarea_2'></textarea><br>"
64 " <input type='button' id='button'></input><br>" 68 " <input type='button' id='button'></input><br>"
(...skipping 10 matching lines...) Expand all
75 79
76 // Enable show-ime event when element is focused by indicating that a user 80 // Enable show-ime event when element is focused by indicating that a user
77 // gesture has been processed since load. 81 // gesture has been processed since load.
78 EXPECT_TRUE(SimulateElementClick("button")); 82 EXPECT_TRUE(SimulateElementClick("button"));
79 } 83 }
80 84
81 void TearDown() override { 85 void TearDown() override {
82 text_.Reset(); 86 text_.Reset();
83 textarea_.Reset(); 87 textarea_.Reset();
84 test_listener_.ClearResults(); 88 test_listener_.ClearResults();
85 page_click_tracker_.reset();
86 ChromeRenderViewTest::TearDown(); 89 ChromeRenderViewTest::TearDown();
87 } 90 }
88 91
89 std::unique_ptr<PageClickTracker> page_click_tracker_;
90 TestPageClickListener test_listener_; 92 TestPageClickListener test_listener_;
91 blink::WebElement text_; 93 blink::WebElement text_;
92 blink::WebElement textarea_; 94 blink::WebElement textarea_;
93 }; 95 };
94 96
95 // Tests that PageClickTracker does notify correctly when an input 97 // Tests that PageClickTracker does notify correctly when an input
96 // node is clicked. 98 // node is clicked.
97 TEST_F(PageClickTrackerTest, PageClickTrackerInputClicked) { 99 TEST_F(PageClickTrackerTest, PageClickTrackerInputClicked) {
98 EXPECT_NE(text_, text_.GetDocument().FocusedElement()); 100 EXPECT_NE(text_, text_.GetDocument().FocusedElement());
99 // Click the text field once. 101 // Click the text field once.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // Tap outside of element bounds, but tap width is overlapping the field. 242 // Tap outside of element bounds, but tap width is overlapping the field.
241 gfx::Rect element_bounds = GetElementBounds("text_1"); 243 gfx::Rect element_bounds = GetElementBounds("text_1");
242 SimulateRectTap(element_bounds - 244 SimulateRectTap(element_bounds -
243 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); 245 gfx::Vector2d(element_bounds.width() / 2 + 1, 0));
244 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); 246 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_);
245 EXPECT_FALSE(test_listener_.was_focused_); 247 EXPECT_FALSE(test_listener_.was_focused_);
246 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); 248 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_);
247 } 249 }
248 250
249 } // namespace autofill 251 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_interactive_uitest.cc ('k') | components/autofill/content/renderer/autofill_agent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698