| OLD | NEW |
| 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/page_click_listener.h" | 8 #include "components/autofill/content/renderer/page_click_listener.h" |
| 9 #include "components/autofill/content/renderer/page_click_tracker.h" | 9 #include "components/autofill/content/renderer/page_click_tracker.h" |
| 10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | 12 #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 13 #include "third_party/WebKit/public/platform/WebSize.h" | 13 #include "third_party/WebKit/public/platform/WebSize.h" |
| 14 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
| 15 #include "third_party/WebKit/public/web/WebInputElement.h" | 15 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 16 #include "third_party/WebKit/public/web/WebRuntimeFeatures.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" |
| 18 #include "ui/events/keycodes/keyboard_codes.h" | 19 #include "ui/events/keycodes/keyboard_codes.h" |
| 20 #include "ui/native_theme/native_theme_switches.h" |
| 21 |
| 22 using blink::WebRuntimeFeatures; |
| 23 |
| 19 | 24 |
| 20 namespace autofill { | 25 namespace autofill { |
| 21 | 26 |
| 22 class TestPageClickListener : public PageClickListener { | 27 class TestPageClickListener : public PageClickListener { |
| 23 public: | 28 public: |
| 24 TestPageClickListener() | 29 TestPageClickListener() |
| 25 : form_control_element_clicked_called_(false), | 30 : form_control_element_clicked_called_(false), |
| 26 was_focused_(false) {} | 31 was_focused_(false) {} |
| 27 | 32 |
| 28 void FormControlElementClicked(const blink::WebFormControlElement& element, | 33 void FormControlElementClicked(const blink::WebFormControlElement& element, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 41 bool form_control_element_clicked_called_; | 46 bool form_control_element_clicked_called_; |
| 42 blink::WebFormControlElement form_control_element_clicked_; | 47 blink::WebFormControlElement form_control_element_clicked_; |
| 43 bool was_focused_; | 48 bool was_focused_; |
| 44 }; | 49 }; |
| 45 | 50 |
| 46 class PageClickTrackerTest : public ChromeRenderViewTest { | 51 class PageClickTrackerTest : public ChromeRenderViewTest { |
| 47 protected: | 52 protected: |
| 48 void SetUp() override { | 53 void SetUp() override { |
| 49 ChromeRenderViewTest::SetUp(); | 54 ChromeRenderViewTest::SetUp(); |
| 50 | 55 |
| 56 WebRuntimeFeatures::enableOverlayScrollbars( |
| 57 ui::IsOverlayScrollbarEnabled()); |
| 58 |
| 51 // RenderView creates PageClickTracker but it doesn't keep it around. | 59 // RenderView creates PageClickTracker but it doesn't keep it around. |
| 52 // Rather than make it do so for the test, we create a new object. | 60 // Rather than make it do so for the test, we create a new object. |
| 53 page_click_tracker_.reset(new PageClickTracker(view_->GetMainRenderFrame(), | 61 page_click_tracker_.reset(new PageClickTracker(view_->GetMainRenderFrame(), |
| 54 &test_listener_)); | 62 &test_listener_)); |
| 55 | 63 |
| 56 // Must be set before loading HTML. | 64 // Must be set before loading HTML. |
| 57 view_->GetWebView()->setDefaultPageScaleLimits(1, 4); | 65 view_->GetWebView()->setDefaultPageScaleLimits(1, 4); |
| 58 | 66 |
| 59 LoadHTML("<form>" | 67 LoadHTML("<form>" |
| 60 " <input type='text' id='text_1'></input><br>" | 68 " <input type='text' id='text_1'></input><br>" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 // Tap outside of element bounds, but tap width is overlapping the field. | 247 // Tap outside of element bounds, but tap width is overlapping the field. |
| 240 gfx::Rect element_bounds = GetElementBounds("text_1"); | 248 gfx::Rect element_bounds = GetElementBounds("text_1"); |
| 241 SimulateRectTap(element_bounds - | 249 SimulateRectTap(element_bounds - |
| 242 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); | 250 gfx::Vector2d(element_bounds.width() / 2 + 1, 0)); |
| 243 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); | 251 EXPECT_TRUE(test_listener_.form_control_element_clicked_called_); |
| 244 EXPECT_FALSE(test_listener_.was_focused_); | 252 EXPECT_FALSE(test_listener_.was_focused_); |
| 245 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); | 253 EXPECT_TRUE(text_ == test_listener_.form_control_element_clicked_); |
| 246 } | 254 } |
| 247 | 255 |
| 248 } // namespace autofill | 256 } // namespace autofill |
| OLD | NEW |